Skip to content

New Rule: enforce messages on assert calls #322

Open
@rockingskier

Description

@rockingskier

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions