@lincy/eslint-config 3.3.0 → 3.3.1

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
@@ -1,4 +1,4 @@
1
- # @lincy/eslint-config
1
+ # @lincy/eslint-config Eslint扁平化规则
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@lincy/eslint-config?color=444&label=)](https://npmjs.com/package/@lincy/eslint-config)
4
4
 
@@ -143,6 +143,18 @@ export default lincy({
143
143
  test: false, // 默认值: true
144
144
  // 是否启用 markdown 规则
145
145
  markdown: false, // 默认值: true
146
+ // 覆盖规则
147
+ overrides: {},
148
+
149
+ // 包含以下键名将会自动整合到一个规则里
150
+ files: [],
151
+ ignores: [],
152
+ languageOptions: {},
153
+ linterOptions: {},
154
+ processor: {},
155
+ plugins: {},
156
+ rules: [],
157
+ settings: {}
146
158
  })
147
159
  ```
148
160
 
@@ -181,13 +193,6 @@ export default lincy(
181
193
  },
182
194
  },
183
195
  },
184
- // 自定义排除文件(夹)
185
- {
186
- ignores: [
187
- '**/assets',
188
- '**/static',
189
- ],
190
- },
191
196
  // 你还可以继续配置多个 ESLint Flat Configs
192
197
  {
193
198
  files: ['**/*.ts'],
@@ -267,10 +272,21 @@ type foo = { bar: 2 }
267
272
 
268
273
  ```js
269
274
  // eslint.config.js
270
- import antfu from '@antfu/eslint-config'
275
+ import lincy from '@lincy/eslint-config'
271
276
 
272
- export default antfu(
273
- { vue: true, typescript: true },
277
+ export default lincy(
278
+ {
279
+ isInEditor: true,
280
+ vue: true,
281
+ typescript: true,
282
+ stylistic: true,
283
+ gitignore: true,
284
+ test: true,
285
+ jsonc: true,
286
+ yaml: true,
287
+ markdown: true,
288
+ overrides: {}
289
+ },
274
290
  {
275
291
  // 记得在这里指定文件 glob,否则可能会导致 vue 插件处理非 vue 文件
276
292
  files: ['**/*.vue'],
@@ -291,21 +307,29 @@ export default antfu(
291
307
 
292
308
  ```js
293
309
  // eslint.config.js
294
- import antfu from '@antfu/eslint-config'
310
+ import lincy from '@lincy/eslint-config'
295
311
 
296
- export default antfu({
312
+ export default lincy({
297
313
  overrides: {
314
+ // 重写vue规则
298
315
  vue: {
299
316
  'vue/operator-linebreak': ['error', 'before'],
300
317
  },
318
+ // 重写ts规则
301
319
  typescript: {
302
320
  'ts/consistent-type-definitions': ['error', 'interface'],
303
321
  },
322
+ // 重写js规则
304
323
  javascript: {},
305
324
  stylistic: {
306
- 'antfu/consistent-list-newline': 'off',
325
+ 'lincy/consistent-list-newline': 'off',
307
326
  },
308
327
  yaml: {},
328
+ jsonc: {},
329
+ markdown: {},
330
+ test: {},
331
+
332
+ // 追加自定义排除文件(夹)
309
333
  ignores: [
310
334
  '**/assets',
311
335
  '**/static',
package/dist/index.cjs CHANGED
@@ -88,7 +88,6 @@ __export(src_exports, {
88
88
  stylistic: () => stylistic,
89
89
  test: () => test,
90
90
  typescript: () => typescript,
91
- typescriptWithTypes: () => typescriptWithTypes,
92
91
  unicorn: () => unicorn,
93
92
  vue: () => vue,
94
93
  warnUnnecessaryOffRules: () => warnUnnecessaryOffRules,
@@ -281,9 +280,12 @@ function imports(options = {}) {
281
280
  return [
282
281
  {
283
282
  plugins: {
283
+ antfu: import_eslint_plugin_antfu.default,
284
284
  import: import_eslint_plugin_i.default
285
285
  },
286
286
  rules: {
287
+ "antfu/import-dedupe": "error",
288
+ "antfu/no-import-node-modules-by-path": "error",
287
289
  "import/export": "error",
288
290
  "import/first": "error",
289
291
  "import/no-duplicates": "error",
@@ -339,8 +341,6 @@ function javascript(options = {}) {
339
341
  },
340
342
  rules: {
341
343
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
342
- "antfu/import-dedupe": "error",
343
- "antfu/no-import-node-modules-by-path": "error",
344
344
  "antfu/top-level-function": "error",
345
345
  "array-callback-return": "error",
346
346
  "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
@@ -685,6 +685,25 @@ function markdown(options = {}) {
685
685
  "unicode-bom": "off",
686
686
  "unused-imports/no-unused-imports": OFF,
687
687
  "unused-imports/no-unused-vars": OFF,
688
+ // Type aware rules
689
+ ...{
690
+ "ts/await-thenable": OFF,
691
+ "ts/dot-notation": OFF,
692
+ "ts/no-floating-promises": OFF,
693
+ "ts/no-for-in-array": OFF,
694
+ "ts/no-implied-eval": OFF,
695
+ "ts/no-misused-promises": OFF,
696
+ "ts/no-throw-literal": OFF,
697
+ "ts/no-unnecessary-type-assertion": OFF,
698
+ "ts/no-unsafe-argument": OFF,
699
+ "ts/no-unsafe-assignment": OFF,
700
+ "ts/no-unsafe-call": OFF,
701
+ "ts/no-unsafe-member-access": OFF,
702
+ "ts/no-unsafe-return": OFF,
703
+ "ts/restrict-plus-operands": OFF,
704
+ "ts/restrict-template-expressions": OFF,
705
+ "ts/unbound-method": OFF
706
+ },
688
707
  ...overrides
689
708
  }
690
709
  }
@@ -1079,8 +1098,31 @@ function warnUnnecessaryOffRules() {
1079
1098
  function typescript(options) {
1080
1099
  const {
1081
1100
  componentExts = [],
1082
- overrides = {}
1101
+ overrides = {},
1102
+ parserOptions = {},
1103
+ tsconfigPath
1083
1104
  } = options ?? {};
1105
+ const typeAwareRules = {
1106
+ "dot-notation": OFF,
1107
+ "no-implied-eval": OFF,
1108
+ "no-throw-literal": OFF,
1109
+ "ts/await-thenable": "error",
1110
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1111
+ "ts/no-floating-promises": "error",
1112
+ "ts/no-for-in-array": "error",
1113
+ "ts/no-implied-eval": "error",
1114
+ "ts/no-misused-promises": "error",
1115
+ "ts/no-throw-literal": "error",
1116
+ "ts/no-unnecessary-type-assertion": "error",
1117
+ "ts/no-unsafe-argument": "error",
1118
+ "ts/no-unsafe-assignment": "error",
1119
+ "ts/no-unsafe-call": "error",
1120
+ "ts/no-unsafe-member-access": "error",
1121
+ "ts/no-unsafe-return": "error",
1122
+ "ts/restrict-plus-operands": "error",
1123
+ "ts/restrict-template-expressions": "error",
1124
+ "ts/unbound-method": "error"
1125
+ };
1084
1126
  return [
1085
1127
  {
1086
1128
  // Install the plugins without globs, so they can be configured separately.
@@ -1099,7 +1141,12 @@ function typescript(options) {
1099
1141
  languageOptions: {
1100
1142
  parser: import_parser.default,
1101
1143
  parserOptions: {
1102
- sourceType: "module"
1144
+ sourceType: "module",
1145
+ ...tsconfigPath ? {
1146
+ project: [tsconfigPath],
1147
+ tsconfigRootDir: import_node_process.default.cwd()
1148
+ } : {},
1149
+ ...parserOptions
1103
1150
  }
1104
1151
  },
1105
1152
  rules: {
@@ -1143,6 +1190,7 @@ function typescript(options) {
1143
1190
  "ts/prefer-ts-expect-error": "error",
1144
1191
  "ts/triple-slash-reference": OFF,
1145
1192
  "ts/unified-signatures": OFF,
1193
+ ...tsconfigPath ? typeAwareRules : {},
1146
1194
  ...overrides
1147
1195
  }
1148
1196
  },
@@ -1169,54 +1217,6 @@ function typescript(options) {
1169
1217
  }
1170
1218
  ];
1171
1219
  }
1172
- function typescriptWithTypes(options) {
1173
- const {
1174
- componentExts = [],
1175
- tsconfigPath,
1176
- tsconfigRootDir = import_node_process.default.cwd(),
1177
- overrides = {}
1178
- } = options;
1179
- return [
1180
- {
1181
- files: [
1182
- GLOB_TS,
1183
- GLOB_TSX,
1184
- ...componentExts.map((ext) => `**/*.${ext}`),
1185
- "!**/*.md/*.*"
1186
- ],
1187
- ignores: ["**/*.md/*.*"],
1188
- languageOptions: {
1189
- parser: import_parser.default,
1190
- parserOptions: {
1191
- project: [tsconfigPath],
1192
- tsconfigRootDir
1193
- }
1194
- },
1195
- rules: {
1196
- "dot-notation": OFF,
1197
- "no-implied-eval": OFF,
1198
- "no-throw-literal": OFF,
1199
- "ts/await-thenable": "error",
1200
- "ts/dot-notation": ["error", { allowKeywords: true }],
1201
- "ts/no-floating-promises": "error",
1202
- "ts/no-for-in-array": "error",
1203
- "ts/no-implied-eval": "error",
1204
- "ts/no-misused-promises": "error",
1205
- "ts/no-throw-literal": "error",
1206
- "ts/no-unnecessary-type-assertion": "error",
1207
- "ts/no-unsafe-argument": "error",
1208
- "ts/no-unsafe-assignment": "error",
1209
- "ts/no-unsafe-call": "error",
1210
- "ts/no-unsafe-member-access": "error",
1211
- "ts/no-unsafe-return": "error",
1212
- "ts/restrict-plus-operands": "error",
1213
- "ts/restrict-template-expressions": "error",
1214
- "ts/unbound-method": "error",
1215
- ...overrides
1216
- }
1217
- }
1218
- ];
1219
- }
1220
1220
 
1221
1221
  // src/configs/unicorn.ts
1222
1222
  function unicorn() {
@@ -1523,16 +1523,10 @@ function lincy(options = {}, ...userConfigs) {
1523
1523
  componentExts.push("vue");
1524
1524
  if (enableTypeScript) {
1525
1525
  configs.push(typescript({
1526
+ ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1526
1527
  componentExts,
1527
1528
  overrides: overrides.typescript
1528
1529
  }));
1529
- if (typeof enableTypeScript !== "boolean") {
1530
- configs.push(typescriptWithTypes({
1531
- ...enableTypeScript,
1532
- componentExts,
1533
- overrides: overrides.typescriptWithTypes
1534
- }));
1535
- }
1536
1530
  }
1537
1531
  if (enableStylistic) {
1538
1532
  configs.push(stylistic({
@@ -1649,7 +1643,6 @@ var src_default = lincy;
1649
1643
  stylistic,
1650
1644
  test,
1651
1645
  typescript,
1652
- typescriptWithTypes,
1653
1646
  unicorn,
1654
1647
  vue,
1655
1648
  warnUnnecessaryOffRules,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { FlatESLintConfigItem } from 'eslint-define-config';
2
2
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
3
+ import { ParserOptions } from '@typescript-eslint/parser';
4
+ export { default as parserTs } from '@typescript-eslint/parser';
3
5
  export { default as pluginAntfu } from 'eslint-plugin-antfu';
4
6
  export { default as pluginComments } from 'eslint-plugin-eslint-comments';
5
7
  export { default as pluginImport } from 'eslint-plugin-i';
@@ -14,7 +16,6 @@ export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
14
16
  export { default as pluginVue } from 'eslint-plugin-vue';
15
17
  export { default as pluginYaml } from 'eslint-plugin-yml';
16
18
  export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
17
- export { default as parserTs } from '@typescript-eslint/parser';
18
19
  export { default as parserVue } from 'vue-eslint-parser';
19
20
  export { default as parserYaml } from 'yaml-eslint-parser';
20
21
  export { default as parserJsonc } from 'jsonc-eslint-parser';
@@ -28,9 +29,18 @@ interface OptionsComponentExts {
28
29
  */
29
30
  componentExts?: string[];
30
31
  }
32
+ interface OptionsTypeScriptParserOptions {
33
+ /**
34
+ * Additional parser options for TypeScript.
35
+ */
36
+ parserOptions?: Partial<ParserOptions>;
37
+ }
31
38
  interface OptionsTypeScriptWithTypes {
32
- tsconfigPath: string;
33
- tsconfigRootDir?: string;
39
+ /**
40
+ * When this options is provided, type aware rules will be enabled.
41
+ * @see https://typescript-eslint.io/linting/typed-linting/
42
+ */
43
+ tsconfigPath?: string;
34
44
  }
35
45
  interface OptionsHasTypeScript {
36
46
  typescript?: boolean;
@@ -110,7 +120,6 @@ interface OptionsConfig {
110
120
  overrides?: {
111
121
  javascript?: FlatESLintConfigItem['rules'];
112
122
  typescript?: FlatESLintConfigItem['rules'];
113
- typescriptWithTypes?: FlatESLintConfigItem['rules'];
114
123
  stylistic?: FlatESLintConfigItem['rules'];
115
124
  test?: FlatESLintConfigItem['rules'];
116
125
  vue?: FlatESLintConfigItem['rules'];
@@ -157,8 +166,7 @@ declare function sortTsconfig(): FlatESLintConfigItem[];
157
166
 
158
167
  declare function stylistic(options?: OptionsOverrides): FlatESLintConfigItem[];
159
168
 
160
- declare function typescript(options?: OptionsComponentExts & OptionsOverrides): FlatESLintConfigItem[];
161
- declare function typescriptWithTypes(options: OptionsTypeScriptWithTypes & OptionsComponentExts & OptionsOverrides): FlatESLintConfigItem[];
169
+ declare function typescript(options?: OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): FlatESLintConfigItem[];
162
170
 
163
171
  declare function unicorn(): FlatESLintConfigItem[];
164
172
 
@@ -201,4 +209,4 @@ declare const GLOB_TESTS: string[];
201
209
  declare const GLOB_ALL_SRC: string[];
202
210
  declare const GLOB_EXCLUDE: string[];
203
211
 
204
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptWithTypes, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, recordRulesState, recordRulesStateConfigs, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, typescriptWithTypes, unicorn, vue, warnUnnecessaryOffRules, yaml };
212
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, recordRulesState, recordRulesStateConfigs, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { FlatESLintConfigItem } from 'eslint-define-config';
2
2
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
3
+ import { ParserOptions } from '@typescript-eslint/parser';
4
+ export { default as parserTs } from '@typescript-eslint/parser';
3
5
  export { default as pluginAntfu } from 'eslint-plugin-antfu';
4
6
  export { default as pluginComments } from 'eslint-plugin-eslint-comments';
5
7
  export { default as pluginImport } from 'eslint-plugin-i';
@@ -14,7 +16,6 @@ export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
14
16
  export { default as pluginVue } from 'eslint-plugin-vue';
15
17
  export { default as pluginYaml } from 'eslint-plugin-yml';
16
18
  export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
17
- export { default as parserTs } from '@typescript-eslint/parser';
18
19
  export { default as parserVue } from 'vue-eslint-parser';
19
20
  export { default as parserYaml } from 'yaml-eslint-parser';
20
21
  export { default as parserJsonc } from 'jsonc-eslint-parser';
@@ -28,9 +29,18 @@ interface OptionsComponentExts {
28
29
  */
29
30
  componentExts?: string[];
30
31
  }
32
+ interface OptionsTypeScriptParserOptions {
33
+ /**
34
+ * Additional parser options for TypeScript.
35
+ */
36
+ parserOptions?: Partial<ParserOptions>;
37
+ }
31
38
  interface OptionsTypeScriptWithTypes {
32
- tsconfigPath: string;
33
- tsconfigRootDir?: string;
39
+ /**
40
+ * When this options is provided, type aware rules will be enabled.
41
+ * @see https://typescript-eslint.io/linting/typed-linting/
42
+ */
43
+ tsconfigPath?: string;
34
44
  }
35
45
  interface OptionsHasTypeScript {
36
46
  typescript?: boolean;
@@ -110,7 +120,6 @@ interface OptionsConfig {
110
120
  overrides?: {
111
121
  javascript?: FlatESLintConfigItem['rules'];
112
122
  typescript?: FlatESLintConfigItem['rules'];
113
- typescriptWithTypes?: FlatESLintConfigItem['rules'];
114
123
  stylistic?: FlatESLintConfigItem['rules'];
115
124
  test?: FlatESLintConfigItem['rules'];
116
125
  vue?: FlatESLintConfigItem['rules'];
@@ -157,8 +166,7 @@ declare function sortTsconfig(): FlatESLintConfigItem[];
157
166
 
158
167
  declare function stylistic(options?: OptionsOverrides): FlatESLintConfigItem[];
159
168
 
160
- declare function typescript(options?: OptionsComponentExts & OptionsOverrides): FlatESLintConfigItem[];
161
- declare function typescriptWithTypes(options: OptionsTypeScriptWithTypes & OptionsComponentExts & OptionsOverrides): FlatESLintConfigItem[];
169
+ declare function typescript(options?: OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): FlatESLintConfigItem[];
162
170
 
163
171
  declare function unicorn(): FlatESLintConfigItem[];
164
172
 
@@ -201,4 +209,4 @@ declare const GLOB_TESTS: string[];
201
209
  declare const GLOB_ALL_SRC: string[];
202
210
  declare const GLOB_EXCLUDE: string[];
203
211
 
204
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptWithTypes, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, recordRulesState, recordRulesStateConfigs, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, typescriptWithTypes, unicorn, vue, warnUnnecessaryOffRules, yaml };
212
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, recordRulesState, recordRulesStateConfigs, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
package/dist/index.js CHANGED
@@ -179,9 +179,12 @@ function imports(options = {}) {
179
179
  return [
180
180
  {
181
181
  plugins: {
182
+ antfu: default2,
182
183
  import: default4
183
184
  },
184
185
  rules: {
186
+ "antfu/import-dedupe": "error",
187
+ "antfu/no-import-node-modules-by-path": "error",
185
188
  "import/export": "error",
186
189
  "import/first": "error",
187
190
  "import/no-duplicates": "error",
@@ -237,8 +240,6 @@ function javascript(options = {}) {
237
240
  },
238
241
  rules: {
239
242
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
240
- "antfu/import-dedupe": "error",
241
- "antfu/no-import-node-modules-by-path": "error",
242
243
  "antfu/top-level-function": "error",
243
244
  "array-callback-return": "error",
244
245
  "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
@@ -583,6 +584,25 @@ function markdown(options = {}) {
583
584
  "unicode-bom": "off",
584
585
  "unused-imports/no-unused-imports": OFF,
585
586
  "unused-imports/no-unused-vars": OFF,
587
+ // Type aware rules
588
+ ...{
589
+ "ts/await-thenable": OFF,
590
+ "ts/dot-notation": OFF,
591
+ "ts/no-floating-promises": OFF,
592
+ "ts/no-for-in-array": OFF,
593
+ "ts/no-implied-eval": OFF,
594
+ "ts/no-misused-promises": OFF,
595
+ "ts/no-throw-literal": OFF,
596
+ "ts/no-unnecessary-type-assertion": OFF,
597
+ "ts/no-unsafe-argument": OFF,
598
+ "ts/no-unsafe-assignment": OFF,
599
+ "ts/no-unsafe-call": OFF,
600
+ "ts/no-unsafe-member-access": OFF,
601
+ "ts/no-unsafe-return": OFF,
602
+ "ts/restrict-plus-operands": OFF,
603
+ "ts/restrict-template-expressions": OFF,
604
+ "ts/unbound-method": OFF
605
+ },
586
606
  ...overrides
587
607
  }
588
608
  }
@@ -977,8 +997,31 @@ function warnUnnecessaryOffRules() {
977
997
  function typescript(options) {
978
998
  const {
979
999
  componentExts = [],
980
- overrides = {}
1000
+ overrides = {},
1001
+ parserOptions = {},
1002
+ tsconfigPath
981
1003
  } = options ?? {};
1004
+ const typeAwareRules = {
1005
+ "dot-notation": OFF,
1006
+ "no-implied-eval": OFF,
1007
+ "no-throw-literal": OFF,
1008
+ "ts/await-thenable": "error",
1009
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1010
+ "ts/no-floating-promises": "error",
1011
+ "ts/no-for-in-array": "error",
1012
+ "ts/no-implied-eval": "error",
1013
+ "ts/no-misused-promises": "error",
1014
+ "ts/no-throw-literal": "error",
1015
+ "ts/no-unnecessary-type-assertion": "error",
1016
+ "ts/no-unsafe-argument": "error",
1017
+ "ts/no-unsafe-assignment": "error",
1018
+ "ts/no-unsafe-call": "error",
1019
+ "ts/no-unsafe-member-access": "error",
1020
+ "ts/no-unsafe-return": "error",
1021
+ "ts/restrict-plus-operands": "error",
1022
+ "ts/restrict-template-expressions": "error",
1023
+ "ts/unbound-method": "error"
1024
+ };
982
1025
  return [
983
1026
  {
984
1027
  // Install the plugins without globs, so they can be configured separately.
@@ -997,7 +1040,12 @@ function typescript(options) {
997
1040
  languageOptions: {
998
1041
  parser: default16,
999
1042
  parserOptions: {
1000
- sourceType: "module"
1043
+ sourceType: "module",
1044
+ ...tsconfigPath ? {
1045
+ project: [tsconfigPath],
1046
+ tsconfigRootDir: process.cwd()
1047
+ } : {},
1048
+ ...parserOptions
1001
1049
  }
1002
1050
  },
1003
1051
  rules: {
@@ -1041,6 +1089,7 @@ function typescript(options) {
1041
1089
  "ts/prefer-ts-expect-error": "error",
1042
1090
  "ts/triple-slash-reference": OFF,
1043
1091
  "ts/unified-signatures": OFF,
1092
+ ...tsconfigPath ? typeAwareRules : {},
1044
1093
  ...overrides
1045
1094
  }
1046
1095
  },
@@ -1067,54 +1116,6 @@ function typescript(options) {
1067
1116
  }
1068
1117
  ];
1069
1118
  }
1070
- function typescriptWithTypes(options) {
1071
- const {
1072
- componentExts = [],
1073
- tsconfigPath,
1074
- tsconfigRootDir = process.cwd(),
1075
- overrides = {}
1076
- } = options;
1077
- return [
1078
- {
1079
- files: [
1080
- GLOB_TS,
1081
- GLOB_TSX,
1082
- ...componentExts.map((ext) => `**/*.${ext}`),
1083
- "!**/*.md/*.*"
1084
- ],
1085
- ignores: ["**/*.md/*.*"],
1086
- languageOptions: {
1087
- parser: default16,
1088
- parserOptions: {
1089
- project: [tsconfigPath],
1090
- tsconfigRootDir
1091
- }
1092
- },
1093
- rules: {
1094
- "dot-notation": OFF,
1095
- "no-implied-eval": OFF,
1096
- "no-throw-literal": OFF,
1097
- "ts/await-thenable": "error",
1098
- "ts/dot-notation": ["error", { allowKeywords: true }],
1099
- "ts/no-floating-promises": "error",
1100
- "ts/no-for-in-array": "error",
1101
- "ts/no-implied-eval": "error",
1102
- "ts/no-misused-promises": "error",
1103
- "ts/no-throw-literal": "error",
1104
- "ts/no-unnecessary-type-assertion": "error",
1105
- "ts/no-unsafe-argument": "error",
1106
- "ts/no-unsafe-assignment": "error",
1107
- "ts/no-unsafe-call": "error",
1108
- "ts/no-unsafe-member-access": "error",
1109
- "ts/no-unsafe-return": "error",
1110
- "ts/restrict-plus-operands": "error",
1111
- "ts/restrict-template-expressions": "error",
1112
- "ts/unbound-method": "error",
1113
- ...overrides
1114
- }
1115
- }
1116
- ];
1117
- }
1118
1119
 
1119
1120
  // src/configs/unicorn.ts
1120
1121
  function unicorn() {
@@ -1421,16 +1422,10 @@ function lincy(options = {}, ...userConfigs) {
1421
1422
  componentExts.push("vue");
1422
1423
  if (enableTypeScript) {
1423
1424
  configs.push(typescript({
1425
+ ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1424
1426
  componentExts,
1425
1427
  overrides: overrides.typescript
1426
1428
  }));
1427
- if (typeof enableTypeScript !== "boolean") {
1428
- configs.push(typescriptWithTypes({
1429
- ...enableTypeScript,
1430
- componentExts,
1431
- overrides: overrides.typescriptWithTypes
1432
- }));
1433
- }
1434
1429
  }
1435
1430
  if (enableStylistic) {
1436
1431
  configs.push(stylistic({
@@ -1547,7 +1542,6 @@ export {
1547
1542
  stylistic,
1548
1543
  test,
1549
1544
  typescript,
1550
- typescriptWithTypes,
1551
1545
  unicorn,
1552
1546
  vue,
1553
1547
  warnUnnecessaryOffRules,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "3.3.0",
4
+ "version": "3.3.1",
5
5
  "packageManager": "pnpm@8.7.6",
6
6
  "description": "LinCenYing's ESLint config",
7
7
  "author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",