Skip to content

refactor: clean up radix rule internals - #21015

Merged
DMartens merged 3 commits into
mainfrom
refactor/radix-global-reference-checks
Jun 29, 2026
Merged

DMartens merged 3 commits into
mainfrom
refactor/radix-global-reference-checks

Conversation

@Pixel998

Copy link
Copy Markdown
Contributor

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

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 radix rule to check parseInt() and Number.parseInt() calls directly from a CallExpression listener.

The rule now uses astUtils.skipChainExpression() and sourceCode.isGlobalReference() instead of walking global scope variables and checking whether they are shadowed.

Is there anything you'd like reviewers to focus on?

@Pixel998
Pixel998 requested a review from a team as a code owner June 23, 2026 11:02
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Jun 23, 2026
@eslint-github-bot eslint-github-bot Bot added the chore This change is not user-facing label Jun 23, 2026
@netlify

netlify Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit d447b1e
🔍 Latest deploy log https://app.netlify.com/projects/docs-eslint/deploys/6a42300a057bbb00091d3b35
😎 Deploy Preview https://deploy-preview-21015--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the rule Relates to ESLint's core rules label Jun 23, 2026
Comment thread lib/rules/radix.js Outdated
* method.
*/
function isParseIntMethod(node) {
function isNumberParseIntMethod(node) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with postponing this change and agree that this should be replaced to make the rule behaviors more consistent.

@DMartens

Copy link
Copy Markdown
Contributor

While the code is simpler, the refactoring also makes the code slower as it has to check for every CallExpression.
As a small test I ran only the rule on the ESLint repository and the rule would be ~1.7x times slower (before: ~10ms, after: ~17ms).
So I would be softly against this change.

@DMartens DMartens moved this from Needs Triage to Feedback Needed in Triage Jun 23, 2026
@Pixel998 Pixel998 changed the title refactor: simplify radix global reference checks refactor: clean up radix rule internals Jun 25, 2026
@Pixel998

Copy link
Copy Markdown
Contributor Author

I've reverted the traversal back to Program:exit to avoid the regression.

Comment thread lib/rules/radix.js
@DMartens DMartens moved this from Feedback Needed to Implementing in Triage Jun 28, 2026

@DMartens DMartens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, thanks.

@DMartens
DMartens merged commit 5ab71d5 into main Jun 29, 2026
35 checks passed
@DMartens
DMartens deleted the refactor/radix-global-reference-checks branch June 29, 2026 22:06
@github-project-automation github-project-automation Bot moved this from Implementing to Complete in Triage Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore This change is not user-facing rule Relates to ESLint's core rules

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants