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
PR-URL: #56325
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: LiviaMedeiros <[email protected]>
  • Loading branch information
aduh95 committed Jan 31, 2025
1 parent b197dfa commit 53b29b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 53b29b0

Please sign in to comment.