mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
tools: fix require-common-first lint rule from subfolder
PR-URL: https://github.com/nodejs/node/pull/56325 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -20,6 +20,12 @@ new RuleTester({
|
||||
code: 'require("common")\n' +
|
||||
'require("assert")'
|
||||
},
|
||||
{
|
||||
code: 'import "../../../../common/index.mjs";',
|
||||
languageOptions: {
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user