From a5f763cae04481ac91febf036b7bc41a80dd5c2c Mon Sep 17 00:00:00 2001 From: Tanuj Kanti Date: Sat, 20 Jan 2024 21:52:46 +0530 Subject: [PATCH 1/5] docs: update no-restricted-imports rule --- docs/src/rules/no-restricted-imports.md | 428 +++++++++++++++--------- 1 file changed, 267 insertions(+), 161 deletions(-) diff --git a/docs/src/rules/no-restricted-imports.md b/docs/src/rules/no-restricted-imports.md index 81f7ad4a6f9..8bfc828d76c 100644 --- a/docs/src/rules/no-restricted-imports.md +++ b/docs/src/rules/no-restricted-imports.md @@ -20,176 +20,140 @@ It applies to static imports only, not dynamic ones. ## Options -The syntax to specify restricted imports looks like this: +This rule has both string and object options to specify the imported modules to restrict. + +Simplest way to specify a module that you want to restrict from being imported is to pass it's name as a string to the options: ```json "no-restricted-imports": ["error", "import1", "import2"] ``` -or like this: +Examples of **incorrect** code for string option: -```json -"no-restricted-imports": ["error", { "paths": ["import1", "import2"] }] -``` +::: incorrect { "sourceType": "module" } -When using the object form, you can also specify an array of gitignore-style patterns: +```js +/*eslint no-restricted-imports: ["error", "fs"]*/ -```json -"no-restricted-imports": ["error", { - "paths": ["import1", "import2"], - "patterns": ["import1/private/*", "import2/*", "!import2/good"] -}] +import fs from 'fs'; ``` -You may also specify a custom message for any paths you want to restrict as follows: +::: -```json -"no-restricted-imports": ["error", { - "name": "import-foo", - "message": "Please use import-bar instead." -}, { - "name": "import-baz", - "message": "Please use import-quux instead." -}] -``` +Specified string can also restrict the module from being exported: -or like this: +::: incorrect { "sourceType": "module" } -```json -"no-restricted-imports": ["error", { - "paths": [{ - "name": "import-foo", - "message": "Please use import-bar instead." - }, { - "name": "import-baz", - "message": "Please use import-quux instead." - }] -}] +```js +/*eslint no-restricted-imports: ["error", "fs"]*/ + +export { fs } from 'fs'; ``` -or like this if you need to restrict only certain imports from a module: +::: -```json -"no-restricted-imports": ["error", { - "paths": [{ - "name": "import-foo", - "importNames": ["Bar"], - "message": "Please use Bar from /import-bar/baz/ instead." - }] -}] -``` +::: incorrect { "sourceType": "module" } -or like this if you want to apply a custom message to pattern matches: +```js +/*eslint no-restricted-imports: ["error", "fs"]*/ -```json -"no-restricted-imports": ["error", { - "patterns": [{ - "group": ["import1/private/*"], - "message": "usage of import1 private modules not allowed." - }, { - "group": ["import2/*", "!import2/good"], - "message": "import2 is deprecated, except the modules in import2/good." - }] -}] +export * from 'fs'; ``` -The custom message will be appended to the default error message. +::: -Pattern matches can also be configured to be case-sensitive: -```json -"no-restricted-imports": ["error", { - "patterns": [{ - "group": ["import1/private/prefix[A-Z]*"], - "caseSensitive": true - }] -}] -``` +Examples of **correct** code for string option: -Pattern matches can restrict specific import names only, similar to the `paths` option: +::: correct { "sourceType": "module" } -```json -"no-restricted-imports": ["error", { - "patterns": [{ - "group": ["utils/*"], - "importNames": ["isEmpty"], - "message": "Use 'isEmpty' from lodash instead." - }] -}] +```js +/*eslint no-restricted-imports: ["error", "fs"]*/ + +import crypto from 'crypto'; +export { foo } from "bar"; ``` -Regex patterns can also be used to restrict specific import Name: +::: + +You may also specify a custom message for a particular module simply using `name` and `message` properties inside an object, where the value of the `name` property will be the name of the module and `message` property will contain the custom message. The custom message will be appended to the default error message: ```json "no-restricted-imports": ["error", { - "patterns": [{ - "group": ["import-foo/*"], - "importNamePattern": "^foo", - }] + "name": "import-foo", + "message": "Please use import-bar instead." +}, { + "name": "import-baz", + "message": "Please use import-quux instead." }] ``` -To restrict the use of all Node.js core imports (via ): - -```json - "no-restricted-imports": ["error", - "assert","buffer","child_process","cluster","crypto","dgram","dns","domain","events","freelist","fs","http","https","module","net","os","path","punycode","querystring","readline","repl","smalloc","stream","string_decoder","sys","timers","tls","tracing","tty","url","util","vm","zlib" - ], -``` - -## Examples - -Examples of **incorrect** code for this rule: +Examples of **incorrect** code for string option: ::: incorrect { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", "fs"]*/ +/*eslint no-restricted-imports: ["error", { + "name": "disallowed-import", + "message": "Please use 'allowed-import' instead" +}]*/ -import fs from 'fs'; +import foo from 'disallowed-import'; ``` ::: -::: incorrect { "sourceType": "module" } +### paths -```js -/*eslint no-restricted-imports: ["error", "fs"]*/ +This is an object option whose value is an array and the name of the module you want to restrict can be specified inside this array, same as in string option above. -export { fs } from 'fs'; +```json +"no-restricted-imports": ["error", { "paths": ["import1", "import2"] }] ``` -::: +Examples of **incorrect** code for `paths`: ::: incorrect { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", "fs"]*/ +/*eslint no-restricted-imports: ["error", { "paths": ["cluster"] }]*/ -export * from 'fs'; +import cluster from 'cluster'; ``` ::: -::: incorrect { "sourceType": "module" } +Custom messages for a particular module can also be specified in `paths` array option using objects as above. -```js -/*eslint no-restricted-imports: ["error", { "paths": ["cluster"] }]*/ - -import cluster from 'cluster'; +```json +"no-restricted-imports": ["error", { + "paths": [{ + "name": "import-foo", + "message": "Please use import-bar instead." + }, { + "name": "import-baz", + "message": "Please use import-quux instead." + }] +}] ``` -::: +#### importNames -::: incorrect { "sourceType": "module" } +This option in `paths` is an array and can be used to specify certain imports to restrict that are being exported from a module. Import names specified inside `paths` array looks for the module specified in the `name` property of corresponding object, so it is required to specify the `name` key with both `importNames` and `message` options. -```js -/*eslint no-restricted-imports: ["error", { "patterns": ["lodash/*"] }]*/ +Passing `"default"` string inside the `importNames` array will restrict the import that is being exported by default by the module. -import pick from 'lodash/pick'; +```json +"no-restricted-imports": ["error", { + "paths": [{ + "name": "import-foo", + "importNames": ["Bar"], + "message": "Please use Bar from /import-bar/baz/ instead." + }] +}] ``` -::: +Examples of **incorrect** code when `importNames` in `paths` has `"default"`: ::: incorrect { "sourceType": "module" } @@ -205,6 +169,8 @@ import DisallowedObject from "foo"; ::: +Examples of **incorrect** code for `importNames` in `paths`: + ::: incorrect { "sourceType": "module" } ```js @@ -237,56 +203,54 @@ import * as Foo from "foo"; ::: -::: incorrect { "sourceType": "module" } +Examples of **correct** code for `importNames` in `paths`: + +Other strings doesn't report default exported import even if the names are same: + +::: correct { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", { patterns: [{ - group: ["lodash/*"], - message: "Please use the default import from 'lodash' instead." -}]}]*/ +/*eslint no-restricted-imports: ["error", { paths: [{ name: "foo", importNames: ["DisallowedObject"] }] }]*/ -import pick from 'lodash/pick'; +import DisallowedObject from "foo" ``` ::: -::: incorrect { "sourceType": "module" } +::: correct { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", { patterns: [{ - group: ["foo[A-Z]*"], - caseSensitive: true +/*eslint no-restricted-imports: ["error", { paths: [{ + name: "foo", + importNames: ["DisallowedObject"], + message: "Please import 'DisallowedObject' from '/bar/baz/' instead." }]}]*/ -import pick from 'fooBar'; +import { AllowedObject as DisallowedObject } from "foo"; ``` ::: -::: incorrect { "sourceType": "module" } +### patterns -```js -/*eslint no-restricted-imports: ["error", { patterns: [{ - group: ["utils/*"], - importNames: ['isEmpty'], - message: "Use 'isEmpty' from lodash instead." -}]}]*/ +This is also an object option whose value is an array. This option comes handy when you need to restrict the modules present inside a perticular directory. Simply, you can specify the modules inside the directories you want to restrict as string in `gitignore-style` patterns. -import { isEmpty } from 'utils/collection-utils'; +Since the patterns follows the `gitignore-style` then if you want to reinclude any particular module this can be done by prefixing a negation (`!`) mark in front of the pattern and it's good to keep the negation patterns in last as `gitignore-style` follows order: + +```json +"no-restricted-imports": ["error", { + "patterns": ["import1/private/*", "import2/*", "!import2/good"] +}] ``` -::: +Examples of **incorrect** code for `pattern` option: ::: incorrect { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", { patterns: [{ - group: ["utils/*"], - importNamePattern: '^is', - message: "Use 'is*' functions from lodash instead." -}]}]*/ +/*eslint no-restricted-imports: ["error", { "patterns": ["lodash/*"] }]*/ -import { isEmpty } from 'utils/collection-utils'; +import pick from 'lodash/pick'; ``` ::: @@ -294,13 +258,9 @@ import { isEmpty } from 'utils/collection-utils'; ::: incorrect { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", { patterns: [{ - group: ["foo/*"], - importNamePattern: '^(is|has)', - message: "Use 'is*' and 'has*' functions from baz/bar instead" -}]}]*/ +/*eslint no-restricted-imports: ["error", { "patterns": ["lodash/*", "!lodash/pick"] }]*/ -import { isSomething, hasSomething } from 'foo/bar'; +import pick from 'lodash/map'; ``` ::: @@ -308,26 +268,24 @@ import { isSomething, hasSomething } from 'foo/bar'; ::: incorrect { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", { patterns: [{ - group: ["foo/*"], - importNames: ["bar"], - importNamePattern: '^baz', -}]}]*/ +/*eslint no-restricted-imports: ["error", { "patterns": ["import1/*", "!import1/private/*"] }]*/ -import { bar, bazQux } from 'foo/quux'; +import pick from 'import1/private/someModule'; ``` ::: -Examples of **correct** code for this rule: +In last example `"!import1/private/*"` is not reincluding the modules inside private directory because in `gitignore-style` negation mark (`!`) does not reinclude the files if it's parent directory is excluded by a pattern. In this case `import1/private` directory is already excluded by the `import1/*` pattern, but excluded directory can be reincluded like using `"!import1/private"`. + +Examples of **correct** code for `pattern` option: + ::: correct { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", "fs"]*/ +/*eslint no-restricted-imports: ["error", { "patterns": ["crypto/*"] }]*/ import crypto from 'crypto'; -export { foo } from "bar"; ``` ::: @@ -335,11 +293,9 @@ export { foo } from "bar"; ::: correct { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", { "paths": ["fs"], "patterns": ["eslint/*"] }]*/ +/*eslint no-restricted-imports: ["error", { "patterns": ["lodash/*", "!lodash/pick"] }]*/ -import crypto from 'crypto'; -import eslint from 'eslint'; -export * from "path"; +import pick from 'lodash/pick'; ``` ::: @@ -347,27 +303,48 @@ export * from "path"; ::: correct { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", { paths: [{ name: "foo", importNames: ["DisallowedObject"] }] }]*/ +/*eslint no-restricted-imports: ["error", { "patterns": ["import1/*", "!import1/private"] }]*/ -import DisallowedObject from "foo" +import pick from 'import1/private/someModule'; ``` ::: -::: correct { "sourceType": "module" } +#### group + +Alternatively you can use this object property which is an array to specify the `gitignore-style` patterns for restricting modules. Custom messages can also be specified like `paths`. + +This is a required property if you are using object options inside the `patterns` array: + +```json +"no-restricted-imports": ["error", { + "patterns": [{ + "group": ["import1/private/*"], + "message": "usage of import1 private modules not allowed." + }, { + "group": ["import2/*", "!import2/good"], + "message": "import2 is deprecated, except the modules in import2/good." + }] +}] +``` + +Examples of **incorrect** code for `group` option: + +::: incorrect { "sourceType": "module" } ```js -/*eslint no-restricted-imports: ["error", { paths: [{ - name: "foo", - importNames: ["DisallowedObject"], - message: "Please import 'DisallowedObject' from '/bar/baz/' instead." +/*eslint no-restricted-imports: ["error", { patterns: [{ + group: ["lodash/*"], + message: "Please use the default import from 'lodash' instead." }]}]*/ -import { AllowedObject as DisallowedObject } from "foo"; +import pick from 'lodash/pick'; ``` ::: +Examples of **correct** code for this `group` option: + ::: correct { "sourceType": "module" } ```js @@ -381,6 +358,36 @@ import lodash from 'lodash'; ::: +#### caseSensitive + +This is a boolean option and allows the patterns specified in the `group` array to be case-sensitive when sets to `true`. Default is `false`: + +```json +"no-restricted-imports": ["error", { + "patterns": [{ + "group": ["import1/private/prefix[A-Z]*"], + "caseSensitive": true + }] +}] +``` + +Examples of **incorrect** code for `caseSensitive: true` option: + +::: incorrect { "sourceType": "module" } + +```js +/*eslint no-restricted-imports: ["error", { patterns: [{ + group: ["foo[A-Z]*"], + caseSensitive: true +}]}]*/ + +import pick from 'fooBar'; +``` + +::: + +Examples of **correct** code for `caseSensitive: true` option: + ::: correct { "sourceType": "module" } ```js @@ -394,6 +401,38 @@ import pick from 'food'; ::: +#### importNames + +`patterns` too has an `importNames` property and this works similar as in `paths`, it just looks for patterns specified inside the `group` array: + +```json +"no-restricted-imports": ["error", { + "patterns": [{ + "group": ["utils/*"], + "importNames": ["isEmpty"], + "message": "Use 'isEmpty' from lodash instead." + }] +}] +``` + +Examples of **incorrect** code for `importNames` in `patterns`: + +::: incorrect { "sourceType": "module" } + +```js +/*eslint no-restricted-imports: ["error", { patterns: [{ + group: ["utils/*"], + importNames: ['isEmpty'], + message: "Use 'isEmpty' from lodash instead." +}]}]*/ + +import { isEmpty } from 'utils/collection-utils'; +``` + +::: + +Examples of **correct** code for `importNames` in `patterns`: + ::: correct { "sourceType": "module" } ```js @@ -408,6 +447,65 @@ import { hasValues } from 'utils/collection-utils'; ::: +#### importNamePattern + +This option allows you to use regex patterns to restrict import names: + +```json +"no-restricted-imports": ["error", { + "patterns": [{ + "group": ["import-foo/*"], + "importNamePattern": "^foo", + }] +}] +``` + +Examples of **incorrect** code for `importNamePattern` option: + +::: incorrect { "sourceType": "module" } + +```js +/*eslint no-restricted-imports: ["error", { patterns: [{ + group: ["utils/*"], + importNamePattern: '^is', + message: "Use 'is*' functions from lodash instead." +}]}]*/ + +import { isEmpty } from 'utils/collection-utils'; +``` + +::: + +::: incorrect { "sourceType": "module" } + +```js +/*eslint no-restricted-imports: ["error", { patterns: [{ + group: ["foo/*"], + importNamePattern: '^(is|has)', + message: "Use 'is*' and 'has*' functions from baz/bar instead" +}]}]*/ + +import { isSomething, hasSomething } from 'foo/bar'; +``` + +::: + +::: incorrect { "sourceType": "module" } + +```js +/*eslint no-restricted-imports: ["error", { patterns: [{ + group: ["foo/*"], + importNames: ["bar"], + importNamePattern: '^baz', +}]}]*/ + +import { bar, bazQux } from 'foo/quux'; +``` + +::: + +Examples of **correct** code for `importNamePattern` option: + ::: correct { "sourceType": "module" } ```js @@ -422,6 +520,14 @@ import isEmpty, { hasValue } from 'utils/collection-utils'; ::: +To restrict the use of all Node.js core imports (via ): + +```json + "no-restricted-imports": ["error", + "assert","buffer","child_process","cluster","crypto","dgram","dns","domain","events","freelist","fs","http","https","module","net","os","path","punycode","querystring","readline","repl","smalloc","stream","string_decoder","sys","timers","tls","tracing","tty","url","util","vm","zlib" + ], +``` + ## When Not To Use It Don't use this rule or don't include a module in the list for this rule if you want to be able to import a module in your project without an ESLint error or warning. From b97625b2ec3ec0739398864ae116e4f5304b66eb Mon Sep 17 00:00:00 2001 From: Tanuj Kanti Date: Sat, 20 Jan 2024 22:03:23 +0530 Subject: [PATCH 2/5] fix linting errors --- docs/src/rules/no-restricted-imports.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/src/rules/no-restricted-imports.md b/docs/src/rules/no-restricted-imports.md index 8bfc828d76c..353b4e305b9 100644 --- a/docs/src/rules/no-restricted-imports.md +++ b/docs/src/rules/no-restricted-imports.md @@ -62,7 +62,6 @@ export * from 'fs'; ::: - Examples of **correct** code for string option: ::: correct { "sourceType": "module" } @@ -279,7 +278,6 @@ In last example `"!import1/private/*"` is not reincluding the modules inside pri Examples of **correct** code for `pattern` option: - ::: correct { "sourceType": "module" } ```js From 09519184978319dcc0849c9961cfd828c96cbe99 Mon Sep 17 00:00:00 2001 From: Tanuj Kanti Date: Wed, 24 Jan 2024 08:12:19 +0530 Subject: [PATCH 3/5] docs: update docs language --- docs/src/rules/no-restricted-imports.md | 31 +++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/src/rules/no-restricted-imports.md b/docs/src/rules/no-restricted-imports.md index 353b4e305b9..8d79bd566a0 100644 --- a/docs/src/rules/no-restricted-imports.md +++ b/docs/src/rules/no-restricted-imports.md @@ -22,7 +22,7 @@ It applies to static imports only, not dynamic ones. This rule has both string and object options to specify the imported modules to restrict. -Simplest way to specify a module that you want to restrict from being imported is to pass it's name as a string to the options: +Using string option, you can specify the name of a module that you want to restrict from being imported as a value in the rule options array: ```json "no-restricted-imports": ["error", "import1", "import2"] @@ -40,7 +40,7 @@ import fs from 'fs'; ::: -Specified string can also restrict the module from being exported: +String options also restrict the module from being exported, as in this example: ::: incorrect { "sourceType": "module" } @@ -75,7 +75,7 @@ export { foo } from "bar"; ::: -You may also specify a custom message for a particular module simply using `name` and `message` properties inside an object, where the value of the `name` property will be the name of the module and `message` property will contain the custom message. The custom message will be appended to the default error message: +You may also specify a custom message for a particular module using the `name` and `message` properties inside an object, where the value of the `name` is the name of the module and `message` property contains the custom message. (The custom message is appended to the default error message from the rule.) ```json "no-restricted-imports": ["error", { @@ -104,7 +104,7 @@ import foo from 'disallowed-import'; ### paths -This is an object option whose value is an array and the name of the module you want to restrict can be specified inside this array, same as in string option above. +This is an object option whose value is an array containing the names of the modules you want to restrict. ```json "no-restricted-imports": ["error", { "paths": ["import1", "import2"] }] @@ -122,7 +122,7 @@ import cluster from 'cluster'; ::: -Custom messages for a particular module can also be specified in `paths` array option using objects as above. +Custom messages for a particular module can also be specified in `paths` array using objects with `name` and `message`. ```json "no-restricted-imports": ["error", { @@ -138,9 +138,10 @@ Custom messages for a particular module can also be specified in `paths` array o #### importNames -This option in `paths` is an array and can be used to specify certain imports to restrict that are being exported from a module. Import names specified inside `paths` array looks for the module specified in the `name` property of corresponding object, so it is required to specify the `name` key with both `importNames` and `message` options. +This option in `paths` is an array and can be used to specify the names of certain bindings exported from a module. Import names specified inside `paths` array affect the module specified in the `name` property of corresponding object, so it is required to specify the `name` property first when you are using `importNames` or `message` option. -Passing `"default"` string inside the `importNames` array will restrict the import that is being exported by default by the module. + +Specifying `"default"` string inside the `importNames` array will restrict the default export from being imported. ```json "no-restricted-imports": ["error", { @@ -204,7 +205,7 @@ import * as Foo from "foo"; Examples of **correct** code for `importNames` in `paths`: -Other strings doesn't report default exported import even if the names are same: +If the local name assigned to a default export is the same as a string in `importNames`, this will not cause an error. ::: correct { "sourceType": "module" } @@ -232,9 +233,9 @@ import { AllowedObject as DisallowedObject } from "foo"; ### patterns -This is also an object option whose value is an array. This option comes handy when you need to restrict the modules present inside a perticular directory. Simply, you can specify the modules inside the directories you want to restrict as string in `gitignore-style` patterns. +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. -Since the patterns follows the `gitignore-style` then if you want to reinclude any particular module this can be done by prefixing a negation (`!`) mark in front of the pattern and it's good to keep the negation patterns in last as `gitignore-style` follows order: +Because the patterns follow the `gitignore`-style, if you want to reinclude any particular module this can be done by prefixing a negation (`!`) mark in front of the pattern. (Negated patterns should come last in the array because order is important.) ```json "no-restricted-imports": ["error", { @@ -274,7 +275,7 @@ import pick from 'import1/private/someModule'; ::: -In last example `"!import1/private/*"` is not reincluding the modules inside private directory because in `gitignore-style` negation mark (`!`) does not reinclude the files if it's parent directory is excluded by a pattern. In this case `import1/private` directory is already excluded by the `import1/*` pattern, but excluded directory can be reincluded like using `"!import1/private"`. +In this example, `"!import1/private/*"` is not reincluding the modules inside `private` because the negation mark (`!`) does not reinclude the files if it's parent directory is excluded by a pattern. In this case, `import1/private` directory is already excluded by the `import1/*` pattern. (The excluded directory can be reincluded using `"!import1/private"`.) Examples of **correct** code for `pattern` option: @@ -310,9 +311,9 @@ import pick from 'import1/private/someModule'; #### group -Alternatively you can use this object property which is an array to specify the `gitignore-style` patterns for restricting modules. Custom messages can also be specified like `paths`. +The `patterns` array can also include objects. The `group` property is used to specify the `gitignore`-style patterns for restricting modules and the `message` property is used to specify a custom message. -This is a required property if you are using object options inside the `patterns` array: +The `group` property is required property when using objects inside the `patterns` array. ```json "no-restricted-imports": ["error", { @@ -358,7 +359,7 @@ import lodash from 'lodash'; #### caseSensitive -This is a boolean option and allows the patterns specified in the `group` array to be case-sensitive when sets to `true`. Default is `false`: +This is a boolean option and sets the patterns specified in the `group` array to be case-sensitive when `true`. Default is `false`. ```json "no-restricted-imports": ["error", { @@ -401,7 +402,7 @@ import pick from 'food'; #### importNames -`patterns` too has an `importNames` property and this works similar as in `paths`, it just looks for patterns specified inside the `group` array: +You can also specify `importNames` on objects inside of `patterns`. In this case, the specified names are applied only to the specified `group`. ```json "no-restricted-imports": ["error", { From 65a6483a0e47413b2e9d08b1ec907d6069aaed2b Mon Sep 17 00:00:00 2001 From: Tanuj Kanti Date: Wed, 24 Jan 2024 08:16:48 +0530 Subject: [PATCH 4/5] fix linting error --- docs/src/rules/no-restricted-imports.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/rules/no-restricted-imports.md b/docs/src/rules/no-restricted-imports.md index 8d79bd566a0..664756af894 100644 --- a/docs/src/rules/no-restricted-imports.md +++ b/docs/src/rules/no-restricted-imports.md @@ -140,7 +140,6 @@ Custom messages for a particular module can also be specified in `paths` array u This option in `paths` is an array and can be used to specify the names of certain bindings exported from a module. Import names specified inside `paths` array affect the module specified in the `name` property of corresponding object, so it is required to specify the `name` property first when you are using `importNames` or `message` option. - Specifying `"default"` string inside the `importNames` array will restrict the default export from being imported. ```json From 82e08e2cd8e969c4dcf34bc80ff99d2f5b12a5ca Mon Sep 17 00:00:00 2001 From: Tanuj Kanti Date: Thu, 25 Jan 2024 07:41:00 +0530 Subject: [PATCH 5/5] remove nodejs import section --- docs/src/rules/no-restricted-imports.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/src/rules/no-restricted-imports.md b/docs/src/rules/no-restricted-imports.md index 664756af894..2ce0d8f9d1a 100644 --- a/docs/src/rules/no-restricted-imports.md +++ b/docs/src/rules/no-restricted-imports.md @@ -518,14 +518,6 @@ import isEmpty, { hasValue } from 'utils/collection-utils'; ::: -To restrict the use of all Node.js core imports (via ): - -```json - "no-restricted-imports": ["error", - "assert","buffer","child_process","cluster","crypto","dgram","dns","domain","events","freelist","fs","http","https","module","net","os","path","punycode","querystring","readline","repl","smalloc","stream","string_decoder","sys","timers","tls","tracing","tty","url","util","vm","zlib" - ], -``` - ## When Not To Use It Don't use this rule or don't include a module in the list for this rule if you want to be able to import a module in your project without an ESLint error or warning.