Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5dcbc51

Browse files
authored
docs: Add example with side-effect imports to no-restricted-imports (#18997)
* docs: Add example with side-effect imports to no-restricted-imports* update quotes for consistency
1 parented4635f commit5dcbc51

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

‎docs/src/rules/no-restricted-imports.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,40 @@ import isEmpty, { hasValue } from 'utils/collection-utils';
694694

695695
:::
696696

697+
You can also use this option to allow only side-effect imports by setting it to a pattern that matches any name, such as`^`.
698+
699+
Examples of**incorrect** code for`importNamePattern` option:
700+
701+
::: incorrect { "sourceType": "module" }
702+
703+
```js
704+
/*eslint no-restricted-imports: ["error", { patterns: [{
705+
group: ["utils/*"],
706+
importNamePattern: "^"
707+
}]}]*/
708+
709+
importisEmpty, {hasValue }from'utils/collection-utils';
710+
711+
import*asfilefrom'utils/file-utils';
712+
```
713+
714+
:::
715+
716+
Examples of**correct** code for`importNamePattern` option:
717+
718+
::: correct { "sourceType": "module" }
719+
720+
```js
721+
/*eslint no-restricted-imports: ["error", { patterns: [{
722+
group: ["utils/*"],
723+
importNamePattern: "^"
724+
}]}]*/
725+
726+
import'utils/init-utils';
727+
```
728+
729+
:::
730+
697731
####allowImportNamePattern
698732

699733
This is a string option. Inverse of`importNamePattern`, this option allows imports that matches the specified regex pattern. So it restricts all imports from a module, except specified allowed patterns.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp