-
-
Notifications
You must be signed in to change notification settings - Fork 412
Add consistent-assert
rule
#2535
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
Conversation
docs/rules/consistent-assert.md
Outdated
<!-- end auto-generated rule header --> | ||
<!-- Do not manually modify this header. Run: `npm run fix:eslint-docs` --> | ||
|
||
Enforce consistent assertion styles with `node:assert`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just repeating the title.
docs/rules/consistent-assert.md
Outdated
assert(true); | ||
|
||
// ✅ | ||
assert.ok(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear from the examples why assert.ok
is better than assert
.
rules/consistent-assert.js
Outdated
const variable = scope.variables.find(variable => variable.name === specifier.local.name); | ||
if (!variable) { | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const variable = scope.variables.find(variable => variable.name === specifier.local.name); | |
if (!variable) { | |
continue; | |
} | |
const variable = sourceCode.getDeclaredVariables(specifier); |
rules/consistent-assert.js
Outdated
|
||
// Skip if the identifier is not part of a call expression | ||
// Skip if the identifier is the object of a member expression | ||
if (!isFunctionCall() || isMemberExpression()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we only check function call?
1ededac
to
90cf41d
Compare
90cf41d
to
ee60f09
Compare
This reverts commit fbd95cf1a34da1ccf37d8a412db124c999b6ce96.
@axetroy Pushed some changes, mainly |
docs/rules/consistent-assert.md
Outdated
``` | ||
|
||
```js | ||
import assert from 'node:assert/strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The node:assert/strict
module should be encouraged to use, let's move this one to top.
Co-authored-by: fisker Cheung <[email protected]>
rules/consistent-assert.js
Outdated
meta: { | ||
type: 'problem', | ||
docs: { | ||
description: 'Enforce consistent assertion styles with `node:assert`', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: 'Enforce consistent assertion styles with `node:assert`', | |
description: 'Enforce consistent assertion styles with `node:assert`.', |
docs/rules/consistent-assert.md
Outdated
@@ -0,0 +1,51 @@ | |||
# Enforce consistent assertion styles with `node:assert` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Enforce consistent assertion styles with `node:assert` | |
# Enforce consistent assertion style with `node:assert` |
Close #1806