Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.5k
feat(no-extraneous-dependencies): add exclude option to rule#3198
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -177,6 +177,17 @@ function checkDependencyDeclaration(deps, packageName, declarationStatus) { | ||||||||||||||||||||
| }), newDeclarationStatus); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| function isInExcludeList(packageName, exclude) { | ||||||||||||||||||||
| if (!exclude) { | ||||||||||||||||||||
| return false; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (Array.isArray(exclude)) { | ||||||||||||||||||||
| return exclude.some((pattern) => minimatch(packageName, pattern)); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return minimatch(packageName, exclude); | ||||||||||||||||||||
Comment on lines +181 to +188 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
| ||||||||||||||||||||
| } | ||||||||||||||||||||
| function reportIfMissing(context, deps, depsOptions, node, name) { | ||||||||||||||||||||
| // Do not report when importing types unless option is enabled | ||||||||||||||||||||
| if ( | ||||||||||||||||||||
| @@ -200,6 +211,10 @@ function reportIfMissing(context, deps, depsOptions, node, name) { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (isInExcludeList(name, depsOptions.exclude)) { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| const resolved = resolve(name, context); | ||||||||||||||||||||
| if (!resolved) { return; } | ||||||||||||||||||||
| @@ -277,6 +292,7 @@ module.exports = { | ||||||||||||||||||||
| packageDir: { type: ['string', 'array'] }, | ||||||||||||||||||||
| includeInternal: { type: ['boolean'] }, | ||||||||||||||||||||
| includeTypes: { type: ['boolean'] }, | ||||||||||||||||||||
| exclude: { type: ['string', 'array'] }, | ||||||||||||||||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. for the array, let's ensure it's unique, and that the items can only be of type string | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| additionalProperties: false, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| @@ -295,6 +311,7 @@ module.exports = { | ||||||||||||||||||||
| allowBundledDeps: testConfig(options.bundledDependencies, filename) !== false, | ||||||||||||||||||||
| verifyInternalDeps: !!options.includeInternal, | ||||||||||||||||||||
| verifyTypeImports: !!options.includeTypes, | ||||||||||||||||||||
| exclude: options.exclude, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| return moduleVisitor((source, node) => { | ||||||||||||||||||||
Uh oh!
There was an error while loading.Please reload this page.