Checks all require path's to exist as files
npm install eslint-plugin-require-path-exists




This repository will give access to new rules for the ESLint tool. You should use it only if you are developing a CommonJS application. It checks for require() function usage (or for import, if you're using ES6 syntax).
- Supports both require() and ES6 import syntax
- Supports aliases in webpack
- Supports different file extensions
- Works in Atom with linter-eslint package
1. Install eslint-plugin-require-path-exists as a dev-dependency:
``shell`
npm install --save-dev eslint-plugin-require-path-exists
2. Enable the plugin by adding it to the plugins and start from default (recommended) configuration in extends in .eslintrc:
`js`
{
"extends": [
"plugin:require-path-exists/recommended"
],
"plugins": [
"require-path-exists"
]
}
.eslintrc
3. You can also configure these rules in your . All rules defined in this plugin have to be prefixed by 'require-path-exists/'
`js`
{
"plugins": [
"require-path-exists"
],
"rules": {
"require-path-exists/notEmpty": 2,
"require-path-exists/tooManyArguments": 2,
"require-path-exists/exists": [ 2, {
"extensions": [
"",
".jsx",
".es.js",
".jsx",
".json5",
".es",
".es6",
".coffee"
],
"webpackConfigPath": "webpack.config.js"
}]
}
]
}
| Name | Description | Default Configuration |
| ------------------------------------ | ---------------------------------------------------------------------- | --------------------- |
| require-path-exists/notEmpty | You should not call require() without arguments or with empty argument | `2` |`
| require-path-exists/tooManyArguments | You should pass only one argument to require() function | 2` |`
| require-path-exists/exists | You should only pass existing paths to require() | [ 2, { "extensions": [ "", ".js", ".json", ".node" ], "webpackConfigPath": null }]`` |
- Tests coverage.
- Check in different CommonJS environments (currently only tested in NodeJS and webpack).
MIT