Repository navigation
refactor: clean up radix rule internals - #21015
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| * method. | ||
| */ | ||
| function isParseIntMethod(node) { | ||
| function isNumberParseIntMethod(node) { |
There was a problem hiding this comment.
We could probably remove this helper and use astUtils.isSpecificMemberAccess(callee, "Number", "parseInt") here. However, that would slightly expand the rule’s behavior because it also matches static computed properties such as Number["parseInt"]("10"), which the current code does not report. Maybe worth handling in a separate PR if we want to make that behavior change.
There was a problem hiding this comment.
I agree with postponing this change and agree that this should be replaced to make the rule behaviors more consistent.
|
While the code is simpler, the refactoring also makes the code slower as it has to check for every |
|
I've reverted the traversal back to |
Prerequisites checklist
AI acknowledgment
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:
What changes did you make? (Give an overview)
Refactored the
radixrule to checkparseInt()andNumber.parseInt()calls directly from aCallExpressionlistener.The rule now uses
astUtils.skipChainExpression()andsourceCode.isGlobalReference()instead of walking global scope variables and checking whether they are shadowed.Is there anything you'd like reviewers to focus on?