Skip to content

Commit 4014721

Browse files
committed
feat(config/eslintrc): separate import ordering rules into a strict preset
1 parent 2b91e39 commit 4014721

File tree

6 files changed

+38
-14
lines changed

6 files changed

+38
-14
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ module.exports = {
9595
}
9696
```
9797

98+
##### Strict Preset
99+
100+
> ✨ The strict preset is recommended for new projects!
101+
102+
A strict preset is also available that includes more agressive linting rules
103+
that enforce the order and grouping of imports.
104+
105+
```js
106+
module.exports = {
107+
extends: [
108+
require.resolve('@hover/javascript/eslint'),
109+
require.resolve('@hover/javascript/eslint/strict'),
110+
],
111+
// Include this when using TypeScript
112+
parserOptions: {
113+
project: ['./tsconfig.json'],
114+
},
115+
}
116+
```
117+
98118
#### Prettier
99119

100120
Or, for Prettier, a `.prettierrc.js` with:

eslint.js

-1
This file was deleted.

eslint/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./dist/config/eslintrc-strict')

eslint/strict.js

Whitespace-only changes.

src/config/eslintrc-strict.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
rules: {
3+
'import/order': [
4+
'error',
5+
{
6+
alphabetize: {order: 'asc'},
7+
'newlines-between': 'always',
8+
pathGroups: [
9+
{pattern: 'src/**/*', group: 'parent', position: 'before'},
10+
{pattern: 'assets/**/*', group: 'parent', position: 'before'},
11+
],
12+
pathGroupsExcludedImportTypes: ['builtin'],
13+
},
14+
],
15+
'sort-imports': ['error', {ignoreDeclarationSort: true}],
16+
},
17+
}

src/config/helpers/build-eslint.js

-13
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,8 @@ const buildConfig = ({withReact = false} = {}) => {
6363
optionalDependencies: false,
6464
},
6565
],
66-
'import/order': [
67-
'error',
68-
{
69-
alphabetize: {order: 'asc'},
70-
'newlines-between': 'always',
71-
pathGroups: [
72-
{pattern: 'src/**/*', group: 'parent', position: 'before'},
73-
{pattern: 'assets/**/*', group: 'parent', position: 'before'},
74-
],
75-
pathGroupsExcludedImportTypes: ['builtin'],
76-
},
77-
],
7866
'no-void': ['error', {allowAsStatement: true}],
7967
'prettier/prettier': 'error',
80-
'sort-imports': ['error', {ignoreDeclarationSort: true}],
8168
...parserRules(false, isReact),
8269
},
8370
overrides: [

0 commit comments

Comments
 (0)