-
Notifications
You must be signed in to change notification settings - Fork 659
Conversation
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.
CI linting is failing due to a bug in the new rule - https://github.com/facebookexperimental/rome/pull/99/checks?check_run_id=479521121
The implementation assumes that all function parameters are identifiers (type: 'Identifier'
) which is not always the case. Perhaps we can ignore the non-identifiers, which is what ESLint seems to be doing.
Please add tests as well. You can refer to the ESLint tests for the possible kinds of functions - https://github.com/eslint/eslint/blob/master/tests/lib/rules/no-dupe-args.js
This lint rule only works on regular name parameters, we can make it work more reliably, and support patterns with the
The usage would be like this:
Then you can just maintain a single Try to avoid the creation of duplicate AST arrays. For example, you used |
An example of the pattern I'm referring to is #98. |
6d067d4
to
191decd
Compare
const uniqueIdentifiers = new Set(); | ||
|
||
for (const param of node.params) { | ||
for (const {name} of getBindingIdentifiers(param)) { |
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.
@zinyando would we be able to re-implement this algorithm by trying to target linear O(N) instead quadratic time O(N²)? unless these are really small and we shouldn't care about the performance.
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.
There isn't a more efficient way to do this. param
could have multiple binding identifiers, which is what this will extract.
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.
I see. thanks.
Thank you! |
Adds a
no-dupe-args
check to lint on #94