@jchiam/eslint-config 5.1.1 → 6.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 +150 -125
- package/package.json +14 -8
- package/react.js +25 -25
- package/recommended.js +135 -111
package/README.md
CHANGED
|
@@ -1,125 +1,150 @@
|
|
|
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
|
-
import
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- [`eslint
|
|
60
|
-
- [`
|
|
61
|
-
- [
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- [`eslint-plugin-react`](https://github.com/
|
|
69
|
-
|
|
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
|
+
import jchiamConfig from '@jchiam/eslint-config';
|
|
34
|
+
import jchiamReact from '@jchiam/eslint-config/react';
|
|
35
|
+
|
|
36
|
+
export default [...jchiamConfig, ...jchiamReact];
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Override rules by appending a config object to the array:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import jchiamConfig from '@jchiam/eslint-config';
|
|
43
|
+
|
|
44
|
+
export default [
|
|
45
|
+
...jchiamConfig,
|
|
46
|
+
{
|
|
47
|
+
rules: {
|
|
48
|
+
'prefer-const': 'warn', // override to warn instead of error
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## What's included
|
|
55
|
+
|
|
56
|
+
### `recommended.js`
|
|
57
|
+
|
|
58
|
+
- [`eslint:recommended`](https://eslint.org/docs/rules/) — ESLint core rules
|
|
59
|
+
- [`typescript-eslint`](https://typescript-eslint.io/) recommended rules
|
|
60
|
+
- [`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/...`)
|
|
61
|
+
- [`@stylistic/eslint-plugin`](https://eslint.style/) for formatting (indent, spacing, quotes, semi, etc.)
|
|
62
|
+
- Additional opinionated rules for best practices and ES6+
|
|
63
|
+
|
|
64
|
+
### `react.js`
|
|
65
|
+
|
|
66
|
+
Extends `recommended.js` intent with:
|
|
67
|
+
- [`@eslint-react/eslint-plugin`](https://github.com/Rel1cx/eslint-react) recommended rules (bundled — no separate install needed)
|
|
68
|
+
- [`eslint-plugin-react-hooks`](https://github.com/facebook/react) rules of hooks + exhaustive deps
|
|
69
|
+
|
|
70
|
+
## Breaking Changes
|
|
71
|
+
|
|
72
|
+
### v5 to v6
|
|
73
|
+
|
|
74
|
+
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.
|
|
75
|
+
|
|
76
|
+
Swap the peer dependency:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
npm uninstall eslint-plugin-import
|
|
80
|
+
npm i -D eslint-plugin-import-x
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**This also unblocks ESLint 10** — you can now bump `eslint` to `^10`.
|
|
84
|
+
|
|
85
|
+
**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.
|
|
86
|
+
|
|
87
|
+
**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:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
// Before
|
|
91
|
+
settings: { 'import/resolver': { /* ... */ } }
|
|
92
|
+
// After
|
|
93
|
+
settings: { 'import-x/resolver': { /* ... */ } }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
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.
|
|
97
|
+
|
|
98
|
+
### v4 to v5
|
|
99
|
+
|
|
100
|
+
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.
|
|
101
|
+
|
|
102
|
+
**Note:** delete your existing `node_modules` and `package-lock.json` before reinstalling — the old lockfile pins conflicting major versions and will cause resolution errors.
|
|
103
|
+
|
|
104
|
+
Install the new peer dependencies:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
npm i -D typescript-eslint
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Remove the old peer dependencies (now bundled or renamed):
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
npm uninstall @typescript-eslint/eslint-plugin @typescript-eslint/parser
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Config format changes from `.eslintrc.js`:
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
// Before (.eslintrc.js)
|
|
120
|
+
module.exports = {
|
|
121
|
+
extends: ['@jchiam/eslint-config/recommended'],
|
|
122
|
+
};
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
To `eslint.config.js`:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
// After
|
|
129
|
+
import jchiamConfig from '@jchiam/eslint-config';
|
|
130
|
+
export default [...jchiamConfig];
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Rule changes:**
|
|
134
|
+
- Formatting rules moved from ESLint core to `@stylistic/eslint-plugin` (same rules, prefixed with `@stylistic/`)
|
|
135
|
+
- `no-shadow` / `no-use-before-define` replaced by their `@typescript-eslint/*` equivalents (TS-aware, no false positives on type declarations)
|
|
136
|
+
- `no-new-object` renamed to `no-object-constructor`
|
|
137
|
+
- `vars-on-top` removed (redundant — `no-var` is enforced and `@typescript-eslint/no-use-before-define` covers the intent)
|
|
138
|
+
- `@typescript-eslint/indent` removed (was deprecated and broken; `@stylistic/indent` is used instead)
|
|
139
|
+
|
|
140
|
+
### v3 to v4
|
|
141
|
+
|
|
142
|
+
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.
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
// Before
|
|
146
|
+
{ "extends": "@jchiam" }
|
|
147
|
+
|
|
148
|
+
// After
|
|
149
|
+
{ "extends": ["@jchiam/eslint-config/recommended", "@jchiam/eslint-config/react"] }
|
|
150
|
+
```
|
package/package.json
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jchiam/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.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,25 @@
|
|
|
1
|
-
import eslintReact from '@eslint-react/eslint-plugin';
|
|
2
|
-
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
3
|
-
import stylistic from '@stylistic/eslint-plugin';
|
|
4
|
-
|
|
5
|
-
export default [
|
|
6
|
-
eslintReact.configs.recommended,
|
|
7
|
-
{
|
|
8
|
-
plugins: {
|
|
9
|
-
'@stylistic': stylistic,
|
|
10
|
-
'react-hooks': reactHooksPlugin,
|
|
11
|
-
},
|
|
12
|
-
languageOptions: {
|
|
13
|
-
parserOptions: {
|
|
14
|
-
ecmaFeatures: {
|
|
15
|
-
jsx: true,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
rules: {
|
|
20
|
-
'react-hooks/rules-of-hooks': 'error',
|
|
21
|
-
'react-hooks/exhaustive-deps': 'warn',
|
|
22
|
-
'@stylistic/jsx-quotes': 'error',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
];
|
|
1
|
+
import eslintReact from '@eslint-react/eslint-plugin';
|
|
2
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
3
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
eslintReact.configs.recommended,
|
|
7
|
+
{
|
|
8
|
+
plugins: {
|
|
9
|
+
'@stylistic': stylistic,
|
|
10
|
+
'react-hooks': reactHooksPlugin,
|
|
11
|
+
},
|
|
12
|
+
languageOptions: {
|
|
13
|
+
parserOptions: {
|
|
14
|
+
ecmaFeatures: {
|
|
15
|
+
jsx: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
21
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
22
|
+
'@stylistic/jsx-quotes': 'error',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
];
|
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
|
+
];
|