|
1 | 1 | # import/no-extraneous-dependencies: Forbid the use of extraneous packages
|
2 | 2 |
|
3 | 3 | Forbid the import of external modules that are not declared in the `package.json`'s `dependencies`, `devDependencies`, `optionalDependencies`, `peerDependencies`, or `bundledDependencies`.
|
4 |
| -The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything. This behavior can be changed with the rule option `packageDir`. |
| 4 | +The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything. This behavior can be changed with the rule option `packageDir`. Normally ignores imports of modules marked internal, but this can be changed with the rule option `includeInternal`. |
5 | 5 |
|
6 | 6 | Modules have to be installed for this rule to work.
|
7 | 7 |
|
@@ -31,6 +31,12 @@ You can also use an array of globs instead of literal booleans:
|
31 | 31 |
|
32 | 32 | When using an array of globs, the setting will be set to `true` (no errors reported) if the name of the file being linted matches a single glob in the array, and `false` otherwise.
|
33 | 33 |
|
| 34 | +There is a boolean option called `includeInternal`, which enables the checking of internal modules, which are otherwise ignored by this rule. |
| 35 | + |
| 36 | +```js |
| 37 | +"import/no-extraneous-dependencies": ["error", {"includeInternal": true}] |
| 38 | +``` |
| 39 | + |
34 | 40 | Also there is one more option called `packageDir`, this option is to specify the path to the folder containing package.json.
|
35 | 41 |
|
36 | 42 | If provided as a relative path string, will be computed relative to the current working directory at linter execution time. If this is not ideal (does not work with some editor integrations), consider using `__dirname` to provide a path relative to your configuration.
|
@@ -99,6 +105,10 @@ var isArray = require('lodash.isarray');
|
99 | 105 | /* eslint import/no-extraneous-dependencies: ["error", {"bundledDependencies": false}] */
|
100 | 106 | import foo from '"@generated/foo"';
|
101 | 107 | var foo = require('"@generated/foo"');
|
| 108 | + |
| 109 | +/* eslint import/no-extraneous-dependencies: ["error", {"includeInternal": true}] */ |
| 110 | +import foo from './foo'; |
| 111 | +var foo = require('./foo'); |
102 | 112 | ```
|
103 | 113 |
|
104 | 114 |
|
|
0 commit comments