Skip to content

Commit 2d67129

Browse files
aduh95RafaelGSS
authored andcommitted
tools: fix require-common-first lint rule from subfolder
PR-URL: #56325 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
1 parent 25d895c commit 2d67129

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

test/parallel/test-eslint-require-common-first.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ new RuleTester().run('require-common-first', rule, {
1616
code: 'require("common")\n' +
1717
'require("assert")'
1818
},
19+
{
20+
code: 'import "../../../../common/index.mjs";',
21+
languageOptions: {
22+
sourceType: 'module',
23+
},
24+
},
1925
],
2026
invalid: [
2127
{

tools/eslint-rules/require-common-first.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
* @returns {string} module name
2323
*/
2424
function getModuleName(str) {
25-
if (str === '../common/index.mjs') {
25+
if (str.startsWith('../') && str.endsWith('/common/index.mjs')) {
2626
return 'common';
2727
}
2828

0 commit comments

Comments
 (0)