@lincy/eslint-config 4.2.2 → 4.2.3

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
@@ -70,6 +70,7 @@ For example:
70
70
  // 在 IDE 中静默样式规则,但仍会自动修复它们
71
71
  "eslint.rules.customizations": [
72
72
  { "rule": "style/*", "severity": "off" },
73
+ { "rule": "format/*", "severity": "off" },
73
74
  { "rule": "*-indent", "severity": "off" },
74
75
  { "rule": "*-spacing", "severity": "off" },
75
76
  { "rule": "*-spaces", "severity": "off" },
@@ -91,7 +92,8 @@ For example:
91
92
  "markdown",
92
93
  "json",
93
94
  "jsonc",
94
- "yaml"
95
+ "yaml",
96
+ "toml"
95
97
  ]
96
98
  }
97
99
  ```
@@ -135,7 +137,7 @@ export default lincy({
135
137
  /**
136
138
  * 是否启用 stylistic 格式化规则
137
139
  * @default 默认值: true
138
- * @example 可选: false | { indent?: number | 'tab'; quotes?: 'single' | 'double'; jsx?: boolean; semi?: boolean}
140
+ * @example 可选: false | { indent?: number | 'tab'; quotes?: 'single' | 'double'; jsx?: boolean; semi?: boolean }
139
141
  */
140
142
  stylistic: true,
141
143
  /**
@@ -147,7 +149,7 @@ export default lincy({
147
149
  /**
148
150
  * 是否启用 vue 规则
149
151
  * @default 默认值: 检测是否安装vue依赖,
150
- * @example 可选: false | true | { files?: string[] }
152
+ * @example 可选: false | true | { files?: string[]; sfcBlocks: boolean }
151
153
  */
152
154
  vue: true,
153
155
  /**
@@ -180,6 +182,12 @@ export default lincy({
180
182
  * @example 可选: false | { files?: string[] }
181
183
  */
182
184
  yaml: false,
185
+ /**
186
+ * 是否启用 toml 规则
187
+ * @default 默认值: false,
188
+ * @example 可选: true
189
+ */
190
+ toml: false,
183
191
  /**
184
192
  * 是否启用 .gitignore 文件
185
193
  * @default 默认值: true,
@@ -201,13 +209,50 @@ export default lincy({
201
209
  /**
202
210
  * 是否启用 formatters 规则
203
211
  * @default 默认值: false,
204
- * @example 可选: true | { css?: 'prettier' | boolean; html?: 'prettier' | boolean; toml?: 'dprint' | boolean; markdown?: 'prettier' | 'dprint' | boolean }
212
+ * @example 可选: true | { css?: 'prettier' | boolean; html?: 'prettier' | boolean; markdown?: 'prettier' | 'dprint' | boolean }
205
213
  */
206
214
  formatters: false,
207
215
  /**
208
216
  * 覆盖规则
209
217
  */
210
- overrides: {},
218
+ overrides: {
219
+ ignores: [
220
+ // 忽略的路径/文件
221
+ ],
222
+ javascript: {
223
+ // javascript 规则
224
+ },
225
+ typescript: {
226
+ // typescript 规则
227
+ },
228
+ stylistic: {
229
+ // stylistic 规则
230
+ },
231
+ test: {
232
+ // test 规则
233
+ },
234
+ vue: {
235
+ // vue 规则
236
+ },
237
+ react: {
238
+ // react 规则
239
+ },
240
+ jsonc: {
241
+ // jsonc 规则
242
+ },
243
+ yaml: {
244
+ // yaml 规则
245
+ },
246
+ toml: {
247
+ // toml 规则
248
+ },
249
+ markdown: {
250
+ // markdown 规则
251
+ },
252
+ unocss: {
253
+ // unocss 规则
254
+ }
255
+ },
211
256
 
212
257
  // 工厂函数第一个参数默认为各规则的开关, 但是也可以作为追加规则使用, 当包含以下键名将会自动整合到一个规则里
213
258
  files: [],
@@ -261,6 +306,9 @@ export default lincy(
261
306
 
262
307
  您还可以导入非常细粒度的配置并根据需要组合它们:
263
308
 
309
+ <details>
310
+ <summary>点击展开例子</summary>
311
+
264
312
  ```js
265
313
  // eslint.config.js
266
314
  import {
@@ -278,6 +326,7 @@ import {
278
326
  sortPackageJson,
279
327
  sortTsconfig,
280
328
  stylistic,
329
+ toml,
281
330
  typescript,
282
331
  unicorn,
283
332
  unocss,
@@ -301,10 +350,13 @@ export default combine(
301
350
  unocss(/* Options */),
302
351
  jsonc(),
303
352
  yaml(),
353
+ toml(),
304
354
  markdown(),
305
355
  )
306
356
  ```
307
357
 
358
+ </details>
359
+
308
360
  查看 [configs](https://github.com/lincenying/eslint-config/blob/main/src/configs) 和 [factory](https://github.com/lincenying/eslint-config/blob/main/src/factory.ts)了解更多详细信息。
309
361
 
310
362
  ### 插件重命名
@@ -337,7 +389,6 @@ import lincy from '@lincy/eslint-config'
337
389
 
338
390
  export default lincy(
339
391
  {
340
- isInEditor: true,
341
392
  vue: true,
342
393
  jsx: true,
343
394
  react: true,
@@ -416,11 +467,47 @@ export default lincy({
416
467
 
417
468
  提供了一些可选配置,默认情况下不包含它们的依赖项
418
469
 
470
+ #### Formatters
471
+
472
+ 使用外部格式化程序来格式化 ESLint 无法处理的文件(.css、.html 等)。 由 [eslint-plugin-format](https://github.com/antfu/eslint-plugin-format) 提供支持
473
+
474
+ ```js
475
+ // eslint.config.js
476
+ import lincy from '@lincy/eslint-config'
477
+
478
+ export default lincy({
479
+ formatters: {
480
+ /**
481
+ * 格式化 CSS、LESS、SCSS 文件,以及 Vue 中的 `<style>` 块
482
+ * 默认使用 Prettier
483
+ */
484
+ css: true,
485
+ /**
486
+ * 格式化 HTML 文件
487
+ * 默认使用 Prettier
488
+ */
489
+ html: true,
490
+ /**
491
+ * 格式化 Markdown 文件
492
+ * 支持 Prettier 和 dprint
493
+ * 默认使用 Prettier
494
+ */
495
+ markdown: 'prettier'
496
+ }
497
+ })
498
+ ```
499
+
500
+ 运行“npx eslint”会提示您安装所需的依赖项,当然,也可以手动安装它们:
501
+
502
+ ```bash
503
+ pnpm add eslint-plugin-format -D
504
+ ```
505
+
419
506
  #### React
420
507
 
421
508
  当检测到依赖安装了`react`, 则默认开启
422
509
 
423
- 运行“npx eslint”会提示您安装所需的依赖项,当然,您也可以手动安装它们:
510
+ 运行“npx eslint”会提示您安装所需的依赖项,当然,也可以手动安装它们:
424
511
 
425
512
  ```bash
426
513
  pnpm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
@@ -439,12 +526,14 @@ export default lincy({
439
526
  })
440
527
  ```
441
528
 
442
- 运行“npx eslint”会提示您安装所需的依赖项,当然,您也可以手动安装它们:
529
+ 运行“npx eslint”会提示您安装所需的依赖项,当然,也可以手动安装它们:
443
530
 
444
531
  ```bash
445
532
  pnpm i -D @unocss/eslint-plugin
446
533
  ```
447
534
 
535
+ ### 可选规则
536
+
448
537
  #### `perfectionist` (sorting)
449
538
 
450
539
  这个插件 [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) 允许你排序对象键名,导入,自动修复等。
package/dist/index.cjs CHANGED
@@ -49,6 +49,7 @@ __export(src_exports, {
49
49
  GLOB_SRC_EXT: () => GLOB_SRC_EXT,
50
50
  GLOB_STYLE: () => GLOB_STYLE,
51
51
  GLOB_TESTS: () => GLOB_TESTS,
52
+ GLOB_TOML: () => GLOB_TOML,
52
53
  GLOB_TS: () => GLOB_TS,
53
54
  GLOB_TSX: () => GLOB_TSX,
54
55
  GLOB_VUE: () => GLOB_VUE,
@@ -76,6 +77,7 @@ __export(src_exports, {
76
77
  stylistic: () => stylistic,
77
78
  test: () => test,
78
79
  toArray: () => toArray,
80
+ toml: () => toml,
79
81
  typescript: () => typescript,
80
82
  unicorn: () => unicorn,
81
83
  unocss: () => unocss,
@@ -135,6 +137,7 @@ var GLOB_MARKDOWN = "**/*.md";
135
137
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
136
138
  var GLOB_VUE = "**/*.vue";
137
139
  var GLOB_YAML = "**/*.y?(a)ml";
140
+ var GLOB_TOML = "**/*.toml";
138
141
  var GLOB_HTML = "**/*.htm?(l)";
139
142
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
140
143
  var GLOB_TESTS = [
@@ -600,44 +603,15 @@ async function jsonc(options = {}) {
600
603
  }
601
604
 
602
605
  // src/configs/markdown.ts
603
- async function markdown(options = {}, formatMarkdown = false) {
606
+ var parserPlain = __toESM(require("eslint-parser-plain"), 1);
607
+ var import_eslint_merge_processors = require("eslint-merge-processors");
608
+ async function markdown(options = {}) {
604
609
  const {
605
610
  componentExts = [],
606
611
  files = [GLOB_MARKDOWN],
607
612
  overrides = {}
608
613
  } = options;
609
614
  const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
610
- const baseProcessor = markdown2.processors.markdown;
611
- const processor = !formatMarkdown ? {
612
- meta: {
613
- name: "markdown-processor"
614
- },
615
- supportsAutofix: true,
616
- ...baseProcessor
617
- } : {
618
- meta: {
619
- name: "markdown-processor-with-content"
620
- },
621
- postprocess(messages, filename) {
622
- const markdownContent = messages.pop();
623
- const codeSnippets = baseProcessor.postprocess(messages, filename);
624
- return [
625
- ...markdownContent || [],
626
- ...codeSnippets || []
627
- ];
628
- },
629
- preprocess(text, filename) {
630
- const result = baseProcessor.preprocess(text, filename);
631
- return [
632
- ...result,
633
- {
634
- filename: ".__markdown_content__",
635
- text
636
- }
637
- ];
638
- },
639
- supportsAutofix: true
640
- };
641
615
  return [
642
616
  {
643
617
  name: "eslint:markdown:setup",
@@ -649,7 +623,17 @@ async function markdown(options = {}, formatMarkdown = false) {
649
623
  files,
650
624
  ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
651
625
  name: "eslint:markdown:processor",
652
- processor
626
+ processor: (0, import_eslint_merge_processors.mergeProcessors)([
627
+ markdown2.processors.markdown,
628
+ import_eslint_merge_processors.processorPassThrough
629
+ ])
630
+ },
631
+ {
632
+ files,
633
+ languageOptions: {
634
+ parser: parserPlain
635
+ },
636
+ name: "eslint:markdown:parser"
653
637
  },
654
638
  {
655
639
  files: [
@@ -725,6 +709,9 @@ async function perfectionist() {
725
709
  ];
726
710
  }
727
711
 
712
+ // src/configs/formatters.ts
713
+ var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
714
+
728
715
  // src/configs/stylistic.ts
729
716
  var StylisticConfigDefaults = {
730
717
  indent: 4,
@@ -781,11 +768,10 @@ async function formatters(options = {}, stylistic2 = {}) {
781
768
  ]);
782
769
  if (options === true) {
783
770
  options = {
784
- css: true,
785
- graphql: false,
771
+ css: false,
772
+ graphql: true,
786
773
  html: true,
787
- markdown: true,
788
- toml: true
774
+ markdown: true
789
775
  };
790
776
  }
791
777
  const {
@@ -798,9 +784,10 @@ async function formatters(options = {}, stylistic2 = {}) {
798
784
  };
799
785
  const prettierOptions = Object.assign(
800
786
  {
787
+ endOfLine: "lf",
801
788
  semi,
802
789
  singleQuote: quotes === "single",
803
- tabWidth: typeof indent === "number" ? indent : 2,
790
+ tabWidth: typeof indent === "number" ? indent : 4,
804
791
  trailingComma: "all",
805
792
  useTabs: indent === "tab"
806
793
  },
@@ -808,7 +795,7 @@ async function formatters(options = {}, stylistic2 = {}) {
808
795
  );
809
796
  const dprintOptions = Object.assign(
810
797
  {
811
- indentWidth: typeof indent === "number" ? indent : 2,
798
+ indentWidth: typeof indent === "number" ? indent : 4,
812
799
  quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
813
800
  useTabs: indent === "tab"
814
801
  },
@@ -828,7 +815,7 @@ async function formatters(options = {}, stylistic2 = {}) {
828
815
  {
829
816
  files: [GLOB_CSS, GLOB_POSTCSS],
830
817
  languageOptions: {
831
- parser: pluginFormat.parserPlain
818
+ parser: parserPlain2
832
819
  },
833
820
  name: "eslint:formatter:css",
834
821
  rules: {
@@ -844,7 +831,7 @@ async function formatters(options = {}, stylistic2 = {}) {
844
831
  {
845
832
  files: [GLOB_SCSS],
846
833
  languageOptions: {
847
- parser: pluginFormat.parserPlain
834
+ parser: parserPlain2
848
835
  },
849
836
  name: "eslint:formatter:scss",
850
837
  rules: {
@@ -860,7 +847,7 @@ async function formatters(options = {}, stylistic2 = {}) {
860
847
  {
861
848
  files: [GLOB_LESS],
862
849
  languageOptions: {
863
- parser: pluginFormat.parserPlain
850
+ parser: parserPlain2
864
851
  },
865
852
  name: "eslint:formatter:less",
866
853
  rules: {
@@ -879,7 +866,7 @@ async function formatters(options = {}, stylistic2 = {}) {
879
866
  configs.push({
880
867
  files: ["**/*.html"],
881
868
  languageOptions: {
882
- parser: pluginFormat.parserPlain
869
+ parser: parserPlain2
883
870
  },
884
871
  name: "eslint:formatter:html",
885
872
  rules: {
@@ -893,30 +880,12 @@ async function formatters(options = {}, stylistic2 = {}) {
893
880
  }
894
881
  });
895
882
  }
896
- if (options.toml) {
897
- configs.push({
898
- files: ["**/*.toml"],
899
- languageOptions: {
900
- parser: pluginFormat.parserPlain
901
- },
902
- name: "eslint:formatter:toml",
903
- rules: {
904
- "format/dprint": [
905
- "error",
906
- {
907
- ...dprintOptions,
908
- language: "toml"
909
- }
910
- ]
911
- }
912
- });
913
- }
914
883
  if (options.markdown) {
915
884
  const formater = options.markdown === true ? "prettier" : options.markdown;
916
885
  configs.push({
917
- files: ["**/*.__markdown_content__"],
886
+ files: [GLOB_MARKDOWN],
918
887
  languageOptions: {
919
- parser: pluginFormat.parserPlain
888
+ parser: parserPlain2
920
889
  },
921
890
  name: "eslint:formatter:markdown",
922
891
  rules: {
@@ -938,7 +907,7 @@ async function formatters(options = {}, stylistic2 = {}) {
938
907
  configs.push({
939
908
  files: ["**/*.graphql"],
940
909
  languageOptions: {
941
- parser: pluginFormat.parserPlain
910
+ parser: parserPlain2
942
911
  },
943
912
  name: "eslint:formatter:graphql",
944
913
  rules: {
@@ -1213,15 +1182,11 @@ async function sortPackageJson() {
1213
1182
  },
1214
1183
  {
1215
1184
  order: { type: "asc" },
1216
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1217
- },
1218
- {
1219
- order: { type: "asc" },
1220
- pathPattern: "^resolutions$"
1185
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1221
1186
  },
1222
1187
  {
1223
1188
  order: { type: "asc" },
1224
- pathPattern: "^pnpm.overrides$"
1189
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1225
1190
  },
1226
1191
  {
1227
1192
  order: [
@@ -1399,6 +1364,7 @@ async function test(options = {}) {
1399
1364
  "node/prefer-global/process": "off",
1400
1365
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1401
1366
  "test/no-identical-title": "error",
1367
+ "test/no-import-node-test": "error",
1402
1368
  "test/no-only-tests": isInEditor ? "off" : "error",
1403
1369
  "test/prefer-hooks-in-order": "error",
1404
1370
  "test/prefer-lowercase-title": "error",
@@ -1587,6 +1553,7 @@ async function unicorn() {
1587
1553
  async function unocss(options = {}) {
1588
1554
  const {
1589
1555
  attributify = true,
1556
+ overrides = {},
1590
1557
  strict = false
1591
1558
  } = options;
1592
1559
  await ensurePackages([
@@ -1610,13 +1577,15 @@ async function unocss(options = {}) {
1610
1577
  } : {},
1611
1578
  ...strict ? {
1612
1579
  "unocss/blocklist": "error"
1613
- } : {}
1580
+ } : {},
1581
+ ...overrides
1614
1582
  }
1615
1583
  }
1616
1584
  ];
1617
1585
  }
1618
1586
 
1619
1587
  // src/configs/vue.ts
1588
+ var import_eslint_merge_processors2 = require("eslint-merge-processors");
1620
1589
  var import_local_pkg3 = require("local-pkg");
1621
1590
  var pkg = (0, import_local_pkg3.getPackageInfoSync)("vue");
1622
1591
  var vueVersion = pkg && pkg.version;
@@ -1628,16 +1597,19 @@ async function vue(options = {}) {
1628
1597
  overrides = {},
1629
1598
  stylistic: stylistic2 = true
1630
1599
  } = options;
1600
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1631
1601
  const {
1632
1602
  indent = 4
1633
1603
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1634
1604
  const [
1635
1605
  pluginVue,
1636
- parserVue
1606
+ parserVue,
1607
+ processorVueBlocks
1637
1608
  ] = await Promise.all([
1638
1609
  // @ts-expect-error missing types
1639
1610
  interopDefault(import("eslint-plugin-vue")),
1640
- interopDefault(import("vue-eslint-parser"))
1611
+ interopDefault(import("vue-eslint-parser")),
1612
+ interopDefault(import("eslint-processor-vue-blocks"))
1641
1613
  ]);
1642
1614
  return [
1643
1615
  {
@@ -1660,7 +1632,16 @@ async function vue(options = {}) {
1660
1632
  }
1661
1633
  },
1662
1634
  name: "eslint:vue:rules",
1663
- processor: pluginVue.processors[".vue"],
1635
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
1636
+ pluginVue.processors[".vue"],
1637
+ processorVueBlocks({
1638
+ ...sfcBlocks,
1639
+ blocks: {
1640
+ ...sfcBlocks.blocks,
1641
+ styles: true
1642
+ }
1643
+ })
1644
+ ]),
1664
1645
  rules: {
1665
1646
  ...pluginVue.configs.base.rules,
1666
1647
  ...vueVersion === "3" ? {
@@ -1818,6 +1799,65 @@ async function yaml(options = {}) {
1818
1799
  ];
1819
1800
  }
1820
1801
 
1802
+ // src/configs/toml.ts
1803
+ async function toml(options = {}) {
1804
+ const {
1805
+ files = [GLOB_TOML],
1806
+ overrides = {},
1807
+ stylistic: stylistic2 = true
1808
+ } = options;
1809
+ const {
1810
+ indent = 4
1811
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1812
+ const [
1813
+ pluginToml,
1814
+ parserToml
1815
+ ] = await Promise.all([
1816
+ interopDefault(import("eslint-plugin-toml")),
1817
+ interopDefault(import("toml-eslint-parser"))
1818
+ ]);
1819
+ return [
1820
+ {
1821
+ name: "antfu:toml:setup",
1822
+ plugins: {
1823
+ toml: pluginToml
1824
+ }
1825
+ },
1826
+ {
1827
+ files,
1828
+ languageOptions: {
1829
+ parser: parserToml
1830
+ },
1831
+ name: "antfu:toml:rules",
1832
+ rules: {
1833
+ "style/spaced-comment": "off",
1834
+ "toml/comma-style": "error",
1835
+ "toml/keys-order": "error",
1836
+ "toml/no-space-dots": "error",
1837
+ "toml/no-unreadable-number-separator": "error",
1838
+ "toml/precision-of-fractional-seconds": "error",
1839
+ "toml/precision-of-integer": "error",
1840
+ "toml/tables-order": "error",
1841
+ "toml/vue-custom-block/no-parsing-error": "error",
1842
+ ...stylistic2 ? {
1843
+ "toml/array-bracket-newline": "error",
1844
+ "toml/array-bracket-spacing": "error",
1845
+ "toml/array-element-newline": "error",
1846
+ "toml/indent": ["error", indent === "tab" ? 4 : indent],
1847
+ "toml/inline-table-curly-spacing": "error",
1848
+ "toml/key-spacing": "error",
1849
+ "toml/padding-line-between-pairs": "error",
1850
+ "toml/padding-line-between-tables": "error",
1851
+ "toml/quoted-keys": "error",
1852
+ "toml/spaced-comment": "error",
1853
+ "toml/table-bracket-spacing": "error"
1854
+ } : {},
1855
+ ...overrides
1856
+ }
1857
+ }
1858
+ ];
1859
+ }
1860
+
1821
1861
  // src/factory.ts
1822
1862
  var flatConfigProps = [
1823
1863
  "files",
@@ -1923,7 +1963,10 @@ async function lincy(options = {}, ...userConfigs) {
1923
1963
  }
1924
1964
  if (enableUnoCSS) {
1925
1965
  configs.push(unocss(
1926
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1966
+ {
1967
+ ...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
1968
+ overrides: overrides.unocss
1969
+ }
1927
1970
  ));
1928
1971
  }
1929
1972
  if (options.jsonc ?? true) {
@@ -1944,14 +1987,19 @@ async function lincy(options = {}, ...userConfigs) {
1944
1987
  stylistic: stylisticOptions
1945
1988
  }));
1946
1989
  }
1990
+ if (options.toml) {
1991
+ configs.push(toml({
1992
+ overrides: overrides.toml,
1993
+ stylistic: stylisticOptions
1994
+ }));
1995
+ }
1947
1996
  if (options.markdown ?? true) {
1948
1997
  configs.push(markdown(
1949
1998
  {
1950
1999
  ...typeof options.markdown !== "boolean" ? options.markdown : {},
1951
2000
  componentExts,
1952
2001
  overrides: overrides.markdown
1953
- },
1954
- options.formatters === true || !!(options.formatters || {})?.markdown
2002
+ }
1955
2003
  ));
1956
2004
  }
1957
2005
  if (options.formatters) {
@@ -1997,6 +2045,7 @@ var src_default = lincy;
1997
2045
  GLOB_SRC_EXT,
1998
2046
  GLOB_STYLE,
1999
2047
  GLOB_TESTS,
2048
+ GLOB_TOML,
2000
2049
  GLOB_TS,
2001
2050
  GLOB_TSX,
2002
2051
  GLOB_VUE,
@@ -2023,6 +2072,7 @@ var src_default = lincy;
2023
2072
  stylistic,
2024
2073
  test,
2025
2074
  toArray,
2075
+ toml,
2026
2076
  typescript,
2027
2077
  unicorn,
2028
2078
  unocss,
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Linter } from 'eslint';
2
2
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
3
3
  import { ParserOptions } from '@typescript-eslint/parser';
4
+ import { Options } from 'eslint-processor-vue-blocks';
4
5
  import { RuleConfig, MergeIntersection, RenamePrefix, VitestRules, YmlRules, NRules, Prefix, ReactHooksRules, ReactRules, ImportRules, EslintRules, JsoncRules, VueRules, EslintCommentsRules, FlatESLintConfigItem } from '@antfu/eslint-define-config';
5
6
  import { RuleOptions as RuleOptions$1 } from '@eslint-types/jsdoc/types';
6
7
  import { RuleOptions } from '@eslint-types/typescript-eslint/types';
@@ -130,6 +131,15 @@ interface OptionsFiles {
130
131
  */
131
132
  files?: string[];
132
133
  }
134
+ interface OptionsVue {
135
+ /**
136
+ * 为 Vue SFC 创建虚拟文件以启用 linting.
137
+ *
138
+ * @see https://github.com/antfu/eslint-processor-vue-blocks
139
+ * @default true
140
+ */
141
+ sfcBlocks?: boolean | Options;
142
+ }
133
143
  interface OptionsFormatters {
134
144
  /**
135
145
  * 启用对 CSS、Less、Sass 和 SCSS 的格式化支持.
@@ -143,12 +153,6 @@ interface OptionsFormatters {
143
153
  * 目前仅支持Prettier.
144
154
  */
145
155
  html?: 'prettier' | boolean;
146
- /**
147
- * 启用 TOML 格式支持.
148
- *
149
- * 目前仅支持dprint.
150
- */
151
- toml?: 'dprint' | boolean;
152
156
  /**
153
157
  * 启用对 Markdown 的格式化支持.
154
158
  *
@@ -234,6 +238,7 @@ interface OptionsUnoCSS {
234
238
  * @default false
235
239
  */
236
240
  strict?: boolean;
241
+ overrides?: FlatConfigItem['rules'];
237
242
  }
238
243
  interface OptionsConfig extends OptionsComponentExts {
239
244
  /**
@@ -272,7 +277,7 @@ interface OptionsConfig extends OptionsComponentExts {
272
277
  *
273
278
  * @default 根据依赖关系自动检测
274
279
  */
275
- vue?: boolean | OptionsFiles;
280
+ vue?: boolean | OptionsFiles | OptionsVue;
276
281
  /**
277
282
  * 启用 React 支持.
278
283
  *
@@ -314,6 +319,12 @@ interface OptionsConfig extends OptionsComponentExts {
314
319
  * @default true
315
320
  */
316
321
  yaml?: boolean | OptionsFiles;
322
+ /**
323
+ * 启用 TOML 支持.
324
+ *
325
+ * @default false
326
+ */
327
+ toml?: boolean;
317
328
  /**
318
329
  * 启用 Markdown 支持.
319
330
  *
@@ -344,6 +355,8 @@ interface OptionsConfig extends OptionsComponentExts {
344
355
  jsonc?: FlatConfigItem['rules'];
345
356
  markdown?: FlatConfigItem['rules'];
346
357
  yaml?: FlatConfigItem['rules'];
358
+ toml?: FlatConfigItem['rules'];
359
+ unocss?: FlatConfigItem['rules'];
347
360
  ignores?: string[];
348
361
  };
349
362
  }
@@ -365,7 +378,7 @@ declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
365
378
 
366
379
  declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
367
380
 
368
- declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides, formatMarkdown?: boolean): Promise<FlatConfigItem[]>;
381
+ declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
369
382
 
370
383
  /**
371
384
  * Optional perfectionist plugin for props and items sorting.
@@ -404,10 +417,12 @@ declare function unicorn(): Promise<FlatConfigItem[]>;
404
417
 
405
418
  declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
406
419
 
407
- declare function vue(options?: OptionsFiles & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
420
+ declare function vue(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles & OptionsVue): Promise<FlatConfigItem[]>;
408
421
 
409
422
  declare function yaml(options?: OptionsFiles & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
410
423
 
424
+ declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
425
+
411
426
  /**
412
427
  * Combine array and non-array configs into a single array.
413
428
  */
@@ -439,10 +454,11 @@ declare const GLOB_MARKDOWN = "**/*.md";
439
454
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
440
455
  declare const GLOB_VUE = "**/*.vue";
441
456
  declare const GLOB_YAML = "**/*.y?(a)ml";
457
+ declare const GLOB_TOML = "**/*.toml";
442
458
  declare const GLOB_HTML = "**/*.htm?(l)";
443
459
  declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
444
460
  declare const GLOB_TESTS: string[];
445
461
  declare const GLOB_ALL_SRC: string[];
446
462
  declare const GLOB_EXCLUDE: string[];
447
463
 
448
- 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_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 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, typescript, unicorn, unocss, vue, yaml };
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 };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Linter } from 'eslint';
2
2
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
3
3
  import { ParserOptions } from '@typescript-eslint/parser';
4
+ import { Options } from 'eslint-processor-vue-blocks';
4
5
  import { RuleConfig, MergeIntersection, RenamePrefix, VitestRules, YmlRules, NRules, Prefix, ReactHooksRules, ReactRules, ImportRules, EslintRules, JsoncRules, VueRules, EslintCommentsRules, FlatESLintConfigItem } from '@antfu/eslint-define-config';
5
6
  import { RuleOptions as RuleOptions$1 } from '@eslint-types/jsdoc/types';
6
7
  import { RuleOptions } from '@eslint-types/typescript-eslint/types';
@@ -130,6 +131,15 @@ interface OptionsFiles {
130
131
  */
131
132
  files?: string[];
132
133
  }
134
+ interface OptionsVue {
135
+ /**
136
+ * 为 Vue SFC 创建虚拟文件以启用 linting.
137
+ *
138
+ * @see https://github.com/antfu/eslint-processor-vue-blocks
139
+ * @default true
140
+ */
141
+ sfcBlocks?: boolean | Options;
142
+ }
133
143
  interface OptionsFormatters {
134
144
  /**
135
145
  * 启用对 CSS、Less、Sass 和 SCSS 的格式化支持.
@@ -143,12 +153,6 @@ interface OptionsFormatters {
143
153
  * 目前仅支持Prettier.
144
154
  */
145
155
  html?: 'prettier' | boolean;
146
- /**
147
- * 启用 TOML 格式支持.
148
- *
149
- * 目前仅支持dprint.
150
- */
151
- toml?: 'dprint' | boolean;
152
156
  /**
153
157
  * 启用对 Markdown 的格式化支持.
154
158
  *
@@ -234,6 +238,7 @@ interface OptionsUnoCSS {
234
238
  * @default false
235
239
  */
236
240
  strict?: boolean;
241
+ overrides?: FlatConfigItem['rules'];
237
242
  }
238
243
  interface OptionsConfig extends OptionsComponentExts {
239
244
  /**
@@ -272,7 +277,7 @@ interface OptionsConfig extends OptionsComponentExts {
272
277
  *
273
278
  * @default 根据依赖关系自动检测
274
279
  */
275
- vue?: boolean | OptionsFiles;
280
+ vue?: boolean | OptionsFiles | OptionsVue;
276
281
  /**
277
282
  * 启用 React 支持.
278
283
  *
@@ -314,6 +319,12 @@ interface OptionsConfig extends OptionsComponentExts {
314
319
  * @default true
315
320
  */
316
321
  yaml?: boolean | OptionsFiles;
322
+ /**
323
+ * 启用 TOML 支持.
324
+ *
325
+ * @default false
326
+ */
327
+ toml?: boolean;
317
328
  /**
318
329
  * 启用 Markdown 支持.
319
330
  *
@@ -344,6 +355,8 @@ interface OptionsConfig extends OptionsComponentExts {
344
355
  jsonc?: FlatConfigItem['rules'];
345
356
  markdown?: FlatConfigItem['rules'];
346
357
  yaml?: FlatConfigItem['rules'];
358
+ toml?: FlatConfigItem['rules'];
359
+ unocss?: FlatConfigItem['rules'];
347
360
  ignores?: string[];
348
361
  };
349
362
  }
@@ -365,7 +378,7 @@ declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
365
378
 
366
379
  declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
367
380
 
368
- declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides, formatMarkdown?: boolean): Promise<FlatConfigItem[]>;
381
+ declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
369
382
 
370
383
  /**
371
384
  * Optional perfectionist plugin for props and items sorting.
@@ -404,10 +417,12 @@ declare function unicorn(): Promise<FlatConfigItem[]>;
404
417
 
405
418
  declare function unocss(options?: OptionsUnoCSS): Promise<FlatConfigItem[]>;
406
419
 
407
- declare function vue(options?: OptionsFiles & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
420
+ declare function vue(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles & OptionsVue): Promise<FlatConfigItem[]>;
408
421
 
409
422
  declare function yaml(options?: OptionsFiles & OptionsOverrides & OptionsStylistic): Promise<FlatConfigItem[]>;
410
423
 
424
+ declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
425
+
411
426
  /**
412
427
  * Combine array and non-array configs into a single array.
413
428
  */
@@ -439,10 +454,11 @@ declare const GLOB_MARKDOWN = "**/*.md";
439
454
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
440
455
  declare const GLOB_VUE = "**/*.vue";
441
456
  declare const GLOB_YAML = "**/*.y?(a)ml";
457
+ declare const GLOB_TOML = "**/*.toml";
442
458
  declare const GLOB_HTML = "**/*.htm?(l)";
443
459
  declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
444
460
  declare const GLOB_TESTS: string[];
445
461
  declare const GLOB_ALL_SRC: string[];
446
462
  declare const GLOB_EXCLUDE: string[];
447
463
 
448
- 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_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 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, typescript, unicorn, unocss, vue, yaml };
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 };
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ var GLOB_MARKDOWN = "**/*.md";
49
49
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
50
50
  var GLOB_VUE = "**/*.vue";
51
51
  var GLOB_YAML = "**/*.y?(a)ml";
52
+ var GLOB_TOML = "**/*.toml";
52
53
  var GLOB_HTML = "**/*.htm?(l)";
53
54
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
54
55
  var GLOB_TESTS = [
@@ -514,44 +515,15 @@ async function jsonc(options = {}) {
514
515
  }
515
516
 
516
517
  // src/configs/markdown.ts
517
- async function markdown(options = {}, formatMarkdown = false) {
518
+ import * as parserPlain from "eslint-parser-plain";
519
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
520
+ async function markdown(options = {}) {
518
521
  const {
519
522
  componentExts = [],
520
523
  files = [GLOB_MARKDOWN],
521
524
  overrides = {}
522
525
  } = options;
523
526
  const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
524
- const baseProcessor = markdown2.processors.markdown;
525
- const processor = !formatMarkdown ? {
526
- meta: {
527
- name: "markdown-processor"
528
- },
529
- supportsAutofix: true,
530
- ...baseProcessor
531
- } : {
532
- meta: {
533
- name: "markdown-processor-with-content"
534
- },
535
- postprocess(messages, filename) {
536
- const markdownContent = messages.pop();
537
- const codeSnippets = baseProcessor.postprocess(messages, filename);
538
- return [
539
- ...markdownContent || [],
540
- ...codeSnippets || []
541
- ];
542
- },
543
- preprocess(text, filename) {
544
- const result = baseProcessor.preprocess(text, filename);
545
- return [
546
- ...result,
547
- {
548
- filename: ".__markdown_content__",
549
- text
550
- }
551
- ];
552
- },
553
- supportsAutofix: true
554
- };
555
527
  return [
556
528
  {
557
529
  name: "eslint:markdown:setup",
@@ -563,7 +535,17 @@ async function markdown(options = {}, formatMarkdown = false) {
563
535
  files,
564
536
  ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
565
537
  name: "eslint:markdown:processor",
566
- processor
538
+ processor: mergeProcessors([
539
+ markdown2.processors.markdown,
540
+ processorPassThrough
541
+ ])
542
+ },
543
+ {
544
+ files,
545
+ languageOptions: {
546
+ parser: parserPlain
547
+ },
548
+ name: "eslint:markdown:parser"
567
549
  },
568
550
  {
569
551
  files: [
@@ -639,6 +621,9 @@ async function perfectionist() {
639
621
  ];
640
622
  }
641
623
 
624
+ // src/configs/formatters.ts
625
+ import * as parserPlain2 from "eslint-parser-plain";
626
+
642
627
  // src/configs/stylistic.ts
643
628
  var StylisticConfigDefaults = {
644
629
  indent: 4,
@@ -695,11 +680,10 @@ async function formatters(options = {}, stylistic2 = {}) {
695
680
  ]);
696
681
  if (options === true) {
697
682
  options = {
698
- css: true,
699
- graphql: false,
683
+ css: false,
684
+ graphql: true,
700
685
  html: true,
701
- markdown: true,
702
- toml: true
686
+ markdown: true
703
687
  };
704
688
  }
705
689
  const {
@@ -712,9 +696,10 @@ async function formatters(options = {}, stylistic2 = {}) {
712
696
  };
713
697
  const prettierOptions = Object.assign(
714
698
  {
699
+ endOfLine: "lf",
715
700
  semi,
716
701
  singleQuote: quotes === "single",
717
- tabWidth: typeof indent === "number" ? indent : 2,
702
+ tabWidth: typeof indent === "number" ? indent : 4,
718
703
  trailingComma: "all",
719
704
  useTabs: indent === "tab"
720
705
  },
@@ -722,7 +707,7 @@ async function formatters(options = {}, stylistic2 = {}) {
722
707
  );
723
708
  const dprintOptions = Object.assign(
724
709
  {
725
- indentWidth: typeof indent === "number" ? indent : 2,
710
+ indentWidth: typeof indent === "number" ? indent : 4,
726
711
  quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
727
712
  useTabs: indent === "tab"
728
713
  },
@@ -742,7 +727,7 @@ async function formatters(options = {}, stylistic2 = {}) {
742
727
  {
743
728
  files: [GLOB_CSS, GLOB_POSTCSS],
744
729
  languageOptions: {
745
- parser: pluginFormat.parserPlain
730
+ parser: parserPlain2
746
731
  },
747
732
  name: "eslint:formatter:css",
748
733
  rules: {
@@ -758,7 +743,7 @@ async function formatters(options = {}, stylistic2 = {}) {
758
743
  {
759
744
  files: [GLOB_SCSS],
760
745
  languageOptions: {
761
- parser: pluginFormat.parserPlain
746
+ parser: parserPlain2
762
747
  },
763
748
  name: "eslint:formatter:scss",
764
749
  rules: {
@@ -774,7 +759,7 @@ async function formatters(options = {}, stylistic2 = {}) {
774
759
  {
775
760
  files: [GLOB_LESS],
776
761
  languageOptions: {
777
- parser: pluginFormat.parserPlain
762
+ parser: parserPlain2
778
763
  },
779
764
  name: "eslint:formatter:less",
780
765
  rules: {
@@ -793,7 +778,7 @@ async function formatters(options = {}, stylistic2 = {}) {
793
778
  configs.push({
794
779
  files: ["**/*.html"],
795
780
  languageOptions: {
796
- parser: pluginFormat.parserPlain
781
+ parser: parserPlain2
797
782
  },
798
783
  name: "eslint:formatter:html",
799
784
  rules: {
@@ -807,30 +792,12 @@ async function formatters(options = {}, stylistic2 = {}) {
807
792
  }
808
793
  });
809
794
  }
810
- if (options.toml) {
811
- configs.push({
812
- files: ["**/*.toml"],
813
- languageOptions: {
814
- parser: pluginFormat.parserPlain
815
- },
816
- name: "eslint:formatter:toml",
817
- rules: {
818
- "format/dprint": [
819
- "error",
820
- {
821
- ...dprintOptions,
822
- language: "toml"
823
- }
824
- ]
825
- }
826
- });
827
- }
828
795
  if (options.markdown) {
829
796
  const formater = options.markdown === true ? "prettier" : options.markdown;
830
797
  configs.push({
831
- files: ["**/*.__markdown_content__"],
798
+ files: [GLOB_MARKDOWN],
832
799
  languageOptions: {
833
- parser: pluginFormat.parserPlain
800
+ parser: parserPlain2
834
801
  },
835
802
  name: "eslint:formatter:markdown",
836
803
  rules: {
@@ -852,7 +819,7 @@ async function formatters(options = {}, stylistic2 = {}) {
852
819
  configs.push({
853
820
  files: ["**/*.graphql"],
854
821
  languageOptions: {
855
- parser: pluginFormat.parserPlain
822
+ parser: parserPlain2
856
823
  },
857
824
  name: "eslint:formatter:graphql",
858
825
  rules: {
@@ -1127,15 +1094,11 @@ async function sortPackageJson() {
1127
1094
  },
1128
1095
  {
1129
1096
  order: { type: "asc" },
1130
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1131
- },
1132
- {
1133
- order: { type: "asc" },
1134
- pathPattern: "^resolutions$"
1097
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1135
1098
  },
1136
1099
  {
1137
1100
  order: { type: "asc" },
1138
- pathPattern: "^pnpm.overrides$"
1101
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1139
1102
  },
1140
1103
  {
1141
1104
  order: [
@@ -1313,6 +1276,7 @@ async function test(options = {}) {
1313
1276
  "node/prefer-global/process": "off",
1314
1277
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1315
1278
  "test/no-identical-title": "error",
1279
+ "test/no-import-node-test": "error",
1316
1280
  "test/no-only-tests": isInEditor ? "off" : "error",
1317
1281
  "test/prefer-hooks-in-order": "error",
1318
1282
  "test/prefer-lowercase-title": "error",
@@ -1501,6 +1465,7 @@ async function unicorn() {
1501
1465
  async function unocss(options = {}) {
1502
1466
  const {
1503
1467
  attributify = true,
1468
+ overrides = {},
1504
1469
  strict = false
1505
1470
  } = options;
1506
1471
  await ensurePackages([
@@ -1524,13 +1489,15 @@ async function unocss(options = {}) {
1524
1489
  } : {},
1525
1490
  ...strict ? {
1526
1491
  "unocss/blocklist": "error"
1527
- } : {}
1492
+ } : {},
1493
+ ...overrides
1528
1494
  }
1529
1495
  }
1530
1496
  ];
1531
1497
  }
1532
1498
 
1533
1499
  // src/configs/vue.ts
1500
+ import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
1534
1501
  import { getPackageInfoSync } from "local-pkg";
1535
1502
  var pkg = getPackageInfoSync("vue");
1536
1503
  var vueVersion = pkg && pkg.version;
@@ -1542,16 +1509,19 @@ async function vue(options = {}) {
1542
1509
  overrides = {},
1543
1510
  stylistic: stylistic2 = true
1544
1511
  } = options;
1512
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1545
1513
  const {
1546
1514
  indent = 4
1547
1515
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1548
1516
  const [
1549
1517
  pluginVue,
1550
- parserVue
1518
+ parserVue,
1519
+ processorVueBlocks
1551
1520
  ] = await Promise.all([
1552
1521
  // @ts-expect-error missing types
1553
1522
  interopDefault(import("eslint-plugin-vue")),
1554
- interopDefault(import("vue-eslint-parser"))
1523
+ interopDefault(import("vue-eslint-parser")),
1524
+ interopDefault(import("eslint-processor-vue-blocks"))
1555
1525
  ]);
1556
1526
  return [
1557
1527
  {
@@ -1574,7 +1544,16 @@ async function vue(options = {}) {
1574
1544
  }
1575
1545
  },
1576
1546
  name: "eslint:vue:rules",
1577
- processor: pluginVue.processors[".vue"],
1547
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
1548
+ pluginVue.processors[".vue"],
1549
+ processorVueBlocks({
1550
+ ...sfcBlocks,
1551
+ blocks: {
1552
+ ...sfcBlocks.blocks,
1553
+ styles: true
1554
+ }
1555
+ })
1556
+ ]),
1578
1557
  rules: {
1579
1558
  ...pluginVue.configs.base.rules,
1580
1559
  ...vueVersion === "3" ? {
@@ -1732,6 +1711,65 @@ async function yaml(options = {}) {
1732
1711
  ];
1733
1712
  }
1734
1713
 
1714
+ // src/configs/toml.ts
1715
+ async function toml(options = {}) {
1716
+ const {
1717
+ files = [GLOB_TOML],
1718
+ overrides = {},
1719
+ stylistic: stylistic2 = true
1720
+ } = options;
1721
+ const {
1722
+ indent = 4
1723
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1724
+ const [
1725
+ pluginToml,
1726
+ parserToml
1727
+ ] = await Promise.all([
1728
+ interopDefault(import("eslint-plugin-toml")),
1729
+ interopDefault(import("toml-eslint-parser"))
1730
+ ]);
1731
+ return [
1732
+ {
1733
+ name: "antfu:toml:setup",
1734
+ plugins: {
1735
+ toml: pluginToml
1736
+ }
1737
+ },
1738
+ {
1739
+ files,
1740
+ languageOptions: {
1741
+ parser: parserToml
1742
+ },
1743
+ name: "antfu:toml:rules",
1744
+ rules: {
1745
+ "style/spaced-comment": "off",
1746
+ "toml/comma-style": "error",
1747
+ "toml/keys-order": "error",
1748
+ "toml/no-space-dots": "error",
1749
+ "toml/no-unreadable-number-separator": "error",
1750
+ "toml/precision-of-fractional-seconds": "error",
1751
+ "toml/precision-of-integer": "error",
1752
+ "toml/tables-order": "error",
1753
+ "toml/vue-custom-block/no-parsing-error": "error",
1754
+ ...stylistic2 ? {
1755
+ "toml/array-bracket-newline": "error",
1756
+ "toml/array-bracket-spacing": "error",
1757
+ "toml/array-element-newline": "error",
1758
+ "toml/indent": ["error", indent === "tab" ? 4 : indent],
1759
+ "toml/inline-table-curly-spacing": "error",
1760
+ "toml/key-spacing": "error",
1761
+ "toml/padding-line-between-pairs": "error",
1762
+ "toml/padding-line-between-tables": "error",
1763
+ "toml/quoted-keys": "error",
1764
+ "toml/spaced-comment": "error",
1765
+ "toml/table-bracket-spacing": "error"
1766
+ } : {},
1767
+ ...overrides
1768
+ }
1769
+ }
1770
+ ];
1771
+ }
1772
+
1735
1773
  // src/factory.ts
1736
1774
  var flatConfigProps = [
1737
1775
  "files",
@@ -1837,7 +1875,10 @@ async function lincy(options = {}, ...userConfigs) {
1837
1875
  }
1838
1876
  if (enableUnoCSS) {
1839
1877
  configs.push(unocss(
1840
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1878
+ {
1879
+ ...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
1880
+ overrides: overrides.unocss
1881
+ }
1841
1882
  ));
1842
1883
  }
1843
1884
  if (options.jsonc ?? true) {
@@ -1858,14 +1899,19 @@ async function lincy(options = {}, ...userConfigs) {
1858
1899
  stylistic: stylisticOptions
1859
1900
  }));
1860
1901
  }
1902
+ if (options.toml) {
1903
+ configs.push(toml({
1904
+ overrides: overrides.toml,
1905
+ stylistic: stylisticOptions
1906
+ }));
1907
+ }
1861
1908
  if (options.markdown ?? true) {
1862
1909
  configs.push(markdown(
1863
1910
  {
1864
1911
  ...typeof options.markdown !== "boolean" ? options.markdown : {},
1865
1912
  componentExts,
1866
1913
  overrides: overrides.markdown
1867
- },
1868
- options.formatters === true || !!(options.formatters || {})?.markdown
1914
+ }
1869
1915
  ));
1870
1916
  }
1871
1917
  if (options.formatters) {
@@ -1910,6 +1956,7 @@ export {
1910
1956
  GLOB_SRC_EXT,
1911
1957
  GLOB_STYLE,
1912
1958
  GLOB_TESTS,
1959
+ GLOB_TOML,
1913
1960
  GLOB_TS,
1914
1961
  GLOB_TSX,
1915
1962
  GLOB_VUE,
@@ -1937,6 +1984,7 @@ export {
1937
1984
  stylistic,
1938
1985
  test,
1939
1986
  toArray,
1987
+ toml,
1940
1988
  typescript,
1941
1989
  unicorn,
1942
1990
  unocss,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "4.2.2",
4
+ "version": "4.2.3",
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,28 +64,33 @@
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.0-beta.0",
68
- "@typescript-eslint/eslint-plugin": "^6.13.2",
69
- "@typescript-eslint/parser": "^6.13.2",
67
+ "@stylistic/eslint-plugin": "1.5.1",
68
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
69
+ "@typescript-eslint/parser": "^6.14.0",
70
70
  "eslint-config-flat-gitignore": "^0.1.2",
71
+ "eslint-merge-processors": "^0.1.0",
72
+ "eslint-parser-plain": "^0.1.0",
71
73
  "eslint-plugin-antfu": "^2.0.0",
72
74
  "eslint-plugin-eslint-comments": "^3.2.0",
73
75
  "eslint-plugin-i": "^2.29.0",
74
76
  "eslint-plugin-jsdoc": "^46.9.0",
75
77
  "eslint-plugin-jsonc": "^2.10.0",
76
78
  "eslint-plugin-markdown": "^3.0.1",
77
- "eslint-plugin-n": "^16.3.1",
79
+ "eslint-plugin-n": "^16.4.0",
78
80
  "eslint-plugin-no-only-tests": "^3.1.0",
79
81
  "eslint-plugin-perfectionist": "^2.5.0",
82
+ "eslint-plugin-toml": "^0.7.1",
80
83
  "eslint-plugin-unicorn": "^49.0.0",
81
84
  "eslint-plugin-unused-imports": "^3.0.0",
82
- "eslint-plugin-vitest": "^0.3.10",
85
+ "eslint-plugin-vitest": "^0.3.16",
83
86
  "eslint-plugin-vue": "^9.19.2",
84
87
  "eslint-plugin-yml": "^1.10.0",
85
- "globals": "^13.23.0",
88
+ "eslint-processor-vue-blocks": "^0.1.1",
89
+ "globals": "^13.24.0",
86
90
  "jsonc-eslint-parser": "^2.4.0",
87
91
  "local-pkg": "^0.5.0",
88
92
  "prompts": "^2.4.2",
93
+ "toml-eslint-parser": "^0.9.3",
89
94
  "vue-eslint-parser": "^9.3.2",
90
95
  "yaml-eslint-parser": "^1.2.2"
91
96
  },
@@ -95,12 +100,12 @@
95
100
  "@eslint-types/typescript-eslint": "^6.12.0",
96
101
  "@eslint-types/unicorn": "^49.0.0",
97
102
  "@lincy/eslint-config": "workspace:*",
98
- "@stylistic/eslint-plugin-migrate": "^1.4.1",
103
+ "@stylistic/eslint-plugin-migrate": "^1.5.1",
99
104
  "@types/eslint": "^8.44.8",
100
- "@types/node": "^20.10.3",
105
+ "@types/node": "^20.10.4",
101
106
  "@types/prompts": "^2.4.9",
102
107
  "@unocss/eslint-plugin": "^0.58.0",
103
- "bumpp": "^9.2.0",
108
+ "bumpp": "^9.2.1",
104
109
  "eslint": "^8.55.0",
105
110
  "eslint-flat-config-viewer": "^0.1.3",
106
111
  "eslint-plugin-format": "^0.1.0",
@@ -109,15 +114,16 @@
109
114
  "eslint-plugin-react-refresh": "^0.4.5",
110
115
  "esno": "^4.0.0",
111
116
  "lint-staged": "^15.2.0",
112
- "prettier": "^3.1.0",
117
+ "prettier": "^3.1.1",
113
118
  "rimraf": "^5.0.5",
114
119
  "simple-git-hooks": "^2.9.0",
115
120
  "simple-open-url": "^3.0.1",
116
121
  "sucrase": "^3.34.0",
117
122
  "tsup": "^8.0.1",
118
- "typescript": "^5.3.2",
123
+ "typescript": "^5.3.3",
119
124
  "unbuild": "^2.0.0",
120
- "vitest": "^1.0.1"
125
+ "vitest": "^1.0.4",
126
+ "vue": "^3.3.11"
121
127
  },
122
128
  "pnpm": {
123
129
  "peerDependencyRules": {