@cuiqg/eslint-config 2.8.3 → 2.8.5

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/README.md +14 -3
  2. package/dist/index.mjs +24 -10
  3. package/package.json +18 -19
package/README.md CHANGED
@@ -13,17 +13,26 @@ npm i -D eslint @cuiqg/eslint-config
13
13
  + "type": "module",
14
14
  "scripts": {
15
15
  + "lint": "eslint .",
16
- + "lint:fix": "eslint . --fix"
16
+ + "lint:fix": "eslint . --fix",
17
+ + "lint:inspect": "eslint . --inspect-config"
17
18
  }
18
19
  }
19
20
  ```
20
21
 
21
- 创建 `eslint.config.js` 文件
22
+ 创建 `eslint.config.mjs` 文件
22
23
 
23
24
  ```js
25
+ import fs from 'node:fs'
24
26
  import cuiqg from '@cuiqg/eslint-config'
27
+ import { FlatCompat } from '@eslint/eslintrc'
25
28
 
26
- export default cuiqg()
29
+ const compat = new FlatCompat()
30
+
31
+ export default cuiqg({},
32
+ fs.existsSync('.eslintrc-auto-import.json')
33
+ ? compat.extend('./.eslintrc-auto-import.json')
34
+ : []
35
+ )
27
36
  ```
28
37
 
29
38
  ## 插件配置
@@ -36,7 +45,9 @@ export default cuiqg()
36
45
  {
37
46
  "prettier.enable": false,
38
47
  "editor.formatOnSave": false,
48
+
39
49
  "eslint.useFlatConfig": true,
50
+
40
51
  "editor.codeActionsOnSave": {
41
52
  "source.fixAll.eslint": "explicit",
42
53
  "source.organizeImports": "never"
package/dist/index.mjs CHANGED
@@ -211,7 +211,10 @@ const stylisticConfigDefaults = {
211
211
  };
212
212
  async function stylistic() {
213
213
  const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
214
- const config = pluginStylistic.configs.customize({ ...stylisticConfigDefaults });
214
+ const config = pluginStylistic.configs.customize({
215
+ ...stylisticConfigDefaults,
216
+ commaDangle: "never"
217
+ });
215
218
  return [{
216
219
  name: "cuiqg/stylistic",
217
220
  plugins: { "@stylistic": pluginStylistic },
@@ -396,7 +399,14 @@ async function imports() {
396
399
  return [{
397
400
  name: "cuiqg/imports",
398
401
  plugins: { "import-x": pluginImportX },
399
- rules: { ...pluginImportX.configs["flat/recommended"].rules },
402
+ rules: {
403
+ "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
404
+ "import-x/first": "error",
405
+ "import-x/no-duplicates": "error",
406
+ "import-x/no-mutable-exports": "error",
407
+ "import-x/no-named-default": "error",
408
+ "import-x/newline-after-import": ["error", { "count": 1 }]
409
+ },
400
410
  settings: { "import-x/core-modules": ["electron", "vue-router/auto-routes"] }
401
411
  }];
402
412
  }
@@ -420,6 +430,7 @@ const hasVue = () => [
420
430
  const hasTypeScript = () => isPackageExists("typescript");
421
431
  const hasUnocss = () => isPackageExists("unocss");
422
432
  const hasTailwindcss = () => isPackageExists("tailwindcss");
433
+ const hasPrettier = () => isPackageExists("prettier");
423
434
 
424
435
  //#endregion
425
436
  //#region src/presets.js
@@ -427,18 +438,21 @@ const defaultPluginRenaming = {};
427
438
  /**
428
439
  *
429
440
  * @param {object} options - 设置选项
430
- * @param {boolean} [options.prettier=false] - 是否启用 prettier 格式化
431
- * @param {boolean} [options.unocss] - 是否启用 unocss 格式化
432
- * @param {boolean} [options.tailwindcss] - 是否启用 tailwindcss 格式化
433
- * @param {boolean} [options.vue] - 是否启用 vue 格式化
434
- * @param {boolean|object} [options.formatter=true] - 是否启用格式化
441
+ * @param {boolean} [options.prettier] - 是否启用 Prettier 格式化
442
+ * @param {boolean} [options.unocss] - 是否启用 Unocss 格式化
443
+ * @param {boolean} [options.tailwindcss] - 是否启用 Tailwindcss 格式化
444
+ * @param {boolean} [options.vue] - 是否启用 VUE 格式化
445
+ * @param {boolean} [options.imports=true] - 是否启用 Import-X
446
+ * @param {boolean} [options.jsdoc=true] - 是否启用 JSDoc 格式化
435
447
  * @param {...Object} userConfigs - 用户配置
448
+ *
436
449
  * @returns {Promise<Object[]>} 合并后的配置
437
450
  */
438
451
  function cuiqg(options = {}, ...userConfigs) {
439
- const { prettier: enablePrettier = false, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), vue: enableVue = hasVue(), imports: enableImports = true } = options;
452
+ const { jsdoc: enableJsdoc = true, prettier: enablePrettier = hasPrettier(), unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), vue: enableVue = hasVue(), imports: enableImports = true } = options;
440
453
  const configs = [];
441
- configs.push(ignores(), javascript(), jsdoc(), stylistic(), packageJson());
454
+ configs.push(ignores(), javascript(), stylistic(), packageJson());
455
+ if (enableJsdoc) configs.push(jsdoc());
442
456
  if (enableImports) configs.push(imports());
443
457
  if (enableVue) configs.push(vue(), macros());
444
458
  if (enableUnocss) configs.push(unocss());
@@ -454,4 +468,4 @@ function cuiqg(options = {}, ...userConfigs) {
454
468
  var src_default = cuiqg;
455
469
 
456
470
  //#endregion
457
- export { GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_PHP, 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, src_default as default, defaultPluginRenaming, hasTailwindcss, hasTypeScript, hasUnocss, hasVue, ignores, imports, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, prettier, stylistic, stylisticConfigDefaults, tailwindcss, unocss, vue };
471
+ export { GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_PHP, 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, src_default as default, defaultPluginRenaming, hasPrettier, hasTailwindcss, hasTypeScript, hasUnocss, hasVue, ignores, imports, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, prettier, stylistic, stylisticConfigDefaults, tailwindcss, unocss, vue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuiqg/eslint-config",
3
- "version": "2.8.3",
3
+ "version": "2.8.5",
4
4
  "description": "Eslint config for @cuiqg",
5
5
  "keywords": [
6
6
  "eslint-config"
@@ -23,44 +23,43 @@
23
23
  "files": [
24
24
  "dist"
25
25
  ],
26
+ "scripts": {
27
+ "build": "tsdown",
28
+ "dev": "tsdown --watch",
29
+ "build:inspect": "npx @eslint/config-inspector build --config eslint-inspector.config.js",
30
+ "lint": "eslint .",
31
+ "lint:inspect": "npx @eslint/config-inspector --open false --config eslint-inspector.config.js",
32
+ "prepublishOnly": "npm run build",
33
+ "release": "bumpp"
34
+ },
26
35
  "devDependencies": {
27
- "@cuiqg/prettier-config": "latest",
28
36
  "@eslint/config-inspector": "^1.4.2",
29
37
  "@eslint/eslintrc": "^3.3.3",
30
38
  "bumpp": "^10.3.2",
31
- "eslint": "^9.39.1",
32
- "tsdown": "^0.16.8"
39
+ "eslint": "^9.39.2",
40
+ "tsdown": "^0.18.2"
33
41
  },
34
42
  "peerDependencies": {
35
43
  "eslint": ">=9.28.0"
36
44
  },
37
45
  "dependencies": {
38
- "@eslint/js": "^9.39.1",
46
+ "@eslint/js": "^9.39.2",
39
47
  "@stylistic/eslint-plugin": "^5.6.1",
40
- "@unocss/eslint-plugin": "^66.5.9",
48
+ "@unocss/eslint-plugin": "^66.5.10",
41
49
  "@vue-macros/eslint-config": "3.0.0-beta.21",
42
50
  "eslint-config-flat-gitignore": "^2.1.0",
43
51
  "eslint-config-prettier": "^10.1.8",
44
52
  "eslint-flat-config-utils": "^2.1.4",
45
- "eslint-plugin-format": "^1.0.2",
53
+ "eslint-plugin-format": "^1.1.0",
46
54
  "eslint-plugin-import-x": "^4.16.1",
47
- "eslint-plugin-jsdoc": "^61.4.1",
55
+ "eslint-plugin-jsdoc": "^61.5.0",
48
56
  "eslint-plugin-package-json": "^0.85.0",
49
57
  "eslint-plugin-prettier": "^5.5.4",
50
58
  "eslint-plugin-tailwindcss": "4.0.0-beta.0",
51
59
  "eslint-plugin-vue": "^10.6.2",
52
60
  "globals": "^16.5.0",
53
- "jsonc-eslint-parser": "^2.4.1",
61
+ "jsonc-eslint-parser": "^2.4.2",
54
62
  "local-pkg": "^1.1.2",
55
63
  "vue-eslint-parser": "^10.2.0"
56
- },
57
- "prettier": "@cuiqg/prettier-config",
58
- "scripts": {
59
- "build": "tsdown",
60
- "dev": "tsdown --watch",
61
- "build:inspect": "pnpx @eslint/config-inspector build --config eslint-inspector.config.js",
62
- "lint": "eslint .",
63
- "lint:inspect": "pnpx @eslint/config-inspector --open false --config eslint-inspector.config.js",
64
- "release": "bumpp"
65
64
  }
66
- }
65
+ }