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
Next Next commit
tools: fix require-common-first lint rule from subfolder
  • Loading branch information
aduh95 committed Dec 20, 2024
commit 814421de8ce64a6b0f7f310f0eae9e6c1c56b3fb
1 change: 0 additions & 1 deletion test/addons/esm/test-esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-eslint-require-common-first.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ new RuleTester({
code: 'require("common")\n' +
'require("assert")'
},
{
code: 'import "../../../../common/index.mjs";',
languageOptions: {
sourceType: 'module',
},
}
],
invalid: [
{
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint-rules/require-common-first.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down