Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rule: enforce messages on assert calls #322

Open
1 task
rockingskier opened this issue Aug 1, 2024 · 1 comment
Open
1 task

New Rule: enforce messages on assert calls #322

rockingskier opened this issue Aug 1, 2024 · 1 comment
Labels
enhancement rule:new A new rule for the package

Comments

@rockingskier
Copy link

rockingskier commented Aug 1, 2024

Rule details

Node's assert functions allow for passing in an optional message.
I'd like a way to enforce passing in that message.

For example, assert takes a value and an optional message.

assert(foo);
assert(foo, 'Foo is required')

Syncing between error logs and code is far easier when your error message is Foo is required rather than undefined == true

What type of rule is this?

Warns about a potential problem

Example code

// Error/warn
assert(foo);
assert.equal(foo, bar);

// Good
assert(foo, 'Foo is required');
assert.equal(foo, bar, 'Foo and Bar are not equal');

Participation

  • I am willing to submit a pull request to implement this rule.

Additional comments

No response

@scagood scagood mentioned this issue Aug 1, 2024
20 tasks
@scagood
Copy link

scagood commented Aug 1, 2024

👍 I am in favour of this.

Thank you for the issue :)

@scagood scagood added rule:new A new rule for the package and removed rule labels Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement rule:new A new rule for the package
Projects
None yet
Development

No branches or pull requests

2 participants