@cuiqg/eslint-config 2.4.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 +380 -294
  3. package/package.json +4 -12
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
@@ -88,233 +95,10 @@ const GLOB_EXCLUDE = [
88
95
  "**/LICENSE*",
89
96
  "**/__snapshots__",
90
97
  "**/auto-import?(s).d.ts",
91
- "**/components.d.ts"
98
+ "**/components.d.ts",
99
+ "**/.eslint-config-inspector"
92
100
  ];
93
101
 
94
- //#endregion
95
- //#region src/utils.ts
96
- async function interopDefault(module) {
97
- try {
98
- let resolved = await module;
99
- return resolved.default || resolved;
100
- } catch (error) {
101
- throw new Error(`Cannot import module: ${String(error)}`);
102
- }
103
- }
104
- function renameRules(rules, map) {
105
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
106
- for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
107
- return [key, value];
108
- }));
109
- }
110
-
111
- //#endregion
112
- //#region src/configs/nextjs.ts
113
- function normalizeRules(rules) {
114
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => [key, typeof value === "string" ? [value] : value]));
115
- }
116
- async function nextjs() {
117
- const files = [GLOB_SRC];
118
- const pluginNextJS = await interopDefault(import("@next/eslint-plugin-next"));
119
- return [{
120
- name: "cuiqg/nextjs/setup",
121
- plugins: { next: pluginNextJS }
122
- }, {
123
- files,
124
- languageOptions: {
125
- parserOptions: { ecmaFeatures: { jsx: true } },
126
- sourceType: "module"
127
- },
128
- name: "cuiqg/nextjs/rules",
129
- rules: {
130
- ...normalizeRules(pluginNextJS.configs.recommended.rules),
131
- ...normalizeRules(pluginNextJS.configs["core-web-vitals"].rules)
132
- },
133
- settings: { react: { version: "detect" } }
134
- }];
135
- }
136
-
137
- //#endregion
138
- //#region src/configs/node.ts
139
- async function node() {
140
- const pluginNode = await interopDefault(import("eslint-plugin-n"));
141
- return [{
142
- name: "cuiqg/node/rules",
143
- plugins: { node: pluginNode },
144
- rules: { ...pluginNode.configs.recommended.rules }
145
- }];
146
- }
147
-
148
- //#endregion
149
- //#region src/configs/package-json.ts
150
- async function packageJson() {
151
- const [pluginPackageJson, parserJson] = await Promise.all([interopDefault(import("eslint-plugin-package-json")), interopDefault(import("jsonc-eslint-parser"))]);
152
- return [{
153
- files: ["**/package.json"],
154
- plugins: { "package-json": pluginPackageJson },
155
- name: "cuiqg/package-json/setup",
156
- languageOptions: { parser: parserJson }
157
- }, {
158
- name: "cuiqg/package-json/rules",
159
- rules: { ...pluginPackageJson.configs.recommended.rules }
160
- }];
161
- }
162
-
163
- //#endregion
164
- //#region src/configs/vue.ts
165
- async function vue() {
166
- const files = [GLOB_VUE];
167
- const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
168
- return [{
169
- languageOptions: { globals: {
170
- computed: "readonly",
171
- defineEmits: "readonly",
172
- defineExpose: "readonly",
173
- defineProps: "readonly",
174
- onMounted: "readonly",
175
- onUnmounted: "readonly",
176
- reactive: "readonly",
177
- ref: "readonly",
178
- shallowReactive: "readonly",
179
- shallowRef: "readonly",
180
- toRef: "readonly",
181
- toRefs: "readonly",
182
- watch: "readonly",
183
- watchEffect: "readonly"
184
- } },
185
- name: "cuiqg/vue/setup",
186
- plugins: { vue: pluginVue }
187
- }, {
188
- files,
189
- languageOptions: {
190
- parser: parserVue,
191
- parserOptions: {
192
- ecmaFeatures: { jsx: true },
193
- extraFileExtensions: [".vue"],
194
- parser: hasTypeScript() ? await interopDefault(import("@typescript-eslint/parser")) : null,
195
- sourceType: "module"
196
- }
197
- },
198
- name: "cuiqg/vue/rules",
199
- processor: pluginVue.processors[".vue"],
200
- rules: {
201
- ...pluginVue.configs.base.rules,
202
- ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
203
- ...acc,
204
- ...c
205
- }), {}),
206
- ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
207
- ...acc,
208
- ...c
209
- }), {}),
210
- ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
211
- ...acc,
212
- ...c
213
- }), {}),
214
- "node/prefer-global/process": "off",
215
- "ts/explicit-function-return-type": "off",
216
- "vue/block-order": ["error", { order: [
217
- "script",
218
- "template",
219
- "style"
220
- ] }],
221
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
222
- "vue/component-options-name-casing": ["error", "PascalCase"],
223
- "vue/component-tags-order": "off",
224
- "vue/custom-event-name-casing": ["error", "camelCase"],
225
- "vue/define-macros-order": ["error", { order: [
226
- "defineOptions",
227
- "defineProps",
228
- "defineEmits",
229
- "defineSlots"
230
- ] }],
231
- "vue/dot-location": ["error", "property"],
232
- "vue/dot-notation": ["error", { allowKeywords: true }],
233
- "vue/eqeqeq": ["error", "smart"],
234
- "vue/html-indent": ["error", 2],
235
- "vue/html-quotes": ["error", "double"],
236
- "vue/max-attributes-per-line": "off",
237
- "vue/multi-word-component-names": "off",
238
- "vue/no-dupe-keys": "off",
239
- "vue/no-empty-pattern": "error",
240
- "vue/no-irregular-whitespace": "error",
241
- "vue/no-loss-of-precision": "error",
242
- "vue/no-restricted-syntax": [
243
- "error",
244
- "DebuggerStatement",
245
- "LabeledStatement",
246
- "WithStatement"
247
- ],
248
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
249
- "vue/no-setup-props-reactivity-loss": "off",
250
- "vue/no-sparse-arrays": "error",
251
- "vue/no-unused-refs": "error",
252
- "vue/no-useless-v-bind": "error",
253
- "vue/no-v-html": "off",
254
- "vue/object-shorthand": [
255
- "error",
256
- "always",
257
- {
258
- avoidQuotes: true,
259
- ignoreConstructors: false
260
- }
261
- ],
262
- "vue/prefer-separate-static-class": "error",
263
- "vue/prefer-template": "error",
264
- "vue/prop-name-casing": ["error", "camelCase"],
265
- "vue/require-default-prop": "off",
266
- "vue/require-prop-types": "off",
267
- "vue/space-infix-ops": "error",
268
- "vue/space-unary-ops": ["error", {
269
- nonwords: false,
270
- words: true
271
- }],
272
- "vue/array-bracket-spacing": ["error", "never"],
273
- "vue/arrow-spacing": ["error", {
274
- after: true,
275
- before: true
276
- }],
277
- "vue/block-spacing": ["error", "always"],
278
- "vue/block-tag-newline": ["error", {
279
- multiline: "always",
280
- singleline: "always"
281
- }],
282
- "vue/brace-style": [
283
- "error",
284
- "stroustrup",
285
- { allowSingleLine: true }
286
- ],
287
- "vue/comma-dangle": ["error", "always-multiline"],
288
- "vue/comma-spacing": ["error", {
289
- after: true,
290
- before: false
291
- }],
292
- "vue/comma-style": ["error", "last"],
293
- "vue/html-comment-content-spacing": [
294
- "error",
295
- "always",
296
- { exceptions: ["-"] }
297
- ],
298
- "vue/key-spacing": ["error", {
299
- afterColon: true,
300
- beforeColon: false
301
- }],
302
- "vue/keyword-spacing": ["error", {
303
- after: true,
304
- before: true
305
- }],
306
- "vue/object-curly-newline": "off",
307
- "vue/object-curly-spacing": ["error", "always"],
308
- "vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
309
- "vue/operator-linebreak": ["error", "before"],
310
- "vue/padding-line-between-blocks": ["error", "always"],
311
- "vue/quote-props": ["error", "consistent-as-needed"],
312
- "vue/space-in-parens": ["error", "never"],
313
- "vue/template-curly-spacing": "error"
314
- }
315
- }];
316
- }
317
-
318
102
  //#endregion
319
103
  //#region src/configs/ignores.ts
320
104
  async function ignores() {
@@ -329,46 +113,31 @@ async function ignores() {
329
113
  }
330
114
 
331
115
  //#endregion
332
- //#region src/configs/unocss.ts
333
- async function unocss() {
334
- const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
335
- return [{
336
- name: "cuiqg/unocss",
337
- plugins: { unocss: pluginUnoCSS },
338
- rules: { ...renameRules(pluginUnoCSS.configs.recommended.rules, { "@unocss": "unocss" }) }
339
- }];
340
- }
341
-
342
- //#endregion
343
- //#region src/configs/de-morgan.ts
344
- async function deMorgan() {
345
- const pluginDeMorgan = await interopDefault(import("eslint-plugin-de-morgan"));
346
- return [{
347
- ...pluginDeMorgan.configs.recommended,
348
- name: "cuiqg/de-morgan"
349
- }];
350
- }
351
-
352
- //#endregion
353
- //#region src/configs/prettier.ts
354
- async function prettier() {
355
- const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
356
- return [{
357
- plugins: { prettier: pluginPrettier },
358
- name: "cuiqg/prettier",
359
- rules: {
360
- ...recommendedPrettier.rules,
361
- "prettier/prettier": "warn"
362
- }
363
- }];
364
- }
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");
365
134
 
366
135
  //#endregion
367
136
  //#region src/configs/javascript.ts
368
137
  async function javascript() {
369
138
  const [pluginUnuseImports, pluginJs] = await Promise.all([interopDefault(import("eslint-plugin-unused-imports")), interopDefault(import("@eslint/js"))]);
370
139
  return [{
371
- name: "cuiqg/javascript/setup",
140
+ name: "cuiqg/javascript",
372
141
  languageOptions: {
373
142
  ecmaVersion: "latest",
374
143
  globals: {
@@ -383,13 +152,11 @@ async function javascript() {
383
152
  },
384
153
  sourceType: "module"
385
154
  },
386
- linterOptions: { reportUnusedDisableDirectives: true }
387
- }, {
155
+ linterOptions: { reportUnusedDisableDirectives: true },
388
156
  plugins: {
389
157
  "unused-imports": pluginUnuseImports,
390
158
  js: pluginJs
391
159
  },
392
- name: "cuiqg/javascript/rules",
393
160
  rules: {
394
161
  ...pluginJs.configs.recommended.rules,
395
162
  "accessor-pairs": ["error", {
@@ -584,6 +351,168 @@ async function javascript() {
584
351
  }];
585
352
  }
586
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
+
587
516
  //#endregion
588
517
  //#region src/configs/typescript.ts
589
518
  async function typescript() {
@@ -591,7 +520,7 @@ async function typescript() {
591
520
  const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
592
521
  return [{
593
522
  files,
594
- name: "cuiqg/typescript/setup",
523
+ name: "cuiqg/typescript",
595
524
  plugins: { ts: pluginTs },
596
525
  languageOptions: {
597
526
  parser: parserTs,
@@ -602,9 +531,7 @@ async function typescript() {
602
531
  sourceType: "module",
603
532
  tsconfigRootDir: process.cwd()
604
533
  }
605
- }
606
- }, {
607
- name: "cuiqg/typescript/rules",
534
+ },
608
535
  rules: {
609
536
  ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, { "@typescript-eslint": "ts" }),
610
537
  ...renameRules(pluginTs.configs.strict.rules, { "@typescript-eslint": "ts" }),
@@ -649,6 +576,170 @@ async function typescript() {
649
576
  }];
650
577
  }
651
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
+
652
743
  //#endregion
653
744
  //#region src/presets.ts
654
745
  const defaultPluginRenaming = {
@@ -660,13 +751,8 @@ const defaultPluginRenaming = {
660
751
  };
661
752
  function cuiqg(options = {}, ...userConfigs) {
662
753
  const { prettier: enablePrettier = false, typescript: enableTypeScript = hasTypeScript(), vue: enableVue = hasVue(), unocss: enableUnocss = hasUnoCss(), nextjs: enableNextjs = hasNextjs() } = options;
663
- const configs = [
664
- packageJson(),
665
- ignores(),
666
- node(),
667
- deMorgan(),
668
- javascript()
669
- ];
754
+ const configs = [];
755
+ configs.push(packageJson(), ignores(), node(), deMorgan(), javascript(), jsdoc(), perfectionist());
670
756
  if (enableTypeScript) configs.push(typescript());
671
757
  if (enableVue) configs.push(vue());
672
758
  if (enableUnocss) configs.push(unocss());
@@ -687,4 +773,4 @@ function cuiqg(options = {}, ...userConfigs) {
687
773
  var src_default = cuiqg;
688
774
 
689
775
  //#endregion
690
- 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,15 +1,12 @@
1
1
  {
2
2
  "name": "@cuiqg/eslint-config",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "description": "Eslint config for @cuiqg",
5
5
  "keywords": [
6
6
  "eslint-config"
7
7
  ],
8
8
  "homepage": "https://eslint.tsuiqg.me",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/cuiqg/eslint-config.git"
12
- },
9
+ "repository": "github:cuiqg/eslint-config",
13
10
  "publishConfig": {
14
11
  "access": "public",
15
12
  "registry": "https://registry.npmjs.org/"
@@ -34,9 +31,6 @@
34
31
  "peerDependencies": {
35
32
  "eslint": ">=9.28.0"
36
33
  },
37
- "engines": {
38
- "node": ">=22.11.0"
39
- },
40
34
  "dependencies": {
41
35
  "@eslint/js": "^9.32.0",
42
36
  "@next/eslint-plugin-next": "^15.4.6",
@@ -46,18 +40,16 @@
46
40
  "eslint-config-flat-gitignore": "^2.1.0",
47
41
  "eslint-config-prettier": "^10.1.8",
48
42
  "eslint-flat-config-utils": "^2.1.1",
49
- "eslint-merge-processors": "^2.0.0",
50
43
  "eslint-plugin-de-morgan": "^1.3.1",
51
44
  "eslint-plugin-depend": "^1.2.0",
52
45
  "eslint-plugin-import-x": "^4.16.1",
53
46
  "eslint-plugin-jsdoc": "^52.0.4",
54
47
  "eslint-plugin-n": "^17.21.3",
55
48
  "eslint-plugin-package-json": "^0.52.1",
49
+ "eslint-plugin-perfectionist": "^4.15.0",
56
50
  "eslint-plugin-prettier": "^5.5.4",
57
51
  "eslint-plugin-unused-imports": "^4.1.4",
58
52
  "eslint-plugin-vue": "^10.4.0",
59
- "eslint-plugin-vuejs-accessibility": "^2.4.1",
60
- "eslint-processor-vue-blocks": "^2.0.0",
61
53
  "globals": "^16.3.0",
62
54
  "jsonc-eslint-parser": "^2.4.0",
63
55
  "local-pkg": "^1.1.1",
@@ -75,7 +67,7 @@
75
67
  "scripts": {
76
68
  "build": "tsdown",
77
69
  "dev": "tsdown --watch",
78
- "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",
79
71
  "lint": "eslint .",
80
72
  "lint:inspect": "eslint-config-inspector --open false --config eslint-inspector.config.ts",
81
73
  "release": "bumpp && pnpm publish",