@kikiutils/eslint-config 11.5.0 → 12.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/README.md +41 -23
- package/dist/_internals/configs/base-rules.d.ts.map +1 -1
- package/dist/_internals/configs/base-rules.js +37 -37
- package/dist/_internals/configs/base-rules.js.map +1 -1
- package/dist/_internals/configs/jsdoc.d.ts +0 -36
- package/dist/_internals/configs/jsdoc.d.ts.map +1 -1
- package/dist/_internals/configs/jsdoc.js +1 -42
- 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 +57 -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 +6 -5
- package/src/_internals/configs/base-rules.ts +29 -44
- package/src/_internals/configs/jsdoc.ts +0 -51
- 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 +55 -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.1",
|
|
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": {
|
|
@@ -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": {
|
|
@@ -72,8 +73,8 @@
|
|
|
72
73
|
"@types/node": "^26.6.11",
|
|
73
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",
|
|
@@ -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,8 +26,13 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
28
26
|
'error',
|
|
29
27
|
'multi-line',
|
|
30
28
|
],
|
|
29
|
+
'eslint-comments/require-description': [
|
|
30
|
+
'error',
|
|
31
|
+
{ ignore: ['eslint-enable'] },
|
|
32
|
+
],
|
|
33
|
+
'for-direction': 'error',
|
|
31
34
|
'jsdoc/check-param-names': [
|
|
32
|
-
'
|
|
35
|
+
'error',
|
|
33
36
|
{ disableMissingParamChecks: true },
|
|
34
37
|
],
|
|
35
38
|
'jsdoc/check-tag-names': 'error',
|
|
@@ -49,17 +52,22 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
49
52
|
'kikiutils/consistent-condition-layout': 'error',
|
|
50
53
|
'kikiutils/consistent-parameter-layout': 'error',
|
|
51
54
|
'kikiutils/no-silent-catch': 'error',
|
|
55
|
+
'kikiutils/prefer-enhanced-date': 'error',
|
|
52
56
|
'kikiutils/statement-padding': 'error',
|
|
53
57
|
'max-classes-per-file': [
|
|
54
58
|
'error',
|
|
55
59
|
1,
|
|
56
60
|
],
|
|
57
61
|
'no-constant-binary-expression': 'error',
|
|
62
|
+
'no-constant-condition': 'error',
|
|
63
|
+
'no-constructor-return': 'error',
|
|
64
|
+
'no-dupe-else-if': 'error',
|
|
58
65
|
// An ignored error needs at least a comment in the block saying why.
|
|
59
66
|
'no-empty': [
|
|
60
67
|
'error',
|
|
61
68
|
{ allowEmptyCatch: false },
|
|
62
69
|
],
|
|
70
|
+
'no-empty-static-block': 'error',
|
|
63
71
|
'no-promise-executor-return': [
|
|
64
72
|
'error',
|
|
65
73
|
{ allowVoid: true },
|
|
@@ -75,22 +83,27 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
75
83
|
],
|
|
76
84
|
},
|
|
77
85
|
],
|
|
86
|
+
// Repeats antfu's entries because a later config replaces the whole option list.
|
|
78
87
|
'no-restricted-syntax': [
|
|
79
88
|
'error',
|
|
80
|
-
|
|
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
|
+
},
|
|
81
99
|
],
|
|
100
|
+
'no-unassigned-vars': 'error',
|
|
101
|
+
'no-unsafe-optional-chaining': 'error',
|
|
82
102
|
'no-useless-assignment': 'error',
|
|
83
103
|
'perfectionist/sort-array-includes': [
|
|
84
104
|
'error',
|
|
85
105
|
basePerfectionistSortOptions,
|
|
86
106
|
],
|
|
87
|
-
'perfectionist/sort-enums': [
|
|
88
|
-
'error',
|
|
89
|
-
{
|
|
90
|
-
...basePerfectionistSortOptions,
|
|
91
|
-
sortByValue: 'never',
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
107
|
'perfectionist/sort-heritage-clauses': [
|
|
95
108
|
'error',
|
|
96
109
|
basePerfectionistSortOptions,
|
|
@@ -146,10 +159,6 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
146
159
|
'error',
|
|
147
160
|
basePerfectionistSortOptions,
|
|
148
161
|
],
|
|
149
|
-
'perfectionist/sort-maps': [
|
|
150
|
-
'error',
|
|
151
|
-
basePerfectionistSortOptions,
|
|
152
|
-
],
|
|
153
162
|
'perfectionist/sort-modules': [
|
|
154
163
|
'error',
|
|
155
164
|
{
|
|
@@ -187,20 +196,9 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
187
196
|
'error',
|
|
188
197
|
basePerfectionistSortOptions,
|
|
189
198
|
],
|
|
190
|
-
'perfectionist/sort-objects': [
|
|
191
|
-
'error',
|
|
192
|
-
basePerfectionistSortOptions,
|
|
193
|
-
],
|
|
194
|
-
'perfectionist/sort-sets': [
|
|
195
|
-
'error',
|
|
196
|
-
basePerfectionistSortOptions,
|
|
197
|
-
],
|
|
198
199
|
'perfectionist/sort-switch-case': [
|
|
199
200
|
'error',
|
|
200
|
-
|
|
201
|
-
ignoreCase: false,
|
|
202
|
-
type: 'natural',
|
|
203
|
-
},
|
|
201
|
+
basePerfectionistSortOptions,
|
|
204
202
|
],
|
|
205
203
|
'perfectionist/sort-union-types': [
|
|
206
204
|
'error',
|
|
@@ -215,6 +213,7 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
215
213
|
'promise/no-return-in-finally': 'error',
|
|
216
214
|
'promise/no-return-wrap': 'error',
|
|
217
215
|
'require-await': 'off',
|
|
216
|
+
'require-yield': 'error',
|
|
218
217
|
'style/array-bracket-newline': [
|
|
219
218
|
'error',
|
|
220
219
|
{ multiline: true },
|
|
@@ -246,15 +245,6 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
246
245
|
'error',
|
|
247
246
|
4,
|
|
248
247
|
],
|
|
249
|
-
'style/max-len': [
|
|
250
|
-
'warn',
|
|
251
|
-
{
|
|
252
|
-
code: 120,
|
|
253
|
-
comments: 120,
|
|
254
|
-
ignoreStrings: true,
|
|
255
|
-
ignoreTemplateLiterals: true,
|
|
256
|
-
},
|
|
257
|
-
],
|
|
258
248
|
'style/member-delimiter-style': [
|
|
259
249
|
'error',
|
|
260
250
|
{
|
|
@@ -307,19 +297,14 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
307
297
|
],
|
|
308
298
|
prev: '*',
|
|
309
299
|
},
|
|
310
|
-
{
|
|
311
|
-
blankLine: 'always',
|
|
312
|
-
next: '*',
|
|
313
|
-
prev: [
|
|
314
|
-
'class',
|
|
315
|
-
'function',
|
|
316
|
-
],
|
|
317
|
-
},
|
|
318
300
|
],
|
|
319
301
|
'style/semi': [
|
|
320
302
|
'error',
|
|
321
303
|
'always',
|
|
322
304
|
],
|
|
305
|
+
'unicorn/no-array-fill-with-reference-type': 'error',
|
|
306
|
+
'unicorn/no-await-in-promise-methods': 'error',
|
|
307
|
+
'unicorn/no-single-promise-in-promise-methods': 'error',
|
|
323
308
|
'unicorn/no-useless-promise-resolve-reject': 'error',
|
|
324
309
|
'unicorn/no-useless-spread': 'error',
|
|
325
310
|
'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,52 +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': 'error',
|
|
41
|
-
'jsdoc/no-types': 'error',
|
|
42
|
-
},
|
|
43
|
-
settings: {
|
|
44
|
-
jsdoc: {
|
|
45
|
-
mode: 'typescript',
|
|
46
|
-
tagNamePreference: {
|
|
47
|
-
...jsdocSettings.jsdoc.tagNamePreference,
|
|
48
|
-
callback: false,
|
|
49
|
-
class: false,
|
|
50
|
-
constructor: false,
|
|
51
|
-
default: 'defaultValue',
|
|
52
|
-
function: false,
|
|
53
|
-
method: false,
|
|
54
|
-
readonly: false,
|
|
55
|
-
static: false,
|
|
56
|
-
template: false,
|
|
57
|
-
type: false,
|
|
58
|
-
typedef: false,
|
|
59
|
-
typeParam: 'typeParam',
|
|
60
|
-
virtual: 'virtual',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
} 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
|
},
|