@fable/eslint-plugin-implicit-dependencies
v1.2.0-beta.1
Published
eslint plugin to detect implicit dependencies
Downloads
10
Readme
eslint-plugin-implicit-dependencies
eslint plugin to detect implicit dependencies
Detects when a module has been 'require'd or 'import'ed that is not listed as a dependency in the project's package.json.
This helps prevent accidentally depending on a module that is present in node_modules as a result of being installed further down your dependency tree, but is not listed as an explicit dependency of your project.
Usage
Add implicit-dependencies
to the plugins section of your ESLint configuration file. You can omit the eslint-plugin-
prefix:
plugins:
- implicit-dependencies
Then configure the plugin under the rules section.
rules:
- implicit-dependencies/no-implicit: error
Options
By default implicit-dependencies
will only look for dependencies in the dependencies
section of your package.json. You can include dev, peer and optional dependencies by configuring the rule to include those sections as follows:
rules:
- implicit-dependencies/no-implicit:
- error
- dev: true
peer: true
optional: true
Or if configuring with javascript:
rules: {
'implicit-dependencies/no-implicit': [
'error',
{ peer: true, dev: true, optional: true }
]
}
Ignoring packages
To suppress no-implicit
errors for a particular package, add ignore
to the rule’s configuration. This can be useful when import aliases are in use, and an import that looks like an npm package is actually local to the source tree:
rules:
- implicit-dependencies/no-implicit:
- error
- ignore: ['src', '@/components']
Or if configuring with javascript:
rules: {
'implicit-dependencies/no-implicit': [
'error',
{ ignore: ['src', '@/components'] }
]
}