Skip to content

Commit 2b0c174

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

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
@@ -94,6 +94,26 @@ module.exports = {
9494
}
9595
```
9696

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

99119
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)