-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
tools: add sort-requires rule to enforce {a, b, c} = require() is in alphabetical order
#44116
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
require-order rule to enforce a convention in the order of require statementrequire-order rule to detect require statement with out of order VariableDeclarator
cc98cfc to
80c4ae3
Compare
tools/eslint-rules/require-order.js
Outdated
| node && | ||
| node.id && | ||
| node.id.type === 'ObjectPattern' |
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.
| node && | |
| node.id && | |
| node.id.type === 'ObjectPattern' | |
| node?.id?.type === 'ObjectPattern' |
require-order rule to detect require statement with out of order VariableDeclaratorrequire-order rule to enforce {a, b, c} = require() is in alphabetical order
80c4ae3 to
a4423eb
Compare
LiviaMedeiros
left a comment
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.
Might be a good idea to include a commit with this rule being applied to the codebase, so it would be easier to estimate the amount of code churn.
Shouldn't something like sort-imports go first?
aduh95
left a comment
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.
Could this rule also enforce trailing commas for require/primordials destructuring?
require-order rule to enforce {a, b, c} = require() is in alphabetical ordersort-requires rule to enforce {a, b, c} = require() is in alphabetical order
a4423eb to
37d47f0
Compare
37d47f0 to
a4c2d41
Compare
aduh95
left a comment
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.
We'd need to split this into several commits to minimize the work of backporting. We'd also need to have this rule reject multi-line destructuring without trailing commas.
|
Close on top of #41768 |
Close #44153
This PR added new custom ESLint rule named
sort-requiresthat verify all destructed members of{} = require()and{} = primordialsare sorted alphabetically inspired byeslint/sort-importsAccording to
make lint-js, there are 221 problems withsort-requires.