Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tools: update rules for ESLint 10
  • Loading branch information
JLHwung committed Mar 3, 2026
commit 34399fc1957ce730417eb337625a8bc52a3b5f6d
2 changes: 1 addition & 1 deletion tools/eslint-rules/prefer-optional-chaining.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
},

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = context.sourceCode;

// Helper function: Checks if two nodes have identical tokens
function equalTokens(left, right) {
Expand Down
13 changes: 7 additions & 6 deletions tools/eslint-rules/require-common-first.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ module.exports = {
// The common module should be loaded in the first place.
const notLoadedFirst = foundModules.indexOf(requiredModule) !== 0;
if (notLoadedFirst) {
context.report(
node,
'Mandatory module "{{moduleName}}" must be loaded ' +
'before any other modules.',
{ moduleName: requiredModule },
);
context.report({
node: node.body[0] ?? node,

@JLHwung JLHwung Feb 20, 2026 •

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.

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

message:
'Mandatory module "{{moduleName}}" must be loaded ' +
'before any other modules.',
data: { moduleName: requiredModule },
});
}
},
};
Expand Down
10 changes: 5 additions & 5 deletions tools/eslint-rules/required-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ module.exports = {
([module]) => foundModules.indexOf(module) === -1,
);
missingModules.forEach(([moduleName]) => {
context.report(
node,
'Mandatory module "{{moduleName}}" must be loaded.',
{ moduleName: moduleName },
);
context.report({
node: node.body[0] ?? node,
message: 'Mandatory module "{{moduleName}}" must be loaded.',
data: { moduleName: moduleName },
});
});
}
},
Expand Down