@foray1010/eslint-config 13.0.3 → 14.0.1
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/CHANGELOG.md +25 -0
- package/bases/base.mjs +9 -74
- package/package.json +22 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [14.0.1](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@14.0.0...@foray1010/eslint-config@14.0.1) (2025-03-11)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **eslint-config:** drop eslint-plugin-functional ([fdc506c](https://github.com/foray1010/common-presets/commit/fdc506cf24792dfb55a2c39e7f96a49cd76044af))
|
|
11
|
+
|
|
12
|
+
## [14.0.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@13.0.3...@foray1010/eslint-config@14.0.0) (2025-03-11)
|
|
13
|
+
|
|
14
|
+
### ⚠ BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
- **deps:** require nodejs `^20.10.0 || >=22.11.0`
|
|
17
|
+
- **deps:** require eslint `^9.21.0`
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
- **eslint-config:** forbid ts enum ([7613ca0](https://github.com/foray1010/common-presets/commit/7613ca06b492dc5f71d562a1ce5b9810b60ab46f))
|
|
22
|
+
- **eslint-config:** report unused disable directives and inline configs ([7bcd4d2](https://github.com/foray1010/common-presets/commit/7bcd4d264826c2c8640c6ad6bed9083761432410))
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
- **deps:** update dependency eslint-plugin-functional to v9 ([e1a3751](https://github.com/foray1010/common-presets/commit/e1a3751a4e14d9bde401643be837f98877898129))
|
|
27
|
+
- **deps:** update dependency eslint-plugin-unicorn to v9 ([c679289](https://github.com/foray1010/common-presets/commit/c679289daa61df03cde537947a7c0f51935ff626))
|
|
28
|
+
- **eslint-config:** remove duplicated typescript-eslint rules ([df34e55](https://github.com/foray1010/common-presets/commit/df34e5519ac288b552e06b6d7cd00b6fb2928085))
|
|
29
|
+
- **eslint-config:** update dependencies ([b88f45c](https://github.com/foray1010/common-presets/commit/b88f45cc4cc78a45525e329c059e64940f717687))
|
|
30
|
+
|
|
6
31
|
## [13.0.3](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@13.0.2...@foray1010/eslint-config@13.0.3) (2025-01-19)
|
|
7
32
|
|
|
8
33
|
### Bug Fixes
|
package/bases/base.mjs
CHANGED
|
@@ -23,9 +23,6 @@ async function generateTypeScriptConfig() {
|
|
|
23
23
|
|
|
24
24
|
// eslint-disable-next-line import-x/no-unresolved
|
|
25
25
|
const tseslint = (await import('typescript-eslint')).default
|
|
26
|
-
// eslint-disable-next-line import-x/no-unresolved
|
|
27
|
-
const eslintPluginFunctional = (await import('eslint-plugin-functional'))
|
|
28
|
-
.default
|
|
29
26
|
|
|
30
27
|
return [
|
|
31
28
|
// @ts-expect-error `Type 'Config' is not assignable to type 'Readonly<FlatConfig<RulesRecord>>' with 'exactOptionalPropertyTypes: true'`
|
|
@@ -50,9 +47,6 @@ async function generateTypeScriptConfig() {
|
|
|
50
47
|
typescript: true,
|
|
51
48
|
},
|
|
52
49
|
},
|
|
53
|
-
plugins: {
|
|
54
|
-
functional: eslintPluginFunctional,
|
|
55
|
-
},
|
|
56
50
|
rules: {
|
|
57
51
|
...eslintPluginImportX.configs['typescript']?.rules,
|
|
58
52
|
// separate type exports which allow certain optimizations within compilers
|
|
@@ -87,14 +81,8 @@ async function generateTypeScriptConfig() {
|
|
|
87
81
|
accessibility: 'explicit',
|
|
88
82
|
},
|
|
89
83
|
],
|
|
90
|
-
// sometimes auto detect can provide a better and narrower type
|
|
91
|
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
92
84
|
// do not allow usage of deprecated code
|
|
93
85
|
'@typescript-eslint/no-deprecated': 'error',
|
|
94
|
-
// disallow duplicated value in enum as it is error-prone
|
|
95
|
-
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
|
96
|
-
// need empty function for react context default value
|
|
97
|
-
'@typescript-eslint/no-empty-function': 'off',
|
|
98
86
|
// TypeScript team suggests to use `<T extends {}>` https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#unconstrained-generics-no-longer-assignable-to
|
|
99
87
|
'@typescript-eslint/no-empty-object-type': 'off',
|
|
100
88
|
// when using typescript 5.0 with verbatimModuleSyntax flag on, compiler will not remove import statements with only inline type imports which lead to side effects
|
|
@@ -106,15 +94,6 @@ async function generateTypeScriptConfig() {
|
|
|
106
94
|
'error',
|
|
107
95
|
{ checksVoidReturn: false },
|
|
108
96
|
],
|
|
109
|
-
// declaration merging between classes and interfaces is unsafe
|
|
110
|
-
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
111
|
-
'@typescript-eslint/no-unused-vars': [
|
|
112
|
-
'error',
|
|
113
|
-
{
|
|
114
|
-
// error is optional now
|
|
115
|
-
caughtErrors: 'all',
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
97
|
// do not block functions referring to other functions
|
|
119
98
|
'@typescript-eslint/no-use-before-define': [
|
|
120
99
|
'error',
|
|
@@ -126,7 +105,6 @@ async function generateTypeScriptConfig() {
|
|
|
126
105
|
variables: true,
|
|
127
106
|
|
|
128
107
|
/* options from @typescript-eslint/no-use-before-define */
|
|
129
|
-
enums: true,
|
|
130
108
|
// confusing option, it will disable `typedefs`
|
|
131
109
|
ignoreTypeReferences: false,
|
|
132
110
|
// tsc allows types to be used before define
|
|
@@ -135,62 +113,10 @@ async function generateTypeScriptConfig() {
|
|
|
135
113
|
],
|
|
136
114
|
// make sure functions which return a promise will just return a rejected promise instead of throwing an error
|
|
137
115
|
'@typescript-eslint/promise-function-async': 'error',
|
|
138
|
-
// allow primitive value in template string
|
|
139
|
-
'@typescript-eslint/restrict-template-expressions': [
|
|
140
|
-
'error',
|
|
141
|
-
{
|
|
142
|
-
allowNumber: true,
|
|
143
|
-
allowBoolean: true,
|
|
144
|
-
allowAny: true, // mistakenly recognize string as any in 4.29.3
|
|
145
|
-
allowNullish: true,
|
|
146
|
-
allowRegExp: true,
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
116
|
// avoid missed switch-case by requiring switch-case statements to be exhaustive with union type
|
|
150
117
|
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
151
118
|
// ignore static function as those are not supposed to use `this`
|
|
152
119
|
'@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
|
|
153
|
-
// use with functional/type-declaration-immutability
|
|
154
|
-
'functional/prefer-immutable-types': [
|
|
155
|
-
'error',
|
|
156
|
-
{
|
|
157
|
-
// as there is no native way to achieve `ReadonlyDeep` in TypeScript
|
|
158
|
-
enforcement: 'ReadonlyShallow',
|
|
159
|
-
// reduce the difficult to use this rule
|
|
160
|
-
ignoreInferredTypes: true,
|
|
161
|
-
// escape hatch without using eslint-disable
|
|
162
|
-
ignoreNamePattern: /Mutable$/u.source,
|
|
163
|
-
ignoreTypePattern: [
|
|
164
|
-
/^React\./u.source, // Some React types does not work with `Readonly`
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
// forbid unnecessary callback wrapper
|
|
169
|
-
'functional/prefer-tacit': 'error',
|
|
170
|
-
// use with functional/prefer-immutable-types
|
|
171
|
-
'functional/type-declaration-immutability': [
|
|
172
|
-
'error',
|
|
173
|
-
{
|
|
174
|
-
rules: [
|
|
175
|
-
{
|
|
176
|
-
identifiers: '.+',
|
|
177
|
-
immutability: 'ReadonlyShallow',
|
|
178
|
-
comparator: 'AtLeast',
|
|
179
|
-
// modified from https://github.com/eslint-functional/eslint-plugin-functional/blob/main/docs/rules/type-declaration-immutability.md#preset-overrides
|
|
180
|
-
fixer: [
|
|
181
|
-
{
|
|
182
|
-
pattern: /^(Array|Map|Set)<(.+)>$/u.source,
|
|
183
|
-
replace: /Readonly\$1<\$2>/u.source,
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
pattern: /^(.+)$/u.source,
|
|
187
|
-
replace: /Readonly<\$1>/u.source,
|
|
188
|
-
},
|
|
189
|
-
],
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
120
|
'no-restricted-syntax': [
|
|
195
121
|
'error',
|
|
196
122
|
{
|
|
@@ -200,6 +126,11 @@ async function generateTypeScriptConfig() {
|
|
|
200
126
|
message:
|
|
201
127
|
'Use #private instead (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields)',
|
|
202
128
|
},
|
|
129
|
+
{
|
|
130
|
+
selector: 'TSEnumDeclaration',
|
|
131
|
+
message:
|
|
132
|
+
'"Use string literals with unions or `as const` instead because they work with Node.js type stripping, see https://news.ycombinator.com/item?id=42767627',
|
|
133
|
+
},
|
|
203
134
|
],
|
|
204
135
|
// @typescript-eslint/eslint-plugin suggests to disable it: https://github.com/typescript-eslint/typescript-eslint/blob/2588e9ea55f78352fdd6ae92a306135aabb49a1a/docs/linting/TROUBLESHOOTING.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
205
136
|
// It is disabled in recommended config but re-enabled here to enforce a subset of global variables that supported by both node.js and browsers
|
|
@@ -331,6 +262,10 @@ const baseConfig = [
|
|
|
331
262
|
},
|
|
332
263
|
},
|
|
333
264
|
{
|
|
265
|
+
linterOptions: {
|
|
266
|
+
reportUnusedDisableDirectives: 'error',
|
|
267
|
+
reportUnusedInlineConfigs: 'error',
|
|
268
|
+
},
|
|
334
269
|
languageOptions: {
|
|
335
270
|
ecmaVersion: 2023,
|
|
336
271
|
globals: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@foray1010/eslint-config",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "14.0.1",
|
|
5
5
|
"homepage": "https://github.com/foray1010/common-presets/tree/master/packages/eslint-config#readme",
|
|
6
6
|
"bugs": "https://github.com/foray1010/common-presets/issues",
|
|
7
7
|
"repository": {
|
|
@@ -20,36 +20,34 @@
|
|
|
20
20
|
"type:check": "tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.
|
|
24
|
-
"@eslint/js": "^9.
|
|
23
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
24
|
+
"@eslint/js": "^9.21.0",
|
|
25
25
|
"@foray1010/common-presets-utils": "^8.0.0",
|
|
26
26
|
"confusing-browser-globals": "^1.0.11",
|
|
27
|
-
"eslint-config-prettier": "^10.0.
|
|
28
|
-
"eslint-import-resolver-typescript": "^3.
|
|
29
|
-
"eslint-plugin-compat": "^6.0.
|
|
30
|
-
"eslint-plugin-
|
|
31
|
-
"eslint-plugin-
|
|
32
|
-
"eslint-plugin-jest": "^
|
|
33
|
-
"eslint-plugin-
|
|
34
|
-
"eslint-plugin-
|
|
35
|
-
"eslint-plugin-
|
|
36
|
-
"eslint-plugin-react": "^
|
|
37
|
-
"eslint-plugin-
|
|
38
|
-
"eslint-plugin-regexp": "^2.6.0",
|
|
27
|
+
"eslint-config-prettier": "^10.0.2",
|
|
28
|
+
"eslint-import-resolver-typescript": "^3.8.3",
|
|
29
|
+
"eslint-plugin-compat": "^6.0.2",
|
|
30
|
+
"eslint-plugin-import-x": "^4.6.1",
|
|
31
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
32
|
+
"eslint-plugin-jest-dom": "^5.5.0",
|
|
33
|
+
"eslint-plugin-n": "^17.15.1",
|
|
34
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
35
|
+
"eslint-plugin-react": "^7.37.4",
|
|
36
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
37
|
+
"eslint-plugin-regexp": "^2.7.0",
|
|
39
38
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
40
|
-
"eslint-plugin-testing-library": "^7.
|
|
41
|
-
"eslint-plugin-unicorn": "^
|
|
42
|
-
"globals": "^
|
|
43
|
-
"typescript-eslint": "^8.
|
|
39
|
+
"eslint-plugin-testing-library": "^7.1.1",
|
|
40
|
+
"eslint-plugin-unicorn": "^57.0.0",
|
|
41
|
+
"globals": "^16.0.0",
|
|
42
|
+
"typescript-eslint": "^8.25.0"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@types/confusing-browser-globals": "1.0.3",
|
|
47
|
-
"@types/eslint": "9.6.1"
|
|
48
|
-
"@types/eslint__js": "8.42.3"
|
|
46
|
+
"@types/eslint": "9.6.1"
|
|
49
47
|
},
|
|
50
48
|
"peerDependencies": {
|
|
51
49
|
"@testing-library/dom": "^10.0.0",
|
|
52
|
-
"eslint": "^9.
|
|
50
|
+
"eslint": "^9.21.0",
|
|
53
51
|
"prettier": "^3.0.0",
|
|
54
52
|
"typescript": "^5.0.2"
|
|
55
53
|
},
|
|
@@ -62,10 +60,10 @@
|
|
|
62
60
|
}
|
|
63
61
|
},
|
|
64
62
|
"engines": {
|
|
65
|
-
"node": "^
|
|
63
|
+
"node": "^20.10.0 || >=22.11.0"
|
|
66
64
|
},
|
|
67
65
|
"publishConfig": {
|
|
68
66
|
"access": "public"
|
|
69
67
|
},
|
|
70
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "c636af09fd413eaa3c2936b2e2b4d32daac1ef0c"
|
|
71
69
|
}
|