@jchiam/eslint-config 5.1.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -125
- package/package.json +14 -8
- package/react.js +31 -25
- package/recommended.js +135 -111
package/README.md
CHANGED
|
@@ -1,125 +1,170 @@
|
|
|
1
|
-
# ESLint Config
|
|
2
|
-
|
|
3
|
-
[](https://npmjs.org/package/@jchiam/eslint-config)
|
|
4
|
-
|
|
5
|
-
My personal shareable ESLint config. Targets TypeScript projects, with an optional React extension.
|
|
6
|
-
|
|
7
|
-
## Requirements
|
|
8
|
-
|
|
9
|
-
- ESLint 9
|
|
10
|
-
- `typescript-eslint` ^8
|
|
11
|
-
- `eslint-plugin-import` ^
|
|
12
|
-
|
|
13
|
-
React projects additionally need:
|
|
14
|
-
- `eslint-plugin-react` ^7.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
import jchiamReact from '@jchiam/eslint-config/react';
|
|
36
|
-
|
|
37
|
-
export default [...
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Override rules by appending a config object to the array:
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
import jchiamConfig from '@jchiam/eslint-config';
|
|
44
|
-
|
|
45
|
-
export default [
|
|
46
|
-
...jchiamConfig,
|
|
47
|
-
{
|
|
48
|
-
rules: {
|
|
49
|
-
'prefer-const': 'warn', // override to warn instead of error
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## What's included
|
|
56
|
-
|
|
57
|
-
### `recommended.js`
|
|
58
|
-
|
|
59
|
-
- [`eslint:recommended`](https://eslint.org/docs/rules/) — ESLint core rules
|
|
60
|
-
- [`typescript-eslint`](https://typescript-eslint.io/) recommended rules
|
|
61
|
-
- [`eslint-plugin-import`](https://github.com/
|
|
62
|
-
- [`@stylistic/eslint-plugin`](https://eslint.style/) for formatting (indent, spacing, quotes, semi, etc.)
|
|
63
|
-
- Additional opinionated rules for best practices and ES6+
|
|
64
|
-
|
|
65
|
-
### `react.js`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- [
|
|
69
|
-
- [`eslint-plugin-react-hooks`](https://github.com/facebook/react) rules of hooks + exhaustive deps
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
# ESLint Config
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/package/@jchiam/eslint-config)
|
|
4
|
+
|
|
5
|
+
My personal shareable ESLint config. Targets TypeScript projects, with an optional React extension.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- ESLint 9 or 10
|
|
10
|
+
- `typescript-eslint` ^8
|
|
11
|
+
- `eslint-plugin-import-x` ^4.16
|
|
12
|
+
|
|
13
|
+
React projects additionally need:
|
|
14
|
+
- `eslint-plugin-react-hooks` ^7.1
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm i -D @jchiam/eslint-config eslint typescript-eslint eslint-plugin-import-x
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Create `eslint.config.js` in your project root:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
// eslint.config.js — TypeScript project
|
|
26
|
+
import jchiamConfig from '@jchiam/eslint-config';
|
|
27
|
+
|
|
28
|
+
export default [...jchiamConfig];
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
// eslint.config.js — React + TypeScript project
|
|
33
|
+
// The /react config is self-contained — it includes the base config, so spread
|
|
34
|
+
// it alone. Do not also spread the base, or it will be included twice.
|
|
35
|
+
import jchiamReact from '@jchiam/eslint-config/react';
|
|
36
|
+
|
|
37
|
+
export default [...jchiamReact];
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Override rules by appending a config object to the array:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import jchiamConfig from '@jchiam/eslint-config';
|
|
44
|
+
|
|
45
|
+
export default [
|
|
46
|
+
...jchiamConfig,
|
|
47
|
+
{
|
|
48
|
+
rules: {
|
|
49
|
+
'prefer-const': 'warn', // override to warn instead of error
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## What's included
|
|
56
|
+
|
|
57
|
+
### `recommended.js`
|
|
58
|
+
|
|
59
|
+
- [`eslint:recommended`](https://eslint.org/docs/rules/) — ESLint core rules
|
|
60
|
+
- [`typescript-eslint`](https://typescript-eslint.io/) recommended rules
|
|
61
|
+
- [`eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x) recommended + TypeScript settings (registered under the `import` namespace, so rules are still `import/...`)
|
|
62
|
+
- [`@stylistic/eslint-plugin`](https://eslint.style/) for formatting (indent, spacing, quotes, semi, etc.)
|
|
63
|
+
- Additional opinionated rules for best practices and ES6+
|
|
64
|
+
|
|
65
|
+
### `react.js`
|
|
66
|
+
|
|
67
|
+
Self-contained — includes everything in `recommended.js`, plus:
|
|
68
|
+
- [`@eslint-react/eslint-plugin`](https://github.com/Rel1cx/eslint-react) recommended rules (bundled — no separate install needed)
|
|
69
|
+
- [`eslint-plugin-react-hooks`](https://github.com/facebook/react) rules of hooks + exhaustive deps
|
|
70
|
+
|
|
71
|
+
Spread it on its own (`[...jchiamReact]`); there is no need to also spread the base config.
|
|
72
|
+
|
|
73
|
+
## Breaking Changes
|
|
74
|
+
|
|
75
|
+
### v6 to v7
|
|
76
|
+
|
|
77
|
+
The `/react` config is now **self-contained** — it includes the base config, so React projects spread a single array instead of composing base + react themselves.
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
// Before (v6)
|
|
81
|
+
import jchiamConfig from '@jchiam/eslint-config';
|
|
82
|
+
import jchiamReact from '@jchiam/eslint-config/react';
|
|
83
|
+
export default [...jchiamConfig, ...jchiamReact];
|
|
84
|
+
|
|
85
|
+
// After (v7)
|
|
86
|
+
import jchiamReact from '@jchiam/eslint-config/react';
|
|
87
|
+
export default [...jchiamReact];
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Spreading both as before still "works" but includes the base config twice. Non-React projects are unaffected — keep using `recommended` as before.
|
|
91
|
+
|
|
92
|
+
### v5 to v6
|
|
93
|
+
|
|
94
|
+
Replaced [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) with its maintained fork [`eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x). The original plugin does not support ESLint 10 (it crashes at runtime under ESLint 10); `import-x` does, and is lighter and faster.
|
|
95
|
+
|
|
96
|
+
Swap the peer dependency:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
npm uninstall eslint-plugin-import
|
|
100
|
+
npm i -D eslint-plugin-import-x
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**This also unblocks ESLint 10** — you can now bump `eslint` to `^10`.
|
|
104
|
+
|
|
105
|
+
**Rule references are unchanged.** `import-x` is a drop-in fork with identical rule names, and this config registers it under the `import` namespace, so existing `import/...` rule overrides in your `eslint.config.js` keep working with no changes.
|
|
106
|
+
|
|
107
|
+
**One caveat — resolver/import *settings* renamed.** `import-x` reads its `settings` under an `import-x/` prefix. If your own config overrides import settings (e.g. a custom resolver), rename the keys:
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
// Before
|
|
111
|
+
settings: { 'import/resolver': { /* ... */ } }
|
|
112
|
+
// After
|
|
113
|
+
settings: { 'import-x/resolver': { /* ... */ } }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
React projects: `eslint-plugin-react-hooks` must be `^7.1` (earlier 7.x does not support ESLint 10). The bundled `@eslint-react/eslint-plugin` was also upgraded to v5 for ESLint 10 support — no install needed, but its recommended rule set has changed across that upgrade.
|
|
117
|
+
|
|
118
|
+
### v4 to v5
|
|
119
|
+
|
|
120
|
+
Migrated to [ESLint flat config](https://eslint.org/docs/latest/use/configure/configuration-files) (required for ESLint 9+). The `.eslintrc` format is no longer supported.
|
|
121
|
+
|
|
122
|
+
**Note:** delete your existing `node_modules` and `package-lock.json` before reinstalling — the old lockfile pins conflicting major versions and will cause resolution errors.
|
|
123
|
+
|
|
124
|
+
Install the new peer dependencies:
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
npm i -D typescript-eslint
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Remove the old peer dependencies (now bundled or renamed):
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
npm uninstall @typescript-eslint/eslint-plugin @typescript-eslint/parser
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Config format changes from `.eslintrc.js`:
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
// Before (.eslintrc.js)
|
|
140
|
+
module.exports = {
|
|
141
|
+
extends: ['@jchiam/eslint-config/recommended'],
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
To `eslint.config.js`:
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
// After
|
|
149
|
+
import jchiamConfig from '@jchiam/eslint-config';
|
|
150
|
+
export default [...jchiamConfig];
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Rule changes:**
|
|
154
|
+
- Formatting rules moved from ESLint core to `@stylistic/eslint-plugin` (same rules, prefixed with `@stylistic/`)
|
|
155
|
+
- `no-shadow` / `no-use-before-define` replaced by their `@typescript-eslint/*` equivalents (TS-aware, no false positives on type declarations)
|
|
156
|
+
- `no-new-object` renamed to `no-object-constructor`
|
|
157
|
+
- `vars-on-top` removed (redundant — `no-var` is enforced and `@typescript-eslint/no-use-before-define` covers the intent)
|
|
158
|
+
- `@typescript-eslint/indent` removed (was deprecated and broken; `@stylistic/indent` is used instead)
|
|
159
|
+
|
|
160
|
+
### v3 to v4
|
|
161
|
+
|
|
162
|
+
The original config file was split from `index.js` into `recommended.js` and `react.js` to allow non-React projects to use only the base config.
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
// Before
|
|
166
|
+
{ "extends": "@jchiam" }
|
|
167
|
+
|
|
168
|
+
// After
|
|
169
|
+
{ "extends": ["@jchiam/eslint-config/recommended", "@jchiam/eslint-config/react"] }
|
|
170
|
+
```
|
package/package.json
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jchiam/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "my personal ESLint rules",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "recommended.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./recommended.js",
|
|
9
|
+
"./recommended": "./recommended.js",
|
|
10
|
+
"./react": "./react.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
7
13
|
"files": [
|
|
8
14
|
"recommended.js",
|
|
9
15
|
"react.js"
|
|
10
16
|
],
|
|
11
17
|
"scripts": {
|
|
12
|
-
"test": "
|
|
18
|
+
"test": "node --test"
|
|
13
19
|
},
|
|
14
20
|
"repository": {
|
|
15
21
|
"type": "git",
|
|
@@ -17,16 +23,16 @@
|
|
|
17
23
|
},
|
|
18
24
|
"author": "Jonathan Chiam",
|
|
19
25
|
"dependencies": {
|
|
20
|
-
"@eslint-react/eslint-plugin": "^
|
|
26
|
+
"@eslint-react/eslint-plugin": "^5.0.0",
|
|
21
27
|
"@eslint/js": "^9.0.0",
|
|
22
28
|
"@stylistic/eslint-plugin": "^5.0.0",
|
|
23
29
|
"globals": "^17.6.0"
|
|
24
30
|
},
|
|
25
31
|
"peerDependencies": {
|
|
26
32
|
"eslint": "^9.0.0 || ^10.0.0",
|
|
27
|
-
"eslint-plugin-import": "^
|
|
28
|
-
"eslint-plugin-jest": "^29.
|
|
29
|
-
"eslint-plugin-react-hooks": "^7.
|
|
33
|
+
"eslint-plugin-import-x": "^4.16.0",
|
|
34
|
+
"eslint-plugin-jest": "^29.13.0",
|
|
35
|
+
"eslint-plugin-react-hooks": "^7.1.0",
|
|
30
36
|
"typescript-eslint": "^8.0.0"
|
|
31
37
|
},
|
|
32
38
|
"peerDependenciesMeta": {
|
|
@@ -38,8 +44,8 @@
|
|
|
38
44
|
}
|
|
39
45
|
},
|
|
40
46
|
"devDependencies": {
|
|
41
|
-
"eslint": "^
|
|
42
|
-
"eslint-plugin-import": "^
|
|
47
|
+
"eslint": "^10.0.0",
|
|
48
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
43
49
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
44
50
|
"typescript": "^5.9.3",
|
|
45
51
|
"typescript-eslint": "^8.59.4"
|
package/react.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import recommended from './recommended.js';
|
|
2
|
+
import eslintReact from '@eslint-react/eslint-plugin';
|
|
3
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
4
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
5
|
+
|
|
6
|
+
// Self-contained React + TypeScript config. It includes the base `recommended`
|
|
7
|
+
// config, so consumers spread a single array (`[...jchiamReact]`) rather than
|
|
8
|
+
// composing base + react themselves and having to get the order right.
|
|
9
|
+
// recommended.js remains the standalone base for non-React projects.
|
|
10
|
+
export default [
|
|
11
|
+
...recommended,
|
|
12
|
+
eslintReact.configs.recommended,
|
|
13
|
+
{
|
|
14
|
+
plugins: {
|
|
15
|
+
'@stylistic': stylistic,
|
|
16
|
+
'react-hooks': reactHooksPlugin,
|
|
17
|
+
},
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parserOptions: {
|
|
20
|
+
ecmaFeatures: {
|
|
21
|
+
jsx: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
rules: {
|
|
26
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
27
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
28
|
+
'@stylistic/jsx-quotes': 'error',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
];
|
package/recommended.js
CHANGED
|
@@ -1,111 +1,135 @@
|
|
|
1
|
-
import js from '@eslint/js';
|
|
2
|
-
import tseslint from 'typescript-eslint';
|
|
3
|
-
import
|
|
4
|
-
import stylistic from '@stylistic/eslint-plugin';
|
|
5
|
-
import globals from 'globals';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
'
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'no-
|
|
56
|
-
'no-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
'
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
'
|
|
83
|
-
'
|
|
84
|
-
'
|
|
85
|
-
'
|
|
86
|
-
'
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'@stylistic/
|
|
90
|
-
'@stylistic/
|
|
91
|
-
'@stylistic/
|
|
92
|
-
'@stylistic/
|
|
93
|
-
'@stylistic/
|
|
94
|
-
'@stylistic/
|
|
95
|
-
'@stylistic/
|
|
96
|
-
'@stylistic/
|
|
97
|
-
'@stylistic/
|
|
98
|
-
'@stylistic/
|
|
99
|
-
'@stylistic/
|
|
100
|
-
'@stylistic/
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
'
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
import { importX } from 'eslint-plugin-import-x';
|
|
4
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
|
|
7
|
+
// eslint-plugin-import-x is a drop-in fork of eslint-plugin-import with identical
|
|
8
|
+
// rule names, but its flat configs register the plugin under the `import-x`
|
|
9
|
+
// namespace. Re-register it under the legacy `import` namespace so consumers'
|
|
10
|
+
// existing `import/...` rule references and overrides keep working with zero
|
|
11
|
+
// renames. NOTE: import-x reads its `settings` under a hard-coded `import-x/`
|
|
12
|
+
// prefix internally, so settings keys (e.g. `import-x/resolver`) are left as-is
|
|
13
|
+
// — only the plugin key and rule names are remapped.
|
|
14
|
+
function asImportNamespace(config) {
|
|
15
|
+
const next = { plugins: { import: config.plugins['import-x'] } };
|
|
16
|
+
if (config.rules) {
|
|
17
|
+
next.rules = Object.fromEntries(
|
|
18
|
+
Object.entries(config.rules).map(([key, value]) => [key.replace(/^import-x\//, 'import/'), value]),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (config.settings) {
|
|
22
|
+
next.settings = { ...config.settings };
|
|
23
|
+
// The resolver is owned by the config block below (node resolver); drop the
|
|
24
|
+
// fork's default `typescript` resolver so behaviour matches the previous
|
|
25
|
+
// eslint-plugin-import setup and no extra resolver package is required.
|
|
26
|
+
delete next.settings['import-x/resolver'];
|
|
27
|
+
}
|
|
28
|
+
return next;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default [
|
|
32
|
+
js.configs.recommended,
|
|
33
|
+
...tseslint.configs.recommended,
|
|
34
|
+
asImportNamespace(importX.flatConfigs.recommended),
|
|
35
|
+
asImportNamespace(importX.flatConfigs.typescript),
|
|
36
|
+
{
|
|
37
|
+
plugins: {
|
|
38
|
+
'@stylistic': stylistic,
|
|
39
|
+
},
|
|
40
|
+
languageOptions: {
|
|
41
|
+
globals: {
|
|
42
|
+
...globals.es2020,
|
|
43
|
+
...globals.node,
|
|
44
|
+
...globals.browser,
|
|
45
|
+
},
|
|
46
|
+
parserOptions: {
|
|
47
|
+
ecmaVersion: 'latest',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
rules: {
|
|
51
|
+
// TypeScript rules
|
|
52
|
+
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
|
|
53
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
54
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
55
|
+
'@typescript-eslint/no-shadow': 'error',
|
|
56
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
57
|
+
|
|
58
|
+
// Disable base rules superseded by TypeScript equivalents
|
|
59
|
+
'no-shadow': 'off',
|
|
60
|
+
'no-use-before-define': 'off',
|
|
61
|
+
|
|
62
|
+
// Best practice rules
|
|
63
|
+
'camelcase': 'error',
|
|
64
|
+
'eqeqeq': ['error', 'smart'],
|
|
65
|
+
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
|
|
66
|
+
'max-depth': 'warn',
|
|
67
|
+
'max-lines': ['warn', { skipBlankLines: true, skipComments: true }],
|
|
68
|
+
'no-bitwise': 'error',
|
|
69
|
+
'no-continue': 'error',
|
|
70
|
+
'no-else-return': 'warn',
|
|
71
|
+
'no-lonely-if': 'error',
|
|
72
|
+
'no-nested-ternary': 'error',
|
|
73
|
+
'no-object-constructor': 'error',
|
|
74
|
+
'no-unneeded-ternary': 'error',
|
|
75
|
+
'operator-assignment': 'error',
|
|
76
|
+
'prefer-object-spread': 'error',
|
|
77
|
+
|
|
78
|
+
// ES6+ rules
|
|
79
|
+
'no-duplicate-imports': 'error',
|
|
80
|
+
'no-useless-computed-key': 'error',
|
|
81
|
+
'no-var': 'error',
|
|
82
|
+
'object-shorthand': 'error',
|
|
83
|
+
'prefer-const': 'error',
|
|
84
|
+
'prefer-destructuring': ['error', { array: false, object: true }],
|
|
85
|
+
'prefer-numeric-literals': 'error',
|
|
86
|
+
'prefer-template': 'error',
|
|
87
|
+
|
|
88
|
+
// Formatting (via @stylistic/eslint-plugin)
|
|
89
|
+
'@stylistic/array-bracket-spacing': 'error',
|
|
90
|
+
'@stylistic/arrow-parens': ['error', 'as-needed'],
|
|
91
|
+
'@stylistic/arrow-spacing': 'error',
|
|
92
|
+
'@stylistic/block-spacing': 'error',
|
|
93
|
+
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
|
94
|
+
'@stylistic/comma-dangle': 'error',
|
|
95
|
+
'@stylistic/comma-spacing': 'error',
|
|
96
|
+
'@stylistic/comma-style': 'error',
|
|
97
|
+
'@stylistic/computed-property-spacing': 'error',
|
|
98
|
+
'@stylistic/eol-last': 'error',
|
|
99
|
+
'@stylistic/function-call-spacing': 'error',
|
|
100
|
+
'@stylistic/indent': ['error', 2, { SwitchCase: 1 }],
|
|
101
|
+
'@stylistic/key-spacing': 'error',
|
|
102
|
+
'@stylistic/keyword-spacing': 'error',
|
|
103
|
+
'@stylistic/lines-around-comment': ['error', { beforeBlockComment: true, allowBlockStart: true }],
|
|
104
|
+
'@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
|
105
|
+
'@stylistic/newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }],
|
|
106
|
+
'@stylistic/no-multi-spaces': ['error', { ignoreEOLComments: true }],
|
|
107
|
+
'@stylistic/no-multiple-empty-lines': 'error',
|
|
108
|
+
'@stylistic/no-tabs': 'error',
|
|
109
|
+
'@stylistic/no-trailing-spaces': 'error',
|
|
110
|
+
'@stylistic/no-whitespace-before-property': 'error',
|
|
111
|
+
'@stylistic/nonblock-statement-body-position': 'error',
|
|
112
|
+
'@stylistic/object-curly-spacing': ['error', 'always'],
|
|
113
|
+
'@stylistic/object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
|
|
114
|
+
'@stylistic/operator-linebreak': ['error', 'after'],
|
|
115
|
+
'@stylistic/quote-props': ['error', 'consistent-as-needed'],
|
|
116
|
+
'@stylistic/quotes': ['error', 'single'],
|
|
117
|
+
'@stylistic/rest-spread-spacing': 'error',
|
|
118
|
+
'@stylistic/semi': 'error',
|
|
119
|
+
'@stylistic/semi-style': 'error',
|
|
120
|
+
'@stylistic/space-before-blocks': 'error',
|
|
121
|
+
'@stylistic/space-before-function-paren': ['error', { anonymous: 'always', named: 'never', asyncArrow: 'always' }],
|
|
122
|
+
'@stylistic/space-in-parens': 'error',
|
|
123
|
+
'@stylistic/switch-colon-spacing': 'error',
|
|
124
|
+
'@stylistic/template-curly-spacing': 'error',
|
|
125
|
+
},
|
|
126
|
+
settings: {
|
|
127
|
+
'import-x/resolver': {
|
|
128
|
+
node: {
|
|
129
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
|
|
130
|
+
moduleDirectory: ['node_modules', 'src'],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
];
|