@lincy/eslint-config 4.2.3 → 4.2.5

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/index.cjs CHANGED
@@ -48,6 +48,7 @@ __export(src_exports, {
48
48
  GLOB_SRC: () => GLOB_SRC,
49
49
  GLOB_SRC_EXT: () => GLOB_SRC_EXT,
50
50
  GLOB_STYLE: () => GLOB_STYLE,
51
+ GLOB_SVELTE: () => GLOB_SVELTE,
51
52
  GLOB_TESTS: () => GLOB_TESTS,
52
53
  GLOB_TOML: () => GLOB_TOML,
53
54
  GLOB_TS: () => GLOB_TS,
@@ -135,6 +136,7 @@ var GLOB_JSON5 = "**/*.json5";
135
136
  var GLOB_JSONC = "**/*.jsonc";
136
137
  var GLOB_MARKDOWN = "**/*.md";
137
138
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
139
+ var GLOB_SVELTE = "**/*.svelte";
138
140
  var GLOB_VUE = "**/*.vue";
139
141
  var GLOB_YAML = "**/*.y?(a)ml";
140
142
  var GLOB_TOML = "**/*.toml";
@@ -151,6 +153,7 @@ var GLOB_ALL_SRC = [
151
153
  GLOB_JSON,
152
154
  GLOB_JSON5,
153
155
  GLOB_MARKDOWN,
156
+ GLOB_SVELTE,
154
157
  GLOB_VUE,
155
158
  GLOB_YAML,
156
159
  GLOB_HTML
@@ -213,6 +216,7 @@ async function imports(options = {}) {
213
216
  },
214
217
  rules: {
215
218
  "antfu/import-dedupe": "error",
219
+ "antfu/no-import-dist": "off",
216
220
  "antfu/no-import-node-modules-by-path": "error",
217
221
  "import/first": "error",
218
222
  "import/no-duplicates": "error",
@@ -318,7 +322,6 @@ async function javascript(options = {}) {
318
322
  "no-multi-str": "error",
319
323
  "no-new": "error",
320
324
  "no-new-func": "error",
321
- "no-new-object": "error",
322
325
  "no-new-symbol": "error",
323
326
  "no-new-wrappers": "error",
324
327
  "no-obj-calls": "error",
@@ -502,7 +505,6 @@ async function jsdoc(options = {}) {
502
505
  {
503
506
  name: "eslint:jsdoc",
504
507
  plugins: {
505
- // @ts-expect-error missing types
506
508
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
507
509
  },
508
510
  rules: {
@@ -892,6 +894,7 @@ async function formatters(options = {}, stylistic2 = {}) {
892
894
  [`format/${formater}`]: [
893
895
  "error",
894
896
  formater === "prettier" ? {
897
+ printWidth: 200,
895
898
  ...prettierOptions,
896
899
  embeddedLanguageFormatting: "off",
897
900
  parser: "markdown"
@@ -1386,6 +1389,9 @@ async function typescript(options = {}) {
1386
1389
  GLOB_SRC,
1387
1390
  ...componentExts.map((ext) => `**/*.${ext}`)
1388
1391
  ];
1392
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1393
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1394
+ const isTypeAware = !!tsconfigPath;
1389
1395
  const typeAwareRules = {
1390
1396
  "dot-notation": "off",
1391
1397
  "no-implied-eval": "off",
@@ -1407,7 +1413,6 @@ async function typescript(options = {}) {
1407
1413
  "ts/restrict-template-expressions": "error",
1408
1414
  "ts/unbound-method": "error"
1409
1415
  };
1410
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1411
1416
  const [
1412
1417
  pluginTs,
1413
1418
  parserTs
@@ -1415,29 +1420,43 @@ async function typescript(options = {}) {
1415
1420
  interopDefault(import("@typescript-eslint/eslint-plugin")),
1416
1421
  interopDefault(import("@typescript-eslint/parser"))
1417
1422
  ]);
1418
- return [
1419
- {
1420
- // Install the plugins without globs, so they can be configured separately.
1421
- name: "eslint:typescript:setup",
1422
- plugins: {
1423
- antfu: import_eslint_plugin_antfu.default,
1424
- ts: pluginTs
1425
- }
1426
- },
1427
- {
1428
- files,
1423
+ function makeParser(typeAware, files2, ignores2) {
1424
+ return {
1425
+ files: files2,
1426
+ ...ignores2 ? { ignores: ignores2 } : {},
1429
1427
  languageOptions: {
1430
1428
  parser: parserTs,
1431
1429
  parserOptions: {
1432
1430
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1433
1431
  sourceType: "module",
1434
- ...tsconfigPath ? {
1432
+ ...typeAware ? {
1435
1433
  project: tsconfigPath,
1436
1434
  tsconfigRootDir: import_node_process2.default.cwd()
1437
1435
  } : {},
1438
1436
  ...parserOptions
1439
1437
  }
1440
1438
  },
1439
+ name: `eslint:typescript:${typeAware ? "type-aware-parser" : "parser"}`
1440
+ };
1441
+ }
1442
+ return [
1443
+ {
1444
+ // Install the plugins without globs, so they can be configured separately.
1445
+ name: "eslint:typescript:setup",
1446
+ plugins: {
1447
+ antfu: import_eslint_plugin_antfu.default,
1448
+ ts: pluginTs
1449
+ }
1450
+ },
1451
+ // assign type-aware parser for type-aware files and type-unaware parser for the rest
1452
+ ...isTypeAware ? [
1453
+ makeParser(true, filesTypeAware),
1454
+ makeParser(false, files, filesTypeAware)
1455
+ ] : [
1456
+ makeParser(false, files)
1457
+ ],
1458
+ {
1459
+ files,
1441
1460
  name: "eslint:typescript:rules",
1442
1461
  rules: {
1443
1462
  ...renameRules(
@@ -1475,6 +1494,13 @@ async function typescript(options = {}) {
1475
1494
  "ts/prefer-ts-expect-error": "error",
1476
1495
  "ts/triple-slash-reference": "off",
1477
1496
  "ts/unified-signatures": "off",
1497
+ ...overrides
1498
+ }
1499
+ },
1500
+ {
1501
+ files: filesTypeAware,
1502
+ name: "eslint:typescript:rules-type-aware",
1503
+ rules: {
1478
1504
  ...tsconfigPath ? typeAwareRules : {},
1479
1505
  ...overrides
1480
1506
  }
@@ -1659,6 +1685,7 @@ async function vue(options = {}) {
1659
1685
  }],
1660
1686
  "vue/component-name-in-template-casing": ["error", "PascalCase"],
1661
1687
  "vue/component-options-name-casing": ["error", "PascalCase"],
1688
+ "vue/component-tags-order": "off",
1662
1689
  "vue/custom-event-name-casing": vueVersion === "3" ? ["error", "camelCase"] : ["error", "kebab-case"],
1663
1690
  ...vueVersion === "2" ? {
1664
1691
  "vue/require-explicit-emits": "off"
@@ -1818,7 +1845,7 @@ async function toml(options = {}) {
1818
1845
  ]);
1819
1846
  return [
1820
1847
  {
1821
- name: "antfu:toml:setup",
1848
+ name: "eslint:toml:setup",
1822
1849
  plugins: {
1823
1850
  toml: pluginToml
1824
1851
  }
@@ -1828,7 +1855,7 @@ async function toml(options = {}) {
1828
1855
  languageOptions: {
1829
1856
  parser: parserToml
1830
1857
  },
1831
- name: "antfu:toml:rules",
1858
+ name: "eslint:toml:rules",
1832
1859
  rules: {
1833
1860
  "style/spaced-comment": "off",
1834
1861
  "toml/comma-style": "error",
@@ -1883,7 +1910,7 @@ async function lincy(options = {}, ...userConfigs) {
1883
1910
  const {
1884
1911
  componentExts = [],
1885
1912
  gitignore: enableGitignore = true,
1886
- isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
1913
+ isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
1887
1914
  overrides = {},
1888
1915
  react: enableReact = ReactPackages.some((i) => (0, import_local_pkg4.isPackageExists)(i)),
1889
1916
  typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
@@ -1962,12 +1989,10 @@ async function lincy(options = {}, ...userConfigs) {
1962
1989
  }));
1963
1990
  }
1964
1991
  if (enableUnoCSS) {
1965
- configs.push(unocss(
1966
- {
1967
- ...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
1968
- overrides: overrides.unocss
1969
- }
1970
- ));
1992
+ configs.push(unocss({
1993
+ ...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
1994
+ overrides: overrides.unocss
1995
+ }));
1971
1996
  }
1972
1997
  if (options.jsonc ?? true) {
1973
1998
  configs.push(
@@ -1994,13 +2019,11 @@ async function lincy(options = {}, ...userConfigs) {
1994
2019
  }));
1995
2020
  }
1996
2021
  if (options.markdown ?? true) {
1997
- configs.push(markdown(
1998
- {
1999
- ...typeof options.markdown !== "boolean" ? options.markdown : {},
2000
- componentExts,
2001
- overrides: overrides.markdown
2002
- }
2003
- ));
2022
+ configs.push(markdown({
2023
+ ...typeof options.markdown !== "boolean" ? options.markdown : {},
2024
+ componentExts,
2025
+ overrides: overrides.markdown
2026
+ }));
2004
2027
  }
2005
2028
  if (options.formatters) {
2006
2029
  configs.push(formatters(
@@ -2044,6 +2067,7 @@ var src_default = lincy;
2044
2067
  GLOB_SRC,
2045
2068
  GLOB_SRC_EXT,
2046
2069
  GLOB_STYLE,
2070
+ GLOB_SVELTE,
2047
2071
  GLOB_TESTS,
2048
2072
  GLOB_TOML,
2049
2073
  GLOB_TS,
package/dist/index.d.cts CHANGED
@@ -10,94 +10,99 @@ import { Rules as Rules$1 } from 'eslint-plugin-antfu';
10
10
  import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/eslint-plugin';
11
11
 
12
12
  /**
13
- * Vendor types from Prettier so we don't rely on the dependency.
13
+ * 来自 Prettier 的供应商类型,因此不依赖依赖项
14
14
  */
15
15
  type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
16
16
  interface VendoredPrettierOptionsRequired {
17
17
  /**
18
- * Specify the number of spaces per indentation-level.
18
+ * 指定换行的行长度.
19
+ * @default 200
20
+ */
21
+ printWidth: number;
22
+ /**
23
+ * 指定每个缩进的空格数.
19
24
  */
20
25
  tabWidth: number;
21
26
  /**
22
- * Indent lines with tabs instead of spaces
27
+ * 使用制表符而不是空格来缩进行
23
28
  */
24
29
  useTabs?: boolean;
25
30
  /**
26
- * Print semicolons at the ends of statements.
31
+ * 在语句末尾添加分号.
27
32
  */
28
33
  semi: boolean;
29
34
  /**
30
- * Use single quotes instead of double quotes.
35
+ * 使用单引号代替双引号.
31
36
  */
32
37
  singleQuote: boolean;
33
38
  /**
34
- * Use single quotes in JSX.
39
+ * JSX 中使用单引号.
35
40
  */
36
41
  jsxSingleQuote: boolean;
37
42
  /**
38
- * Print trailing commas wherever possible.
43
+ * 尽可能添加尾随逗号.
39
44
  */
40
45
  trailingComma: 'none' | 'es5' | 'all';
41
46
  /**
42
- * Print spaces between brackets in object literals.
47
+ * 对象文字中括号之间的空格.
43
48
  */
44
49
  bracketSpacing: boolean;
45
50
  /**
46
- * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
47
- * alone on the next line (does not apply to self closing elements).
51
+ * 将多行 HTMLHTMLJSXVueAngular)元素的 `>` 放在最后一行的末尾,
52
+ * 而不是单独放在下一行(不适用于自闭合元素)。
48
53
  */
49
54
  bracketSameLine: boolean;
50
55
  /**
51
- * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
52
- * @deprecated use bracketSameLine instead
56
+ * 将多行 JSX 元素的 `>` 放在最后一行的末尾,而不是单独放在下一行.
57
+ * @deprecated 使用 bracketSameLine 代替
53
58
  */
54
59
  jsxBracketSameLine: boolean;
55
60
  /**
56
- * Format only a segment of a file.
61
+ * 仅格式化文件的一部分.
57
62
  */
58
63
  rangeStart: number;
59
64
  /**
60
- * Format only a segment of a file.
65
+ * 仅格式化文件的一部分.
61
66
  * @default Number.POSITIVE_INFINITY
62
67
  */
63
68
  rangeEnd: number;
64
69
  /**
65
- * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
66
- * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
70
+ * 默认情况下,Prettier 将按原样包装 Markdown 文本,因为某些服务使用换行敏感渲染器.
71
+ * 在某些情况下,您可能希望依靠编辑器/查看器软包装,因此此选项允许您选择退出.
67
72
  * @default "preserve"
68
73
  */
69
74
  proseWrap: 'always' | 'never' | 'preserve';
70
75
  /**
71
- * Include parentheses around a sole arrow function parameter.
76
+ * 箭头函数参数周围包含括号.
72
77
  * @default "always"
73
78
  */
74
79
  arrowParens: 'avoid' | 'always';
75
80
  /**
76
- * Provide ability to support new languages to prettier.
81
+ * Prettier 提供支持新语言的能力.
77
82
  */
78
83
  plugins: Array<string | any>;
79
84
  /**
80
- * How to handle whitespaces in HTML.
85
+ * 如何处理 HTML 中的空格.
81
86
  * @default "css"
82
87
  */
83
88
  htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
84
89
  /**
85
- * Which end of line characters to apply.
90
+ * 应用哪个换行符.
86
91
  * @default "lf"
87
92
  */
88
93
  endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
89
94
  /**
90
- * Change when properties in objects are quoted.
95
+ * 引用对象中的属性时发生更改.
91
96
  * @default "as-needed"
92
97
  */
93
98
  quoteProps: 'as-needed' | 'consistent' | 'preserve';
94
99
  /**
95
- * Whether or not to indent the code inside <script> and <style> tags in Vue files.
100
+ * 是否缩进Vue文件中<script>和<style>标签内的代码.
96
101
  * @default false
97
102
  */
98
103
  vueIndentScriptAndStyle: boolean;
99
104
  /**
100
- * Enforce single attribute per line in HTML, Vue and JSX.
105
+ * HTMLVue JSX 中强制每行使用单一属性.
101
106
  * @default false
102
107
  */
103
108
  singleAttributePerLine: boolean;
@@ -192,6 +197,11 @@ interface OptionsTypeScriptParserOptions {
192
197
  * TypeScript 的附加解析器选项。
193
198
  */
194
199
  parserOptions?: Partial<ParserOptions>;
200
+ /**
201
+ * 应该识别类型的文件的全局模式.
202
+ * @default ['**\/*.{ts,tsx}']
203
+ */
204
+ filesTypeAware?: string[];
195
205
  }
196
206
  interface OptionsTypeScriptWithTypes {
197
207
  /**
@@ -289,6 +299,16 @@ interface OptionsConfig extends OptionsComponentExts {
289
299
  * @default 根据依赖关系自动检测
290
300
  */
291
301
  react?: boolean | OptionsReact | OptionsFiles;
302
+ /**
303
+ * 启用 svelte 支持.
304
+ *
305
+ * 需要安装:
306
+ * - `eslint-plugin-svelte`
307
+ * - `svelte-eslint-parser`
308
+ *
309
+ * @default false
310
+ */
311
+ svelte?: boolean;
292
312
  /**
293
313
  * 启用 unocss rules.
294
314
  *
@@ -352,6 +372,7 @@ interface OptionsConfig extends OptionsComponentExts {
352
372
  test?: FlatConfigItem['rules'];
353
373
  vue?: FlatConfigItem['rules'];
354
374
  react?: FlatConfigItem['rules'];
375
+ svelte?: FlatConfigItem['rules'];
355
376
  jsonc?: FlatConfigItem['rules'];
356
377
  markdown?: FlatConfigItem['rules'];
357
378
  yaml?: FlatConfigItem['rules'];
@@ -452,6 +473,7 @@ declare const GLOB_JSON5 = "**/*.json5";
452
473
  declare const GLOB_JSONC = "**/*.jsonc";
453
474
  declare const GLOB_MARKDOWN = "**/*.md";
454
475
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
476
+ declare const GLOB_SVELTE = "**/*.svelte";
455
477
  declare const GLOB_VUE = "**/*.vue";
456
478
  declare const GLOB_YAML = "**/*.y?(a)ml";
457
479
  declare const GLOB_TOML = "**/*.toml";
@@ -461,4 +483,4 @@ declare const GLOB_TESTS: string[];
461
483
  declare const GLOB_ALL_SRC: string[];
462
484
  declare const GLOB_EXCLUDE: string[];
463
485
 
464
- export { type Awaitable, type FlatConfigItem, 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_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIgnores, type OptionsIsInEditor, type OptionsOverrides, type OptionsReact, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOverridesConfig, type UserConfigItem, type WrapRuleConfig, combine, comments, lincy as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, lincy, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
486
+ export { type Awaitable, type FlatConfigItem, 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_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIgnores, type OptionsIsInEditor, type OptionsOverrides, type OptionsReact, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOverridesConfig, type UserConfigItem, type WrapRuleConfig, combine, comments, lincy as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, lincy, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.d.ts CHANGED
@@ -10,94 +10,99 @@ import { Rules as Rules$1 } from 'eslint-plugin-antfu';
10
10
  import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/eslint-plugin';
11
11
 
12
12
  /**
13
- * Vendor types from Prettier so we don't rely on the dependency.
13
+ * 来自 Prettier 的供应商类型,因此不依赖依赖项
14
14
  */
15
15
  type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
16
16
  interface VendoredPrettierOptionsRequired {
17
17
  /**
18
- * Specify the number of spaces per indentation-level.
18
+ * 指定换行的行长度.
19
+ * @default 200
20
+ */
21
+ printWidth: number;
22
+ /**
23
+ * 指定每个缩进的空格数.
19
24
  */
20
25
  tabWidth: number;
21
26
  /**
22
- * Indent lines with tabs instead of spaces
27
+ * 使用制表符而不是空格来缩进行
23
28
  */
24
29
  useTabs?: boolean;
25
30
  /**
26
- * Print semicolons at the ends of statements.
31
+ * 在语句末尾添加分号.
27
32
  */
28
33
  semi: boolean;
29
34
  /**
30
- * Use single quotes instead of double quotes.
35
+ * 使用单引号代替双引号.
31
36
  */
32
37
  singleQuote: boolean;
33
38
  /**
34
- * Use single quotes in JSX.
39
+ * JSX 中使用单引号.
35
40
  */
36
41
  jsxSingleQuote: boolean;
37
42
  /**
38
- * Print trailing commas wherever possible.
43
+ * 尽可能添加尾随逗号.
39
44
  */
40
45
  trailingComma: 'none' | 'es5' | 'all';
41
46
  /**
42
- * Print spaces between brackets in object literals.
47
+ * 对象文字中括号之间的空格.
43
48
  */
44
49
  bracketSpacing: boolean;
45
50
  /**
46
- * Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
47
- * alone on the next line (does not apply to self closing elements).
51
+ * 将多行 HTMLHTMLJSXVueAngular)元素的 `>` 放在最后一行的末尾,
52
+ * 而不是单独放在下一行(不适用于自闭合元素)。
48
53
  */
49
54
  bracketSameLine: boolean;
50
55
  /**
51
- * Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
52
- * @deprecated use bracketSameLine instead
56
+ * 将多行 JSX 元素的 `>` 放在最后一行的末尾,而不是单独放在下一行.
57
+ * @deprecated 使用 bracketSameLine 代替
53
58
  */
54
59
  jsxBracketSameLine: boolean;
55
60
  /**
56
- * Format only a segment of a file.
61
+ * 仅格式化文件的一部分.
57
62
  */
58
63
  rangeStart: number;
59
64
  /**
60
- * Format only a segment of a file.
65
+ * 仅格式化文件的一部分.
61
66
  * @default Number.POSITIVE_INFINITY
62
67
  */
63
68
  rangeEnd: number;
64
69
  /**
65
- * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
66
- * In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
70
+ * 默认情况下,Prettier 将按原样包装 Markdown 文本,因为某些服务使用换行敏感渲染器.
71
+ * 在某些情况下,您可能希望依靠编辑器/查看器软包装,因此此选项允许您选择退出.
67
72
  * @default "preserve"
68
73
  */
69
74
  proseWrap: 'always' | 'never' | 'preserve';
70
75
  /**
71
- * Include parentheses around a sole arrow function parameter.
76
+ * 箭头函数参数周围包含括号.
72
77
  * @default "always"
73
78
  */
74
79
  arrowParens: 'avoid' | 'always';
75
80
  /**
76
- * Provide ability to support new languages to prettier.
81
+ * Prettier 提供支持新语言的能力.
77
82
  */
78
83
  plugins: Array<string | any>;
79
84
  /**
80
- * How to handle whitespaces in HTML.
85
+ * 如何处理 HTML 中的空格.
81
86
  * @default "css"
82
87
  */
83
88
  htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore';
84
89
  /**
85
- * Which end of line characters to apply.
90
+ * 应用哪个换行符.
86
91
  * @default "lf"
87
92
  */
88
93
  endOfLine: 'auto' | 'lf' | 'crlf' | 'cr';
89
94
  /**
90
- * Change when properties in objects are quoted.
95
+ * 引用对象中的属性时发生更改.
91
96
  * @default "as-needed"
92
97
  */
93
98
  quoteProps: 'as-needed' | 'consistent' | 'preserve';
94
99
  /**
95
- * Whether or not to indent the code inside <script> and <style> tags in Vue files.
100
+ * 是否缩进Vue文件中<script>和<style>标签内的代码.
96
101
  * @default false
97
102
  */
98
103
  vueIndentScriptAndStyle: boolean;
99
104
  /**
100
- * Enforce single attribute per line in HTML, Vue and JSX.
105
+ * HTMLVue JSX 中强制每行使用单一属性.
101
106
  * @default false
102
107
  */
103
108
  singleAttributePerLine: boolean;
@@ -192,6 +197,11 @@ interface OptionsTypeScriptParserOptions {
192
197
  * TypeScript 的附加解析器选项。
193
198
  */
194
199
  parserOptions?: Partial<ParserOptions>;
200
+ /**
201
+ * 应该识别类型的文件的全局模式.
202
+ * @default ['**\/*.{ts,tsx}']
203
+ */
204
+ filesTypeAware?: string[];
195
205
  }
196
206
  interface OptionsTypeScriptWithTypes {
197
207
  /**
@@ -289,6 +299,16 @@ interface OptionsConfig extends OptionsComponentExts {
289
299
  * @default 根据依赖关系自动检测
290
300
  */
291
301
  react?: boolean | OptionsReact | OptionsFiles;
302
+ /**
303
+ * 启用 svelte 支持.
304
+ *
305
+ * 需要安装:
306
+ * - `eslint-plugin-svelte`
307
+ * - `svelte-eslint-parser`
308
+ *
309
+ * @default false
310
+ */
311
+ svelte?: boolean;
292
312
  /**
293
313
  * 启用 unocss rules.
294
314
  *
@@ -352,6 +372,7 @@ interface OptionsConfig extends OptionsComponentExts {
352
372
  test?: FlatConfigItem['rules'];
353
373
  vue?: FlatConfigItem['rules'];
354
374
  react?: FlatConfigItem['rules'];
375
+ svelte?: FlatConfigItem['rules'];
355
376
  jsonc?: FlatConfigItem['rules'];
356
377
  markdown?: FlatConfigItem['rules'];
357
378
  yaml?: FlatConfigItem['rules'];
@@ -452,6 +473,7 @@ declare const GLOB_JSON5 = "**/*.json5";
452
473
  declare const GLOB_JSONC = "**/*.jsonc";
453
474
  declare const GLOB_MARKDOWN = "**/*.md";
454
475
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
476
+ declare const GLOB_SVELTE = "**/*.svelte";
455
477
  declare const GLOB_VUE = "**/*.vue";
456
478
  declare const GLOB_YAML = "**/*.y?(a)ml";
457
479
  declare const GLOB_TOML = "**/*.toml";
@@ -461,4 +483,4 @@ declare const GLOB_TESTS: string[];
461
483
  declare const GLOB_ALL_SRC: string[];
462
484
  declare const GLOB_EXCLUDE: string[];
463
485
 
464
- export { type Awaitable, type FlatConfigItem, 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_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIgnores, type OptionsIsInEditor, type OptionsOverrides, type OptionsReact, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOverridesConfig, type UserConfigItem, type WrapRuleConfig, combine, comments, lincy as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, lincy, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
486
+ export { type Awaitable, type FlatConfigItem, 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_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIgnores, type OptionsIsInEditor, type OptionsOverrides, type OptionsReact, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOverridesConfig, type UserConfigItem, type WrapRuleConfig, combine, comments, lincy as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, lincy, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.js CHANGED
@@ -47,6 +47,7 @@ var GLOB_JSON5 = "**/*.json5";
47
47
  var GLOB_JSONC = "**/*.jsonc";
48
48
  var GLOB_MARKDOWN = "**/*.md";
49
49
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
50
+ var GLOB_SVELTE = "**/*.svelte";
50
51
  var GLOB_VUE = "**/*.vue";
51
52
  var GLOB_YAML = "**/*.y?(a)ml";
52
53
  var GLOB_TOML = "**/*.toml";
@@ -63,6 +64,7 @@ var GLOB_ALL_SRC = [
63
64
  GLOB_JSON,
64
65
  GLOB_JSON5,
65
66
  GLOB_MARKDOWN,
67
+ GLOB_SVELTE,
66
68
  GLOB_VUE,
67
69
  GLOB_YAML,
68
70
  GLOB_HTML
@@ -125,6 +127,7 @@ async function imports(options = {}) {
125
127
  },
126
128
  rules: {
127
129
  "antfu/import-dedupe": "error",
130
+ "antfu/no-import-dist": "off",
128
131
  "antfu/no-import-node-modules-by-path": "error",
129
132
  "import/first": "error",
130
133
  "import/no-duplicates": "error",
@@ -230,7 +233,6 @@ async function javascript(options = {}) {
230
233
  "no-multi-str": "error",
231
234
  "no-new": "error",
232
235
  "no-new-func": "error",
233
- "no-new-object": "error",
234
236
  "no-new-symbol": "error",
235
237
  "no-new-wrappers": "error",
236
238
  "no-obj-calls": "error",
@@ -414,7 +416,6 @@ async function jsdoc(options = {}) {
414
416
  {
415
417
  name: "eslint:jsdoc",
416
418
  plugins: {
417
- // @ts-expect-error missing types
418
419
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
419
420
  },
420
421
  rules: {
@@ -804,6 +805,7 @@ async function formatters(options = {}, stylistic2 = {}) {
804
805
  [`format/${formater}`]: [
805
806
  "error",
806
807
  formater === "prettier" ? {
808
+ printWidth: 200,
807
809
  ...prettierOptions,
808
810
  embeddedLanguageFormatting: "off",
809
811
  parser: "markdown"
@@ -1298,6 +1300,9 @@ async function typescript(options = {}) {
1298
1300
  GLOB_SRC,
1299
1301
  ...componentExts.map((ext) => `**/*.${ext}`)
1300
1302
  ];
1303
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1304
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1305
+ const isTypeAware = !!tsconfigPath;
1301
1306
  const typeAwareRules = {
1302
1307
  "dot-notation": "off",
1303
1308
  "no-implied-eval": "off",
@@ -1319,7 +1324,6 @@ async function typescript(options = {}) {
1319
1324
  "ts/restrict-template-expressions": "error",
1320
1325
  "ts/unbound-method": "error"
1321
1326
  };
1322
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1323
1327
  const [
1324
1328
  pluginTs,
1325
1329
  parserTs
@@ -1327,29 +1331,43 @@ async function typescript(options = {}) {
1327
1331
  interopDefault(import("@typescript-eslint/eslint-plugin")),
1328
1332
  interopDefault(import("@typescript-eslint/parser"))
1329
1333
  ]);
1330
- return [
1331
- {
1332
- // Install the plugins without globs, so they can be configured separately.
1333
- name: "eslint:typescript:setup",
1334
- plugins: {
1335
- antfu: default2,
1336
- ts: pluginTs
1337
- }
1338
- },
1339
- {
1340
- files,
1334
+ function makeParser(typeAware, files2, ignores2) {
1335
+ return {
1336
+ files: files2,
1337
+ ...ignores2 ? { ignores: ignores2 } : {},
1341
1338
  languageOptions: {
1342
1339
  parser: parserTs,
1343
1340
  parserOptions: {
1344
1341
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1345
1342
  sourceType: "module",
1346
- ...tsconfigPath ? {
1343
+ ...typeAware ? {
1347
1344
  project: tsconfigPath,
1348
1345
  tsconfigRootDir: process2.cwd()
1349
1346
  } : {},
1350
1347
  ...parserOptions
1351
1348
  }
1352
1349
  },
1350
+ name: `eslint:typescript:${typeAware ? "type-aware-parser" : "parser"}`
1351
+ };
1352
+ }
1353
+ return [
1354
+ {
1355
+ // Install the plugins without globs, so they can be configured separately.
1356
+ name: "eslint:typescript:setup",
1357
+ plugins: {
1358
+ antfu: default2,
1359
+ ts: pluginTs
1360
+ }
1361
+ },
1362
+ // assign type-aware parser for type-aware files and type-unaware parser for the rest
1363
+ ...isTypeAware ? [
1364
+ makeParser(true, filesTypeAware),
1365
+ makeParser(false, files, filesTypeAware)
1366
+ ] : [
1367
+ makeParser(false, files)
1368
+ ],
1369
+ {
1370
+ files,
1353
1371
  name: "eslint:typescript:rules",
1354
1372
  rules: {
1355
1373
  ...renameRules(
@@ -1387,6 +1405,13 @@ async function typescript(options = {}) {
1387
1405
  "ts/prefer-ts-expect-error": "error",
1388
1406
  "ts/triple-slash-reference": "off",
1389
1407
  "ts/unified-signatures": "off",
1408
+ ...overrides
1409
+ }
1410
+ },
1411
+ {
1412
+ files: filesTypeAware,
1413
+ name: "eslint:typescript:rules-type-aware",
1414
+ rules: {
1390
1415
  ...tsconfigPath ? typeAwareRules : {},
1391
1416
  ...overrides
1392
1417
  }
@@ -1571,6 +1596,7 @@ async function vue(options = {}) {
1571
1596
  }],
1572
1597
  "vue/component-name-in-template-casing": ["error", "PascalCase"],
1573
1598
  "vue/component-options-name-casing": ["error", "PascalCase"],
1599
+ "vue/component-tags-order": "off",
1574
1600
  "vue/custom-event-name-casing": vueVersion === "3" ? ["error", "camelCase"] : ["error", "kebab-case"],
1575
1601
  ...vueVersion === "2" ? {
1576
1602
  "vue/require-explicit-emits": "off"
@@ -1730,7 +1756,7 @@ async function toml(options = {}) {
1730
1756
  ]);
1731
1757
  return [
1732
1758
  {
1733
- name: "antfu:toml:setup",
1759
+ name: "eslint:toml:setup",
1734
1760
  plugins: {
1735
1761
  toml: pluginToml
1736
1762
  }
@@ -1740,7 +1766,7 @@ async function toml(options = {}) {
1740
1766
  languageOptions: {
1741
1767
  parser: parserToml
1742
1768
  },
1743
- name: "antfu:toml:rules",
1769
+ name: "eslint:toml:rules",
1744
1770
  rules: {
1745
1771
  "style/spaced-comment": "off",
1746
1772
  "toml/comma-style": "error",
@@ -1795,7 +1821,7 @@ async function lincy(options = {}, ...userConfigs) {
1795
1821
  const {
1796
1822
  componentExts = [],
1797
1823
  gitignore: enableGitignore = true,
1798
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
1824
+ isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1799
1825
  overrides = {},
1800
1826
  react: enableReact = ReactPackages.some((i) => isPackageExists3(i)),
1801
1827
  typescript: enableTypeScript = isPackageExists3("typescript"),
@@ -1874,12 +1900,10 @@ async function lincy(options = {}, ...userConfigs) {
1874
1900
  }));
1875
1901
  }
1876
1902
  if (enableUnoCSS) {
1877
- configs.push(unocss(
1878
- {
1879
- ...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
1880
- overrides: overrides.unocss
1881
- }
1882
- ));
1903
+ configs.push(unocss({
1904
+ ...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
1905
+ overrides: overrides.unocss
1906
+ }));
1883
1907
  }
1884
1908
  if (options.jsonc ?? true) {
1885
1909
  configs.push(
@@ -1906,13 +1930,11 @@ async function lincy(options = {}, ...userConfigs) {
1906
1930
  }));
1907
1931
  }
1908
1932
  if (options.markdown ?? true) {
1909
- configs.push(markdown(
1910
- {
1911
- ...typeof options.markdown !== "boolean" ? options.markdown : {},
1912
- componentExts,
1913
- overrides: overrides.markdown
1914
- }
1915
- ));
1933
+ configs.push(markdown({
1934
+ ...typeof options.markdown !== "boolean" ? options.markdown : {},
1935
+ componentExts,
1936
+ overrides: overrides.markdown
1937
+ }));
1916
1938
  }
1917
1939
  if (options.formatters) {
1918
1940
  configs.push(formatters(
@@ -1955,6 +1977,7 @@ export {
1955
1977
  GLOB_SRC,
1956
1978
  GLOB_SRC_EXT,
1957
1979
  GLOB_STYLE,
1980
+ GLOB_SVELTE,
1958
1981
  GLOB_TESTS,
1959
1982
  GLOB_TOML,
1960
1983
  GLOB_TS,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "4.2.3",
4
+ "version": "4.2.5",
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/)",
@@ -64,66 +64,66 @@
64
64
  "dependencies": {
65
65
  "@antfu/eslint-define-config": "1.23.0-2",
66
66
  "@antfu/install-pkg": "^0.3.1",
67
- "@stylistic/eslint-plugin": "1.5.1",
68
- "@typescript-eslint/eslint-plugin": "^6.14.0",
69
- "@typescript-eslint/parser": "^6.14.0",
67
+ "@stylistic/eslint-plugin": "1.5.4",
68
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
69
+ "@typescript-eslint/parser": "^6.19.0",
70
70
  "eslint-config-flat-gitignore": "^0.1.2",
71
71
  "eslint-merge-processors": "^0.1.0",
72
72
  "eslint-parser-plain": "^0.1.0",
73
- "eslint-plugin-antfu": "^2.0.0",
73
+ "eslint-plugin-antfu": "^2.1.1",
74
74
  "eslint-plugin-eslint-comments": "^3.2.0",
75
- "eslint-plugin-i": "^2.29.0",
76
- "eslint-plugin-jsdoc": "^46.9.0",
77
- "eslint-plugin-jsonc": "^2.10.0",
75
+ "eslint-plugin-i": "^2.29.1",
76
+ "eslint-plugin-jsdoc": "^48.0.2",
77
+ "eslint-plugin-jsonc": "^2.12.2",
78
78
  "eslint-plugin-markdown": "^3.0.1",
79
- "eslint-plugin-n": "^16.4.0",
79
+ "eslint-plugin-n": "^16.6.2",
80
80
  "eslint-plugin-no-only-tests": "^3.1.0",
81
81
  "eslint-plugin-perfectionist": "^2.5.0",
82
- "eslint-plugin-toml": "^0.7.1",
83
- "eslint-plugin-unicorn": "^49.0.0",
82
+ "eslint-plugin-toml": "^0.9.2",
83
+ "eslint-plugin-unicorn": "^50.0.1",
84
84
  "eslint-plugin-unused-imports": "^3.0.0",
85
- "eslint-plugin-vitest": "^0.3.16",
86
- "eslint-plugin-vue": "^9.19.2",
87
- "eslint-plugin-yml": "^1.10.0",
85
+ "eslint-plugin-vitest": "^0.3.20",
86
+ "eslint-plugin-vue": "^9.20.1",
87
+ "eslint-plugin-yml": "^1.12.2",
88
88
  "eslint-processor-vue-blocks": "^0.1.1",
89
89
  "globals": "^13.24.0",
90
90
  "jsonc-eslint-parser": "^2.4.0",
91
91
  "local-pkg": "^0.5.0",
92
92
  "prompts": "^2.4.2",
93
93
  "toml-eslint-parser": "^0.9.3",
94
- "vue-eslint-parser": "^9.3.2",
94
+ "vue-eslint-parser": "^9.4.0",
95
95
  "yaml-eslint-parser": "^1.2.2"
96
96
  },
97
97
  "devDependencies": {
98
98
  "@antfu/ni": "^0.21.12",
99
- "@eslint-types/jsdoc": "46.9.0",
100
- "@eslint-types/typescript-eslint": "^6.12.0",
101
- "@eslint-types/unicorn": "^49.0.0",
99
+ "@eslint-types/jsdoc": "48.0.2",
100
+ "@eslint-types/typescript-eslint": "^6.18.1",
101
+ "@eslint-types/unicorn": "^50.0.1",
102
102
  "@lincy/eslint-config": "workspace:*",
103
- "@stylistic/eslint-plugin-migrate": "^1.5.1",
104
- "@types/eslint": "^8.44.8",
105
- "@types/node": "^20.10.4",
103
+ "@stylistic/eslint-plugin-migrate": "^1.5.4",
104
+ "@types/eslint": "^8.56.2",
105
+ "@types/node": "^20.11.5",
106
106
  "@types/prompts": "^2.4.9",
107
- "@unocss/eslint-plugin": "^0.58.0",
108
- "bumpp": "^9.2.1",
109
- "eslint": "^8.55.0",
110
- "eslint-flat-config-viewer": "^0.1.3",
107
+ "@unocss/eslint-plugin": "^0.58.3",
108
+ "bumpp": "^9.3.0",
109
+ "eslint": "^8.56.0",
110
+ "eslint-flat-config-viewer": "^0.1.11",
111
111
  "eslint-plugin-format": "^0.1.0",
112
112
  "eslint-plugin-react": "^7.33.2",
113
113
  "eslint-plugin-react-hooks": "^4.6.0",
114
114
  "eslint-plugin-react-refresh": "^0.4.5",
115
115
  "esno": "^4.0.0",
116
116
  "lint-staged": "^15.2.0",
117
- "prettier": "^3.1.1",
117
+ "prettier": "^3.2.4",
118
118
  "rimraf": "^5.0.5",
119
119
  "simple-git-hooks": "^2.9.0",
120
120
  "simple-open-url": "^3.0.1",
121
- "sucrase": "^3.34.0",
121
+ "sucrase": "^3.35.0",
122
122
  "tsup": "^8.0.1",
123
123
  "typescript": "^5.3.3",
124
124
  "unbuild": "^2.0.0",
125
- "vitest": "^1.0.4",
126
- "vue": "^3.3.11"
125
+ "vitest": "^1.2.1",
126
+ "vue": "^3.4.15"
127
127
  },
128
128
  "pnpm": {
129
129
  "peerDependencyRules": {