Skip to content

Commit

Permalink
tools: fix require-common-first lint rule from subfolder
Browse files Browse the repository at this point in the history
PR-URL: #56325
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: LiviaMedeiros <[email protected]>
  • Loading branch information
aduh95 authored Dec 22, 2024
1 parent 31c20f6 commit 48c75bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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

0 comments on commit 48c75bc

Please sign in to comment.