eslint-plugin-quintoandar
Advanced tools
Comparing version 1.9.3 to 1.10.0
@@ -22,2 +22,3 @@ /* eslint-disable global-require */ | ||
'no-default-message': require('./rules/no-default-message'), | ||
'quintoandar-import-order': require('./rules/quintoandar-import-order'), | ||
}, | ||
@@ -41,2 +42,3 @@ configs: { | ||
'no-default-message': 2, | ||
'quintoandar-import-order': 2, | ||
}, | ||
@@ -43,0 +45,0 @@ }, |
{ | ||
"name": "eslint-plugin-quintoandar", | ||
"version": "1.9.3", | ||
"version": "1.10.0", | ||
"description": "An eslint-plugin for PWA-Tenants custom rules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -201,2 +201,85 @@ <div align="center"> | ||
### QuintoAndar custom import order | ||
Enforces the following custom import order: | ||
1 - `react` import; | ||
2 - external libs imports; | ||
3 - `@quintoandar` imports; | ||
4 - projects absolute imports; | ||
5 - projects relative imports; | ||
#### Why | ||
This rule aims in the direction of standardizing our code style. Beyond that it makes easier to find the imports. | ||
#### How to use it | ||
Just add the code below in your rules array: | ||
```js | ||
"quintoandar/quintoandar-import-order": 2, | ||
``` | ||
#### Options | ||
##### projectAbsolutePaths | ||
With the `projectAbsolutePaths` option you can pass extra paths to be evaluated as absolute paths from the project. You can use it adding the following to your rules array: | ||
```js | ||
'quintoandar/quintoandar-import-order': [ | ||
2, | ||
{ | ||
projectAbsolutePaths: ['experiments/'], | ||
}, | ||
], | ||
``` | ||
With the above configuration, all imports from `experiments` will be considered internal imports from the project: | ||
```js | ||
// Start with external libs | ||
import something from 'external-lib/something-a'; | ||
import anotherThing from 'external-lib/something-b'; | ||
// Then projects absolute imports | ||
import SomeInternalComponent from 'components/SomeComponent'; | ||
import SomeInternalContainer from 'containers/SomeContainer'; | ||
import SomeExperiment from 'experiments/someExperiment'; | ||
import someInternalHelper from 'helpers/someHelper'; | ||
import someInternalUtil from 'utils/someUtil'; | ||
``` | ||
You can pass the `override` option too: | ||
```js | ||
'quintoandar/quintoandar-import-order': [ | ||
2, | ||
{ | ||
override: true, | ||
projectAbsolutePaths: ['components', 'containers', 'experiments/'], | ||
}, | ||
], | ||
``` | ||
This way the default absolute paths (`components/`, `containers/`, `helpers/` or `utils/`) are overwritten. So the code above would not valid anymore, but the following would be: | ||
```js | ||
// Start with external libs | ||
import something from 'external-lib/something-a'; | ||
import anotherThing from 'external-lib/something-b'; | ||
import someInternalHelper from 'helpers/someHelper'; | ||
import someInternalUtil from 'utils/someUtil'; | ||
// Then projects absolute imports | ||
import SomeInternalComponent from 'components/SomeComponent'; | ||
import SomeInternalContainer from 'containers/SomeContainer'; | ||
import SomeExperiment from 'experiments/someExperiment'; | ||
``` | ||
## Versioning | ||
@@ -203,0 +286,0 @@ |
66194
40
1478
314