@cuiqg/eslint-config 2.8.13 → 2.8.15

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 (2) hide show
  1. package/dist/index.mjs +39 -46
  2. package/package.json +21 -14
package/dist/index.mjs CHANGED
@@ -1,11 +1,31 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
2
  import globals from "globals";
3
- import { fileURLToPath } from "node:url";
4
- import { isPackageExists } from "local-pkg";
5
3
  import path from "node:path";
6
4
  import fs from "node:fs";
7
5
  import process$1 from "node:process";
6
+ import { isPackageExists } from "local-pkg";
7
+
8
+ //#region src/utils.js
9
+ async function interopDefault(module) {
10
+ const resolved = await module;
11
+ return resolved.default || resolved;
12
+ }
13
+
14
+ //#endregion
15
+ //#region src/configs/baseline.js
16
+ async function baseline() {
17
+ const [pluginBaseline] = await Promise.all([interopDefault(import("eslint-plugin-baseline-js"))]);
18
+ return [{
19
+ name: "cuiqg/baseline",
20
+ plugins: { "baseline-js": pluginBaseline },
21
+ rules: { ...pluginBaseline.configs.recommended({
22
+ available: "widely",
23
+ level: "warn"
24
+ }).rules }
25
+ }];
26
+ }
8
27
 
28
+ //#endregion
9
29
  //#region src/globs.js
10
30
  const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
11
31
  const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
@@ -13,12 +33,9 @@ const GLOB_TS = `**/*.?([cm])ts`;
13
33
  const GLOB_TSX = `**/*.?([cm])tsx`;
14
34
  const GLOB_JS = `**/*.?([cm])js`;
15
35
  const GLOB_JSX = `**/*.?([cm])jsx`;
16
- const GLOB_STYLE = "**/*.{c,le,sc}ss";
36
+ const GLOB_STYLE = "**/*.{c,sc}ss";
17
37
  const GLOB_CSS = "**/*.css";
18
38
  const GLOB_SCSS = "**/*.scss";
19
- const GLOB_LESS = "**/*.less";
20
- const GLOB_STYLUS = "**/*.styl";
21
- const GLOB_POSTCSS = "**/*.{p,post}css";
22
39
  const GLOB_VUE = "**/*.vue";
23
40
  const GLOB_EXCLUDE = [
24
41
  "**/node_modules",
@@ -64,22 +81,14 @@ const GLOB_EXCLUDE = [
64
81
  //#endregion
65
82
  //#region src/configs/ignores.js
66
83
  async function ignores() {
84
+ const [pluginGitignore] = await Promise.all([interopDefault(import("eslint-config-flat-gitignore"))]);
67
85
  return [{
68
86
  ignores: [...GLOB_EXCLUDE],
69
87
  name: "cuiqg/ignores"
70
- }];
71
- }
72
-
73
- //#endregion
74
- //#region src/utils.js
75
- const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
76
- async function interopDefault(module) {
77
- try {
78
- let resolved = await module;
79
- return resolved?.default || resolved;
80
- } catch (error) {
81
- throw new Error(`Cannot import module: ${String(error)}`);
82
- }
88
+ }, { ...pluginGitignore({
89
+ name: "cuiqg/ignores/gitignore",
90
+ strict: false
91
+ }) }];
83
92
  }
84
93
 
85
94
  //#endregion
@@ -327,8 +336,9 @@ async function jsdoc() {
327
336
  //#endregion
328
337
  //#region src/configs/macros.js
329
338
  async function macros() {
339
+ const [configMacros] = await Promise.all([interopDefault(import("@vue-macros/eslint-config"))]);
330
340
  return [{
331
- ...await interopDefault(import("@vue-macros/eslint-config")),
341
+ ...configMacros,
332
342
  name: "cuiqg/macros"
333
343
  }];
334
344
  }
@@ -429,7 +439,7 @@ async function stylistic(options = {}) {
429
439
  //#endregion
430
440
  //#region src/configs/unocss.js
431
441
  async function unocss() {
432
- const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
442
+ const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
433
443
  return [{
434
444
  name: "cuiqg/unocss",
435
445
  plugins: { "@unocss": pluginUnoCSS },
@@ -481,8 +491,8 @@ async function vue(options = {}) {
481
491
  "vue/define-props-destructuring": ["error", { destructure: "always" }],
482
492
  "vue/enforce-style-attribute": ["error", { allow: ["scoped", "plain"] }],
483
493
  "vue/max-attributes-per-line": ["error", {
484
- "singleline": { "max": 1 },
485
- "multiline": { "max": 1 }
494
+ singleline: { max: 1 },
495
+ multiline: { max: 1 }
486
496
  }],
487
497
  "vue/html-button-has-type": "error",
488
498
  "vue/html-end-tags": "error",
@@ -619,7 +629,7 @@ async function vue(options = {}) {
619
629
  //#endregion
620
630
  //#region src/configs/tailwindcss.js
621
631
  async function tailwindcss() {
622
- const pluginTailwindcss = await interopDefault(import("eslint-plugin-tailwindcss"));
632
+ const [pluginTailwindcss] = await Promise.all([interopDefault(import("eslint-plugin-tailwindcss"))]);
623
633
  return [{
624
634
  name: "cuiqg/tailwindcss",
625
635
  plugins: { tailwindcss: pluginTailwindcss },
@@ -632,7 +642,7 @@ async function tailwindcss() {
632
642
  //#endregion
633
643
  //#region src/configs/comments.js
634
644
  async function comments() {
635
- const pluginComments = await interopDefault(import("@eslint-community/eslint-plugin-eslint-comments"));
645
+ const [pluginComments] = await Promise.all([interopDefault(import("@eslint-community/eslint-plugin-eslint-comments"))]);
636
646
  return [{
637
647
  name: "cuiqg/eslint-comments",
638
648
  plugins: { "@eslint-community/eslint-comments": pluginComments },
@@ -863,37 +873,20 @@ const isInEditor = () => {
863
873
  return !!(process$1.env.VSCODE_PID || process$1.env.VSCODE_CWD || process$1.env.JETBRAINS_IDE || process$1.env.VIM || process$1.env.NVIM);
864
874
  };
865
875
  const hasVue = () => isPackageExists("vue");
866
- const hasTypeScript = () => isPackageExists("typescript");
867
876
  const hasUnocss = () => isPackageExists("unocss");
868
- const hasTailwindcss = () => isPackageExists("tailwindcss");
869
877
 
870
878
  //#endregion
871
879
  //#region src/presets.js
872
- /**
873
- *
874
- * @param {object} options - 设置选项
875
- * @param {boolean} [options.typescript] - 是否启用 TypeScript 格式化
876
- * @param {boolean} [options.unocss] - 是否启用 Unocss 格式化
877
- * @param {boolean} [options.tailwindcss] - 是否启用 TailwindCSS 格式化
878
- * @param {boolean} [options.vue] - 是否启用 VUE 格式化
879
- * @param {boolean} [options.jsdoc=true] - 是否启用 JSDoc 格式化
880
- * @param {...Object} userConfigs - 用户配置
881
- *
882
- * @returns {Promise<Object[]>} 合并后的配置
883
- */
884
880
  function cuiqg(options = {}, ...userConfigs) {
885
- const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), typescript: enableTypescript = hasTypeScript(), vue: enableVue = hasVue() } = options;
881
+ const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = false, typescript: enableTypescript = false, vue: enableVue = hasVue() } = options;
886
882
  const configs = [];
887
- configs.push(autoImports(), ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
883
+ configs.push(autoImports(), baseline(), ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
888
884
  if (enableTypescript) configs.push(typescript());
889
885
  if (enableJsdoc) configs.push(jsdoc());
890
886
  if (enableVue) configs.push(vue({ typescript: enableTypescript }), macros());
891
887
  if (enableUnocss) configs.push(unocss());
892
888
  if (enableTailwindcss) configs.push(tailwindcss());
893
- let composer = new FlatConfigComposer();
894
- composer = composer.append(...configs, ...userConfigs);
895
- if (isInEditor) composer = composer.disableRulesFix(["unused-imports/no-unused-imports"], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
896
- return composer;
889
+ return new FlatConfigComposer(...configs, ...userConfigs);
897
890
  }
898
891
 
899
892
  //#endregion
@@ -901,4 +894,4 @@ function cuiqg(options = {}, ...userConfigs) {
901
894
  var src_default = cuiqg;
902
895
 
903
896
  //#endregion
904
- export { GLOB_CSS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_LESS, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_TS, GLOB_TSX, GLOB_VUE, autoImports, comments, cuiqg, src_default as default, hasTailwindcss, hasTypeScript, hasUnocss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, stylistic, stylisticConfigDefaults, tailwindcss, typescript, unocss, vue };
897
+ export { GLOB_CSS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TS, GLOB_TSX, GLOB_VUE, autoImports, baseline, comments, cuiqg, src_default as default, hasUnocss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, stylistic, stylisticConfigDefaults, tailwindcss, typescript, unocss, vue };
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@cuiqg/eslint-config",
3
- "version": "2.8.13",
3
+ "version": "2.8.15",
4
4
  "description": "Eslint config for @cuiqg",
5
5
  "keywords": [
6
6
  "eslint-config"
7
7
  ],
8
8
  "homepage": "https://eslint-config.tsuiqg.me",
9
- "repository": "github:cuiqg/eslint-config",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/cuiqg/eslint-config.git"
12
+ },
10
13
  "publishConfig": {
11
14
  "access": "public",
12
15
  "registry": "https://registry.npmjs.org/"
@@ -17,26 +20,20 @@
17
20
  "main": "./dist/index.mjs",
18
21
  "module": "./dist/index.mjs",
19
22
  "exports": {
20
- ".": "./dist/index.mjs"
23
+ ".": "./dist/index.mjs",
24
+ "./package.json": "./package.json"
21
25
  },
22
26
  "files": [
23
27
  "dist"
24
28
  ],
25
- "scripts": {
26
- "build": "tsdown",
27
- "dev": "tsdown --watch",
28
- "build:inspect": "npx @eslint/config-inspector build --config eslint-inspector.config.js",
29
- "lint": "eslint .",
30
- "lint:inspect": "npx @eslint/config-inspector --open false --config eslint-inspector.config.js",
31
- "prerelease": "npm run build",
32
- "release": "bumpp && npm publish"
33
- },
34
29
  "devDependencies": {
35
30
  "@eslint/config-inspector": "^1.4.2",
31
+ "@types/node": "^25.0.3",
36
32
  "bumpp": "^10.3.2",
37
33
  "eslint": "^9.39.2",
38
34
  "tsdown": "^0.18.2",
39
- "typescript": "^5.9.3"
35
+ "typescript": "^5.9.3",
36
+ "unrun": "^0.2.22"
40
37
  },
41
38
  "peerDependencies": {
42
39
  "eslint": ">=9.28.0"
@@ -48,7 +45,9 @@
48
45
  "@typescript-eslint/parser": "^8.50.1",
49
46
  "@unocss/eslint-plugin": "^66.5.10",
50
47
  "@vue-macros/eslint-config": "3.0.0-beta.21",
48
+ "eslint-config-flat-gitignore": "^2.1.0",
51
49
  "eslint-flat-config-utils": "^2.1.4",
50
+ "eslint-plugin-baseline-js": "^0.4.2",
52
51
  "eslint-plugin-depend": "^1.4.0",
53
52
  "eslint-plugin-import-x": "^4.16.1",
54
53
  "eslint-plugin-jsdoc": "^61.5.0",
@@ -60,5 +59,13 @@
60
59
  "jsonc-eslint-parser": "^2.4.2",
61
60
  "local-pkg": "^1.1.2",
62
61
  "vue-eslint-parser": "^10.2.0"
62
+ },
63
+ "scripts": {
64
+ "build": "tsdown",
65
+ "dev": "tsdown --watch",
66
+ "build:inspect": "npx @eslint/config-inspector build --config eslint-inspector.config.js",
67
+ "lint": "eslint .",
68
+ "lint:inspect": "npx @eslint/config-inspector --open false --config eslint-inspector.config.js",
69
+ "release": "bumpp"
63
70
  }
64
- }
71
+ }