@cuiqg/eslint-config 2.5.0 → 2.5.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +21 -15
  2. package/dist/index.js +378 -293
  3. package/package.json +3 -5
package/dist/index.d.ts CHANGED
@@ -57,6 +57,18 @@ declare const defaultPluginRenaming: {
57
57
  };
58
58
  declare function cuiqg(options?: OptionsConfig & Omit<FlatConfigItem, 'files'>, ...userConfigs: Awaitable<FlatConfigItem | FlatConfigItem[]>[]): FlatConfigComposer<FlatConfigItem, string>;
59
59
  //#endregion
60
+ //#region src/configs/de-morgan.d.ts
61
+ declare function deMorgan(): Promise<FlatConfigItem[]>;
62
+ //#endregion
63
+ //#region src/configs/ignores.d.ts
64
+ declare function ignores(): Promise<FlatConfigItem[]>;
65
+ //#endregion
66
+ //#region src/configs/javascript.d.ts
67
+ declare function javascript(): Promise<FlatConfigItem[]>;
68
+ //#endregion
69
+ //#region src/configs/jsdoc.d.ts
70
+ declare function jsdoc(): Promise<FlatConfigItem[]>;
71
+ //#endregion
60
72
  //#region src/configs/nextjs.d.ts
61
73
  declare function nextjs(): Promise<FlatConfigItem[]>;
62
74
  //#endregion
@@ -66,27 +78,21 @@ declare function node(): Promise<FlatConfigItem[]>;
66
78
  //#region src/configs/package-json.d.ts
67
79
  declare function packageJson(): Promise<FlatConfigItem[]>;
68
80
  //#endregion
69
- //#region src/configs/vue.d.ts
70
- declare function vue(): Promise<FlatConfigItem[]>;
71
- //#endregion
72
- //#region src/configs/ignores.d.ts
73
- declare function ignores(): Promise<FlatConfigItem[]>;
74
- //#endregion
75
- //#region src/configs/unocss.d.ts
76
- declare function unocss(): Promise<FlatConfigItem[]>;
77
- //#endregion
78
- //#region src/configs/de-morgan.d.ts
79
- declare function deMorgan(): Promise<FlatConfigItem[]>;
81
+ //#region src/configs/perfectionist.d.ts
82
+ declare function perfectionist(): Promise<FlatConfigItem[]>;
80
83
  //#endregion
81
84
  //#region src/configs/prettier.d.ts
82
85
  declare function prettier(): Promise<FlatConfigItem[]>;
83
86
  //#endregion
84
- //#region src/configs/javascript.d.ts
85
- declare function javascript(): Promise<FlatConfigItem[]>;
86
- //#endregion
87
87
  //#region src/configs/typescript.d.ts
88
88
  declare function typescript(): Promise<FlatConfigItem[]>;
89
89
  //#endregion
90
+ //#region src/configs/unocss.d.ts
91
+ declare function unocss(): Promise<FlatConfigItem[]>;
92
+ //#endregion
93
+ //#region src/configs/vue.d.ts
94
+ declare function vue(): Promise<FlatConfigItem[]>;
95
+ //#endregion
90
96
  //#region src/env.d.ts
91
97
  declare const isInGitHookOrLintStaged: () => boolean;
92
98
  declare const isInEditor: () => boolean;
@@ -121,4 +127,4 @@ declare const GLOB_HTML = "**/*.htm?(l)";
121
127
  declare const GLOB_ALL_SRC: string[];
122
128
  declare const GLOB_EXCLUDE: string[];
123
129
  //#endregion
124
- export { Awaitable, FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, OptionsConfig, OptionsFiles, OptionsOverrides, cuiqg, deMorgan, cuiqg as default, defaultPluginRenaming, hasNextjs, hasTypeScript, hasUnoCss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, nextjs, node, packageJson, prettier, typescript, unocss, vue };
130
+ export { Awaitable, FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, OptionsConfig, OptionsFiles, OptionsOverrides, cuiqg, deMorgan, cuiqg as default, defaultPluginRenaming, hasNextjs, hasTypeScript, hasUnoCss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, nextjs, node, packageJson, perfectionist, prettier, typescript, unocss, vue };
package/dist/index.js CHANGED
@@ -1,26 +1,33 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
- import process$1 from "node:process";
3
- import { isPackageExists } from "local-pkg";
4
2
  import globals from "globals";
3
+ import process from "node:process";
4
+ import { isPackageExists } from "local-pkg";
5
5
 
6
- //#region src/env.ts
7
- const isInGitHookOrLintStaged = () => {
8
- return !!(process$1.env.GIT_PARAMS || process$1.env.VSCODE_GIT_COMMAND || process$1.env.npm_lifecycle_script?.startsWith("lint-staged"));
9
- };
10
- const isInEditor = () => {
11
- if (process$1.env.CI) return false;
12
- if (isInGitHookOrLintStaged()) return false;
13
- return !!(process$1.env.VSCODE_PID || process$1.env.VSCODE_CWD || process$1.env.JETBRAINS_IDE || process$1.env.VIM || process$1.env.NVIM);
14
- };
15
- const hasVue = () => [
16
- "vue",
17
- "nuxt",
18
- "vitepress",
19
- "@slidev/cli"
20
- ].some((i) => isPackageExists("vue"));
21
- const hasTypeScript = () => isPackageExists("typescript");
22
- const hasUnoCss = () => isPackageExists("unocss");
23
- const hasNextjs = () => isPackageExists("next");
6
+ //#region src/utils.ts
7
+ async function interopDefault(module) {
8
+ try {
9
+ let resolved = await module;
10
+ return resolved.default || resolved;
11
+ } catch (error) {
12
+ throw new Error(`Cannot import module: ${String(error)}`);
13
+ }
14
+ }
15
+ function renameRules(rules, map) {
16
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
17
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
18
+ return [key, value];
19
+ }));
20
+ }
21
+
22
+ //#endregion
23
+ //#region src/configs/de-morgan.ts
24
+ async function deMorgan() {
25
+ const pluginDeMorgan = await interopDefault(import("eslint-plugin-de-morgan"));
26
+ return [{
27
+ ...pluginDeMorgan.configs.recommended,
28
+ name: "cuiqg/de-morgan"
29
+ }];
30
+ }
24
31
 
25
32
  //#endregion
26
33
  //#region src/globs.ts
@@ -92,230 +99,6 @@ const GLOB_EXCLUDE = [
92
99
  "**/.eslint-config-inspector"
93
100
  ];
94
101
 
95
- //#endregion
96
- //#region src/utils.ts
97
- async function interopDefault(module) {
98
- try {
99
- let resolved = await module;
100
- return resolved.default || resolved;
101
- } catch (error) {
102
- throw new Error(`Cannot import module: ${String(error)}`);
103
- }
104
- }
105
- function renameRules(rules, map) {
106
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
107
- for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
108
- return [key, value];
109
- }));
110
- }
111
-
112
- //#endregion
113
- //#region src/configs/nextjs.ts
114
- function normalizeRules(rules) {
115
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => [key, typeof value === "string" ? [value] : value]));
116
- }
117
- async function nextjs() {
118
- const files = [GLOB_SRC];
119
- const pluginNextJS = await interopDefault(import("@next/eslint-plugin-next"));
120
- return [{
121
- name: "cuiqg/nextjs/setup",
122
- plugins: { next: pluginNextJS }
123
- }, {
124
- files,
125
- languageOptions: {
126
- parserOptions: { ecmaFeatures: { jsx: true } },
127
- sourceType: "module"
128
- },
129
- name: "cuiqg/nextjs/rules",
130
- rules: {
131
- ...normalizeRules(pluginNextJS.configs.recommended.rules),
132
- ...normalizeRules(pluginNextJS.configs["core-web-vitals"].rules)
133
- },
134
- settings: { react: { version: "detect" } }
135
- }];
136
- }
137
-
138
- //#endregion
139
- //#region src/configs/node.ts
140
- async function node() {
141
- const pluginNode = await interopDefault(import("eslint-plugin-n"));
142
- return [{
143
- name: "cuiqg/node/rules",
144
- plugins: { node: pluginNode },
145
- rules: { ...pluginNode.configs.recommended.rules }
146
- }];
147
- }
148
-
149
- //#endregion
150
- //#region src/configs/package-json.ts
151
- async function packageJson() {
152
- const [pluginPackageJson, parserJson] = await Promise.all([interopDefault(import("eslint-plugin-package-json")), interopDefault(import("jsonc-eslint-parser"))]);
153
- return [{
154
- files: ["**/package.json"],
155
- plugins: { "package-json": pluginPackageJson },
156
- name: "cuiqg/package-json/setup",
157
- languageOptions: { parser: parserJson }
158
- }, {
159
- name: "cuiqg/package-json/rules",
160
- rules: { ...pluginPackageJson.configs.recommended.rules }
161
- }];
162
- }
163
-
164
- //#endregion
165
- //#region src/configs/vue.ts
166
- async function vue() {
167
- const files = [GLOB_VUE];
168
- const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
169
- return [{
170
- languageOptions: { globals: {
171
- computed: "readonly",
172
- defineEmits: "readonly",
173
- defineExpose: "readonly",
174
- defineProps: "readonly",
175
- onMounted: "readonly",
176
- onUnmounted: "readonly",
177
- reactive: "readonly",
178
- ref: "readonly",
179
- shallowReactive: "readonly",
180
- shallowRef: "readonly",
181
- toRef: "readonly",
182
- toRefs: "readonly",
183
- watch: "readonly",
184
- watchEffect: "readonly"
185
- } },
186
- name: "cuiqg/vue/setup",
187
- plugins: { vue: pluginVue }
188
- }, {
189
- files,
190
- languageOptions: {
191
- parser: parserVue,
192
- parserOptions: {
193
- ecmaFeatures: { jsx: true },
194
- extraFileExtensions: [".vue"],
195
- parser: hasTypeScript() ? await interopDefault(import("@typescript-eslint/parser")) : null,
196
- sourceType: "module"
197
- }
198
- },
199
- name: "cuiqg/vue/rules",
200
- processor: pluginVue.processors[".vue"],
201
- rules: {
202
- ...pluginVue.configs.base.rules,
203
- ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
204
- ...acc,
205
- ...c
206
- }), {}),
207
- ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
208
- ...acc,
209
- ...c
210
- }), {}),
211
- ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
212
- ...acc,
213
- ...c
214
- }), {}),
215
- "node/prefer-global/process": "off",
216
- "ts/explicit-function-return-type": "off",
217
- "vue/block-order": ["error", { order: [
218
- "script",
219
- "template",
220
- "style"
221
- ] }],
222
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
223
- "vue/component-options-name-casing": ["error", "PascalCase"],
224
- "vue/component-tags-order": "off",
225
- "vue/custom-event-name-casing": ["error", "camelCase"],
226
- "vue/define-macros-order": ["error", { order: [
227
- "defineOptions",
228
- "defineProps",
229
- "defineEmits",
230
- "defineSlots"
231
- ] }],
232
- "vue/dot-location": ["error", "property"],
233
- "vue/dot-notation": ["error", { allowKeywords: true }],
234
- "vue/eqeqeq": ["error", "smart"],
235
- "vue/html-indent": ["error", 2],
236
- "vue/html-quotes": ["error", "double"],
237
- "vue/max-attributes-per-line": "off",
238
- "vue/multi-word-component-names": "off",
239
- "vue/no-dupe-keys": "off",
240
- "vue/no-empty-pattern": "error",
241
- "vue/no-irregular-whitespace": "error",
242
- "vue/no-loss-of-precision": "error",
243
- "vue/no-restricted-syntax": [
244
- "error",
245
- "DebuggerStatement",
246
- "LabeledStatement",
247
- "WithStatement"
248
- ],
249
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
250
- "vue/no-setup-props-reactivity-loss": "off",
251
- "vue/no-sparse-arrays": "error",
252
- "vue/no-unused-refs": "error",
253
- "vue/no-useless-v-bind": "error",
254
- "vue/no-v-html": "off",
255
- "vue/object-shorthand": [
256
- "error",
257
- "always",
258
- {
259
- avoidQuotes: true,
260
- ignoreConstructors: false
261
- }
262
- ],
263
- "vue/prefer-separate-static-class": "error",
264
- "vue/prefer-template": "error",
265
- "vue/prop-name-casing": ["error", "camelCase"],
266
- "vue/require-default-prop": "off",
267
- "vue/require-prop-types": "off",
268
- "vue/space-infix-ops": "error",
269
- "vue/space-unary-ops": ["error", {
270
- nonwords: false,
271
- words: true
272
- }],
273
- "vue/array-bracket-spacing": ["error", "never"],
274
- "vue/arrow-spacing": ["error", {
275
- after: true,
276
- before: true
277
- }],
278
- "vue/block-spacing": ["error", "always"],
279
- "vue/block-tag-newline": ["error", {
280
- multiline: "always",
281
- singleline: "always"
282
- }],
283
- "vue/brace-style": [
284
- "error",
285
- "stroustrup",
286
- { allowSingleLine: true }
287
- ],
288
- "vue/comma-dangle": ["error", "always-multiline"],
289
- "vue/comma-spacing": ["error", {
290
- after: true,
291
- before: false
292
- }],
293
- "vue/comma-style": ["error", "last"],
294
- "vue/html-comment-content-spacing": [
295
- "error",
296
- "always",
297
- { exceptions: ["-"] }
298
- ],
299
- "vue/key-spacing": ["error", {
300
- afterColon: true,
301
- beforeColon: false
302
- }],
303
- "vue/keyword-spacing": ["error", {
304
- after: true,
305
- before: true
306
- }],
307
- "vue/object-curly-newline": "off",
308
- "vue/object-curly-spacing": ["error", "always"],
309
- "vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
310
- "vue/operator-linebreak": ["error", "before"],
311
- "vue/padding-line-between-blocks": ["error", "always"],
312
- "vue/quote-props": ["error", "consistent-as-needed"],
313
- "vue/space-in-parens": ["error", "never"],
314
- "vue/template-curly-spacing": "error"
315
- }
316
- }];
317
- }
318
-
319
102
  //#endregion
320
103
  //#region src/configs/ignores.ts
321
104
  async function ignores() {
@@ -330,46 +113,31 @@ async function ignores() {
330
113
  }
331
114
 
332
115
  //#endregion
333
- //#region src/configs/unocss.ts
334
- async function unocss() {
335
- const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
336
- return [{
337
- name: "cuiqg/unocss",
338
- plugins: { unocss: pluginUnoCSS },
339
- rules: { ...renameRules(pluginUnoCSS.configs.recommended.rules, { "@unocss": "unocss" }) }
340
- }];
341
- }
342
-
343
- //#endregion
344
- //#region src/configs/de-morgan.ts
345
- async function deMorgan() {
346
- const pluginDeMorgan = await interopDefault(import("eslint-plugin-de-morgan"));
347
- return [{
348
- ...pluginDeMorgan.configs.recommended,
349
- name: "cuiqg/de-morgan"
350
- }];
351
- }
352
-
353
- //#endregion
354
- //#region src/configs/prettier.ts
355
- async function prettier() {
356
- const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
357
- return [{
358
- plugins: { prettier: pluginPrettier },
359
- name: "cuiqg/prettier",
360
- rules: {
361
- ...recommendedPrettier.rules,
362
- "prettier/prettier": "warn"
363
- }
364
- }];
365
- }
116
+ //#region src/env.ts
117
+ const isInGitHookOrLintStaged = () => {
118
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
119
+ };
120
+ const isInEditor = () => {
121
+ if (process.env.CI) return false;
122
+ if (isInGitHookOrLintStaged()) return false;
123
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
124
+ };
125
+ const hasVue = () => [
126
+ "vue",
127
+ "nuxt",
128
+ "vitepress",
129
+ "@slidev/cli"
130
+ ].some((i) => isPackageExists("vue"));
131
+ const hasTypeScript = () => isPackageExists("typescript");
132
+ const hasUnoCss = () => isPackageExists("unocss");
133
+ const hasNextjs = () => isPackageExists("next");
366
134
 
367
135
  //#endregion
368
136
  //#region src/configs/javascript.ts
369
137
  async function javascript() {
370
138
  const [pluginUnuseImports, pluginJs] = await Promise.all([interopDefault(import("eslint-plugin-unused-imports")), interopDefault(import("@eslint/js"))]);
371
139
  return [{
372
- name: "cuiqg/javascript/setup",
140
+ name: "cuiqg/javascript",
373
141
  languageOptions: {
374
142
  ecmaVersion: "latest",
375
143
  globals: {
@@ -384,13 +152,11 @@ async function javascript() {
384
152
  },
385
153
  sourceType: "module"
386
154
  },
387
- linterOptions: { reportUnusedDisableDirectives: true }
388
- }, {
155
+ linterOptions: { reportUnusedDisableDirectives: true },
389
156
  plugins: {
390
157
  "unused-imports": pluginUnuseImports,
391
158
  js: pluginJs
392
159
  },
393
- name: "cuiqg/javascript/rules",
394
160
  rules: {
395
161
  ...pluginJs.configs.recommended.rules,
396
162
  "accessor-pairs": ["error", {
@@ -585,6 +351,168 @@ async function javascript() {
585
351
  }];
586
352
  }
587
353
 
354
+ //#endregion
355
+ //#region src/configs/jsdoc.ts
356
+ async function jsdoc() {
357
+ const pluginJsdoc = await interopDefault(import("eslint-plugin-jsdoc"));
358
+ return [{
359
+ name: "cuiqg/jsdoc",
360
+ plugins: { jsdoc: pluginJsdoc },
361
+ rules: {
362
+ "jsdoc/check-access": "warn",
363
+ "jsdoc/check-param-names": "warn",
364
+ "jsdoc/check-property-names": "warn",
365
+ "jsdoc/check-types": "warn",
366
+ "jsdoc/empty-tags": "warn",
367
+ "jsdoc/implements-on-classes": "warn",
368
+ "jsdoc/no-defaults": "warn",
369
+ "jsdoc/no-multi-asterisks": "warn",
370
+ "jsdoc/require-param-name": "warn",
371
+ "jsdoc/require-property": "warn",
372
+ "jsdoc/require-property-description": "warn",
373
+ "jsdoc/require-property-name": "warn",
374
+ "jsdoc/require-returns-check": "warn",
375
+ "jsdoc/require-returns-description": "warn",
376
+ "jsdoc/require-yields-check": "warn"
377
+ }
378
+ }];
379
+ }
380
+
381
+ //#endregion
382
+ //#region src/configs/nextjs.ts
383
+ function normalizeRules(rules) {
384
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => [key, typeof value === "string" ? [value] : value]));
385
+ }
386
+ async function nextjs() {
387
+ const files = [GLOB_SRC];
388
+ const pluginNextJS = await interopDefault(import("@next/eslint-plugin-next"));
389
+ return [{
390
+ name: "cuiqg/nextjs",
391
+ files,
392
+ plugins: { next: pluginNextJS },
393
+ languageOptions: {
394
+ parserOptions: { ecmaFeatures: { jsx: true } },
395
+ sourceType: "module"
396
+ },
397
+ rules: {
398
+ ...normalizeRules(pluginNextJS.configs.recommended.rules),
399
+ ...normalizeRules(pluginNextJS.configs["core-web-vitals"].rules)
400
+ },
401
+ settings: { react: { version: "detect" } }
402
+ }];
403
+ }
404
+
405
+ //#endregion
406
+ //#region src/configs/node.ts
407
+ async function node() {
408
+ const pluginNode = await interopDefault(import("eslint-plugin-n"));
409
+ return [{
410
+ name: "cuiqg/node",
411
+ plugins: { node: pluginNode },
412
+ rules: {
413
+ "node/handle-callback-err": ["error", "^(err|error)$"],
414
+ "node/no-deprecated-api": "error",
415
+ "node/no-exports-assign": "error",
416
+ "node/no-new-require": "error",
417
+ "node/no-path-concat": "error",
418
+ "node/prefer-global/buffer": ["error", "never"],
419
+ "node/prefer-global/process": ["error", "never"],
420
+ "node/process-exit-as-throw": "error"
421
+ }
422
+ }];
423
+ }
424
+
425
+ //#endregion
426
+ //#region src/configs/package-json.ts
427
+ async function packageJson() {
428
+ const [pluginPackageJson, pluginDepend, parserJsonc] = await Promise.all([
429
+ interopDefault(import("eslint-plugin-package-json")),
430
+ interopDefault(import("eslint-plugin-depend")),
431
+ interopDefault(import("jsonc-eslint-parser"))
432
+ ]);
433
+ return [{
434
+ files: ["**/package.json"],
435
+ plugins: {
436
+ depend: pluginDepend,
437
+ "package-json": pluginPackageJson
438
+ },
439
+ languageOptions: { parser: parserJsonc },
440
+ name: "cuiqg/package-json",
441
+ rules: {
442
+ "depend/ban-dependencies": "error",
443
+ ...pluginPackageJson.configs.recommended.rules
444
+ },
445
+ settings: { packageJson: { enforceForPrivate: false } }
446
+ }];
447
+ }
448
+
449
+ //#endregion
450
+ //#region src/configs/perfectionist.ts
451
+ async function perfectionist() {
452
+ const pluginPerfectionist = await interopDefault(import("eslint-plugin-perfectionist"));
453
+ return [{
454
+ name: "cuiqg/perfectionist",
455
+ plugins: { perfectionist: pluginPerfectionist },
456
+ rules: {
457
+ "perfectionist/sort-exports": ["error", {
458
+ order: "asc",
459
+ type: "natural"
460
+ }],
461
+ "perfectionist/sort-imports": ["error", {
462
+ groups: [
463
+ "type",
464
+ [
465
+ "parent-type",
466
+ "sibling-type",
467
+ "index-type",
468
+ "internal-type"
469
+ ],
470
+ "builtin",
471
+ "external",
472
+ "internal",
473
+ [
474
+ "parent",
475
+ "sibling",
476
+ "index"
477
+ ],
478
+ "side-effect",
479
+ "object",
480
+ "unknown"
481
+ ],
482
+ newlinesBetween: "ignore",
483
+ order: "asc",
484
+ type: "natural"
485
+ }],
486
+ "perfectionist/sort-named-exports": ["error", {
487
+ order: "asc",
488
+ type: "natural"
489
+ }],
490
+ "perfectionist/sort-named-imports": ["error", {
491
+ order: "asc",
492
+ type: "natural"
493
+ }]
494
+ },
495
+ settings: { perfectionist: {
496
+ order: "desc",
497
+ type: "line-length"
498
+ } }
499
+ }];
500
+ }
501
+
502
+ //#endregion
503
+ //#region src/configs/prettier.ts
504
+ async function prettier() {
505
+ const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
506
+ return [{
507
+ plugins: { prettier: pluginPrettier },
508
+ name: "cuiqg/prettier",
509
+ rules: {
510
+ ...recommendedPrettier.rules,
511
+ "prettier/prettier": "warn"
512
+ }
513
+ }];
514
+ }
515
+
588
516
  //#endregion
589
517
  //#region src/configs/typescript.ts
590
518
  async function typescript() {
@@ -592,7 +520,7 @@ async function typescript() {
592
520
  const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
593
521
  return [{
594
522
  files,
595
- name: "cuiqg/typescript/setup",
523
+ name: "cuiqg/typescript",
596
524
  plugins: { ts: pluginTs },
597
525
  languageOptions: {
598
526
  parser: parserTs,
@@ -603,9 +531,7 @@ async function typescript() {
603
531
  sourceType: "module",
604
532
  tsconfigRootDir: process.cwd()
605
533
  }
606
- }
607
- }, {
608
- name: "cuiqg/typescript/rules",
534
+ },
609
535
  rules: {
610
536
  ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, { "@typescript-eslint": "ts" }),
611
537
  ...renameRules(pluginTs.configs.strict.rules, { "@typescript-eslint": "ts" }),
@@ -650,6 +576,170 @@ async function typescript() {
650
576
  }];
651
577
  }
652
578
 
579
+ //#endregion
580
+ //#region src/configs/unocss.ts
581
+ async function unocss() {
582
+ const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
583
+ return [{
584
+ name: "cuiqg/unocss",
585
+ plugins: { unocss: pluginUnoCSS },
586
+ rules: { ...renameRules(pluginUnoCSS.configs.recommended.rules, { "@unocss": "unocss" }) }
587
+ }];
588
+ }
589
+
590
+ //#endregion
591
+ //#region src/configs/vue.ts
592
+ async function vue() {
593
+ const files = [GLOB_VUE];
594
+ const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
595
+ return [{
596
+ languageOptions: {
597
+ globals: {
598
+ computed: "readonly",
599
+ defineEmits: "readonly",
600
+ defineExpose: "readonly",
601
+ defineProps: "readonly",
602
+ onMounted: "readonly",
603
+ onUnmounted: "readonly",
604
+ reactive: "readonly",
605
+ ref: "readonly",
606
+ shallowReactive: "readonly",
607
+ shallowRef: "readonly",
608
+ toRef: "readonly",
609
+ toRefs: "readonly",
610
+ watch: "readonly",
611
+ watchEffect: "readonly"
612
+ },
613
+ parser: parserVue,
614
+ parserOptions: {
615
+ ecmaFeatures: { jsx: true },
616
+ extraFileExtensions: [".vue"],
617
+ parser: hasTypeScript() ? await interopDefault(import("@typescript-eslint/parser")) : null,
618
+ sourceType: "module"
619
+ }
620
+ },
621
+ name: "cuiqg/vue",
622
+ plugins: { vue: pluginVue },
623
+ files,
624
+ processor: pluginVue.processors[".vue"],
625
+ rules: {
626
+ ...pluginVue.configs.base.rules,
627
+ ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
628
+ ...acc,
629
+ ...c
630
+ }), {}),
631
+ ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
632
+ ...acc,
633
+ ...c
634
+ }), {}),
635
+ ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
636
+ ...acc,
637
+ ...c
638
+ }), {}),
639
+ "node/prefer-global/process": "off",
640
+ "ts/explicit-function-return-type": "off",
641
+ "vue/block-order": ["error", { order: [
642
+ "script",
643
+ "template",
644
+ "style"
645
+ ] }],
646
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
647
+ "vue/component-options-name-casing": ["error", "PascalCase"],
648
+ "vue/component-tags-order": "off",
649
+ "vue/custom-event-name-casing": ["error", "camelCase"],
650
+ "vue/define-macros-order": ["error", { order: [
651
+ "defineOptions",
652
+ "defineProps",
653
+ "defineEmits",
654
+ "defineSlots"
655
+ ] }],
656
+ "vue/dot-location": ["error", "property"],
657
+ "vue/dot-notation": ["error", { allowKeywords: true }],
658
+ "vue/eqeqeq": ["error", "smart"],
659
+ "vue/html-indent": ["error", 2],
660
+ "vue/html-quotes": ["error", "double"],
661
+ "vue/max-attributes-per-line": "off",
662
+ "vue/multi-word-component-names": "off",
663
+ "vue/no-dupe-keys": "off",
664
+ "vue/no-empty-pattern": "error",
665
+ "vue/no-irregular-whitespace": "error",
666
+ "vue/no-loss-of-precision": "error",
667
+ "vue/no-restricted-syntax": [
668
+ "error",
669
+ "DebuggerStatement",
670
+ "LabeledStatement",
671
+ "WithStatement"
672
+ ],
673
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
674
+ "vue/no-setup-props-reactivity-loss": "off",
675
+ "vue/no-sparse-arrays": "error",
676
+ "vue/no-unused-refs": "error",
677
+ "vue/no-useless-v-bind": "error",
678
+ "vue/no-v-html": "off",
679
+ "vue/object-shorthand": [
680
+ "error",
681
+ "always",
682
+ {
683
+ avoidQuotes: true,
684
+ ignoreConstructors: false
685
+ }
686
+ ],
687
+ "vue/prefer-separate-static-class": "error",
688
+ "vue/prefer-template": "error",
689
+ "vue/prop-name-casing": ["error", "camelCase"],
690
+ "vue/require-default-prop": "off",
691
+ "vue/require-prop-types": "off",
692
+ "vue/space-infix-ops": "error",
693
+ "vue/space-unary-ops": ["error", {
694
+ nonwords: false,
695
+ words: true
696
+ }],
697
+ "vue/array-bracket-spacing": ["error", "never"],
698
+ "vue/arrow-spacing": ["error", {
699
+ after: true,
700
+ before: true
701
+ }],
702
+ "vue/block-spacing": ["error", "always"],
703
+ "vue/block-tag-newline": ["error", {
704
+ multiline: "always",
705
+ singleline: "always"
706
+ }],
707
+ "vue/brace-style": [
708
+ "error",
709
+ "stroustrup",
710
+ { allowSingleLine: true }
711
+ ],
712
+ "vue/comma-dangle": ["error", "always-multiline"],
713
+ "vue/comma-spacing": ["error", {
714
+ after: true,
715
+ before: false
716
+ }],
717
+ "vue/comma-style": ["error", "last"],
718
+ "vue/html-comment-content-spacing": [
719
+ "error",
720
+ "always",
721
+ { exceptions: ["-"] }
722
+ ],
723
+ "vue/key-spacing": ["error", {
724
+ afterColon: true,
725
+ beforeColon: false
726
+ }],
727
+ "vue/keyword-spacing": ["error", {
728
+ after: true,
729
+ before: true
730
+ }],
731
+ "vue/object-curly-newline": "off",
732
+ "vue/object-curly-spacing": ["error", "always"],
733
+ "vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
734
+ "vue/operator-linebreak": ["error", "before"],
735
+ "vue/padding-line-between-blocks": ["error", "always"],
736
+ "vue/quote-props": ["error", "consistent-as-needed"],
737
+ "vue/space-in-parens": ["error", "never"],
738
+ "vue/template-curly-spacing": "error"
739
+ }
740
+ }];
741
+ }
742
+
653
743
  //#endregion
654
744
  //#region src/presets.ts
655
745
  const defaultPluginRenaming = {
@@ -661,13 +751,8 @@ const defaultPluginRenaming = {
661
751
  };
662
752
  function cuiqg(options = {}, ...userConfigs) {
663
753
  const { prettier: enablePrettier = false, typescript: enableTypeScript = hasTypeScript(), vue: enableVue = hasVue(), unocss: enableUnocss = hasUnoCss(), nextjs: enableNextjs = hasNextjs() } = options;
664
- const configs = [
665
- packageJson(),
666
- ignores(),
667
- node(),
668
- deMorgan(),
669
- javascript()
670
- ];
754
+ const configs = [];
755
+ configs.push(packageJson(), ignores(), node(), deMorgan(), javascript(), jsdoc(), perfectionist());
671
756
  if (enableTypeScript) configs.push(typescript());
672
757
  if (enableVue) configs.push(vue());
673
758
  if (enableUnocss) configs.push(unocss());
@@ -688,4 +773,4 @@ function cuiqg(options = {}, ...userConfigs) {
688
773
  var src_default = cuiqg;
689
774
 
690
775
  //#endregion
691
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, cuiqg, deMorgan, src_default as default, defaultPluginRenaming, hasNextjs, hasTypeScript, hasUnoCss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, nextjs, node, packageJson, prettier, typescript, unocss, vue };
776
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, cuiqg, deMorgan, src_default as default, defaultPluginRenaming, hasNextjs, hasTypeScript, hasUnoCss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, nextjs, node, packageJson, perfectionist, prettier, typescript, unocss, vue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuiqg/eslint-config",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "Eslint config for @cuiqg",
5
5
  "keywords": [
6
6
  "eslint-config"
@@ -40,18 +40,16 @@
40
40
  "eslint-config-flat-gitignore": "^2.1.0",
41
41
  "eslint-config-prettier": "^10.1.8",
42
42
  "eslint-flat-config-utils": "^2.1.1",
43
- "eslint-merge-processors": "^2.0.0",
44
43
  "eslint-plugin-de-morgan": "^1.3.1",
45
44
  "eslint-plugin-depend": "^1.2.0",
46
45
  "eslint-plugin-import-x": "^4.16.1",
47
46
  "eslint-plugin-jsdoc": "^52.0.4",
48
47
  "eslint-plugin-n": "^17.21.3",
49
48
  "eslint-plugin-package-json": "^0.52.1",
49
+ "eslint-plugin-perfectionist": "^4.15.0",
50
50
  "eslint-plugin-prettier": "^5.5.4",
51
51
  "eslint-plugin-unused-imports": "^4.1.4",
52
52
  "eslint-plugin-vue": "^10.4.0",
53
- "eslint-plugin-vuejs-accessibility": "^2.4.1",
54
- "eslint-processor-vue-blocks": "^2.0.0",
55
53
  "globals": "^16.3.0",
56
54
  "jsonc-eslint-parser": "^2.4.0",
57
55
  "local-pkg": "^1.1.1",
@@ -69,7 +67,7 @@
69
67
  "scripts": {
70
68
  "build": "tsdown",
71
69
  "dev": "tsdown --watch",
72
- "build:inspect": "pnpm build && eslint-config-inspector build --config eslint-inspector.config.ts",
70
+ "build:inspect": "eslint-config-inspector build --config eslint-inspector.config.ts",
73
71
  "lint": "eslint .",
74
72
  "lint:inspect": "eslint-config-inspector --open false --config eslint-inspector.config.ts",
75
73
  "release": "bumpp && pnpm publish",