mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(linter): rule: no-restricted-imports support option patterns with group key (#8050)
one/two wierd tests are not covered > This is also an object option whose value is an array. This option allows you to specify multiple modules to restrict using gitignore-style patterns or regular expressions. _https://eslint.org/docs/latest/rules/no-restricted-imports#patterns_ --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
78d2e837f0
commit
10a1fd57e5
4 changed files with 722 additions and 407 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1691,6 +1691,7 @@ dependencies = [
|
|||
"dashmap 6.1.0",
|
||||
"fast-glob",
|
||||
"globset",
|
||||
"ignore",
|
||||
"insta",
|
||||
"itertools",
|
||||
"json-strip-comments",
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ cow-utils = { workspace = true }
|
|||
dashmap = { workspace = true }
|
||||
fast-glob = { workspace = true }
|
||||
globset = { workspace = true }
|
||||
ignore = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
json-strip-comments = { workspace = true }
|
||||
language-tags = { workspace = true }
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -30,6 +30,48 @@ snapshot_kind: text
|
|||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'foo/bar' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:26]
|
||||
1 │ import withPatterns from "foo/bar";
|
||||
· ─────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): foo is forbidden, use foo/bar instead
|
||||
╭─[no_restricted_imports.tsx:1:26]
|
||||
1 │ import withPatterns from "foo/baz";
|
||||
· ─────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): some foo subimports are restricted
|
||||
╭─[no_restricted_imports.tsx:1:26]
|
||||
1 │ import withPatterns from "foo/baz";
|
||||
· ─────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'foo/bar' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:26]
|
||||
1 │ import withPatterns from "foo/bar";
|
||||
· ─────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'foo' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:41]
|
||||
1 │ import withPatternsCaseInsensitive from 'foo';
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'foo/bar' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:28]
|
||||
1 │ import withGitignores from "foo/bar";
|
||||
· ─────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'fs' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:1]
|
||||
1 │ export * from "fs";
|
||||
|
|
@ -275,6 +317,13 @@ snapshot_kind: text
|
|||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): import Image from ui/_components instead
|
||||
╭─[no_restricted_imports.tsx:1:41]
|
||||
1 │ import { Image, Text, ScrollView } from 'react-native'
|
||||
· ──────────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): import Text from ui/_components instead
|
||||
╭─[no_restricted_imports.tsx:1:41]
|
||||
1 │ import { Image, Text, ScrollView } from 'react-native'
|
||||
|
|
@ -289,13 +338,6 @@ snapshot_kind: text
|
|||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): import Image from ui/_components instead
|
||||
╭─[no_restricted_imports.tsx:1:41]
|
||||
1 │ import { Image, Text, ScrollView } from 'react-native'
|
||||
· ──────────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Import foo from qux instead.
|
||||
╭─[no_restricted_imports.tsx:1:31]
|
||||
1 │ import { foo, bar, baz } from 'mod'
|
||||
|
|
@ -310,6 +352,13 @@ snapshot_kind: text
|
|||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Don"t use "foo" and `qux` from "mod".
|
||||
╭─[no_restricted_imports.tsx:1:36]
|
||||
1 │ import { foo, bar, baz, qux } from 'mod'
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Use `barbaz` instead of `bar`.
|
||||
╭─[no_restricted_imports.tsx:1:36]
|
||||
1 │ import { foo, bar, baz, qux } from 'mod'
|
||||
|
|
@ -324,20 +373,6 @@ snapshot_kind: text
|
|||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Don"t use "foo" and `qux` from "mod".
|
||||
╭─[no_restricted_imports.tsx:1:36]
|
||||
1 │ import { foo, bar, baz, qux } from 'mod'
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Don"t use "foo" or "baz" from "mod".
|
||||
╭─[no_restricted_imports.tsx:1:36]
|
||||
1 │ import { foo, bar, baz, qux } from 'mod'
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Don"t use "foo" or "baz" from "mod".
|
||||
╭─[no_restricted_imports.tsx:1:36]
|
||||
1 │ import { foo, bar, baz, qux } from 'mod'
|
||||
|
|
@ -352,6 +387,13 @@ snapshot_kind: text
|
|||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Don"t use "foo" or "baz" from "mod".
|
||||
╭─[no_restricted_imports.tsx:1:36]
|
||||
1 │ import { foo, bar, baz, qux } from 'mod'
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Import foo from qux instead.
|
||||
╭─[no_restricted_imports.tsx:1:22]
|
||||
1 │ import * as mod from 'mod'
|
||||
|
|
@ -471,6 +513,13 @@ snapshot_kind: text
|
|||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): '../foo' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:34]
|
||||
1 │ import relativeWithPatterns from '../foo';
|
||||
· ────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): '/foo' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:22]
|
||||
1 │ import absolute from '/foo';
|
||||
|
|
@ -485,6 +534,83 @@ snapshot_kind: text
|
|||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): '/foo' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:34]
|
||||
1 │ import absoluteWithPatterns from '/foo';
|
||||
· ──────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): '../../my/relative-module' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:21]
|
||||
1 │ import { Foo } from '../../my/relative-module';
|
||||
· ──────────────────────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Import from @/utils instead.
|
||||
╭─[no_restricted_imports.tsx:1:26]
|
||||
1 │ import { Foo, Bar } from '../../my/relative-module';
|
||||
· ──────────────────────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Import from @/utils instead.
|
||||
╭─[no_restricted_imports.tsx:1:26]
|
||||
1 │ import { Foo, Bar } from '../../my/relative-module';
|
||||
· ──────────────────────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): '../../my/relative-module' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:22]
|
||||
1 │ import * as All from '../../my/relative-module';
|
||||
· ──────────────────────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Import from @/utils instead.
|
||||
╭─[no_restricted_imports.tsx:1:39]
|
||||
1 │ import * as AllWithCustomMessage from '../../my/relative-module';
|
||||
· ──────────────────────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'mod' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:26]
|
||||
1 │ import def, * as ns from 'mod';
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'mod' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:26]
|
||||
1 │ import def, * as ns from 'mod';
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'mod' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:17]
|
||||
1 │ import Foo from 'mod';
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'foo' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:49]
|
||||
1 │ import { AllowedObject, DisallowedObject } from "foo";
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Only "AllowedObject" is allowed to be imported from "foo".
|
||||
╭─[no_restricted_imports.tsx:1:49]
|
||||
1 │ import { AllowedObject, DisallowedObject } from "foo";
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'foo' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:49]
|
||||
1 │ import { AllowedObject, DisallowedObject } from "foo";
|
||||
|
|
@ -512,3 +638,24 @@ snapshot_kind: text
|
|||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): 'foo/bar' import is restricted from being used.
|
||||
╭─[no_restricted_imports.tsx:1:32]
|
||||
1 │ import * as AllowedObject from "foo/bar";
|
||||
· ─────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): Only "AllowedObject" is allowed to be imported from "foo".
|
||||
╭─[no_restricted_imports.tsx:1:32]
|
||||
1 │ import * as AllowedObject from "foo/bar";
|
||||
· ─────────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
||||
⚠ eslint(no-restricted-imports): foo is forbidden, use bar instead
|
||||
╭─[no_restricted_imports.tsx:1:39]
|
||||
1 │ import withPatternsCaseSensitive from 'foo';
|
||||
· ─────
|
||||
╰────
|
||||
help: Remove the import statement.
|
||||
|
|
|
|||
Loading…
Reference in a new issue