Skip to content

tools: update eslint to v10#61905

Open
JLHwung wants to merge 9 commits intonodejs:mainfrom
JLHwung:update-eslint
Open

tools: update eslint to v10#61905
JLHwung wants to merge 9 commits intonodejs:mainfrom
JLHwung:update-eslint

Conversation

@JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Feb 20, 2026

In this PR we bumped tools/eslint to v10 and the @babel/* to 8.0.0-rc.2, the first version shipped with ESLint v10 support.

The eslint rules are revised due to breaking changes in ESLint v10. To limit the size of this PR, I have also turned off one new recommended rules in v10: no-useless-assignment, as it introduced hundreds of errors across the codebase. We can investigate later if we want to enable this rule.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/single-executable

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Feb 20, 2026
{ moduleName: requiredModule },
);
context.report({
node: node.body[0] ?? node,
Copy link
Contributor Author

@JLHwung JLHwung Feb 20, 2026

Choose a reason for hiding this comment

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

The ESLint v10 has modified the ranges of a Program to cover the leading comments.
https://eslint.org/docs/latest/use/migrate-to-10.0.0#-program-ast-node-range-spans-entire-source-text

As a result, the /* eslint-disable */ comment does not work if we still report error at the start of the program, since the comment will be after the start of the Program node. Here we report at the first statement.

c.f. eslint/eslint#20451

jsdoc.configs['flat/recommended'],
{
files: ['**/*.{js,cjs}'],
files: ['**/*.js'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ESLint will automatically set sourceType of .cjs to commonjs, so we don't need specify the sourceType for cjs files.

Disable `reportGlobalThis`, essentially restore the behaviour to ESLint v9.
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.78%. Comparing base (199daab) to head (8c8490b).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61905      +/-   ##
==========================================
+ Coverage   89.75%   89.78%   +0.02%     
==========================================
  Files         674      674              
  Lines      204886   204955      +69     
  Branches    39376    39388      +12     
==========================================
+ Hits       183894   184014     +120     
+ Misses      13280    13216      -64     
- Partials     7712     7725      +13     
Files with missing lines Coverage Δ
lib/internal/modules/cjs/loader.js 98.36% <100.00%> (-0.01%) ⬇️

... and 37 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Feb 22, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 22, 2026
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@sheplu sheplu left a comment

Choose a reason for hiding this comment

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

LGTM but do we want to wait for a stable release of babel?

@JLHwung
Copy link
Contributor Author

JLHwung commented Feb 22, 2026

do we want to wait for a stable release of babel?

I understand your concern, as a maintainer I am pretty confident about rc.2: features are frozen and the parser passed all test262 test cases for a long time. As the CI shows it also successfully parses all js files in this repo.

The remaining Babel 8 tasks towards a stable release are mostly typing improvements, as it is the first major Babel release with typing definitions. But we (the Node.js repo) don't use the typing part anyway so it is not very relevant.

I can open a new PR once Babel 8 reaches a stable release.

This option is enabled by default in Babel 8.
@bricss
Copy link
Contributor

bricss commented Feb 25, 2026

IMO, babel can probably be removed from the config, as eslint already supports all modern syntax features OOTB 🙂

@JLHwung
Copy link
Contributor Author

JLHwung commented Feb 25, 2026

Yes, you are right. The policy of ESLint is to support every stage 4 features, so it supports all modern syntax out of the box. However, I believe we used @babel/eslint-parser because of source phase imports, a stage 3 feature not yet supported by ESLint,

node/eslint.config.mjs

Lines 103 to 108 in 488a854

babelOptions: {
parserOpts: { createImportExpressions: true },
plugins: [
babelPluginSyntaxImportSource,
],
},

which is used in our docs (eslint also lints example codes):

node/doc/api/esm.md

Lines 749 to 764 in 488a854

```js
import source libraryModule from './library.wasm';
const instance1 = await WebAssembly.instantiate(libraryModule, importObject1);
const instance2 = await WebAssembly.instantiate(libraryModule, importObject2);
```
In addition to the static source phase, there is also a dynamic variant of the
source phase via the `import.source` dynamic phase import syntax:
```js
const dynamicLibrary = await import.source('./library.wasm');
const instance = await WebAssembly.instantiate(dynamicLibrary, importObject);
```

We could switch @babel/eslint-parser to espree once ESLint supports it, but we would require @babel/eslint-parser one day if we would like to showcase or use stage 3 features supported by V8.

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

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants