diff --git a/test/addons/esm/test-esm.mjs b/test/addons/esm/test-esm.mjs index fd2ab14c501cd4..8635d7fc49f684 100644 --- a/test/addons/esm/test-esm.mjs +++ b/test/addons/esm/test-esm.mjs @@ -4,7 +4,6 @@ * the ESM loader or the CJS loader. */ -// eslint-disable-next-line node-core/require-common-first import { buildType } from '../../common/index.mjs'; import assert from 'node:assert'; import { createRequire } from 'node:module'; diff --git a/test/parallel/test-eslint-require-common-first.js b/test/parallel/test-eslint-require-common-first.js index ef19f95b97d635..d7980cebedbfb8 100644 --- a/test/parallel/test-eslint-require-common-first.js +++ b/test/parallel/test-eslint-require-common-first.js @@ -20,6 +20,12 @@ new RuleTester({ code: 'require("common")\n' + 'require("assert")' }, + { + code: 'import "../../../../common/index.mjs";', + languageOptions: { + sourceType: 'module', + }, + }, ], invalid: [ { diff --git a/tools/eslint-rules/require-common-first.js b/tools/eslint-rules/require-common-first.js index 2bfe146086e577..5a8980d5d1c71b 100644 --- a/tools/eslint-rules/require-common-first.js +++ b/tools/eslint-rules/require-common-first.js @@ -22,7 +22,7 @@ module.exports = { * @returns {string} module name */ function getModuleName(str) { - if (str === '../common/index.mjs') { + if (str.startsWith('../') && str.endsWith('/common/index.mjs')) { return 'common'; }