Diff Delta:
71
About 44 Diff Delta/hour
Classified as:
General
andymai's Description of Work
Summary
Addresses https://github.com/import-js/eslint-plugin-import/issues/1281
Recreation of #3200, which became unrecoverable after I deleted the fork β apologies for the churn. This is the final state of that PR (post-review), rebased onto current main, with both review comments addressed:
- Uses
minimatch(already a dependency) instead of dynamic regex construction, per review feedback - The matching is inlined directly in
isBuiltInβ no wrapper function, per review feedback
Changes
-
src/core/importType.js: patterns inimport/core-modulescontaining*are matched withminimatch(exact matches still useindexOffirst) - Tests for basic wildcards (
@my-monorepo/*), multiple wildcards (@my-*/*), mixed exact + wildcard lists, and subpaths of wildcard-matched modules -
no-extraneous-dependenciesrule tests for wildcard core-modules - README example of wildcard usage
Test plan
- [x] All existing tests pass
- [x] New tests in
tests/src/core/importType.jsandtests/src/rules/no-extraneous-dependencies.js
Notes
- Non-string entries in the setting are ignored (previously
indexOftolerated them;pattern.includeswould have thrown), and minimatch's!negation /#comment semantics are disabled (nonegate/nocomment) so a pattern like!@foo/*can't accidentally match everything. -
Known limitation:eslint-module-utils'resolvestill does an exact-matchSet.has()onimport/core-modules(utils/resolve.js), so wildcard entries are honored byimportType-based rules but not by resolver-based ones likeno-unresolved. Happy to extend this toeslint-module-utilsin this PR or a follow-up if that's the preferred direction.
5 total changed files
Loading changes...
Loading changes...
Loading changes...
Loading changes...
Loading changes...
Congrats, you've cleared the final file
Like the credits, but with fewer stunts.