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
  • Loading branch information
aduh95 committed Dec 20, 2024
1 parent b6df128 commit 814421d
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',
},
}

Check failure on line 28 in test/parallel/test-eslint-require-common-first.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing trailing comma
],
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 814421d

Please sign in to comment.