@cuiqg/eslint-config 2.8.11 → 2.8.12

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/README.md CHANGED
@@ -22,17 +22,9 @@ npm i -D eslint @cuiqg/eslint-config
22
22
  创建 `eslint.config.mjs` 文件
23
23
 
24
24
  ```js
25
- import fs from 'node:fs'
26
25
  import cuiqg from '@cuiqg/eslint-config'
27
- import { FlatCompat } from '@eslint/eslintrc'
28
26
 
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
+ export default cuiqg()
36
28
  ```
37
29
 
38
30
  ## 插件配置
package/dist/index.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
+ import globals from "globals";
2
3
  import { fileURLToPath } from "node:url";
3
4
  import { isPackageExists } from "local-pkg";
4
- import globals from "globals";
5
+ import path from "node:path";
6
+ import fs from "node:fs";
5
7
  import process$1 from "node:process";
6
8
 
7
9
  //#region src/globs.js
@@ -59,6 +61,15 @@ const GLOB_EXCLUDE = [
59
61
  "**/.eslint-config-inspector"
60
62
  ];
61
63
 
64
+ //#endregion
65
+ //#region src/configs/ignores.js
66
+ async function ignores() {
67
+ return [{
68
+ ignores: [...GLOB_EXCLUDE],
69
+ name: "cuiqg/ignores"
70
+ }];
71
+ }
72
+
62
73
  //#endregion
63
74
  //#region src/utils.js
64
75
  const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
@@ -71,19 +82,6 @@ async function interopDefault(module) {
71
82
  }
72
83
  }
73
84
 
74
- //#endregion
75
- //#region src/configs/ignores.js
76
- async function ignores() {
77
- const configGitignore = await interopDefault(import("eslint-config-flat-gitignore"));
78
- return [{
79
- ignores: [...GLOB_EXCLUDE],
80
- name: "cuiqg/ignores"
81
- }, configGitignore({
82
- name: "cuiqg/gitignore",
83
- strict: false
84
- })];
85
- }
86
-
87
85
  //#endregion
88
86
  //#region src/configs/javascript.js
89
87
  async function javascript(options = {}) {
@@ -834,6 +832,22 @@ async function typescript() {
834
832
  }];
835
833
  }
836
834
 
835
+ //#endregion
836
+ //#region src/configs/auto-imports.js
837
+ async function autoImports(options = {}) {
838
+ const { cwd = process.cwd(), filename = ".eslintrc-auto-import.json", strict = true } = options;
839
+ const config = [];
840
+ if (fs.existsSync(path.join(cwd, filename))) try {
841
+ config.push({
842
+ name: "cuiqg/auto-imports",
843
+ languageOptions: { ...JSON.parse(fs.readFileSync(path.join(cwd, filename), "utf8")) }
844
+ });
845
+ } catch (error) {
846
+ if (strict) throw error;
847
+ }
848
+ return config;
849
+ }
850
+
837
851
  //#endregion
838
852
  //#region src/env.js
839
853
  const isInGitHookOrLintStaged = () => {
@@ -866,7 +880,7 @@ const hasTailwindcss = () => isPackageExists("tailwindcss");
866
880
  function cuiqg(options = {}, ...userConfigs) {
867
881
  const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), typescript: enableTypescript = hasTypeScript(), vue: enableVue = hasVue() } = options;
868
882
  const configs = [];
869
- configs.push(ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
883
+ configs.push(autoImports(), ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
870
884
  if (enableTypescript) configs.push(typescript());
871
885
  if (enableJsdoc) configs.push(jsdoc());
872
886
  if (enableVue) configs.push(vue({ typescript: enableTypescript }), macros());
@@ -883,4 +897,4 @@ function cuiqg(options = {}, ...userConfigs) {
883
897
  var src_default = cuiqg;
884
898
 
885
899
  //#endregion
886
- 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, comments, cuiqg, src_default as default, hasTailwindcss, hasTypeScript, hasUnocss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, stylistic, stylisticConfigDefaults, tailwindcss, typescript, unocss, vue };
900
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuiqg/eslint-config",
3
- "version": "2.8.11",
3
+ "version": "2.8.12",
4
4
  "description": "Eslint config for @cuiqg",
5
5
  "keywords": [
6
6
  "eslint-config"
@@ -28,8 +28,8 @@
28
28
  "build:inspect": "npx @eslint/config-inspector build --config eslint-inspector.config.js",
29
29
  "lint": "eslint .",
30
30
  "lint:inspect": "npx @eslint/config-inspector --open false --config eslint-inspector.config.js",
31
- "prepublishOnly": "npm run build",
32
- "release": "bumpp"
31
+ "prerelease": "npm run build",
32
+ "release": "bumpp && npm publish"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@eslint/config-inspector": "^1.4.2",
@@ -48,7 +48,6 @@
48
48
  "@typescript-eslint/parser": "^8.50.1",
49
49
  "@unocss/eslint-plugin": "^66.5.10",
50
50
  "@vue-macros/eslint-config": "3.0.0-beta.21",
51
- "eslint-config-flat-gitignore": "^2.1.0",
52
51
  "eslint-flat-config-utils": "^2.1.4",
53
52
  "eslint-plugin-depend": "^1.4.0",
54
53
  "eslint-plugin-import-x": "^4.16.1",