@cuiqg/eslint-config 2.8.9 → 2.8.11

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 +60 -47
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -84,43 +84,24 @@ async function ignores() {
84
84
  })];
85
85
  }
86
86
 
87
- //#endregion
88
- //#region src/env.js
89
- const isInGitHookOrLintStaged = () => {
90
- return !!(process$1.env.GIT_PARAMS || process$1.env.VSCODE_GIT_COMMAND || process$1.env.npm_lifecycle_script?.startsWith("lint-staged"));
91
- };
92
- const isInEditor = () => {
93
- if (process$1.env.CI) return false;
94
- if (isInGitHookOrLintStaged()) return false;
95
- return !!(process$1.env.VSCODE_PID || process$1.env.VSCODE_CWD || process$1.env.JETBRAINS_IDE || process$1.env.VIM || process$1.env.NVIM);
96
- };
97
- const hasVue = () => isPackageExists("vue");
98
- const hasTypeScript = () => isPackageExists("typescript");
99
- const hasUnocss = () => isPackageExists("unocss");
100
- const hasTailwindcss = () => isPackageExists("tailwindcss");
101
-
102
87
  //#endregion
103
88
  //#region src/configs/javascript.js
104
- async function javascript() {
105
- const files = [GLOB_SRC];
89
+ async function javascript(options = {}) {
90
+ const { isInEditor: isInEditor$1 = false } = options;
106
91
  const pluginUnusedImports = await interopDefault(import("eslint-plugin-unused-imports"));
107
92
  return [{
108
- files,
109
93
  name: "cuiqg/javascript",
110
94
  plugins: { "unused-imports": pluginUnusedImports },
111
95
  languageOptions: {
112
- ecmaVersion: "latest",
113
96
  globals: {
114
97
  ...globals.browser,
115
98
  ...globals.es2025,
116
99
  ...globals.node
117
100
  },
118
101
  parserOptions: {
119
- ecmaFeatures: { jsx: true },
120
102
  ecmaVersion: "latest",
121
103
  sourceType: "module"
122
- },
123
- sourceType: "module"
104
+ }
124
105
  },
125
106
  linterOptions: { reportUnusedDisableDirectives: true },
126
107
  rules: {
@@ -285,7 +266,7 @@ async function javascript() {
285
266
  allowNamedFunctions: false,
286
267
  allowUnboundThis: true
287
268
  }],
288
- "prefer-const": [isInEditor ? "warn" : "error", {
269
+ "prefer-const": [isInEditor$1 ? "warn" : "error", {
289
270
  destructuring: "all",
290
271
  ignoreReadBeforeAssign: true
291
272
  }],
@@ -297,7 +278,7 @@ async function javascript() {
297
278
  "prefer-template": "error",
298
279
  "symbol-description": "error",
299
280
  "unicode-bom": ["error", "never"],
300
- "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
281
+ "unused-imports/no-unused-imports": isInEditor$1 ? "warn" : "error",
301
282
  "unused-imports/no-unused-vars": ["error", {
302
283
  args: "after-used",
303
284
  argsIgnorePattern: "^_",
@@ -340,7 +321,8 @@ async function jsdoc() {
340
321
  "jsdoc/require-yields-check": "warn",
341
322
  "jsdoc/check-alignment": "warn",
342
323
  "jsdoc/multiline-blocks": "warn"
343
- }
324
+ },
325
+ settings: { jsdoc: { mode: "jsdoc" } }
344
326
  }];
345
327
  }
346
328
 
@@ -414,17 +396,35 @@ const stylisticConfigDefaults = {
414
396
  quotes: "single",
415
397
  semi: false
416
398
  };
417
- async function stylistic() {
399
+ async function stylistic(options = {}) {
400
+ const { commaDangle = "never", experimental, indent, jsx, quotes, semi } = {
401
+ ...stylisticConfigDefaults,
402
+ ...options
403
+ };
418
404
  const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
419
405
  const config = pluginStylistic.configs.customize({
420
- ...stylisticConfigDefaults,
421
- commaDangle: "never",
422
- pluginName: "@stylistic"
406
+ commaDangle,
407
+ experimental,
408
+ indent,
409
+ jsx,
410
+ pluginName: "@stylistic",
411
+ quotes,
412
+ semi
423
413
  });
424
414
  return [{
425
415
  name: "cuiqg/stylistic",
426
416
  plugins: { "@stylistic": pluginStylistic },
427
- rules: { ...config.rules }
417
+ rules: {
418
+ ...config.rules,
419
+ "@stylistic/generator-star-spacing": ["error", {
420
+ after: true,
421
+ before: false
422
+ }],
423
+ "@stylistic/yield-star-spacing": ["error", {
424
+ after: true,
425
+ before: false
426
+ }]
427
+ }
428
428
  }];
429
429
  }
430
430
 
@@ -444,19 +444,12 @@ async function unocss() {
444
444
 
445
445
  //#endregion
446
446
  //#region src/configs/vue.js
447
- async function vue() {
448
- let additionalParserOptions = {};
447
+ async function vue(options = {}) {
448
+ const { typescript: typescript$1 = false } = options;
449
+ let parserOptions = null;
449
450
  const files = [GLOB_VUE];
450
451
  const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
451
- if (hasTypeScript) {
452
- const parserTs = await interopDefault(import("@typescript-eslint/parser"));
453
- additionalParserOptions = {
454
- ...additionalParserOptions,
455
- parser: parserTs,
456
- projectService: true,
457
- tsconfigRootDir: process.cwd()
458
- };
459
- }
452
+ if (typescript$1) parserOptions = { parser: await interopDefault(import("@typescript-eslint/parser")) };
460
453
  return [{
461
454
  files,
462
455
  name: "cuiqg/vue",
@@ -464,10 +457,11 @@ async function vue() {
464
457
  languageOptions: {
465
458
  parser: parserVue,
466
459
  parserOptions: {
460
+ ecmaFeatures: { jsx: true },
467
461
  ecmaVersion: "latest",
468
462
  extraFileExtensions: [".vue"],
469
463
  sourceType: "module",
470
- ...additionalParserOptions
464
+ ...parserOptions
471
465
  }
472
466
  },
473
467
  processor: pluginVue.processors[".vue"],
@@ -652,7 +646,11 @@ async function comments() {
652
646
  //#endregion
653
647
  //#region src/configs/typescript.js
654
648
  async function typescript() {
655
- const files = [GLOB_TS, GLOB_TSX];
649
+ const files = [
650
+ GLOB_TS,
651
+ GLOB_TSX,
652
+ GLOB_VUE
653
+ ];
656
654
  const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
657
655
  return [{
658
656
  files,
@@ -836,14 +834,29 @@ async function typescript() {
836
834
  }];
837
835
  }
838
836
 
837
+ //#endregion
838
+ //#region src/env.js
839
+ const isInGitHookOrLintStaged = () => {
840
+ return !!(process$1.env.GIT_PARAMS || process$1.env.VSCODE_GIT_COMMAND || process$1.env.npm_lifecycle_script?.startsWith("lint-staged"));
841
+ };
842
+ const isInEditor = () => {
843
+ if (process$1.env.CI) return false;
844
+ if (isInGitHookOrLintStaged()) return false;
845
+ return !!(process$1.env.VSCODE_PID || process$1.env.VSCODE_CWD || process$1.env.JETBRAINS_IDE || process$1.env.VIM || process$1.env.NVIM);
846
+ };
847
+ const hasVue = () => isPackageExists("vue");
848
+ const hasTypeScript = () => isPackageExists("typescript");
849
+ const hasUnocss = () => isPackageExists("unocss");
850
+ const hasTailwindcss = () => isPackageExists("tailwindcss");
851
+
839
852
  //#endregion
840
853
  //#region src/presets.js
841
854
  /**
842
855
  *
843
856
  * @param {object} options - 设置选项
844
- * @param {boolean} [options.prettier=false] - 是否启用 Prettier 格式化
857
+ * @param {boolean} [options.typescript] - 是否启用 TypeScript 格式化
845
858
  * @param {boolean} [options.unocss] - 是否启用 Unocss 格式化
846
- * @param {boolean} [options.tailwindcss] - 是否启用 Tailwindcss 格式化
859
+ * @param {boolean} [options.tailwindcss] - 是否启用 TailwindCSS 格式化
847
860
  * @param {boolean} [options.vue] - 是否启用 VUE 格式化
848
861
  * @param {boolean} [options.jsdoc=true] - 是否启用 JSDoc 格式化
849
862
  * @param {...Object} userConfigs - 用户配置
@@ -853,10 +866,10 @@ async function typescript() {
853
866
  function cuiqg(options = {}, ...userConfigs) {
854
867
  const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), typescript: enableTypescript = hasTypeScript(), vue: enableVue = hasVue() } = options;
855
868
  const configs = [];
856
- configs.push(ignores(), comments(), javascript(), stylistic(), packageJson());
869
+ configs.push(ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
857
870
  if (enableTypescript) configs.push(typescript());
858
871
  if (enableJsdoc) configs.push(jsdoc());
859
- if (enableVue) configs.push(vue(), macros());
872
+ if (enableVue) configs.push(vue({ typescript: enableTypescript }), macros());
860
873
  if (enableUnocss) configs.push(unocss());
861
874
  if (enableTailwindcss) configs.push(tailwindcss());
862
875
  let composer = new FlatConfigComposer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuiqg/eslint-config",
3
- "version": "2.8.9",
3
+ "version": "2.8.11",
4
4
  "description": "Eslint config for @cuiqg",
5
5
  "keywords": [
6
6
  "eslint-config"