@lincy/eslint-config 4.2.1 → 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,
@@ -765,6 +752,8 @@ async function stylistic(options = {}) {
765
752
  "antfu/if-newline": "error",
766
753
  "antfu/top-level-function": "error",
767
754
  "curly": ["error", "multi-or-nest", "consistent"],
755
+ // 覆盖`stylistic`默认规则
756
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
768
757
  "style/multiline-ternary": ["error", "never"],
769
758
  ...overrides
770
759
  }
@@ -779,11 +768,10 @@ async function formatters(options = {}, stylistic2 = {}) {
779
768
  ]);
780
769
  if (options === true) {
781
770
  options = {
782
- css: true,
783
- graphql: false,
771
+ css: false,
772
+ graphql: true,
784
773
  html: true,
785
- markdown: true,
786
- toml: true
774
+ markdown: true
787
775
  };
788
776
  }
789
777
  const {
@@ -796,9 +784,10 @@ async function formatters(options = {}, stylistic2 = {}) {
796
784
  };
797
785
  const prettierOptions = Object.assign(
798
786
  {
787
+ endOfLine: "lf",
799
788
  semi,
800
789
  singleQuote: quotes === "single",
801
- tabWidth: typeof indent === "number" ? indent : 2,
790
+ tabWidth: typeof indent === "number" ? indent : 4,
802
791
  trailingComma: "all",
803
792
  useTabs: indent === "tab"
804
793
  },
@@ -806,7 +795,7 @@ async function formatters(options = {}, stylistic2 = {}) {
806
795
  );
807
796
  const dprintOptions = Object.assign(
808
797
  {
809
- indentWidth: typeof indent === "number" ? indent : 2,
798
+ indentWidth: typeof indent === "number" ? indent : 4,
810
799
  quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
811
800
  useTabs: indent === "tab"
812
801
  },
@@ -826,7 +815,7 @@ async function formatters(options = {}, stylistic2 = {}) {
826
815
  {
827
816
  files: [GLOB_CSS, GLOB_POSTCSS],
828
817
  languageOptions: {
829
- parser: pluginFormat.parserPlain
818
+ parser: parserPlain2
830
819
  },
831
820
  name: "eslint:formatter:css",
832
821
  rules: {
@@ -842,7 +831,7 @@ async function formatters(options = {}, stylistic2 = {}) {
842
831
  {
843
832
  files: [GLOB_SCSS],
844
833
  languageOptions: {
845
- parser: pluginFormat.parserPlain
834
+ parser: parserPlain2
846
835
  },
847
836
  name: "eslint:formatter:scss",
848
837
  rules: {
@@ -858,7 +847,7 @@ async function formatters(options = {}, stylistic2 = {}) {
858
847
  {
859
848
  files: [GLOB_LESS],
860
849
  languageOptions: {
861
- parser: pluginFormat.parserPlain
850
+ parser: parserPlain2
862
851
  },
863
852
  name: "eslint:formatter:less",
864
853
  rules: {
@@ -877,7 +866,7 @@ async function formatters(options = {}, stylistic2 = {}) {
877
866
  configs.push({
878
867
  files: ["**/*.html"],
879
868
  languageOptions: {
880
- parser: pluginFormat.parserPlain
869
+ parser: parserPlain2
881
870
  },
882
871
  name: "eslint:formatter:html",
883
872
  rules: {
@@ -891,30 +880,12 @@ async function formatters(options = {}, stylistic2 = {}) {
891
880
  }
892
881
  });
893
882
  }
894
- if (options.toml) {
895
- configs.push({
896
- files: ["**/*.toml"],
897
- languageOptions: {
898
- parser: pluginFormat.parserPlain
899
- },
900
- name: "eslint:formatter:toml",
901
- rules: {
902
- "format/dprint": [
903
- "error",
904
- {
905
- ...dprintOptions,
906
- language: "toml"
907
- }
908
- ]
909
- }
910
- });
911
- }
912
883
  if (options.markdown) {
913
884
  const formater = options.markdown === true ? "prettier" : options.markdown;
914
885
  configs.push({
915
- files: ["**/*.__markdown_content__"],
886
+ files: [GLOB_MARKDOWN],
916
887
  languageOptions: {
917
- parser: pluginFormat.parserPlain
888
+ parser: parserPlain2
918
889
  },
919
890
  name: "eslint:formatter:markdown",
920
891
  rules: {
@@ -936,7 +907,7 @@ async function formatters(options = {}, stylistic2 = {}) {
936
907
  configs.push({
937
908
  files: ["**/*.graphql"],
938
909
  languageOptions: {
939
- parser: pluginFormat.parserPlain
910
+ parser: parserPlain2
940
911
  },
941
912
  name: "eslint:formatter:graphql",
942
913
  rules: {
@@ -1211,15 +1182,11 @@ async function sortPackageJson() {
1211
1182
  },
1212
1183
  {
1213
1184
  order: { type: "asc" },
1214
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1215
- },
1216
- {
1217
- order: { type: "asc" },
1218
- pathPattern: "^resolutions$"
1185
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1219
1186
  },
1220
1187
  {
1221
1188
  order: { type: "asc" },
1222
- pathPattern: "^pnpm.overrides$"
1189
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1223
1190
  },
1224
1191
  {
1225
1192
  order: [
@@ -1397,6 +1364,7 @@ async function test(options = {}) {
1397
1364
  "node/prefer-global/process": "off",
1398
1365
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1399
1366
  "test/no-identical-title": "error",
1367
+ "test/no-import-node-test": "error",
1400
1368
  "test/no-only-tests": isInEditor ? "off" : "error",
1401
1369
  "test/prefer-hooks-in-order": "error",
1402
1370
  "test/prefer-lowercase-title": "error",
@@ -1585,6 +1553,7 @@ async function unicorn() {
1585
1553
  async function unocss(options = {}) {
1586
1554
  const {
1587
1555
  attributify = true,
1556
+ overrides = {},
1588
1557
  strict = false
1589
1558
  } = options;
1590
1559
  await ensurePackages([
@@ -1608,13 +1577,15 @@ async function unocss(options = {}) {
1608
1577
  } : {},
1609
1578
  ...strict ? {
1610
1579
  "unocss/blocklist": "error"
1611
- } : {}
1580
+ } : {},
1581
+ ...overrides
1612
1582
  }
1613
1583
  }
1614
1584
  ];
1615
1585
  }
1616
1586
 
1617
1587
  // src/configs/vue.ts
1588
+ var import_eslint_merge_processors2 = require("eslint-merge-processors");
1618
1589
  var import_local_pkg3 = require("local-pkg");
1619
1590
  var pkg = (0, import_local_pkg3.getPackageInfoSync)("vue");
1620
1591
  var vueVersion = pkg && pkg.version;
@@ -1626,16 +1597,19 @@ async function vue(options = {}) {
1626
1597
  overrides = {},
1627
1598
  stylistic: stylistic2 = true
1628
1599
  } = options;
1600
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1629
1601
  const {
1630
1602
  indent = 4
1631
1603
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1632
1604
  const [
1633
1605
  pluginVue,
1634
- parserVue
1606
+ parserVue,
1607
+ processorVueBlocks
1635
1608
  ] = await Promise.all([
1636
1609
  // @ts-expect-error missing types
1637
1610
  interopDefault(import("eslint-plugin-vue")),
1638
- interopDefault(import("vue-eslint-parser"))
1611
+ interopDefault(import("vue-eslint-parser")),
1612
+ interopDefault(import("eslint-processor-vue-blocks"))
1639
1613
  ]);
1640
1614
  return [
1641
1615
  {
@@ -1658,7 +1632,16 @@ async function vue(options = {}) {
1658
1632
  }
1659
1633
  },
1660
1634
  name: "eslint:vue:rules",
1661
- 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
+ ]),
1662
1645
  rules: {
1663
1646
  ...pluginVue.configs.base.rules,
1664
1647
  ...vueVersion === "3" ? {
@@ -1816,6 +1799,65 @@ async function yaml(options = {}) {
1816
1799
  ];
1817
1800
  }
1818
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
+
1819
1861
  // src/factory.ts
1820
1862
  var flatConfigProps = [
1821
1863
  "files",
@@ -1921,7 +1963,10 @@ async function lincy(options = {}, ...userConfigs) {
1921
1963
  }
1922
1964
  if (enableUnoCSS) {
1923
1965
  configs.push(unocss(
1924
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1966
+ {
1967
+ ...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
1968
+ overrides: overrides.unocss
1969
+ }
1925
1970
  ));
1926
1971
  }
1927
1972
  if (options.jsonc ?? true) {
@@ -1942,14 +1987,19 @@ async function lincy(options = {}, ...userConfigs) {
1942
1987
  stylistic: stylisticOptions
1943
1988
  }));
1944
1989
  }
1990
+ if (options.toml) {
1991
+ configs.push(toml({
1992
+ overrides: overrides.toml,
1993
+ stylistic: stylisticOptions
1994
+ }));
1995
+ }
1945
1996
  if (options.markdown ?? true) {
1946
1997
  configs.push(markdown(
1947
1998
  {
1948
1999
  ...typeof options.markdown !== "boolean" ? options.markdown : {},
1949
2000
  componentExts,
1950
2001
  overrides: overrides.markdown
1951
- },
1952
- options.formatters === true || !!(options.formatters || {})?.markdown
2002
+ }
1953
2003
  ));
1954
2004
  }
1955
2005
  if (options.formatters) {
@@ -1995,6 +2045,7 @@ var src_default = lincy;
1995
2045
  GLOB_SRC_EXT,
1996
2046
  GLOB_STYLE,
1997
2047
  GLOB_TESTS,
2048
+ GLOB_TOML,
1998
2049
  GLOB_TS,
1999
2050
  GLOB_TSX,
2000
2051
  GLOB_VUE,
@@ -2021,6 +2072,7 @@ var src_default = lincy;
2021
2072
  stylistic,
2022
2073
  test,
2023
2074
  toArray,
2075
+ toml,
2024
2076
  typescript,
2025
2077
  unicorn,
2026
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,
@@ -679,6 +664,8 @@ async function stylistic(options = {}) {
679
664
  "antfu/if-newline": "error",
680
665
  "antfu/top-level-function": "error",
681
666
  "curly": ["error", "multi-or-nest", "consistent"],
667
+ // 覆盖`stylistic`默认规则
668
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
682
669
  "style/multiline-ternary": ["error", "never"],
683
670
  ...overrides
684
671
  }
@@ -693,11 +680,10 @@ async function formatters(options = {}, stylistic2 = {}) {
693
680
  ]);
694
681
  if (options === true) {
695
682
  options = {
696
- css: true,
697
- graphql: false,
683
+ css: false,
684
+ graphql: true,
698
685
  html: true,
699
- markdown: true,
700
- toml: true
686
+ markdown: true
701
687
  };
702
688
  }
703
689
  const {
@@ -710,9 +696,10 @@ async function formatters(options = {}, stylistic2 = {}) {
710
696
  };
711
697
  const prettierOptions = Object.assign(
712
698
  {
699
+ endOfLine: "lf",
713
700
  semi,
714
701
  singleQuote: quotes === "single",
715
- tabWidth: typeof indent === "number" ? indent : 2,
702
+ tabWidth: typeof indent === "number" ? indent : 4,
716
703
  trailingComma: "all",
717
704
  useTabs: indent === "tab"
718
705
  },
@@ -720,7 +707,7 @@ async function formatters(options = {}, stylistic2 = {}) {
720
707
  );
721
708
  const dprintOptions = Object.assign(
722
709
  {
723
- indentWidth: typeof indent === "number" ? indent : 2,
710
+ indentWidth: typeof indent === "number" ? indent : 4,
724
711
  quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
725
712
  useTabs: indent === "tab"
726
713
  },
@@ -740,7 +727,7 @@ async function formatters(options = {}, stylistic2 = {}) {
740
727
  {
741
728
  files: [GLOB_CSS, GLOB_POSTCSS],
742
729
  languageOptions: {
743
- parser: pluginFormat.parserPlain
730
+ parser: parserPlain2
744
731
  },
745
732
  name: "eslint:formatter:css",
746
733
  rules: {
@@ -756,7 +743,7 @@ async function formatters(options = {}, stylistic2 = {}) {
756
743
  {
757
744
  files: [GLOB_SCSS],
758
745
  languageOptions: {
759
- parser: pluginFormat.parserPlain
746
+ parser: parserPlain2
760
747
  },
761
748
  name: "eslint:formatter:scss",
762
749
  rules: {
@@ -772,7 +759,7 @@ async function formatters(options = {}, stylistic2 = {}) {
772
759
  {
773
760
  files: [GLOB_LESS],
774
761
  languageOptions: {
775
- parser: pluginFormat.parserPlain
762
+ parser: parserPlain2
776
763
  },
777
764
  name: "eslint:formatter:less",
778
765
  rules: {
@@ -791,7 +778,7 @@ async function formatters(options = {}, stylistic2 = {}) {
791
778
  configs.push({
792
779
  files: ["**/*.html"],
793
780
  languageOptions: {
794
- parser: pluginFormat.parserPlain
781
+ parser: parserPlain2
795
782
  },
796
783
  name: "eslint:formatter:html",
797
784
  rules: {
@@ -805,30 +792,12 @@ async function formatters(options = {}, stylistic2 = {}) {
805
792
  }
806
793
  });
807
794
  }
808
- if (options.toml) {
809
- configs.push({
810
- files: ["**/*.toml"],
811
- languageOptions: {
812
- parser: pluginFormat.parserPlain
813
- },
814
- name: "eslint:formatter:toml",
815
- rules: {
816
- "format/dprint": [
817
- "error",
818
- {
819
- ...dprintOptions,
820
- language: "toml"
821
- }
822
- ]
823
- }
824
- });
825
- }
826
795
  if (options.markdown) {
827
796
  const formater = options.markdown === true ? "prettier" : options.markdown;
828
797
  configs.push({
829
- files: ["**/*.__markdown_content__"],
798
+ files: [GLOB_MARKDOWN],
830
799
  languageOptions: {
831
- parser: pluginFormat.parserPlain
800
+ parser: parserPlain2
832
801
  },
833
802
  name: "eslint:formatter:markdown",
834
803
  rules: {
@@ -850,7 +819,7 @@ async function formatters(options = {}, stylistic2 = {}) {
850
819
  configs.push({
851
820
  files: ["**/*.graphql"],
852
821
  languageOptions: {
853
- parser: pluginFormat.parserPlain
822
+ parser: parserPlain2
854
823
  },
855
824
  name: "eslint:formatter:graphql",
856
825
  rules: {
@@ -1125,15 +1094,11 @@ async function sortPackageJson() {
1125
1094
  },
1126
1095
  {
1127
1096
  order: { type: "asc" },
1128
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1129
- },
1130
- {
1131
- order: { type: "asc" },
1132
- pathPattern: "^resolutions$"
1097
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1133
1098
  },
1134
1099
  {
1135
1100
  order: { type: "asc" },
1136
- pathPattern: "^pnpm.overrides$"
1101
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1137
1102
  },
1138
1103
  {
1139
1104
  order: [
@@ -1311,6 +1276,7 @@ async function test(options = {}) {
1311
1276
  "node/prefer-global/process": "off",
1312
1277
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1313
1278
  "test/no-identical-title": "error",
1279
+ "test/no-import-node-test": "error",
1314
1280
  "test/no-only-tests": isInEditor ? "off" : "error",
1315
1281
  "test/prefer-hooks-in-order": "error",
1316
1282
  "test/prefer-lowercase-title": "error",
@@ -1499,6 +1465,7 @@ async function unicorn() {
1499
1465
  async function unocss(options = {}) {
1500
1466
  const {
1501
1467
  attributify = true,
1468
+ overrides = {},
1502
1469
  strict = false
1503
1470
  } = options;
1504
1471
  await ensurePackages([
@@ -1522,13 +1489,15 @@ async function unocss(options = {}) {
1522
1489
  } : {},
1523
1490
  ...strict ? {
1524
1491
  "unocss/blocklist": "error"
1525
- } : {}
1492
+ } : {},
1493
+ ...overrides
1526
1494
  }
1527
1495
  }
1528
1496
  ];
1529
1497
  }
1530
1498
 
1531
1499
  // src/configs/vue.ts
1500
+ import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
1532
1501
  import { getPackageInfoSync } from "local-pkg";
1533
1502
  var pkg = getPackageInfoSync("vue");
1534
1503
  var vueVersion = pkg && pkg.version;
@@ -1540,16 +1509,19 @@ async function vue(options = {}) {
1540
1509
  overrides = {},
1541
1510
  stylistic: stylistic2 = true
1542
1511
  } = options;
1512
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1543
1513
  const {
1544
1514
  indent = 4
1545
1515
  } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1546
1516
  const [
1547
1517
  pluginVue,
1548
- parserVue
1518
+ parserVue,
1519
+ processorVueBlocks
1549
1520
  ] = await Promise.all([
1550
1521
  // @ts-expect-error missing types
1551
1522
  interopDefault(import("eslint-plugin-vue")),
1552
- interopDefault(import("vue-eslint-parser"))
1523
+ interopDefault(import("vue-eslint-parser")),
1524
+ interopDefault(import("eslint-processor-vue-blocks"))
1553
1525
  ]);
1554
1526
  return [
1555
1527
  {
@@ -1572,7 +1544,16 @@ async function vue(options = {}) {
1572
1544
  }
1573
1545
  },
1574
1546
  name: "eslint:vue:rules",
1575
- 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
+ ]),
1576
1557
  rules: {
1577
1558
  ...pluginVue.configs.base.rules,
1578
1559
  ...vueVersion === "3" ? {
@@ -1730,6 +1711,65 @@ async function yaml(options = {}) {
1730
1711
  ];
1731
1712
  }
1732
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
+
1733
1773
  // src/factory.ts
1734
1774
  var flatConfigProps = [
1735
1775
  "files",
@@ -1835,7 +1875,10 @@ async function lincy(options = {}, ...userConfigs) {
1835
1875
  }
1836
1876
  if (enableUnoCSS) {
1837
1877
  configs.push(unocss(
1838
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1878
+ {
1879
+ ...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
1880
+ overrides: overrides.unocss
1881
+ }
1839
1882
  ));
1840
1883
  }
1841
1884
  if (options.jsonc ?? true) {
@@ -1856,14 +1899,19 @@ async function lincy(options = {}, ...userConfigs) {
1856
1899
  stylistic: stylisticOptions
1857
1900
  }));
1858
1901
  }
1902
+ if (options.toml) {
1903
+ configs.push(toml({
1904
+ overrides: overrides.toml,
1905
+ stylistic: stylisticOptions
1906
+ }));
1907
+ }
1859
1908
  if (options.markdown ?? true) {
1860
1909
  configs.push(markdown(
1861
1910
  {
1862
1911
  ...typeof options.markdown !== "boolean" ? options.markdown : {},
1863
1912
  componentExts,
1864
1913
  overrides: overrides.markdown
1865
- },
1866
- options.formatters === true || !!(options.formatters || {})?.markdown
1914
+ }
1867
1915
  ));
1868
1916
  }
1869
1917
  if (options.formatters) {
@@ -1908,6 +1956,7 @@ export {
1908
1956
  GLOB_SRC_EXT,
1909
1957
  GLOB_STYLE,
1910
1958
  GLOB_TESTS,
1959
+ GLOB_TOML,
1911
1960
  GLOB_TS,
1912
1961
  GLOB_TSX,
1913
1962
  GLOB_VUE,
@@ -1935,6 +1984,7 @@ export {
1935
1984
  stylistic,
1936
1985
  test,
1937
1986
  toArray,
1987
+ toml,
1938
1988
  typescript,
1939
1989
  unicorn,
1940
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.1",
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": {