Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions doc/api/perf_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2199,6 +2199,8 @@ const timedImport = performance.timerify(async (module) => {
await timedImport('some-module');
```

<!-- eslint-disable no-global-assign -->

```cjs
'use strict';
const {
Expand Down
2 changes: 2 additions & 0 deletions doc/api/single-executable-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ To load modules from the file system in the injected main script, users can
create a `require` function that can load from the file system using
`module.createRequire()`. For example, in a CommonJS entry point:

<!-- eslint-disable no-global-assign -->

```js
const { createRequire } = require('node:module');
require = createRequire(__filename);
Expand Down
7 changes: 4 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ export default [
js.configs.recommended,
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.

languageOptions: {
// The default is `commonjs` but it's not supported by the Babel parser.
sourceType: 'script',
sourceType: 'commonjs',
},
},
{
Expand Down Expand Up @@ -229,6 +228,7 @@ export default [
...noRestrictedSyntaxCommonLib,
],
'no-self-compare': 'error',
'no-shadow-restricted-names': ['error', { reportGlobalThis: false }],
'no-template-curly-in-string': 'error',
'no-throw-literal': 'error',
'no-undef': ['error', { typeof: true }],
Expand Down Expand Up @@ -256,6 +256,7 @@ export default [

// ESLint recommended rules that we disable.
'no-inner-declarations': 'off',
'no-useless-assignment': 'off',

// JSDoc rules.
'jsdoc/require-jsdoc': 'off',
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1778,8 +1778,6 @@ Module.prototype._compile = function(content, filename, format) {
}
}

let redirects;

let compiledWrapper;
if (format !== 'module') {
const result = wrapSafe(filename, content, this, format);
Expand All @@ -1795,7 +1793,7 @@ Module.prototype._compile = function(content, filename, format) {
}

const dirname = path.dirname(filename);
const require = makeRequireFunction(this, redirects);
const require = makeRequireFunction(this);
let result;
const exports = this.exports;
const thisValue = exports;
Expand Down
10 changes: 5 additions & 5 deletions test/common/sea.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function generateSEA(fixtureDir, options = {}) {
} catch (e) {
const message = `Cannot copy ${process.execPath} to ${outputFile}: ${inspect(e)}`;
if (verifyWorkflow) {
throw new Error(message);
throw new Error(message, { cause: e });
}
common.skip(message);
}
Expand Down Expand Up @@ -192,7 +192,7 @@ function generateSEA(fixtureDir, options = {}) {
} catch (e) {
const message = `Cannot inject ${seaPrepBlob} into ${outputFile}: ${inspect(e)}`;
if (verifyWorkflow) {
throw new Error(message);
throw new Error(message, { cause: e });
}
common.skip(message);
}
Expand All @@ -210,7 +210,7 @@ function signSEA(targetExecutable, verifyWorkflow = false) {
} catch (e) {
const message = `Cannot sign ${targetExecutable}: ${inspect(e)}`;
if (verifyWorkflow) {
throw new Error(message);
throw new Error(message, { cause: e });
}
common.skip(message);
}
Expand All @@ -221,7 +221,7 @@ function signSEA(targetExecutable, verifyWorkflow = false) {
} catch (e) {
const message = `Cannot find signtool: ${inspect(e)}`;
if (verifyWorkflow) {
throw new Error(message);
throw new Error(message, { cause: e });
}
common.skip(message);
}
Expand All @@ -232,7 +232,7 @@ function signSEA(targetExecutable, verifyWorkflow = false) {
} catch (e) {
const message = `Cannot sign ${targetExecutable}: ${inspect(e)}\n${stderr}`;
if (verifyWorkflow) {
throw new Error(message);
throw new Error(message, { cause: e });
}
common.skip(message);
}
Expand Down
1 change: 1 addition & 0 deletions test/es-module/test-esm-detect-ambiguous.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL },
}

it('should not hint wrong format in resolve hook', async () => {
// eslint-disable-next-line no-unassigned-vars
let writeSync;
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
'--no-warnings',
Expand Down
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,
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

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
Loading
Loading