@kikiutils/eslint-config 9.3.2 → 10.1.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/src/base.ts CHANGED
@@ -2,10 +2,22 @@ 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
 
15
+ import {
16
+ jsdocSettings,
17
+ typescriptJsdocConfig,
18
+ } from './_internals/jsdoc';
8
19
  import { customPlugins } from './_internals/plugins';
20
+ import { createTypeAwareConfig } from './_internals/type-aware';
9
21
 
10
22
  // Constants/Variables
11
23
  const basePerfectionistSortOptions = {
@@ -13,6 +25,18 @@ const basePerfectionistSortOptions = {
13
25
  type: 'natural',
14
26
  } as const;
15
27
 
28
+ const vscodeOrderSensitiveArrayProperties = [
29
+ 'args',
30
+ 'autoAttachSmartPattern',
31
+ 'dependsOn',
32
+ 'options',
33
+ 'outFiles',
34
+ 'problemMatcher',
35
+ 'resolveSourceMapLocations',
36
+ 'runtimeArgs',
37
+ 'skipFiles',
38
+ ].join('|');
39
+
16
40
  // Functions
17
41
  export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem[] {
18
42
  return [
@@ -21,19 +45,19 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
21
45
  rules: {
22
46
  'e18e/ban-dependencies': [
23
47
  'error',
24
- {
25
- allowed: [
26
- 'axios',
27
- 'rimraf',
28
- ],
29
- },
48
+ { allowed: ['axios'] },
30
49
  ],
31
- 'e18e/prefer-static-regex': ['off'],
50
+ 'e18e/prefer-static-regex': 'off',
32
51
  },
33
52
  },
34
- // JavaScript
53
+ // JavaScript and TypeScript
35
54
  {
36
- files: ['**/*.{cjs,js,mjs}'],
55
+ files: [
56
+ GLOB_JS,
57
+ GLOB_JSX,
58
+ GLOB_TS,
59
+ GLOB_TSX,
60
+ ],
37
61
  plugins: {
38
62
  kikiutils: customPlugins,
39
63
  promise,
@@ -45,19 +69,19 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
45
69
  'always',
46
70
  ],
47
71
  },
72
+ settings: jsdocSettings,
48
73
  },
49
74
  // TypeScript
50
75
  {
51
- files: ['**/*.{ts,tsx}'],
52
- plugins: {
53
- kikiutils: customPlugins,
54
- promise,
55
- },
76
+ files: [
77
+ GLOB_TS,
78
+ GLOB_TSX,
79
+ ],
56
80
  rules: {
57
- ...createBaseRules(environment),
58
- 'node/prefer-global/process': [
81
+ ...typescriptJsdocConfig.rules,
82
+ 'ts/array-type': [
59
83
  'error',
60
- 'always',
84
+ { default: 'array-simple' },
61
85
  ],
62
86
  'ts/consistent-generic-constructors': [
63
87
  'error',
@@ -65,8 +89,67 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
65
89
  ],
66
90
  'ts/no-redeclare': 'off',
67
91
  },
92
+ settings: typescriptJsdocConfig.settings,
93
+ },
94
+ // Type-aware TypeScript
95
+ {
96
+ ...createTypeAwareConfig(),
97
+ files: [
98
+ GLOB_TS,
99
+ GLOB_TSX,
100
+ ],
101
+ ignores: ['**/*.config.?([cm])ts'],
102
+ },
103
+ // Tests
104
+ {
105
+ files: GLOB_TESTS,
106
+ rules: {
107
+ 'kikiutils/consistent-parameter-layout': [
108
+ 'error',
109
+ { compactTestCalls: true },
110
+ ],
111
+ 'no-restricted-imports': [
112
+ 'error',
113
+ {
114
+ paths: [
115
+ {
116
+ importNames: ['expect'],
117
+ message: 'Use `expect` from the test context.',
118
+ name: 'vitest',
119
+ },
120
+ ],
121
+ },
122
+ ],
123
+ 'test/consistent-each-for': [
124
+ 'error',
125
+ {
126
+ it: 'for',
127
+ test: 'for',
128
+ },
129
+ ],
130
+ 'test/prefer-each': 'error',
131
+ 'test/prefer-hooks-on-top': 'error',
132
+ 'test/prefer-lowercase-title': [
133
+ 'error',
134
+ {
135
+ ignoreTopLevelDescribe: true,
136
+ lowercaseFirstCharacterOnly: true,
137
+ },
138
+ ],
139
+ 'test/prefer-to-be': 'error',
140
+ 'test/valid-describe-callback': 'error',
141
+ 'test/valid-expect': 'error',
142
+ 'test/valid-expect-in-promise': 'error',
143
+ 'test/valid-title': [
144
+ 'error',
145
+ {
146
+ mustMatch: { it: '^should ' },
147
+ mustNotMatch: { it: String.raw`\.$` },
148
+ },
149
+ ],
150
+ },
68
151
  },
69
- // VsCode jsonc
152
+ // VS Code JSONC
70
153
  {
71
154
  files: ['**/.vscode/*.json'],
72
155
  rules: {
@@ -77,7 +160,8 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
77
160
  natural: true,
78
161
  type: 'asc',
79
162
  },
80
- pathPattern: '^.*$',
163
+ // Preserve ordered fields and any argument or option arrays nested inside them.
164
+ pathPattern: String.raw`^(?!.*(?:^|\.|\[")(?:${vscodeOrderSensitiveArrayProperties})(?:$|\.|\[|"\])).*`,
81
165
  },
82
166
  ],
83
167
  'jsonc/sort-keys': [
@@ -90,6 +174,8 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
90
174
  ],
91
175
  },
92
176
  },
177
+ // Ignore all extracted Markdown code blocks, but keep linting Markdown itself.
178
+ { ignores: ['**/*.md/**'] },
93
179
  ];
94
180
  }
95
181
 
@@ -114,6 +200,27 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
114
200
  'error',
115
201
  'multi-line',
116
202
  ],
203
+ 'jsdoc/check-tag-names': 'error',
204
+ 'jsdoc/multiline-blocks': [
205
+ 'error',
206
+ {
207
+ noSingleLineBlocks: true,
208
+ singleLineTags: [
209
+ 'type',
210
+ 'import',
211
+ ],
212
+ },
213
+ ],
214
+ 'jsdoc/no-blank-blocks': [
215
+ 'error',
216
+ { enableFixer: true },
217
+ ],
218
+ 'jsdoc/require-asterisk-prefix': 'error',
219
+ 'jsdoc/require-hyphen-before-param-description': [
220
+ 'error',
221
+ 'always',
222
+ { tags: { typeParam: 'always' } },
223
+ ],
117
224
  'kikiutils/compact-iteration-layout': 'error',
118
225
  'kikiutils/consistent-condition-layout': 'error',
119
226
  'kikiutils/consistent-parameter-layout': 'error',
@@ -122,10 +229,12 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
122
229
  'error',
123
230
  1,
124
231
  ],
232
+ 'no-constant-binary-expression': 'error',
125
233
  'no-promise-executor-return': [
126
234
  'error',
127
235
  { allowVoid: true },
128
236
  ],
237
+ 'no-useless-assignment': 'error',
129
238
  'perfectionist/sort-array-includes': [
130
239
  'error',
131
240
  basePerfectionistSortOptions,
@@ -139,10 +248,7 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
139
248
  ],
140
249
  'perfectionist/sort-heritage-clauses': [
141
250
  'error',
142
- {
143
- ignoreCase: false,
144
- type: 'natural',
145
- },
251
+ basePerfectionistSortOptions,
146
252
  ],
147
253
  'perfectionist/sort-imports': [
148
254
  'error',
@@ -259,6 +365,7 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
259
365
  'error',
260
366
  basePerfectionistSortOptions,
261
367
  ],
368
+ 'preserve-caught-error': 'error',
262
369
  'promise/no-multiple-resolved': 'error',
263
370
  'promise/no-return-in-finally': 'error',
264
371
  'promise/no-return-wrap': 'error',
@@ -299,6 +406,8 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
299
406
  {
300
407
  code: 120,
301
408
  comments: 120,
409
+ ignoreStrings: true,
410
+ ignoreTemplateLiterals: true,
302
411
  },
303
412
  ],
304
413
  'style/member-delimiter-style': [
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' | 'sass' | 'scss'): TypedFlatConfigItem {
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,29 @@
1
1
  import type { TypedFlatConfigItem } from '@antfu/eslint-config';
2
2
  import kikiutilsEslintPluginVue from '@kikiutils/eslint-plugin-vue';
3
- import betteTailwindcss from 'eslint-plugin-better-tailwindcss';
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
+ import { typescriptJsdocConfig } from './_internals/jsdoc';
7
8
  import { customPlugins } from './_internals/plugins';
9
+ import { createTypeAwareConfig } from './_internals/type-aware';
8
10
  import { createBaseRules } from './base';
9
11
 
10
12
  export function createVueConfig(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem {
13
+ const typeAwareConfig = createTypeAwareConfig();
11
14
  return {
12
15
  files: ['**/*.vue'],
16
+ languageOptions: typeAwareConfig.languageOptions,
13
17
  plugins: {
14
18
  '@kikiutils/vue': kikiutilsEslintPluginVue,
15
- 'better-tailwindcss': betteTailwindcss,
19
+ 'better-tailwindcss': betterTailwindcss,
16
20
  'kikiutils': customPlugins,
17
21
  promise,
18
22
  },
19
23
  rules: {
20
24
  ...createBaseRules(environment),
25
+ ...typescriptJsdocConfig.rules,
26
+ ...typeAwareConfig.rules,
21
27
  '@kikiutils/vue/attributes-order': [
22
28
  'error',
23
29
  {
@@ -35,6 +41,10 @@ export function createVueConfig(environment: 'bun' | 'node' = 'node'): TypedFlat
35
41
  'better-tailwindcss/no-duplicate-classes': 'error',
36
42
  'better-tailwindcss/no-unnecessary-whitespace': 'error',
37
43
  'style/max-len': 'off',
44
+ 'ts/array-type': [
45
+ 'error',
46
+ { default: 'array-simple' },
47
+ ],
38
48
  'vue/attribute-hyphenation': 'error',
39
49
  'vue/attributes-order': 'off',
40
50
  'vue/block-order': [
@@ -69,6 +79,8 @@ export function createVueConfig(environment: 'bun' | 'node' = 'node'): TypedFlat
69
79
  {
70
80
  code: 120,
71
81
  comments: 120,
82
+ ignoreStrings: true,
83
+ ignoreTemplateLiterals: true,
72
84
  template: 120,
73
85
  },
74
86
  ],
@@ -80,9 +92,9 @@ export function createVueConfig(environment: 'bun' | 'node' = 'node'): TypedFlat
80
92
  'vue/no-template-target-blank': 'error',
81
93
  'vue/no-v-html': 'error',
82
94
  'vue/prefer-define-options': 'error',
83
- 'vue/prefer-separate-static-class': 'error',
84
95
  'vue/require-explicit-emits': 'error',
85
96
  'vue/require-typed-ref': 'error',
86
97
  },
98
+ settings: typescriptJsdocConfig.settings,
87
99
  };
88
100
  }