Skip to content

[eslint-plugin] Fix valid-styles crash on ESLint 9 and 10 - #1976

Open
rodrigosdev wants to merge 3 commits into
meta:mainfrom
rodrigosdev:fix/eslint-9-get-scope
Open

rodrigosdev wants to merge 3 commits into
meta:mainfrom
rodrigosdev:fix/eslint-9-get-scope

Conversation

@rodrigosdev

@rodrigosdev rodrigosdev commented Oct 21, 2026 •

Copy link
Copy Markdown

What changed / motivation ?

On ESLint 9 and 10, valid-styles crashes with context.getScope is not a function when a number-valued property is set to an imported or undeclared identifier, e.g. flexGrow: IMPORTED. isNumber still calls context.getScope(), which ESLint 9 removed.

This switches to sourceCode.getScope(node) through the existing getSourceCode helper.

History

sourceCode.getScope(node) works on every version from 8.37 up, so older setups are unaffected.

Linked PR/Issues

Related to #1248 and #1645

Additional Context

Linted a fixture with every rule against ESLint 8.40.0, 8.57.1, 9.39.5 and 10.13.0. Before: 9.39.5 and 10.13.0 crash in valid-styles. After: all four report the same 7 messages with no fatal errors. Existing eslint-plugin tests pass.

Pre-flight checklist

🤖 Generated with Claude Code

`isNumber` called `context.getScope()`, which ESLint 9 removed. Any
number-valued property set to an imported or undeclared identifier made
`valid-styles` throw `context.getScope is not a function`. Use
`sourceCode.getScope(node)` instead, available since ESLint 8.37.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla

meta-cla Bot commented Oct 21, 2026

Copy link
Copy Markdown

Hi @rodrigosdev!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
stylex Ignored Ignored Oct 21, 2026 4:20pm UTC

Request Review

Comment on lines +37 to +38
// `context.getScope()` was removed in ESLint 9; `sourceCode.getScope(node)`
// is available since ESLint 8.37.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I would drop this comment and just let the PR explain the reasoning and historical context.

rodrigosdev and others added 2 commits October 21, 2026 17:04
The reasoning lives in the PR description instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 21, 2026
@henryqdineen

Copy link
Copy Markdown
Collaborator

👍 Would love to see this land. It should also let the rules be supported by Oxlint.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants