Skip to content

Commit 3bc48fc

Browse files
authored
fix: enable nocomment glob option for rule no-unassigned-import's allow option (#352)
1 parent 12a7cda commit 3bc48fc

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

.changeset/wise-tables-stop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": patch
3+
---
4+
5+
fix: enable `nocomment` glob option for rule `no-unassigned-import`'s `allow` option

src/rules/no-unassigned-import.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ function testIsAllow(
2121

2222
return globs.some(
2323
glob =>
24-
minimatch(filePath, glob) ||
25-
minimatch(filePath, path.resolve(glob), { windowsPathsNoEscape: true }),
24+
minimatch(filePath, glob, { nocomment: true }) ||
25+
minimatch(filePath, path.resolve(glob), {
26+
nocomment: true,
27+
windowsPathsNoEscape: true,
28+
}),
2629
)
2730
}
2831

test/rules/no-unassigned-import.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ ruleTester.run('no-unassigned-import', rule, {
7373
filename: path.resolve('src/app.js'),
7474
options: [{ allow: ['src/styles/**', '**/scripts/*.js'] }],
7575
}),
76+
tValid({
77+
code: 'import "#app/side-effects.js"',
78+
// exactly matched
79+
options: [{ allow: ['#app/side-effects.js'] }],
80+
}),
81+
tValid({
82+
code: 'import "#app/side-effects.js"',
83+
/**
84+
* Matched by glob
85+
*
86+
* @see https://github.com/isaacs/minimatch#comparisons-to-other-fnmatchglob-implementations
87+
*/
88+
options: [{ allow: [String.raw`\#app/side-effects.js`] }],
89+
}),
7690
],
7791
invalid: [
7892
tInvalid({

0 commit comments

Comments
 (0)