Skip to content

Commit a4f336f

Browse files
committed
tools: fix require-common-first lint rule from subfolder
PR-URL: #56325 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
1 parent 0ec2ed0 commit a4f336f

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

test/addons/esm/test-esm.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* the ESM loader or the CJS loader.
55
*/
66

7-
// eslint-disable-next-line node-core/require-common-first
87
import { buildType } from '../../common/index.mjs';
98
import assert from 'node:assert';
109
import { createRequire } from 'node:module';

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ new RuleTester({
2020
code: 'require("common")\n' +
2121
'require("assert")'
2222
},
23+
{
24+
code: 'import "../../../../common/index.mjs";',
25+
languageOptions: {
26+
sourceType: 'module',
27+
},
28+
},
2329
],
2430
invalid: [
2531
{

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy