@kikiutils/eslint-config 11.4.0 → 12.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 +41 -23
- package/dist/_internals/configs/base-rules.d.ts.map +1 -1
- package/dist/_internals/configs/base-rules.js +39 -40
- package/dist/_internals/configs/base-rules.js.map +1 -1
- package/dist/_internals/configs/jsdoc.d.ts +0 -39
- package/dist/_internals/configs/jsdoc.d.ts.map +1 -1
- package/dist/_internals/configs/jsdoc.js +1 -45
- package/dist/_internals/configs/jsdoc.js.map +1 -1
- package/dist/_internals/configs/type-aware.d.ts.map +1 -1
- package/dist/_internals/configs/type-aware.js +26 -1
- package/dist/_internals/configs/type-aware.js.map +1 -1
- package/dist/_internals/configs/typescript.d.ts +42 -0
- package/dist/_internals/configs/typescript.d.ts.map +1 -0
- package/dist/_internals/configs/typescript.js +49 -0
- package/dist/_internals/configs/typescript.js.map +1 -0
- package/dist/_internals/eslint-plugin-promise.d.ts +7 -0
- package/dist/_internals/eslint-plugin-promise.d.ts.map +1 -0
- package/dist/_internals/rules/consistent-condition-layout.d.ts.map +1 -1
- package/dist/_internals/rules/consistent-condition-layout.js +15 -14
- package/dist/_internals/rules/consistent-condition-layout.js.map +1 -1
- package/dist/_internals/rules/consistent-parameter-layout.d.ts.map +1 -1
- package/dist/_internals/rules/consistent-parameter-layout.js +17 -11
- package/dist/_internals/rules/consistent-parameter-layout.js.map +1 -1
- package/dist/_internals/rules/index.d.ts +7 -1
- package/dist/_internals/rules/index.d.ts.map +1 -1
- package/dist/_internals/rules/index.js +11 -2
- package/dist/_internals/rules/index.js.map +1 -1
- package/dist/_internals/rules/no-composable-in-head-getter.d.ts.map +1 -1
- package/dist/_internals/rules/no-composable-in-head-getter.js +97 -19
- package/dist/_internals/rules/no-composable-in-head-getter.js.map +1 -1
- package/dist/_internals/rules/no-reactive-composable-return.d.ts +3 -0
- package/dist/_internals/rules/no-reactive-composable-return.d.ts.map +1 -0
- package/dist/_internals/rules/no-reactive-composable-return.js +43 -0
- package/dist/_internals/rules/no-reactive-composable-return.js.map +1 -0
- package/dist/_internals/rules/no-reactive-destructure.d.ts +3 -0
- package/dist/_internals/rules/no-reactive-destructure.d.ts.map +1 -0
- package/dist/_internals/rules/no-reactive-destructure.js +44 -0
- package/dist/_internals/rules/no-reactive-destructure.js.map +1 -0
- package/dist/_internals/rules/no-silent-catch.d.ts.map +1 -1
- package/dist/_internals/rules/no-silent-catch.js +3 -2
- package/dist/_internals/rules/no-silent-catch.js.map +1 -1
- package/dist/_internals/rules/no-thenable-zod-refinement.d.ts.map +1 -1
- package/dist/_internals/rules/no-thenable-zod-refinement.js +9 -3
- package/dist/_internals/rules/no-thenable-zod-refinement.js.map +1 -1
- package/dist/_internals/rules/prefer-enhanced-date.d.ts +3 -0
- package/dist/_internals/rules/prefer-enhanced-date.d.ts.map +1 -0
- package/dist/_internals/rules/prefer-enhanced-date.js +307 -0
- package/dist/_internals/rules/prefer-enhanced-date.js.map +1 -0
- package/dist/_internals/rules/promise-function-async.d.ts.map +1 -1
- package/dist/_internals/rules/promise-function-async.js.map +1 -1
- package/dist/_internals/rules/statement-padding.d.ts.map +1 -1
- package/dist/_internals/rules/statement-padding.js +19 -15
- package/dist/_internals/rules/statement-padding.js.map +1 -1
- package/dist/_internals/rules/utils.d.ts +23 -0
- package/dist/_internals/rules/utils.d.ts.map +1 -0
- package/dist/_internals/rules/utils.js +17 -0
- package/dist/_internals/rules/utils.js.map +1 -0
- package/dist/_internals/rules/vue-reactivity.d.ts +3 -0
- package/dist/_internals/rules/vue-reactivity.d.ts.map +1 -0
- package/dist/_internals/rules/vue-reactivity.js +30 -0
- package/dist/_internals/rules/vue-reactivity.js.map +1 -0
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +51 -29
- package/dist/base.js.map +1 -1
- package/dist/nuxt.d.ts +3 -1
- package/dist/nuxt.d.ts.map +1 -1
- package/dist/nuxt.js +53 -3
- package/dist/nuxt.js.map +1 -1
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +1 -0
- package/dist/style.js.map +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +17 -19
- package/dist/vue.js.map +1 -1
- package/package.json +13 -12
- package/src/_internals/configs/base-rules.ts +33 -52
- package/src/_internals/configs/jsdoc.ts +0 -57
- package/src/_internals/configs/type-aware.ts +29 -1
- package/src/_internals/configs/typescript.ts +62 -0
- package/src/_internals/eslint-plugin-promise.d.ts +6 -0
- package/src/_internals/rules/consistent-condition-layout.ts +20 -23
- package/src/_internals/rules/consistent-parameter-layout.ts +30 -34
- package/src/_internals/rules/index.ts +10 -1
- package/src/_internals/rules/no-composable-in-head-getter.ts +132 -26
- package/src/_internals/rules/no-reactive-composable-return.ts +55 -0
- package/src/_internals/rules/no-reactive-destructure.ts +64 -0
- package/src/_internals/rules/no-silent-catch.ts +4 -10
- package/src/_internals/rules/no-thenable-zod-refinement.ts +14 -9
- package/src/_internals/rules/prefer-enhanced-date.ts +448 -0
- package/src/_internals/rules/promise-function-async.ts +2 -6
- package/src/_internals/rules/statement-padding.ts +23 -24
- package/src/_internals/{utils.ts → rules/utils.ts} +31 -0
- package/src/_internals/rules/vue-reactivity.ts +42 -0
- package/src/base.ts +51 -47
- package/src/nuxt.ts +90 -5
- package/src/style.ts +1 -0
- package/src/vue.ts +24 -26
- package/dist/_internals/configs/restricted-syntax.d.ts +0 -5
- package/dist/_internals/configs/restricted-syntax.d.ts.map +0 -1
- package/dist/_internals/configs/restricted-syntax.js +0 -12
- package/dist/_internals/configs/restricted-syntax.js.map +0 -1
- package/dist/_internals/configs/typefest.d.ts +0 -3
- package/dist/_internals/configs/typefest.d.ts.map +0 -1
- package/dist/_internals/configs/typefest.js +0 -21
- package/dist/_internals/configs/typefest.js.map +0 -1
- package/dist/_internals/utils.d.ts +0 -4
- package/dist/_internals/utils.d.ts.map +0 -1
- package/dist/_internals/utils.js +0 -10
- package/dist/_internals/utils.js.map +0 -1
- package/src/_internals/configs/restricted-syntax.ts +0 -8
- package/src/_internals/configs/typefest.ts +0 -19
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "12.0.0",
|
|
5
|
+
"description": "Opinionated ESLint flat config presets layered on @antfu/eslint-config, with type-aware TypeScript and Vue checks and custom rules, built for the author's own repositories.",
|
|
6
6
|
"author": "kiki-kanri",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"./src"
|
|
24
24
|
],
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">=24.15.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsdown",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"eslint": "^10.13.0",
|
|
44
44
|
"tailwindcss": "^4.3.3",
|
|
45
45
|
"ts-extras": "^3.0.0",
|
|
46
|
-
"type-fest": "^6.0.3"
|
|
46
|
+
"type-fest": "^6.0.3",
|
|
47
|
+
"typescript": "^6.0.3"
|
|
47
48
|
},
|
|
48
49
|
"peerDependenciesMeta": {
|
|
49
50
|
"eslint": {
|
|
@@ -55,9 +56,9 @@
|
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
58
|
"@eslint/css": "^2.0.1",
|
|
58
|
-
"@html-eslint/parser": "^0.
|
|
59
|
+
"@html-eslint/parser": "^0.69.0",
|
|
59
60
|
"@kikiutils/eslint-plugin-vue": "^10.10.0",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "^8.74.0",
|
|
61
62
|
"eslint-plugin-better-tailwindcss": "^4.11.0",
|
|
62
63
|
"eslint-plugin-format": "^2.0.1",
|
|
63
64
|
"eslint-plugin-promise": "^7.3.0",
|
|
@@ -68,18 +69,18 @@
|
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@antfu/eslint-config": "^10.0.0",
|
|
70
71
|
"@arethetypeswrong/core": "^0.18.5",
|
|
71
|
-
"@kikiutils/tsconfigs": "^
|
|
72
|
-
"@types/node": "^26.6.
|
|
73
|
-
"@vitest/coverage-v8": "^5.1.
|
|
72
|
+
"@kikiutils/tsconfigs": "^8.0.0",
|
|
73
|
+
"@types/node": "^26.6.11",
|
|
74
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
74
75
|
"changelogen": "^0.6.2",
|
|
75
|
-
"eslint": "^10.
|
|
76
|
-
"knip": "^6.
|
|
76
|
+
"eslint": "^10.16.0",
|
|
77
|
+
"knip": "^6.49.0",
|
|
77
78
|
"publint": "^0.3.25",
|
|
78
79
|
"ts-extras": "^3.0.0",
|
|
79
80
|
"tsdown": "^0.23.7",
|
|
80
81
|
"type-fest": "^6.0.3",
|
|
81
82
|
"typescript": "^6.0.3",
|
|
82
83
|
"unplugin-unused": "^0.6.0",
|
|
83
|
-
"vitest": "^5.1.
|
|
84
|
+
"vitest": "^5.1.2"
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Rules } from '@antfu/eslint-config';
|
|
2
2
|
|
|
3
|
-
import { restrictedSyntax } from './restricted-syntax';
|
|
4
|
-
|
|
5
3
|
const basePerfectionistSortOptions = {
|
|
6
4
|
ignoreCase: false,
|
|
7
5
|
type: 'natural',
|
|
@@ -28,17 +26,17 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
28
26
|
'error',
|
|
29
27
|
'multi-line',
|
|
30
28
|
],
|
|
31
|
-
'
|
|
32
|
-
'jsdoc/multiline-blocks': [
|
|
29
|
+
'eslint-comments/require-description': [
|
|
33
30
|
'error',
|
|
34
|
-
{
|
|
35
|
-
noSingleLineBlocks: true,
|
|
36
|
-
singleLineTags: [
|
|
37
|
-
'type',
|
|
38
|
-
'import',
|
|
39
|
-
],
|
|
40
|
-
},
|
|
31
|
+
{ ignore: ['eslint-enable'] },
|
|
41
32
|
],
|
|
33
|
+
'for-direction': 'error',
|
|
34
|
+
'jsdoc/check-param-names': [
|
|
35
|
+
'error',
|
|
36
|
+
{ disableMissingParamChecks: true },
|
|
37
|
+
],
|
|
38
|
+
'jsdoc/check-tag-names': 'error',
|
|
39
|
+
'jsdoc/multiline-blocks': 'error',
|
|
42
40
|
'jsdoc/no-blank-blocks': [
|
|
43
41
|
'error',
|
|
44
42
|
{ enableFixer: true },
|
|
@@ -54,17 +52,22 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
54
52
|
'kikiutils/consistent-condition-layout': 'error',
|
|
55
53
|
'kikiutils/consistent-parameter-layout': 'error',
|
|
56
54
|
'kikiutils/no-silent-catch': 'error',
|
|
55
|
+
'kikiutils/prefer-enhanced-date': 'error',
|
|
57
56
|
'kikiutils/statement-padding': 'error',
|
|
58
57
|
'max-classes-per-file': [
|
|
59
58
|
'error',
|
|
60
59
|
1,
|
|
61
60
|
],
|
|
62
61
|
'no-constant-binary-expression': 'error',
|
|
62
|
+
'no-constant-condition': 'error',
|
|
63
|
+
'no-constructor-return': 'error',
|
|
64
|
+
'no-dupe-else-if': 'error',
|
|
63
65
|
// An ignored error needs at least a comment in the block saying why.
|
|
64
66
|
'no-empty': [
|
|
65
67
|
'error',
|
|
66
68
|
{ allowEmptyCatch: false },
|
|
67
69
|
],
|
|
70
|
+
'no-empty-static-block': 'error',
|
|
68
71
|
'no-promise-executor-return': [
|
|
69
72
|
'error',
|
|
70
73
|
{ allowVoid: true },
|
|
@@ -80,22 +83,27 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
80
83
|
],
|
|
81
84
|
},
|
|
82
85
|
],
|
|
86
|
+
// Repeats antfu's entries because a later config replaces the whole option list.
|
|
83
87
|
'no-restricted-syntax': [
|
|
84
88
|
'error',
|
|
85
|
-
|
|
89
|
+
'TSEnumDeclaration[const=true]',
|
|
90
|
+
'TSExportAssignment',
|
|
91
|
+
{
|
|
92
|
+
message: 'Use `axios.isAxiosError(error)`; `instanceof` fails when the error comes from another copy of axios.',
|
|
93
|
+
selector: 'BinaryExpression[operator="instanceof"][right.name="AxiosError"]',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
message: '`structuredClone()` drops prototypes, turning class instances such as `ObjectId` into plain objects, and throws on Vue reactive proxies. Use `cloneDeep()` from es-toolkit, or spread only the level you change.',
|
|
97
|
+
selector: 'CallExpression[callee.name="structuredClone"]',
|
|
98
|
+
},
|
|
86
99
|
],
|
|
100
|
+
'no-unassigned-vars': 'error',
|
|
101
|
+
'no-unsafe-optional-chaining': 'error',
|
|
87
102
|
'no-useless-assignment': 'error',
|
|
88
103
|
'perfectionist/sort-array-includes': [
|
|
89
104
|
'error',
|
|
90
105
|
basePerfectionistSortOptions,
|
|
91
106
|
],
|
|
92
|
-
'perfectionist/sort-enums': [
|
|
93
|
-
'error',
|
|
94
|
-
{
|
|
95
|
-
...basePerfectionistSortOptions,
|
|
96
|
-
sortByValue: 'never',
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
107
|
'perfectionist/sort-heritage-clauses': [
|
|
100
108
|
'error',
|
|
101
109
|
basePerfectionistSortOptions,
|
|
@@ -151,10 +159,6 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
151
159
|
'error',
|
|
152
160
|
basePerfectionistSortOptions,
|
|
153
161
|
],
|
|
154
|
-
'perfectionist/sort-maps': [
|
|
155
|
-
'error',
|
|
156
|
-
basePerfectionistSortOptions,
|
|
157
|
-
],
|
|
158
162
|
'perfectionist/sort-modules': [
|
|
159
163
|
'error',
|
|
160
164
|
{
|
|
@@ -192,20 +196,9 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
192
196
|
'error',
|
|
193
197
|
basePerfectionistSortOptions,
|
|
194
198
|
],
|
|
195
|
-
'perfectionist/sort-objects': [
|
|
196
|
-
'error',
|
|
197
|
-
basePerfectionistSortOptions,
|
|
198
|
-
],
|
|
199
|
-
'perfectionist/sort-sets': [
|
|
200
|
-
'error',
|
|
201
|
-
basePerfectionistSortOptions,
|
|
202
|
-
],
|
|
203
199
|
'perfectionist/sort-switch-case': [
|
|
204
200
|
'error',
|
|
205
|
-
|
|
206
|
-
ignoreCase: false,
|
|
207
|
-
type: 'natural',
|
|
208
|
-
},
|
|
201
|
+
basePerfectionistSortOptions,
|
|
209
202
|
],
|
|
210
203
|
'perfectionist/sort-union-types': [
|
|
211
204
|
'error',
|
|
@@ -220,6 +213,7 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
220
213
|
'promise/no-return-in-finally': 'error',
|
|
221
214
|
'promise/no-return-wrap': 'error',
|
|
222
215
|
'require-await': 'off',
|
|
216
|
+
'require-yield': 'error',
|
|
223
217
|
'style/array-bracket-newline': [
|
|
224
218
|
'error',
|
|
225
219
|
{ multiline: true },
|
|
@@ -251,15 +245,6 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
251
245
|
'error',
|
|
252
246
|
4,
|
|
253
247
|
],
|
|
254
|
-
'style/max-len': [
|
|
255
|
-
'warn',
|
|
256
|
-
{
|
|
257
|
-
code: 120,
|
|
258
|
-
comments: 120,
|
|
259
|
-
ignoreStrings: true,
|
|
260
|
-
ignoreTemplateLiterals: true,
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
248
|
'style/member-delimiter-style': [
|
|
264
249
|
'error',
|
|
265
250
|
{
|
|
@@ -312,19 +297,15 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
312
297
|
],
|
|
313
298
|
prev: '*',
|
|
314
299
|
},
|
|
315
|
-
{
|
|
316
|
-
blankLine: 'always',
|
|
317
|
-
next: '*',
|
|
318
|
-
prev: [
|
|
319
|
-
'class',
|
|
320
|
-
'function',
|
|
321
|
-
],
|
|
322
|
-
},
|
|
323
300
|
],
|
|
324
301
|
'style/semi': [
|
|
325
302
|
'error',
|
|
326
303
|
'always',
|
|
327
304
|
],
|
|
305
|
+
'unicorn/no-array-callback-reference': 'error',
|
|
306
|
+
'unicorn/no-array-fill-with-reference-type': 'error',
|
|
307
|
+
'unicorn/no-await-in-promise-methods': 'error',
|
|
308
|
+
'unicorn/no-single-promise-in-promise-methods': 'error',
|
|
328
309
|
'unicorn/no-useless-promise-resolve-reject': 'error',
|
|
329
310
|
'unicorn/no-useless-spread': 'error',
|
|
330
311
|
'unicorn/prefer-array-find': 'error',
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
-
|
|
3
1
|
export const jsdocSettings = {
|
|
4
2
|
jsdoc: {
|
|
5
3
|
tagNamePreference: {
|
|
@@ -13,58 +11,3 @@ export const jsdocSettings = {
|
|
|
13
11
|
},
|
|
14
12
|
},
|
|
15
13
|
};
|
|
16
|
-
|
|
17
|
-
export const typescriptJsdocConfig = {
|
|
18
|
-
rules: {
|
|
19
|
-
'jsdoc/check-tag-names': [
|
|
20
|
-
'error',
|
|
21
|
-
{
|
|
22
|
-
definedTags: [
|
|
23
|
-
'alpha',
|
|
24
|
-
'beta',
|
|
25
|
-
'defaultValue',
|
|
26
|
-
'eventProperty',
|
|
27
|
-
'experimental',
|
|
28
|
-
'hidden',
|
|
29
|
-
'inheritDoc',
|
|
30
|
-
'internal',
|
|
31
|
-
'packageDocumentation',
|
|
32
|
-
'privateRemarks',
|
|
33
|
-
'remarks',
|
|
34
|
-
'sealed',
|
|
35
|
-
'typeParam',
|
|
36
|
-
'virtual',
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
'jsdoc/multiline-blocks': [
|
|
41
|
-
'error',
|
|
42
|
-
{
|
|
43
|
-
noSingleLineBlocks: true,
|
|
44
|
-
singleLineTags: [],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
'jsdoc/no-types': 'error',
|
|
48
|
-
},
|
|
49
|
-
settings: {
|
|
50
|
-
jsdoc: {
|
|
51
|
-
mode: 'typescript',
|
|
52
|
-
tagNamePreference: {
|
|
53
|
-
...jsdocSettings.jsdoc.tagNamePreference,
|
|
54
|
-
callback: false,
|
|
55
|
-
class: false,
|
|
56
|
-
constructor: false,
|
|
57
|
-
default: 'defaultValue',
|
|
58
|
-
function: false,
|
|
59
|
-
method: false,
|
|
60
|
-
readonly: false,
|
|
61
|
-
static: false,
|
|
62
|
-
template: false,
|
|
63
|
-
type: false,
|
|
64
|
-
typedef: false,
|
|
65
|
-
typeParam: 'typeParam',
|
|
66
|
-
virtual: 'virtual',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
} satisfies TypedFlatConfigItem;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
import typefest from 'eslint-plugin-typefest';
|
|
2
3
|
|
|
3
4
|
export function createTypeAwareConfig(): TypedFlatConfigItem {
|
|
4
5
|
return {
|
|
@@ -8,15 +9,22 @@ export function createTypeAwareConfig(): TypedFlatConfigItem {
|
|
|
8
9
|
tsconfigRootDir: process.cwd(),
|
|
9
10
|
},
|
|
10
11
|
},
|
|
12
|
+
plugins: { typefest },
|
|
11
13
|
rules: {
|
|
14
|
+
// Core rules turned off here are replaced by their typed `ts/` versions, which report more accurately.
|
|
15
|
+
'dot-notation': 'off',
|
|
16
|
+
'kikiutils/no-reactive-destructure': 'error',
|
|
12
17
|
'kikiutils/no-thenable-zod-refinement': 'error',
|
|
13
18
|
'kikiutils/promise-function-async': 'error',
|
|
14
|
-
// The typed replacements below report these more accurately.
|
|
15
19
|
'no-implied-eval': 'off',
|
|
16
20
|
'no-throw-literal': 'off',
|
|
17
21
|
'prefer-promise-reject-errors': 'off',
|
|
18
22
|
'ts/await-thenable': 'error',
|
|
19
23
|
'ts/consistent-type-exports': 'error',
|
|
24
|
+
'ts/dot-notation': [
|
|
25
|
+
'error',
|
|
26
|
+
{ allowKeywords: true },
|
|
27
|
+
],
|
|
20
28
|
'ts/no-array-delete': 'error',
|
|
21
29
|
'ts/no-base-to-string': 'error',
|
|
22
30
|
'ts/no-deprecated': 'error',
|
|
@@ -35,12 +43,21 @@ export function createTypeAwareConfig(): TypedFlatConfigItem {
|
|
|
35
43
|
],
|
|
36
44
|
'ts/no-for-in-array': 'error',
|
|
37
45
|
'ts/no-implied-eval': 'error',
|
|
46
|
+
'ts/no-meaningless-void-operator': 'error',
|
|
38
47
|
'ts/no-misused-promises': 'error',
|
|
39
48
|
'ts/no-misused-spread': 'error',
|
|
49
|
+
'ts/no-redundant-type-constituents': 'error',
|
|
40
50
|
'ts/no-unnecessary-boolean-literal-compare': 'error',
|
|
41
51
|
'ts/no-unnecessary-template-expression': 'error',
|
|
42
52
|
'ts/no-unnecessary-type-arguments': 'error',
|
|
43
53
|
'ts/no-unnecessary-type-assertion': 'error',
|
|
54
|
+
'ts/no-unnecessary-type-conversion': 'error',
|
|
55
|
+
'ts/no-unsafe-argument': 'error',
|
|
56
|
+
'ts/no-unsafe-assignment': 'error',
|
|
57
|
+
'ts/no-unsafe-call': 'error',
|
|
58
|
+
'ts/no-unsafe-member-access': 'error',
|
|
59
|
+
'ts/no-unsafe-return': 'error',
|
|
60
|
+
'ts/no-useless-default-assignment': 'error',
|
|
44
61
|
'ts/only-throw-error': 'error',
|
|
45
62
|
// Matches only-throw-error, which allows `any` and `unknown` by default.
|
|
46
63
|
'ts/prefer-promise-reject-errors': [
|
|
@@ -52,6 +69,7 @@ export function createTypeAwareConfig(): TypedFlatConfigItem {
|
|
|
52
69
|
],
|
|
53
70
|
'ts/promise-function-async': 'off',
|
|
54
71
|
'ts/require-await': 'off',
|
|
72
|
+
'ts/restrict-plus-operands': 'error',
|
|
55
73
|
// Exhaustive-switch fallbacks interpolate the `never` value into their error message.
|
|
56
74
|
'ts/restrict-template-expressions': [
|
|
57
75
|
'error',
|
|
@@ -65,6 +83,16 @@ export function createTypeAwareConfig(): TypedFlatConfigItem {
|
|
|
65
83
|
'error',
|
|
66
84
|
{ considerDefaultExhaustiveForUnions: true },
|
|
67
85
|
],
|
|
86
|
+
'ts/use-unknown-in-catch-callback-variable': 'error',
|
|
87
|
+
'typefest/prefer-ts-extras-is-present-filter': 'error',
|
|
88
|
+
'typefest/prefer-ts-extras-object-entries': 'error',
|
|
89
|
+
'typefest/prefer-ts-extras-object-has-own': 'error',
|
|
90
|
+
'typefest/prefer-ts-extras-object-keys': 'error',
|
|
91
|
+
'typefest/prefer-ts-extras-object-values': 'error',
|
|
92
|
+
'typefest/prefer-type-fest-array-values': 'error',
|
|
93
|
+
'typefest/prefer-type-fest-arrayable': 'error',
|
|
94
|
+
'typefest/prefer-type-fest-unknown-record': 'error',
|
|
95
|
+
'typefest/prefer-type-fest-value-of': 'error',
|
|
68
96
|
},
|
|
69
97
|
};
|
|
70
98
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
|
|
3
|
+
import { jsdocSettings } from './jsdoc';
|
|
4
|
+
|
|
5
|
+
// antfu's TypeScript rules also cover `.vue` files, so these overrides are shared by the TS and Vue items.
|
|
6
|
+
export const typescriptConfig = {
|
|
7
|
+
rules: {
|
|
8
|
+
'jsdoc/check-tag-names': [
|
|
9
|
+
'error',
|
|
10
|
+
{
|
|
11
|
+
definedTags: [
|
|
12
|
+
'alpha',
|
|
13
|
+
'beta',
|
|
14
|
+
'defaultValue',
|
|
15
|
+
'eventProperty',
|
|
16
|
+
'experimental',
|
|
17
|
+
'hidden',
|
|
18
|
+
'inheritDoc',
|
|
19
|
+
'internal',
|
|
20
|
+
'packageDocumentation',
|
|
21
|
+
'privateRemarks',
|
|
22
|
+
'remarks',
|
|
23
|
+
'sealed',
|
|
24
|
+
'typeParam',
|
|
25
|
+
'virtual',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
'jsdoc/no-types': 'error',
|
|
30
|
+
'ts/array-type': [
|
|
31
|
+
'error',
|
|
32
|
+
{ default: 'array-simple' },
|
|
33
|
+
],
|
|
34
|
+
'ts/consistent-generic-constructors': [
|
|
35
|
+
'error',
|
|
36
|
+
'constructor',
|
|
37
|
+
],
|
|
38
|
+
'ts/no-explicit-any': 'error',
|
|
39
|
+
'ts/no-redeclare': 'off',
|
|
40
|
+
},
|
|
41
|
+
settings: {
|
|
42
|
+
jsdoc: {
|
|
43
|
+
mode: 'typescript',
|
|
44
|
+
tagNamePreference: {
|
|
45
|
+
...jsdocSettings.jsdoc.tagNamePreference,
|
|
46
|
+
callback: false,
|
|
47
|
+
class: false,
|
|
48
|
+
constructor: false,
|
|
49
|
+
default: 'defaultValue',
|
|
50
|
+
function: false,
|
|
51
|
+
method: false,
|
|
52
|
+
readonly: false,
|
|
53
|
+
static: false,
|
|
54
|
+
template: false,
|
|
55
|
+
type: false,
|
|
56
|
+
typedef: false,
|
|
57
|
+
typeParam: 'typeParam',
|
|
58
|
+
virtual: 'virtual',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
} satisfies TypedFlatConfigItem;
|
|
@@ -3,11 +3,27 @@ import type {
|
|
|
3
3
|
Rule,
|
|
4
4
|
} from 'eslint';
|
|
5
5
|
|
|
6
|
-
import type { TokenStore } from '
|
|
7
|
-
import {
|
|
6
|
+
import type { TokenStore } from './utils';
|
|
7
|
+
import {
|
|
8
|
+
defineScriptAndTemplateVisitors,
|
|
9
|
+
insertNewlines,
|
|
10
|
+
} from './utils';
|
|
8
11
|
|
|
9
12
|
type LogicalNode = Extract<Rule.Node, { type: 'LogicalExpression' }>;
|
|
10
13
|
|
|
14
|
+
const comparisonOperators = new Set([
|
|
15
|
+
'!=',
|
|
16
|
+
'!==',
|
|
17
|
+
'<',
|
|
18
|
+
'<=',
|
|
19
|
+
'==',
|
|
20
|
+
'===',
|
|
21
|
+
'>',
|
|
22
|
+
'>=',
|
|
23
|
+
'in',
|
|
24
|
+
'instanceof',
|
|
25
|
+
]);
|
|
26
|
+
|
|
11
27
|
export const consistentConditionLayout: Rule.RuleModule = {
|
|
12
28
|
create(context) {
|
|
13
29
|
function createVisitor(tokenStore: TokenStore): Rule.RuleListener {
|
|
@@ -76,13 +92,7 @@ export const consistentConditionLayout: Rule.RuleModule = {
|
|
|
76
92
|
|
|
77
93
|
if (newlineOffsets.length) {
|
|
78
94
|
context.report({
|
|
79
|
-
fix: (
|
|
80
|
-
[
|
|
81
|
-
offset,
|
|
82
|
-
offset,
|
|
83
|
-
],
|
|
84
|
-
'\n',
|
|
85
|
-
)),
|
|
95
|
+
fix: insertNewlines(newlineOffsets),
|
|
86
96
|
messageId: 'newline',
|
|
87
97
|
node,
|
|
88
98
|
});
|
|
@@ -91,20 +101,7 @@ export const consistentConditionLayout: Rule.RuleModule = {
|
|
|
91
101
|
|
|
92
102
|
return {
|
|
93
103
|
BinaryExpression: (node) => {
|
|
94
|
-
if (
|
|
95
|
-
[
|
|
96
|
-
'!=',
|
|
97
|
-
'!==',
|
|
98
|
-
'<',
|
|
99
|
-
'<=',
|
|
100
|
-
'==',
|
|
101
|
-
'===',
|
|
102
|
-
'>',
|
|
103
|
-
'>=',
|
|
104
|
-
'in',
|
|
105
|
-
'instanceof',
|
|
106
|
-
].includes(node.operator)
|
|
107
|
-
) checkParentheses(node);
|
|
104
|
+
if (comparisonOperators.has(node.operator)) checkParentheses(node);
|
|
108
105
|
},
|
|
109
106
|
DoWhileStatement: (node) => checkParentheses(node.test),
|
|
110
107
|
IfStatement: (node) => checkParentheses(node.test),
|
|
@@ -3,8 +3,12 @@ import type {
|
|
|
3
3
|
Rule,
|
|
4
4
|
} from 'eslint';
|
|
5
5
|
|
|
6
|
-
import type { TokenStore } from '
|
|
7
|
-
import {
|
|
6
|
+
import type { TokenStore } from './utils';
|
|
7
|
+
import {
|
|
8
|
+
defineScriptAndTemplateVisitors,
|
|
9
|
+
insertNewlines,
|
|
10
|
+
isMemberNamed,
|
|
11
|
+
} from './utils';
|
|
8
12
|
|
|
9
13
|
type CallNode = Extract<Rule.Node, { type: 'CallExpression' | 'NewExpression' }> & { typeArguments?: Rule.Node };
|
|
10
14
|
type FunctionNode = Extract<
|
|
@@ -14,18 +18,32 @@ type FunctionNode = Extract<
|
|
|
14
18
|
|
|
15
19
|
type ListItem = CallNode['arguments'][number] | FunctionNode['params'][number];
|
|
16
20
|
|
|
21
|
+
function isTestCall(callee: CallNode['callee']): boolean {
|
|
22
|
+
let target = callee;
|
|
23
|
+
if (target.type === 'CallExpression') {
|
|
24
|
+
if (!isMemberNamed(target.callee, 'for')) return false;
|
|
25
|
+
target = target.callee.object;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (isMemberNamed(target, 'concurrent')) target = target.object;
|
|
29
|
+
return target.type === 'Identifier' && (target.name === 'describe' || target.name === 'it');
|
|
30
|
+
}
|
|
31
|
+
|
|
17
32
|
export const consistentParameterLayout: Rule.RuleModule = {
|
|
18
33
|
create(context) {
|
|
19
|
-
const
|
|
34
|
+
const options = context.options[0] as undefined | { compactTestCalls?: boolean };
|
|
35
|
+
const compactTestCalls = options?.compactTestCalls === true;
|
|
20
36
|
|
|
21
37
|
function createVisitor(tokenStore: TokenStore, isTemplate: boolean): Rule.RuleListener {
|
|
38
|
+
const getCallOpeningParen = (node: CallNode) => tokenStore.getTokenAfter(
|
|
39
|
+
node.typeArguments ?? node.callee,
|
|
40
|
+
(token) => token.type === 'Punctuator' && token.value === '(',
|
|
41
|
+
);
|
|
42
|
+
|
|
22
43
|
function checkTestCallLayout(node: CallNode): void {
|
|
23
44
|
const items = node.arguments;
|
|
24
45
|
if (!items.length) return;
|
|
25
|
-
const openingParen =
|
|
26
|
-
node.typeArguments ?? node.callee,
|
|
27
|
-
(token) => token.type === 'Punctuator' && token.value === '(',
|
|
28
|
-
)!;
|
|
46
|
+
const openingParen = getCallOpeningParen(node)!;
|
|
29
47
|
|
|
30
48
|
const closingParen = tokenStore.getLastToken(node)!;
|
|
31
49
|
const previous = tokenStore.getTokenBefore(closingParen)!;
|
|
@@ -103,10 +121,7 @@ export const consistentParameterLayout: Rule.RuleModule = {
|
|
|
103
121
|
if (isSingleParameter && (firstType === 'JSXElement' || firstType === 'JSXFragment')) return;
|
|
104
122
|
let openingParen;
|
|
105
123
|
if (node.type === 'CallExpression' || node.type === 'NewExpression') {
|
|
106
|
-
openingParen =
|
|
107
|
-
node.typeArguments ?? node.callee,
|
|
108
|
-
(token) => token.type === 'Punctuator' && token.value === '(',
|
|
109
|
-
);
|
|
124
|
+
openingParen = getCallOpeningParen(node);
|
|
110
125
|
} else {
|
|
111
126
|
openingParen = tokenStore.getTokenBefore(first);
|
|
112
127
|
}
|
|
@@ -169,13 +184,7 @@ export const consistentParameterLayout: Rule.RuleModule = {
|
|
|
169
184
|
|
|
170
185
|
if (newlineOffsets.length) {
|
|
171
186
|
context.report({
|
|
172
|
-
fix: (
|
|
173
|
-
[
|
|
174
|
-
offset,
|
|
175
|
-
offset,
|
|
176
|
-
],
|
|
177
|
-
'\n',
|
|
178
|
-
)),
|
|
187
|
+
fix: insertNewlines(newlineOffsets),
|
|
179
188
|
messageId: 'newline',
|
|
180
189
|
node: first,
|
|
181
190
|
});
|
|
@@ -196,22 +205,9 @@ export const consistentParameterLayout: Rule.RuleModule = {
|
|
|
196
205
|
return {
|
|
197
206
|
ArrowFunctionExpression: (node) => checkParameterLayout(node, node.params),
|
|
198
207
|
CallExpression: (node) => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
&& !callee.computed
|
|
203
|
-
&& callee.property.type === 'Identifier'
|
|
204
|
-
&& callee.property.name === 'concurrent'
|
|
205
|
-
? callee.object
|
|
206
|
-
: callee;
|
|
207
|
-
|
|
208
|
-
if (
|
|
209
|
-
target.type === 'Identifier'
|
|
210
|
-
&& (target.name === 'describe' || target.name === 'it')
|
|
211
|
-
) {
|
|
212
|
-
checkTestCallLayout(node);
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
208
|
+
if (compactTestCalls && isTestCall(node.callee)) {
|
|
209
|
+
checkTestCallLayout(node);
|
|
210
|
+
return;
|
|
215
211
|
}
|
|
216
212
|
|
|
217
213
|
checkParameterLayout(node, node.arguments);
|
|
@@ -6,8 +6,11 @@ import { consistentConditionLayout } from './consistent-condition-layout';
|
|
|
6
6
|
import { consistentParameterLayout } from './consistent-parameter-layout';
|
|
7
7
|
import { nitroRouteMethodSuffix } from './nitro-route-method-suffix';
|
|
8
8
|
import { noComposableInHeadGetter } from './no-composable-in-head-getter';
|
|
9
|
+
import { noReactiveComposableReturn } from './no-reactive-composable-return';
|
|
10
|
+
import { noReactiveDestructure } from './no-reactive-destructure';
|
|
9
11
|
import { noSilentCatch } from './no-silent-catch';
|
|
10
12
|
import { noThenableZodRefinement } from './no-thenable-zod-refinement';
|
|
13
|
+
import { preferEnhancedDate } from './prefer-enhanced-date';
|
|
11
14
|
import { promiseFunctionAsync } from './promise-function-async';
|
|
12
15
|
import { statementPadding } from './statement-padding';
|
|
13
16
|
|
|
@@ -18,7 +21,7 @@ const coreRules = builtinRules;
|
|
|
18
21
|
const noRestrictedImports = coreRules.get('no-restricted-imports')!;
|
|
19
22
|
const noRestrictedSyntax = coreRules.get('no-restricted-syntax')!;
|
|
20
23
|
|
|
21
|
-
export const
|
|
24
|
+
export const kikiutilsPlugin = {
|
|
22
25
|
rules: {
|
|
23
26
|
'comment-indent': commentIndent,
|
|
24
27
|
'compact-iteration-layout': compactIterationLayout,
|
|
@@ -26,12 +29,18 @@ export const customPlugins = {
|
|
|
26
29
|
'consistent-parameter-layout': consistentParameterLayout,
|
|
27
30
|
'nitro-route-method-suffix': nitroRouteMethodSuffix,
|
|
28
31
|
'no-composable-in-head-getter': noComposableInHeadGetter,
|
|
32
|
+
'no-reactive-composable-return': noReactiveComposableReturn,
|
|
33
|
+
'no-reactive-destructure': noReactiveDestructure,
|
|
34
|
+
'no-restricted-nuxt-app-syntax': noRestrictedSyntax,
|
|
35
|
+
'no-restricted-nuxt-component-syntax': noRestrictedSyntax,
|
|
29
36
|
'no-restricted-nuxt-page-syntax': noRestrictedSyntax,
|
|
30
37
|
'no-restricted-nuxt-server-imports': noRestrictedImports,
|
|
31
38
|
'no-restricted-nuxt-syntax': noRestrictedSyntax,
|
|
32
39
|
'no-restricted-test-imports': noRestrictedImports,
|
|
40
|
+
'no-restricted-test-syntax': noRestrictedSyntax,
|
|
33
41
|
'no-silent-catch': noSilentCatch,
|
|
34
42
|
'no-thenable-zod-refinement': noThenableZodRefinement,
|
|
43
|
+
'prefer-enhanced-date': preferEnhancedDate,
|
|
35
44
|
'promise-function-async': promiseFunctionAsync,
|
|
36
45
|
'statement-padding': statementPadding,
|
|
37
46
|
},
|