Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fix require-common-first lint rule from subfolder #56325

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading