@agilebot/eslint-config 0.3.9 → 0.3.10

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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @agilebot/eslint-config v0.3.9
2
+ * @license @agilebot/eslint-config v0.3.10
3
3
  *
4
4
  * Copyright (c) Agilebot, Inc. and its affiliates.
5
5
  *
@@ -48,21 +48,12 @@ var import_node_fs = __toESM(require("fs"));
48
48
  var import_node_path = __toESM(require("path"));
49
49
  var import_eslint_utils = require("@agilebot/eslint-utils");
50
50
 
51
- // src/factory/constants.ts
52
- var defaultExtensions = [
53
- ".js",
54
- ".jsx",
55
- ".ts",
56
- ".tsx",
57
- ".cjs",
58
- ".mjs",
59
- ".cts",
60
- ".mts",
61
- ".vue"
62
- ];
63
-
64
- // src/cli/constants.ts
65
- var isEslint = /^\.eslint.*/;
51
+ // src/constants.ts
52
+ var JS_EXTS = [".js", ".jsx", ".cjs", ".cjsx", ".mjs", ".mjsx"];
53
+ var TS_EXTS = [".ts", ".tsx", ".cts", ".ctsx", ".mts", ".mtsx"];
54
+ var VUE_EXTS = [".vue"];
55
+ var DEFAULT_EXTS = [...JS_EXTS, ...TS_EXTS, ...VUE_EXTS];
56
+ var IS_ESLINT = /^\.eslint.*/;
66
57
 
67
58
  // src/cli/index.ts
68
59
  function cli() {
@@ -87,7 +78,7 @@ function cli() {
87
78
  process.argv.splice(2, 0, "--fix");
88
79
  }
89
80
  if (!has.ext) {
90
- process.argv.splice(2, 0, "--ext", defaultExtensions.join(","));
81
+ process.argv.splice(2, 0, "--ext", DEFAULT_EXTS.join(","));
91
82
  }
92
83
  if (has.progress && !(0, import_eslint_utils.isCI)()) {
93
84
  process.argv.splice(
@@ -108,7 +99,7 @@ function cli() {
108
99
  throw err;
109
100
  }
110
101
  has.config = has.config || files.some((file) => {
111
- return isEslint.test(file);
102
+ return IS_ESLINT.test(file);
112
103
  });
113
104
  if (!has.config) {
114
105
  throw new Error("No ESLint configuration file found");
package/dist/index.d.ts CHANGED
@@ -45,7 +45,7 @@ interface FactoryOptions {
45
45
  * Flag indicating whether to enable GoDaddy configurations
46
46
  * @default undefined
47
47
  */
48
- godaddy?: boolean;
48
+ godaddy?: boolean | 'typescript';
49
49
  /**
50
50
  * Flag indicating whether to enable JSDoc configurations
51
51
  * @default true
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @agilebot/eslint-config v0.3.9
2
+ * @license @agilebot/eslint-config v0.3.10
3
3
  *
4
4
  * Copyright (c) Agilebot, Inc. and its affiliates.
5
5
  *
@@ -59,16 +59,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
59
59
  ));
60
60
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
61
61
 
62
- // ../../node_modules/.pnpm/tsup@8.0.2_postcss@8.4.38_ts-node@10.9.2_@types+node@20.11.28_typescript@5.4.5__typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js
62
+ // ../../node_modules/.pnpm/tsup@8.1.0_postcss@8.4.39_ts-node@10.9.2_@types+node@20.11.28_typescript@5.4.5__typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js
63
63
  var init_cjs_shims = __esm({
64
- "../../node_modules/.pnpm/tsup@8.0.2_postcss@8.4.38_ts-node@10.9.2_@types+node@20.11.28_typescript@5.4.5__typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js"() {
64
+ "../../node_modules/.pnpm/tsup@8.1.0_postcss@8.4.39_ts-node@10.9.2_@types+node@20.11.28_typescript@5.4.5__typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js"() {
65
65
  "use strict";
66
66
  }
67
67
  });
68
68
 
69
- // ../../node_modules/.pnpm/eslint-config-love@47.0.0_@typescript-eslint+eslint-plugin@7.9.0_@typescript-eslint+parser@7._yewwkxdqextsdihbrotj7foatu/node_modules/eslint-config-love/lib/index.js
69
+ // ../../node_modules/.pnpm/eslint-config-love@47.0.0_@typescript-eslint+eslint-plugin@7.16.0_@typescript-eslint+parser@7_bx3ud3a5a3wg7ark6pvzt2lrse/node_modules/eslint-config-love/lib/index.js
70
70
  var require_lib = __commonJS({
71
- "../../node_modules/.pnpm/eslint-config-love@47.0.0_@typescript-eslint+eslint-plugin@7.9.0_@typescript-eslint+parser@7._yewwkxdqextsdihbrotj7foatu/node_modules/eslint-config-love/lib/index.js"(exports2, module2) {
71
+ "../../node_modules/.pnpm/eslint-config-love@47.0.0_@typescript-eslint+eslint-plugin@7.16.0_@typescript-eslint+parser@7_bx3ud3a5a3wg7ark6pvzt2lrse/node_modules/eslint-config-love/lib/index.js"(exports2, module2) {
72
72
  "use strict";
73
73
  init_cjs_shims();
74
74
  var eslint_1 = require("eslint");
@@ -520,9 +520,10 @@ function standard() {
520
520
  standardRules[key] = value;
521
521
  }
522
522
  });
523
+ const disabled = standardDisabled();
523
524
  return {
524
525
  plugins: ["@typescript-eslint", "import-x", "n", "promise"],
525
- rules: __spreadProps(__spreadValues({}, standardRules), {
526
+ rules: __spreadValues(__spreadProps(__spreadValues({}, standardRules), {
526
527
  "no-alert": "error",
527
528
  // 找出TODO注释,以便后期修复
528
529
  "no-warning-comments": [
@@ -545,8 +546,13 @@ function standard() {
545
546
  "promise/valid-params": "error",
546
547
  "promise/no-multiple-resolved": "error",
547
548
  "promise/no-return-in-finally": "error",
548
- "promise/prefer-await-to-then": "warn",
549
- // 覆盖standard中的规则
549
+ "promise/prefer-await-to-then": "warn"
550
+ }), disabled.rules)
551
+ };
552
+ }
553
+ function standardDisabled() {
554
+ return {
555
+ rules: {
550
556
  "@typescript-eslint/no-confusing-void-expression": "off",
551
557
  "@typescript-eslint/space-before-function-paren": "off",
552
558
  "@typescript-eslint/unbound-method": "off",
@@ -557,9 +563,8 @@ function standard() {
557
563
  "@typescript-eslint/strict-boolean-expressions": "off",
558
564
  "@typescript-eslint/explicit-function-return-type": "off",
559
565
  "@typescript-eslint/restrict-template-expressions": "off",
560
- "@typescript-eslint/explicit-member-accessibility": "off",
561
566
  "@typescript-eslint/no-unsafe-argument": "off"
562
- })
567
+ }
563
568
  };
564
569
  }
565
570
 
@@ -666,6 +671,32 @@ function ts() {
666
671
  }
667
672
  };
668
673
  }
674
+ function tsOnly() {
675
+ return {
676
+ rules: {
677
+ "@typescript-eslint/explicit-member-accessibility": "error"
678
+ }
679
+ };
680
+ }
681
+ function jsOnly() {
682
+ return {
683
+ rules: {
684
+ "@typescript-eslint/no-var-requires": "off"
685
+ }
686
+ };
687
+ }
688
+ function dts() {
689
+ return {
690
+ rules: {
691
+ // .d.ts中支持导入ts文件中的类型
692
+ "@typescript-eslint/consistent-type-imports": "off",
693
+ // .d.ts中忽略属性命名规则
694
+ "@typescript-eslint/naming-convention": "off",
695
+ // .d.ts中忽略三斜线引用
696
+ "@typescript-eslint/triple-slash-reference": "off"
697
+ }
698
+ };
699
+ }
669
700
 
670
701
  // src/configs/imports.ts
671
702
  init_cjs_shims();
@@ -1123,27 +1154,21 @@ function godaddy() {
1123
1154
  };
1124
1155
  }
1125
1156
 
1126
- // src/factory/constants.ts
1157
+ // src/constants.ts
1127
1158
  init_cjs_shims();
1128
- var defaultExtensions = [
1129
- ".js",
1130
- ".jsx",
1131
- ".ts",
1132
- ".tsx",
1133
- ".cjs",
1134
- ".mjs",
1135
- ".cts",
1136
- ".mts",
1137
- ".vue"
1138
- ];
1139
- var jsExtensions = [".js", ".jsx", ".cjs", ".mjs"];
1140
- var tsExtensions = [".ts", ".tsx", ".cts", ".mts"];
1141
- var dtsExtensions = [".d.ts", ".d.cts", ".d.mts"];
1159
+ var JS_EXTS = [".js", ".jsx", ".cjs", ".cjsx", ".mjs", ".mjsx"];
1160
+ var TS_EXTS = [".ts", ".tsx", ".cts", ".ctsx", ".mts", ".mtsx"];
1161
+ var DTS_EXTS = [".d.ts", ".d.cts", ".d.mts"];
1162
+ var VUE_EXTS = [".vue"];
1163
+ var DEFAULT_EXTS = [...JS_EXTS, ...TS_EXTS, ...VUE_EXTS];
1142
1164
 
1143
1165
  // src/factory/index.ts
1144
1166
  function factory(root, options) {
1145
1167
  var _a, _b, _c, _d, _e;
1146
1168
  import_node_assert.default.ok(root, "root option is required");
1169
+ const tsconfigFiles = (0, import_eslint_utils3.findTsconfigFiles)(root, {
1170
+ absolute: true
1171
+ });
1147
1172
  const defaultOptions = {
1148
1173
  jsdoc: true,
1149
1174
  prettier: true,
@@ -1173,8 +1198,11 @@ function factory(root, options) {
1173
1198
  }) : {},
1174
1199
  options.prettier ? prettier() : {}
1175
1200
  ];
1201
+ let config;
1176
1202
  if (options == null ? void 0 : options.godaddy) {
1177
- return (0, import_eslint_utils3.mergeESLintConfig)(
1203
+ config = __spreadValues({
1204
+ parser: options.godaddy === "typescript" ? "@typescript-eslint/parser" : void 0
1205
+ }, (0, import_eslint_utils3.mergeESLintConfig)(
1178
1206
  godaddy(),
1179
1207
  (options == null ? void 0 : options.jsdoc) ? jsdoc({
1180
1208
  ts: false
@@ -1184,82 +1212,69 @@ function factory(root, options) {
1184
1212
  ts: false
1185
1213
  }) : {},
1186
1214
  (_b = options == null ? void 0 : options.config) != null ? _b : {}
1187
- );
1188
- }
1189
- const tsconfigFiles = (0, import_eslint_utils3.findTsconfigFiles)(root, {
1190
- absolute: true
1191
- });
1192
- const config = {
1193
- overrides: [
1194
- __spreadValues({
1195
- files: defaultExtensions.map((ext) => `*${ext}`),
1196
- parser: !(options == null ? void 0 : options.vue) ? "@typescript-eslint/parser" : "vue-eslint-parser",
1197
- parserOptions: {
1198
- parser: "@typescript-eslint/parser",
1199
- tsconfigRootDir: root,
1200
- ecmaFeatures: {
1201
- jsx: true
1202
- },
1203
- sourceType: options.module ? "module" : void 0,
1204
- extraFileExtensions: !(options == null ? void 0 : options.vue) ? void 0 : [".vue"]
1205
- }
1206
- }, (0, import_eslint_utils3.mergeESLintConfig)(
1207
- env(),
1208
- standard(),
1209
- // standard必须在ts之前
1210
- ts(),
1211
- (options == null ? void 0 : options.react) ? react({ version: options.react }) : {},
1212
- (options == null ? void 0 : options.vue) ? vue({
1213
- version: options.vue
1214
- }) : {},
1215
- (options == null ? void 0 : options.jsdoc) ? jsdoc({
1216
- ts: true
1217
- }) : {},
1218
- (options == null ? void 0 : options.lodash) ? lodash() : {},
1219
- deprecation(),
1220
- (options == null ? void 0 : options.cspell) ? cspell({
1221
- words: (_c = options == null ? void 0 : options.cspellWords) != null ? _c : []
1222
- }) : {},
1223
- ...commonConfigs,
1224
- agilebot({
1225
- root,
1226
- monorepoScope: options == null ? void 0 : options.monorepoScope
1227
- }),
1228
- (_d = options == null ? void 0 : options.config) != null ? _d : {}
1229
- )),
1230
- __spreadValues({
1231
- files: jsExtensions.map((ext) => `*${ext}`)
1232
- }, (0, import_eslint_utils3.mergeESLintConfig)(
1233
- {
1234
- rules: {
1235
- "@typescript-eslint/no-var-requires": "off"
1215
+ ));
1216
+ } else {
1217
+ config = {
1218
+ overrides: [
1219
+ __spreadValues({
1220
+ files: DEFAULT_EXTS.map((ext) => `*${ext}`),
1221
+ parser: !(options == null ? void 0 : options.vue) ? "@typescript-eslint/parser" : "vue-eslint-parser",
1222
+ parserOptions: {
1223
+ parser: "@typescript-eslint/parser",
1224
+ tsconfigRootDir: root,
1225
+ ecmaFeatures: {
1226
+ jsx: true
1227
+ },
1228
+ sourceType: options.module ? "module" : void 0,
1229
+ extraFileExtensions: !(options == null ? void 0 : options.vue) ? void 0 : [".vue"]
1236
1230
  }
1237
- },
1238
- (options == null ? void 0 : options.jsdoc) ? jsdoc({
1239
- ts: false
1240
- }) : {}
1241
- )),
1242
- {
1243
- files: tsExtensions.map((ext) => `*${ext}`),
1244
- rules: {
1245
- "@typescript-eslint/explicit-member-accessibility": "error"
1246
- }
1247
- },
1248
- {
1249
- files: dtsExtensions.map((ext) => `*${ext}`),
1250
- rules: {
1251
- // .d.ts中支持导入ts文件中的类型
1252
- "@typescript-eslint/consistent-type-imports": "off",
1253
- // .d.ts中忽略属性命名规则
1254
- "@typescript-eslint/naming-convention": "off",
1255
- // .d.ts中忽略三斜线引用
1256
- "@typescript-eslint/triple-slash-reference": "off"
1257
- }
1258
- }
1259
- ]
1260
- };
1231
+ }, (0, import_eslint_utils3.mergeESLintConfig)(
1232
+ env(),
1233
+ standard(),
1234
+ // standard必须在ts之前
1235
+ ts(),
1236
+ (options == null ? void 0 : options.react) ? react({ version: options.react }) : {},
1237
+ (options == null ? void 0 : options.vue) ? vue({
1238
+ version: options.vue
1239
+ }) : {},
1240
+ (options == null ? void 0 : options.jsdoc) ? jsdoc({
1241
+ ts: true
1242
+ }) : {},
1243
+ (options == null ? void 0 : options.lodash) ? lodash() : {},
1244
+ deprecation(),
1245
+ (options == null ? void 0 : options.cspell) ? cspell({
1246
+ words: (_c = options == null ? void 0 : options.cspellWords) != null ? _c : []
1247
+ }) : {},
1248
+ ...commonConfigs,
1249
+ agilebot({
1250
+ root,
1251
+ monorepoScope: options == null ? void 0 : options.monorepoScope
1252
+ }),
1253
+ (_d = options == null ? void 0 : options.config) != null ? _d : {}
1254
+ )),
1255
+ __spreadValues({
1256
+ files: JS_EXTS.map((ext) => `*${ext}`)
1257
+ }, (0, import_eslint_utils3.mergeESLintConfig)(
1258
+ jsOnly(),
1259
+ (options == null ? void 0 : options.jsdoc) ? jsdoc({
1260
+ ts: false
1261
+ }) : {}
1262
+ )),
1263
+ __spreadValues({
1264
+ files: TS_EXTS.map((ext) => `*${ext}`)
1265
+ }, tsOnly()),
1266
+ __spreadValues({
1267
+ files: DTS_EXTS.map((ext) => `*${ext}`)
1268
+ }, dts())
1269
+ ]
1270
+ };
1271
+ }
1261
1272
  if ((_e = config.overrides) == null ? void 0 : _e[0].parserOptions) {
1262
1273
  config.overrides[0].parserOptions.project = tsconfigFiles.length > 0 ? tsconfigFiles : true;
1274
+ } else if (config.parser) {
1275
+ config.parserOptions = {
1276
+ project: tsconfigFiles.length > 0 ? tsconfigFiles : true
1277
+ };
1263
1278
  }
1264
1279
  return config;
1265
1280
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilebot/eslint-config",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "description": "Agilebot's ESLint config",
5
5
  "bin": {
6
6
  "eslint-agilebot": "bin/eslint-agilebot"
@@ -18,40 +18,40 @@
18
18
  },
19
19
  "homepage": "https://github.com/sh-agilebot/frontend-toolkit/tree/master/packages/eslint-config#readme",
20
20
  "dependencies": {
21
- "@cspell/eslint-plugin": "^8.8.1",
22
- "@eslint-react/eslint-plugin": "^1.5.11",
23
- "@stylistic/eslint-plugin": "^2.1.0",
24
- "@typescript-eslint/eslint-plugin": "~7.9.0",
25
- "@typescript-eslint/parser": "~7.9.0",
21
+ "@cspell/eslint-plugin": "^8.10.4",
22
+ "@eslint-react/eslint-plugin": "^1.5.23",
23
+ "@stylistic/eslint-plugin": "^2.3.0",
24
+ "@typescript-eslint/eslint-plugin": "~7.16.0",
25
+ "@typescript-eslint/parser": "~7.16.0",
26
26
  "eslint-config-godaddy": "^6.0.0",
27
27
  "eslint-config-prettier": "^9.1.0",
28
28
  "eslint-import-resolver-typescript": "^3.6.1",
29
- "eslint-plugin-deprecation": "^2.0.0",
29
+ "eslint-plugin-deprecation": "^3.0.0",
30
30
  "eslint-plugin-eslint-comments": "^3.2.0",
31
31
  "eslint-plugin-file-progress": "^1.4.0",
32
- "eslint-plugin-import-x": "^0.5.0",
33
- "eslint-plugin-jsdoc": "^48.2.4",
34
- "eslint-plugin-jsx-a11y": "^6.8.0",
35
- "eslint-plugin-n": "^17.7.0",
36
- "eslint-plugin-no-relative-import-paths": "^1.5.4",
32
+ "eslint-plugin-import-x": "^0.5.3",
33
+ "eslint-plugin-jsdoc": "^48.5.2",
34
+ "eslint-plugin-jsx-a11y": "^6.9.0",
35
+ "eslint-plugin-n": "^17.9.0",
36
+ "eslint-plugin-no-relative-import-paths": "^1.5.5",
37
37
  "eslint-plugin-prefer-arrow-functions": "^3.3.2",
38
38
  "eslint-plugin-prettier": "^5.1.3",
39
- "eslint-plugin-promise": "^6.0.0",
40
- "eslint-plugin-react": "^7.34.1",
39
+ "eslint-plugin-promise": "^6.4.0",
40
+ "eslint-plugin-react": "^7.34.3",
41
41
  "eslint-plugin-react-hooks": "^4.6.2",
42
- "eslint-plugin-unicorn": "^53.0.0",
42
+ "eslint-plugin-unicorn": "^54.0.0",
43
43
  "eslint-plugin-unused-imports": "^3.2.0",
44
44
  "eslint-plugin-vue": "^9.26.0",
45
45
  "eslint-plugin-you-dont-need-lodash-underscore": "^6.13.0",
46
46
  "vue-eslint-parser": "^9.4.2",
47
- "@agilebot/eslint-utils": "0.3.9"
47
+ "@agilebot/eslint-utils": "0.3.10"
48
48
  },
49
49
  "devDependencies": {
50
50
  "eslint-config-love": "^47.0.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "eslint": "^7.0.0 || ^8.0.0",
54
- "@agilebot/eslint-plugin": "0.3.9"
54
+ "@agilebot/eslint-plugin": "0.3.10"
55
55
  },
56
56
  "files": [
57
57
  "bin",