Skip to content

Commit 65a6616

Browse files
committed
fix: support literal path instead of glob for rule no-unassigned-import's allow option
close #347
1 parent 12a7cda commit 65a6616

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
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: support literal path instead of glob for rule `no-unassigned-import`'s `allow` option

src/rules/no-unassigned-import.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function testIsAllow(
2121

2222
return globs.some(
2323
glob =>
24+
filePath === glob ||
2425
minimatch(filePath, glob) ||
2526
minimatch(filePath, path.resolve(glob), { windowsPathsNoEscape: true }),
2627
)

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)