@kikiutils/eslint-config 9.3.2 → 10.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 +8 -0
- package/dist/_internals/rules/consistent-parameter-layout.d.ts.map +1 -1
- package/dist/_internals/rules/consistent-parameter-layout.js +102 -55
- package/dist/_internals/rules/consistent-parameter-layout.js.map +1 -1
- package/dist/_internals/rules/statement-padding.js +21 -11
- package/dist/_internals/rules/statement-padding.js.map +1 -1
- package/dist/_internals/type-aware.d.ts +3 -0
- package/dist/_internals/type-aware.d.ts.map +1 -0
- package/dist/_internals/type-aware.js +25 -0
- package/dist/_internals/type-aware.js.map +1 -0
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +43 -16
- package/dist/base.js.map +1 -1
- package/dist/style.js +1 -5
- package/dist/style.js.map +1 -1
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +7 -3
- package/dist/vue.js.map +1 -1
- package/package.json +11 -38
- package/src/_internals/rules/consistent-parameter-layout.ts +179 -98
- package/src/_internals/rules/statement-padding.ts +33 -22
- package/src/_internals/type-aware.ts +28 -0
- package/src/base.ts +66 -23
- package/src/style.ts +1 -2
- package/src/vue.ts +10 -3
package/src/base.ts
CHANGED
|
@@ -2,10 +2,18 @@ import type {
|
|
|
2
2
|
Rules,
|
|
3
3
|
TypedFlatConfigItem,
|
|
4
4
|
} from '@antfu/eslint-config';
|
|
5
|
+
import {
|
|
6
|
+
GLOB_JS,
|
|
7
|
+
GLOB_JSX,
|
|
8
|
+
GLOB_TESTS,
|
|
9
|
+
GLOB_TS,
|
|
10
|
+
GLOB_TSX,
|
|
11
|
+
} from '@antfu/eslint-config';
|
|
5
12
|
// @ts-expect-error No declare file.
|
|
6
13
|
import promise from 'eslint-plugin-promise';
|
|
7
14
|
|
|
8
15
|
import { customPlugins } from './_internals/plugins';
|
|
16
|
+
import { createTypeAwareConfig } from './_internals/type-aware';
|
|
9
17
|
|
|
10
18
|
// Constants/Variables
|
|
11
19
|
const basePerfectionistSortOptions = {
|
|
@@ -13,6 +21,18 @@ const basePerfectionistSortOptions = {
|
|
|
13
21
|
type: 'natural',
|
|
14
22
|
} as const;
|
|
15
23
|
|
|
24
|
+
const vscodeOrderSensitiveArrayProperties = [
|
|
25
|
+
'args',
|
|
26
|
+
'autoAttachSmartPattern',
|
|
27
|
+
'dependsOn',
|
|
28
|
+
'options',
|
|
29
|
+
'outFiles',
|
|
30
|
+
'problemMatcher',
|
|
31
|
+
'resolveSourceMapLocations',
|
|
32
|
+
'runtimeArgs',
|
|
33
|
+
'skipFiles',
|
|
34
|
+
].join('|');
|
|
35
|
+
|
|
16
36
|
// Functions
|
|
17
37
|
export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem[] {
|
|
18
38
|
return [
|
|
@@ -21,19 +41,19 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
|
|
|
21
41
|
rules: {
|
|
22
42
|
'e18e/ban-dependencies': [
|
|
23
43
|
'error',
|
|
24
|
-
{
|
|
25
|
-
allowed: [
|
|
26
|
-
'axios',
|
|
27
|
-
'rimraf',
|
|
28
|
-
],
|
|
29
|
-
},
|
|
44
|
+
{ allowed: ['axios'] },
|
|
30
45
|
],
|
|
31
|
-
'e18e/prefer-static-regex':
|
|
46
|
+
'e18e/prefer-static-regex': 'off',
|
|
32
47
|
},
|
|
33
48
|
},
|
|
34
|
-
// JavaScript
|
|
49
|
+
// JavaScript and TypeScript
|
|
35
50
|
{
|
|
36
|
-
files: [
|
|
51
|
+
files: [
|
|
52
|
+
GLOB_JS,
|
|
53
|
+
GLOB_JSX,
|
|
54
|
+
GLOB_TS,
|
|
55
|
+
GLOB_TSX,
|
|
56
|
+
],
|
|
37
57
|
plugins: {
|
|
38
58
|
kikiutils: customPlugins,
|
|
39
59
|
promise,
|
|
@@ -48,16 +68,14 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
|
|
|
48
68
|
},
|
|
49
69
|
// TypeScript
|
|
50
70
|
{
|
|
51
|
-
files: [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
71
|
+
files: [
|
|
72
|
+
GLOB_TS,
|
|
73
|
+
GLOB_TSX,
|
|
74
|
+
],
|
|
56
75
|
rules: {
|
|
57
|
-
|
|
58
|
-
'node/prefer-global/process': [
|
|
76
|
+
'ts/array-type': [
|
|
59
77
|
'error',
|
|
60
|
-
'
|
|
78
|
+
{ default: 'array-simple' },
|
|
61
79
|
],
|
|
62
80
|
'ts/consistent-generic-constructors': [
|
|
63
81
|
'error',
|
|
@@ -66,7 +84,28 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
|
|
|
66
84
|
'ts/no-redeclare': 'off',
|
|
67
85
|
},
|
|
68
86
|
},
|
|
69
|
-
//
|
|
87
|
+
// Type-aware TypeScript
|
|
88
|
+
{
|
|
89
|
+
...createTypeAwareConfig(),
|
|
90
|
+
files: [
|
|
91
|
+
GLOB_TS,
|
|
92
|
+
GLOB_TSX,
|
|
93
|
+
],
|
|
94
|
+
ignores: ['**/*.config.?([cm])ts'],
|
|
95
|
+
},
|
|
96
|
+
// Tests
|
|
97
|
+
{
|
|
98
|
+
files: GLOB_TESTS,
|
|
99
|
+
rules: {
|
|
100
|
+
'kikiutils/consistent-parameter-layout': [
|
|
101
|
+
'error',
|
|
102
|
+
{ compactTestCalls: true },
|
|
103
|
+
],
|
|
104
|
+
'test/valid-expect': 'error',
|
|
105
|
+
'test/valid-expect-in-promise': 'error',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
// VS Code JSONC
|
|
70
109
|
{
|
|
71
110
|
files: ['**/.vscode/*.json'],
|
|
72
111
|
rules: {
|
|
@@ -77,7 +116,9 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
|
|
|
77
116
|
natural: true,
|
|
78
117
|
type: 'asc',
|
|
79
118
|
},
|
|
80
|
-
|
|
119
|
+
// Preserve ordered fields and any argument or option arrays nested inside them.
|
|
120
|
+
// eslint-disable-next-line style/max-len
|
|
121
|
+
pathPattern: String.raw`^(?!.*(?:^|\.|\[")(?:${vscodeOrderSensitiveArrayProperties})(?:$|\.|\[|"\])).*`,
|
|
81
122
|
},
|
|
82
123
|
],
|
|
83
124
|
'jsonc/sort-keys': [
|
|
@@ -90,6 +131,8 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
|
|
|
90
131
|
],
|
|
91
132
|
},
|
|
92
133
|
},
|
|
134
|
+
// Ignore all extracted Markdown code blocks, but keep linting Markdown itself.
|
|
135
|
+
{ ignores: ['**/*.md/**'] },
|
|
93
136
|
];
|
|
94
137
|
}
|
|
95
138
|
|
|
@@ -122,10 +165,12 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
122
165
|
'error',
|
|
123
166
|
1,
|
|
124
167
|
],
|
|
168
|
+
'no-constant-binary-expression': 'error',
|
|
125
169
|
'no-promise-executor-return': [
|
|
126
170
|
'error',
|
|
127
171
|
{ allowVoid: true },
|
|
128
172
|
],
|
|
173
|
+
'no-useless-assignment': 'error',
|
|
129
174
|
'perfectionist/sort-array-includes': [
|
|
130
175
|
'error',
|
|
131
176
|
basePerfectionistSortOptions,
|
|
@@ -139,10 +184,7 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
139
184
|
],
|
|
140
185
|
'perfectionist/sort-heritage-clauses': [
|
|
141
186
|
'error',
|
|
142
|
-
|
|
143
|
-
ignoreCase: false,
|
|
144
|
-
type: 'natural',
|
|
145
|
-
},
|
|
187
|
+
basePerfectionistSortOptions,
|
|
146
188
|
],
|
|
147
189
|
'perfectionist/sort-imports': [
|
|
148
190
|
'error',
|
|
@@ -259,6 +301,7 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
259
301
|
'error',
|
|
260
302
|
basePerfectionistSortOptions,
|
|
261
303
|
],
|
|
304
|
+
'preserve-caught-error': 'error',
|
|
262
305
|
'promise/no-multiple-resolved': 'error',
|
|
263
306
|
'promise/no-return-in-finally': 'error',
|
|
264
307
|
'promise/no-return-wrap': 'error',
|
package/src/style.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
2
|
import format from 'eslint-plugin-format';
|
|
3
3
|
|
|
4
|
-
function createPrettierCssConfig(parser: 'css' | '
|
|
4
|
+
function createPrettierCssConfig(parser: 'css' | 'scss'): TypedFlatConfigItem {
|
|
5
5
|
return {
|
|
6
6
|
files: [`**/*.${parser}`],
|
|
7
7
|
languageOptions: { parser: format.parserPlain },
|
|
@@ -23,7 +23,6 @@ function createPrettierCssConfig(parser: 'css' | 'sass' | 'scss'): TypedFlatConf
|
|
|
23
23
|
export function createStyleFilesConfigs(): TypedFlatConfigItem[] {
|
|
24
24
|
return [
|
|
25
25
|
createPrettierCssConfig('css'),
|
|
26
|
-
createPrettierCssConfig('sass'),
|
|
27
26
|
createPrettierCssConfig('scss'),
|
|
28
27
|
];
|
|
29
28
|
}
|
package/src/vue.ts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
2
|
import kikiutilsEslintPluginVue from '@kikiutils/eslint-plugin-vue';
|
|
3
|
-
import
|
|
3
|
+
import betterTailwindcss from 'eslint-plugin-better-tailwindcss';
|
|
4
4
|
// @ts-expect-error No declare file.
|
|
5
5
|
import promise from 'eslint-plugin-promise';
|
|
6
6
|
|
|
7
7
|
import { customPlugins } from './_internals/plugins';
|
|
8
|
+
import { createTypeAwareConfig } from './_internals/type-aware';
|
|
8
9
|
import { createBaseRules } from './base';
|
|
9
10
|
|
|
10
11
|
export function createVueConfig(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem {
|
|
12
|
+
const typeAwareConfig = createTypeAwareConfig();
|
|
11
13
|
return {
|
|
12
14
|
files: ['**/*.vue'],
|
|
15
|
+
languageOptions: typeAwareConfig.languageOptions,
|
|
13
16
|
plugins: {
|
|
14
17
|
'@kikiutils/vue': kikiutilsEslintPluginVue,
|
|
15
|
-
'better-tailwindcss':
|
|
18
|
+
'better-tailwindcss': betterTailwindcss,
|
|
16
19
|
'kikiutils': customPlugins,
|
|
17
20
|
promise,
|
|
18
21
|
},
|
|
19
22
|
rules: {
|
|
20
23
|
...createBaseRules(environment),
|
|
24
|
+
...typeAwareConfig.rules,
|
|
21
25
|
'@kikiutils/vue/attributes-order': [
|
|
22
26
|
'error',
|
|
23
27
|
{
|
|
@@ -35,6 +39,10 @@ export function createVueConfig(environment: 'bun' | 'node' = 'node'): TypedFlat
|
|
|
35
39
|
'better-tailwindcss/no-duplicate-classes': 'error',
|
|
36
40
|
'better-tailwindcss/no-unnecessary-whitespace': 'error',
|
|
37
41
|
'style/max-len': 'off',
|
|
42
|
+
'ts/array-type': [
|
|
43
|
+
'error',
|
|
44
|
+
{ default: 'array-simple' },
|
|
45
|
+
],
|
|
38
46
|
'vue/attribute-hyphenation': 'error',
|
|
39
47
|
'vue/attributes-order': 'off',
|
|
40
48
|
'vue/block-order': [
|
|
@@ -80,7 +88,6 @@ export function createVueConfig(environment: 'bun' | 'node' = 'node'): TypedFlat
|
|
|
80
88
|
'vue/no-template-target-blank': 'error',
|
|
81
89
|
'vue/no-v-html': 'error',
|
|
82
90
|
'vue/prefer-define-options': 'error',
|
|
83
|
-
'vue/prefer-separate-static-class': 'error',
|
|
84
91
|
'vue/require-explicit-emits': 'error',
|
|
85
92
|
'vue/require-typed-ref': 'error',
|
|
86
93
|
},
|