eslint-plugin-no-relative-import-paths
Advanced tools
Comparing version 1.0.3 to 1.0.5
{ | ||
"name": "eslint-plugin-no-relative-import-paths", | ||
"version": "1.0.3", | ||
"version": "1.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,1 +0,62 @@ | ||
# eslint-plugin-no-relative-import-paths | ||
# eslint-plugin-no-relative-import-paths | ||
Moving a file to different folder, could result in changing all imports statement in that file. This will not happen is the import paths are absolute. The eslint rule helps enforcing having absolute import paths. | ||
# Installation | ||
Install [ESLint](https://www.github.com/eslint/eslint) either locally or globally. (Note that locally, per project, is strongly preferred) | ||
```sh | ||
$ npm install eslint --save-dev | ||
``` | ||
If you installed `ESLint` globally, you have to install this plugin globally too. Otherwise, install it locally. | ||
```sh | ||
$ npm install eslint-plugin-no-relative-import-paths --save-dev | ||
``` | ||
# Configuration | ||
Add the plugin to the plugins section, and configure the rule options. | ||
```json | ||
{ | ||
"plugins": ["no-relative-import-paths"], | ||
"rules": { | ||
"no-relative-import-paths/no-relative-import-paths": [ | ||
"warn", | ||
{ "allowSameFolder": true } | ||
] | ||
} | ||
} | ||
``` | ||
## Rule options | ||
```json | ||
... | ||
"no-relative-import-paths/no-relative-import-paths": [ | ||
"warn", | ||
{ "allowSameFolder": true } | ||
] | ||
... | ||
``` | ||
- `enabled`: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0. | ||
- `ignorePureComponents`: optional boolean set to `true` to allow relative import paths for imported files from the same folder (default to `false`). | ||
### `allowSameFolder` | ||
When `true` the rule will ignore relative import paths for imported files from the same folder | ||
Examples of code for this rule: | ||
```js | ||
// when true this will be ignored | ||
// when false this will generate a warning | ||
import Something from "./something"; | ||
// will always generate a warning | ||
import Something from "../modules/something"; | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4150
63