Skip to content

[eslint-plugin] ESLint 10 compatibility - #1645

Merged
mellyeliu merged 1 commit into
meta:mainfrom
Daniel15:eslint10
May 5, 2026
Merged

mellyeliu merged 1 commit into
meta:mainfrom
Daniel15:eslint10

Conversation

@Daniel15

@Daniel15 Daniel15 commented May 4, 2026 •

Copy link
Copy Markdown
Member

What changed / motivation ?

Several functions that were deprecated in ESLint 9 were deleted in ESLint 10. This diff removes usage of these legacy functions. The only one that was used in stylex is getFilename(), which has been replaced by the filename property.

https://eslint.org/docs/latest/use/migrate-to-10.0.0#-removal-of-deprecated-context-members

The filename property has existed since ESLint 8, so this will not break any projects that are still on old ESLint evrsions.

Upgrading stylex itself to ESLint v10 is outside the scope of this diff. I tried doing that, but the config file needs to be rewritten as it's in the legacy eslintrc format.

Test plan

All tests for the ESLint plugin still pass:

10:26 danlo@danlo-fedora-MJ0FLNP7 ~/src/stylex/packages/@stylexjs/eslint-plugin  (eslint10)
% yarn test  
...
Test Suites: 9 passed, 9 total
Tests:       546 passed, 546 total
Snapshots:   0 total
Time:        7.338 s

Copilot AI review requested due to automatic review settings May 4, 2026 17:30
@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 May 4, 2026
@vercel

vercel Bot commented May 4, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
stylex Skipped Skipped May 4, 2026 5:30pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the StyleX ESLint plugin toward ESLint 10 by replacing deprecated rule-context filename accessors and aligning the local Flow libdef with the newer context shape.

Changes:

  • Replaced context.getFilename() usages with context.filename in two ESLint rules.
  • Updated the bundled Flow RuleContext libdef to expose filename, physicalFilename, and cwd properties.
  • Kept the scope limited to plugin-side compatibility changes rather than upgrading the monorepo itself to ESLint 10.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/@stylexjs/eslint-plugin/src/stylex-valid-styles.js Swaps filename lookup to the newer ESLint context property in the main style validation rule.
packages/@stylexjs/eslint-plugin/src/stylex-enforce-extension.js Swaps filename lookup to the newer ESLint context property in the extension enforcement rule.
packages/@stylexjs/eslint-plugin/flow_modules/eslint/eslint-rule.js.flow Updates the published Flow libdef for ESLint rule contexts to the newer property-based API.

// Track same-file defineVars/defineVarsNested/defineConstsNested declarations.
const currentFilename =
context.getFilename != null ? context.getFilename() : '';
const currentFilename = context.filename;

@Daniel15 Daniel15 May 4, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

getScope() was removed in ESLint 9, not 10: https://eslint.org/docs/latest/use/troubleshooting/v9-rule-api-changes.

ESLint 9 was released around two years ago. This would have already been an issue? I might need to double-check, but I'm sure that if the lint rule was broken on ESLint 9, we would have heard about it by now.

let hasDefineMarkerExports = false;
let reportedDefaultExportError = false;
const fileName = context.getFilename();
const fileName = context.filename;

@Daniel15 Daniel15 May 4, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updating the repo to use ESLint 10 is outside the scope of this diff, since it involves rewriting the config file and ensuring that all lint rules used in the repo are compatible. It can be done in a separate diff.

The fact that the tests pass with ESLint 8 shows that the change is backwards-compatible. Ideally the tests would run with multiple ESLint versions (maybe 8, 9, and 10) but I'm not sure how to do that.

Comment on lines +112 to +123
// parserPath: string,
// parserServices: SourceCode.ParserServices;
sourceCode: SourceCode,
getAncestors(): Array<ESTree.Node>,

// getDeclaredVariables(node: ESTree.Node): Scope.Variable[];

getFilename(): string,
filename: string;

getPhysicalFilename(): string,
physicalFilename: string;

getCwd(): string,
cwd: string;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Realistically I don't think this would be an issue. ESLint 8 and 9 have these properties too, and I'm not sure how many (if any) downstream users are using Flow along with the types shipped with eslint-plugin. There's a bunch of stuff missing from these types.

@mellyeliu mellyeliu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for cleaning this up, it'll be great to get on ESLint 10 soon

@mellyeliu
mellyeliu merged commit 0ddec95 into meta:main May 5, 2026
11 of 14 checks passed

This branch was previously deployed

1 inactive deployment
Preview — b0cb492b Deployed May 4, 2026 by vercel[bot]
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.

3 participants