@lincy/eslint-config 4.2.2 → 4.2.4
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 +97 -8
- package/dist/index.cjs +146 -86
- package/dist/index.d.cts +71 -33
- package/dist/index.d.ts +71 -33
- package/dist/index.js +143 -86
- package/package.json +28 -22
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;
|
|
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
|
@@ -48,7 +48,9 @@ __export(src_exports, {
|
|
|
48
48
|
GLOB_SRC: () => GLOB_SRC,
|
|
49
49
|
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
50
50
|
GLOB_STYLE: () => GLOB_STYLE,
|
|
51
|
+
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
51
52
|
GLOB_TESTS: () => GLOB_TESTS,
|
|
53
|
+
GLOB_TOML: () => GLOB_TOML,
|
|
52
54
|
GLOB_TS: () => GLOB_TS,
|
|
53
55
|
GLOB_TSX: () => GLOB_TSX,
|
|
54
56
|
GLOB_VUE: () => GLOB_VUE,
|
|
@@ -76,6 +78,7 @@ __export(src_exports, {
|
|
|
76
78
|
stylistic: () => stylistic,
|
|
77
79
|
test: () => test,
|
|
78
80
|
toArray: () => toArray,
|
|
81
|
+
toml: () => toml,
|
|
79
82
|
typescript: () => typescript,
|
|
80
83
|
unicorn: () => unicorn,
|
|
81
84
|
unocss: () => unocss,
|
|
@@ -133,8 +136,10 @@ var GLOB_JSON5 = "**/*.json5";
|
|
|
133
136
|
var GLOB_JSONC = "**/*.jsonc";
|
|
134
137
|
var GLOB_MARKDOWN = "**/*.md";
|
|
135
138
|
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
139
|
+
var GLOB_SVELTE = "**/*.svelte";
|
|
136
140
|
var GLOB_VUE = "**/*.vue";
|
|
137
141
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
142
|
+
var GLOB_TOML = "**/*.toml";
|
|
138
143
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
139
144
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
140
145
|
var GLOB_TESTS = [
|
|
@@ -148,6 +153,7 @@ var GLOB_ALL_SRC = [
|
|
|
148
153
|
GLOB_JSON,
|
|
149
154
|
GLOB_JSON5,
|
|
150
155
|
GLOB_MARKDOWN,
|
|
156
|
+
GLOB_SVELTE,
|
|
151
157
|
GLOB_VUE,
|
|
152
158
|
GLOB_YAML,
|
|
153
159
|
GLOB_HTML
|
|
@@ -210,6 +216,7 @@ async function imports(options = {}) {
|
|
|
210
216
|
},
|
|
211
217
|
rules: {
|
|
212
218
|
"antfu/import-dedupe": "error",
|
|
219
|
+
"antfu/no-import-dist": "error",
|
|
213
220
|
"antfu/no-import-node-modules-by-path": "error",
|
|
214
221
|
"import/first": "error",
|
|
215
222
|
"import/no-duplicates": "error",
|
|
@@ -600,44 +607,15 @@ async function jsonc(options = {}) {
|
|
|
600
607
|
}
|
|
601
608
|
|
|
602
609
|
// src/configs/markdown.ts
|
|
603
|
-
|
|
610
|
+
var parserPlain = __toESM(require("eslint-parser-plain"), 1);
|
|
611
|
+
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
612
|
+
async function markdown(options = {}) {
|
|
604
613
|
const {
|
|
605
614
|
componentExts = [],
|
|
606
615
|
files = [GLOB_MARKDOWN],
|
|
607
616
|
overrides = {}
|
|
608
617
|
} = options;
|
|
609
618
|
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
619
|
return [
|
|
642
620
|
{
|
|
643
621
|
name: "eslint:markdown:setup",
|
|
@@ -649,7 +627,17 @@ async function markdown(options = {}, formatMarkdown = false) {
|
|
|
649
627
|
files,
|
|
650
628
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
651
629
|
name: "eslint:markdown:processor",
|
|
652
|
-
processor
|
|
630
|
+
processor: (0, import_eslint_merge_processors.mergeProcessors)([
|
|
631
|
+
markdown2.processors.markdown,
|
|
632
|
+
import_eslint_merge_processors.processorPassThrough
|
|
633
|
+
])
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
files,
|
|
637
|
+
languageOptions: {
|
|
638
|
+
parser: parserPlain
|
|
639
|
+
},
|
|
640
|
+
name: "eslint:markdown:parser"
|
|
653
641
|
},
|
|
654
642
|
{
|
|
655
643
|
files: [
|
|
@@ -725,6 +713,9 @@ async function perfectionist() {
|
|
|
725
713
|
];
|
|
726
714
|
}
|
|
727
715
|
|
|
716
|
+
// src/configs/formatters.ts
|
|
717
|
+
var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
|
|
718
|
+
|
|
728
719
|
// src/configs/stylistic.ts
|
|
729
720
|
var StylisticConfigDefaults = {
|
|
730
721
|
indent: 4,
|
|
@@ -781,11 +772,10 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
781
772
|
]);
|
|
782
773
|
if (options === true) {
|
|
783
774
|
options = {
|
|
784
|
-
css:
|
|
785
|
-
graphql:
|
|
775
|
+
css: false,
|
|
776
|
+
graphql: true,
|
|
786
777
|
html: true,
|
|
787
|
-
markdown: true
|
|
788
|
-
toml: true
|
|
778
|
+
markdown: true
|
|
789
779
|
};
|
|
790
780
|
}
|
|
791
781
|
const {
|
|
@@ -798,9 +788,10 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
798
788
|
};
|
|
799
789
|
const prettierOptions = Object.assign(
|
|
800
790
|
{
|
|
791
|
+
endOfLine: "lf",
|
|
801
792
|
semi,
|
|
802
793
|
singleQuote: quotes === "single",
|
|
803
|
-
tabWidth: typeof indent === "number" ? indent :
|
|
794
|
+
tabWidth: typeof indent === "number" ? indent : 4,
|
|
804
795
|
trailingComma: "all",
|
|
805
796
|
useTabs: indent === "tab"
|
|
806
797
|
},
|
|
@@ -808,7 +799,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
808
799
|
);
|
|
809
800
|
const dprintOptions = Object.assign(
|
|
810
801
|
{
|
|
811
|
-
indentWidth: typeof indent === "number" ? indent :
|
|
802
|
+
indentWidth: typeof indent === "number" ? indent : 4,
|
|
812
803
|
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
813
804
|
useTabs: indent === "tab"
|
|
814
805
|
},
|
|
@@ -828,7 +819,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
828
819
|
{
|
|
829
820
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
830
821
|
languageOptions: {
|
|
831
|
-
parser:
|
|
822
|
+
parser: parserPlain2
|
|
832
823
|
},
|
|
833
824
|
name: "eslint:formatter:css",
|
|
834
825
|
rules: {
|
|
@@ -844,7 +835,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
844
835
|
{
|
|
845
836
|
files: [GLOB_SCSS],
|
|
846
837
|
languageOptions: {
|
|
847
|
-
parser:
|
|
838
|
+
parser: parserPlain2
|
|
848
839
|
},
|
|
849
840
|
name: "eslint:formatter:scss",
|
|
850
841
|
rules: {
|
|
@@ -860,7 +851,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
860
851
|
{
|
|
861
852
|
files: [GLOB_LESS],
|
|
862
853
|
languageOptions: {
|
|
863
|
-
parser:
|
|
854
|
+
parser: parserPlain2
|
|
864
855
|
},
|
|
865
856
|
name: "eslint:formatter:less",
|
|
866
857
|
rules: {
|
|
@@ -879,7 +870,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
879
870
|
configs.push({
|
|
880
871
|
files: ["**/*.html"],
|
|
881
872
|
languageOptions: {
|
|
882
|
-
parser:
|
|
873
|
+
parser: parserPlain2
|
|
883
874
|
},
|
|
884
875
|
name: "eslint:formatter:html",
|
|
885
876
|
rules: {
|
|
@@ -893,36 +884,19 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
893
884
|
}
|
|
894
885
|
});
|
|
895
886
|
}
|
|
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
887
|
if (options.markdown) {
|
|
915
888
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
916
889
|
configs.push({
|
|
917
|
-
files: [
|
|
890
|
+
files: [GLOB_MARKDOWN],
|
|
918
891
|
languageOptions: {
|
|
919
|
-
parser:
|
|
892
|
+
parser: parserPlain2
|
|
920
893
|
},
|
|
921
894
|
name: "eslint:formatter:markdown",
|
|
922
895
|
rules: {
|
|
923
896
|
[`format/${formater}`]: [
|
|
924
897
|
"error",
|
|
925
898
|
formater === "prettier" ? {
|
|
899
|
+
printWidth: 200,
|
|
926
900
|
...prettierOptions,
|
|
927
901
|
embeddedLanguageFormatting: "off",
|
|
928
902
|
parser: "markdown"
|
|
@@ -938,7 +912,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
938
912
|
configs.push({
|
|
939
913
|
files: ["**/*.graphql"],
|
|
940
914
|
languageOptions: {
|
|
941
|
-
parser:
|
|
915
|
+
parser: parserPlain2
|
|
942
916
|
},
|
|
943
917
|
name: "eslint:formatter:graphql",
|
|
944
918
|
rules: {
|
|
@@ -1213,15 +1187,11 @@ async function sortPackageJson() {
|
|
|
1213
1187
|
},
|
|
1214
1188
|
{
|
|
1215
1189
|
order: { type: "asc" },
|
|
1216
|
-
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies
|
|
1190
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
1217
1191
|
},
|
|
1218
1192
|
{
|
|
1219
1193
|
order: { type: "asc" },
|
|
1220
|
-
pathPattern: "^resolutions$"
|
|
1221
|
-
},
|
|
1222
|
-
{
|
|
1223
|
-
order: { type: "asc" },
|
|
1224
|
-
pathPattern: "^pnpm.overrides$"
|
|
1194
|
+
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
1225
1195
|
},
|
|
1226
1196
|
{
|
|
1227
1197
|
order: [
|
|
@@ -1399,6 +1369,7 @@ async function test(options = {}) {
|
|
|
1399
1369
|
"node/prefer-global/process": "off",
|
|
1400
1370
|
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1401
1371
|
"test/no-identical-title": "error",
|
|
1372
|
+
"test/no-import-node-test": "error",
|
|
1402
1373
|
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1403
1374
|
"test/prefer-hooks-in-order": "error",
|
|
1404
1375
|
"test/prefer-lowercase-title": "error",
|
|
@@ -1420,6 +1391,7 @@ async function typescript(options = {}) {
|
|
|
1420
1391
|
GLOB_SRC,
|
|
1421
1392
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1422
1393
|
];
|
|
1394
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1423
1395
|
const typeAwareRules = {
|
|
1424
1396
|
"dot-notation": "off",
|
|
1425
1397
|
"no-implied-eval": "off",
|
|
@@ -1509,6 +1481,13 @@ async function typescript(options = {}) {
|
|
|
1509
1481
|
"ts/prefer-ts-expect-error": "error",
|
|
1510
1482
|
"ts/triple-slash-reference": "off",
|
|
1511
1483
|
"ts/unified-signatures": "off",
|
|
1484
|
+
...overrides
|
|
1485
|
+
}
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
files: filesTypeAware,
|
|
1489
|
+
name: "eslint:typescript:rules-type-aware",
|
|
1490
|
+
rules: {
|
|
1512
1491
|
...tsconfigPath ? typeAwareRules : {},
|
|
1513
1492
|
...overrides
|
|
1514
1493
|
}
|
|
@@ -1587,6 +1566,7 @@ async function unicorn() {
|
|
|
1587
1566
|
async function unocss(options = {}) {
|
|
1588
1567
|
const {
|
|
1589
1568
|
attributify = true,
|
|
1569
|
+
overrides = {},
|
|
1590
1570
|
strict = false
|
|
1591
1571
|
} = options;
|
|
1592
1572
|
await ensurePackages([
|
|
@@ -1610,13 +1590,15 @@ async function unocss(options = {}) {
|
|
|
1610
1590
|
} : {},
|
|
1611
1591
|
...strict ? {
|
|
1612
1592
|
"unocss/blocklist": "error"
|
|
1613
|
-
} : {}
|
|
1593
|
+
} : {},
|
|
1594
|
+
...overrides
|
|
1614
1595
|
}
|
|
1615
1596
|
}
|
|
1616
1597
|
];
|
|
1617
1598
|
}
|
|
1618
1599
|
|
|
1619
1600
|
// src/configs/vue.ts
|
|
1601
|
+
var import_eslint_merge_processors2 = require("eslint-merge-processors");
|
|
1620
1602
|
var import_local_pkg3 = require("local-pkg");
|
|
1621
1603
|
var pkg = (0, import_local_pkg3.getPackageInfoSync)("vue");
|
|
1622
1604
|
var vueVersion = pkg && pkg.version;
|
|
@@ -1628,16 +1610,19 @@ async function vue(options = {}) {
|
|
|
1628
1610
|
overrides = {},
|
|
1629
1611
|
stylistic: stylistic2 = true
|
|
1630
1612
|
} = options;
|
|
1613
|
+
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1631
1614
|
const {
|
|
1632
1615
|
indent = 4
|
|
1633
1616
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1634
1617
|
const [
|
|
1635
1618
|
pluginVue,
|
|
1636
|
-
parserVue
|
|
1619
|
+
parserVue,
|
|
1620
|
+
processorVueBlocks
|
|
1637
1621
|
] = await Promise.all([
|
|
1638
1622
|
// @ts-expect-error missing types
|
|
1639
1623
|
interopDefault(import("eslint-plugin-vue")),
|
|
1640
|
-
interopDefault(import("vue-eslint-parser"))
|
|
1624
|
+
interopDefault(import("vue-eslint-parser")),
|
|
1625
|
+
interopDefault(import("eslint-processor-vue-blocks"))
|
|
1641
1626
|
]);
|
|
1642
1627
|
return [
|
|
1643
1628
|
{
|
|
@@ -1660,7 +1645,16 @@ async function vue(options = {}) {
|
|
|
1660
1645
|
}
|
|
1661
1646
|
},
|
|
1662
1647
|
name: "eslint:vue:rules",
|
|
1663
|
-
processor: pluginVue.processors[".vue"],
|
|
1648
|
+
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
|
|
1649
|
+
pluginVue.processors[".vue"],
|
|
1650
|
+
processorVueBlocks({
|
|
1651
|
+
...sfcBlocks,
|
|
1652
|
+
blocks: {
|
|
1653
|
+
...sfcBlocks.blocks,
|
|
1654
|
+
styles: true
|
|
1655
|
+
}
|
|
1656
|
+
})
|
|
1657
|
+
]),
|
|
1664
1658
|
rules: {
|
|
1665
1659
|
...pluginVue.configs.base.rules,
|
|
1666
1660
|
...vueVersion === "3" ? {
|
|
@@ -1818,6 +1812,65 @@ async function yaml(options = {}) {
|
|
|
1818
1812
|
];
|
|
1819
1813
|
}
|
|
1820
1814
|
|
|
1815
|
+
// src/configs/toml.ts
|
|
1816
|
+
async function toml(options = {}) {
|
|
1817
|
+
const {
|
|
1818
|
+
files = [GLOB_TOML],
|
|
1819
|
+
overrides = {},
|
|
1820
|
+
stylistic: stylistic2 = true
|
|
1821
|
+
} = options;
|
|
1822
|
+
const {
|
|
1823
|
+
indent = 4
|
|
1824
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1825
|
+
const [
|
|
1826
|
+
pluginToml,
|
|
1827
|
+
parserToml
|
|
1828
|
+
] = await Promise.all([
|
|
1829
|
+
interopDefault(import("eslint-plugin-toml")),
|
|
1830
|
+
interopDefault(import("toml-eslint-parser"))
|
|
1831
|
+
]);
|
|
1832
|
+
return [
|
|
1833
|
+
{
|
|
1834
|
+
name: "antfu:toml:setup",
|
|
1835
|
+
plugins: {
|
|
1836
|
+
toml: pluginToml
|
|
1837
|
+
}
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
files,
|
|
1841
|
+
languageOptions: {
|
|
1842
|
+
parser: parserToml
|
|
1843
|
+
},
|
|
1844
|
+
name: "antfu:toml:rules",
|
|
1845
|
+
rules: {
|
|
1846
|
+
"style/spaced-comment": "off",
|
|
1847
|
+
"toml/comma-style": "error",
|
|
1848
|
+
"toml/keys-order": "error",
|
|
1849
|
+
"toml/no-space-dots": "error",
|
|
1850
|
+
"toml/no-unreadable-number-separator": "error",
|
|
1851
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
1852
|
+
"toml/precision-of-integer": "error",
|
|
1853
|
+
"toml/tables-order": "error",
|
|
1854
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1855
|
+
...stylistic2 ? {
|
|
1856
|
+
"toml/array-bracket-newline": "error",
|
|
1857
|
+
"toml/array-bracket-spacing": "error",
|
|
1858
|
+
"toml/array-element-newline": "error",
|
|
1859
|
+
"toml/indent": ["error", indent === "tab" ? 4 : indent],
|
|
1860
|
+
"toml/inline-table-curly-spacing": "error",
|
|
1861
|
+
"toml/key-spacing": "error",
|
|
1862
|
+
"toml/padding-line-between-pairs": "error",
|
|
1863
|
+
"toml/padding-line-between-tables": "error",
|
|
1864
|
+
"toml/quoted-keys": "error",
|
|
1865
|
+
"toml/spaced-comment": "error",
|
|
1866
|
+
"toml/table-bracket-spacing": "error"
|
|
1867
|
+
} : {},
|
|
1868
|
+
...overrides
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
];
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1821
1874
|
// src/factory.ts
|
|
1822
1875
|
var flatConfigProps = [
|
|
1823
1876
|
"files",
|
|
@@ -1843,7 +1896,7 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1843
1896
|
const {
|
|
1844
1897
|
componentExts = [],
|
|
1845
1898
|
gitignore: enableGitignore = true,
|
|
1846
|
-
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
|
|
1899
|
+
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
|
|
1847
1900
|
overrides = {},
|
|
1848
1901
|
react: enableReact = ReactPackages.some((i) => (0, import_local_pkg4.isPackageExists)(i)),
|
|
1849
1902
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
@@ -1922,9 +1975,10 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1922
1975
|
}));
|
|
1923
1976
|
}
|
|
1924
1977
|
if (enableUnoCSS) {
|
|
1925
|
-
configs.push(unocss(
|
|
1926
|
-
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
1927
|
-
|
|
1978
|
+
configs.push(unocss({
|
|
1979
|
+
...typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS,
|
|
1980
|
+
overrides: overrides.unocss
|
|
1981
|
+
}));
|
|
1928
1982
|
}
|
|
1929
1983
|
if (options.jsonc ?? true) {
|
|
1930
1984
|
configs.push(
|
|
@@ -1944,15 +1998,18 @@ async function lincy(options = {}, ...userConfigs) {
|
|
|
1944
1998
|
stylistic: stylisticOptions
|
|
1945
1999
|
}));
|
|
1946
2000
|
}
|
|
2001
|
+
if (options.toml) {
|
|
2002
|
+
configs.push(toml({
|
|
2003
|
+
overrides: overrides.toml,
|
|
2004
|
+
stylistic: stylisticOptions
|
|
2005
|
+
}));
|
|
2006
|
+
}
|
|
1947
2007
|
if (options.markdown ?? true) {
|
|
1948
|
-
configs.push(markdown(
|
|
1949
|
-
{
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
},
|
|
1954
|
-
options.formatters === true || !!(options.formatters || {})?.markdown
|
|
1955
|
-
));
|
|
2008
|
+
configs.push(markdown({
|
|
2009
|
+
...typeof options.markdown !== "boolean" ? options.markdown : {},
|
|
2010
|
+
componentExts,
|
|
2011
|
+
overrides: overrides.markdown
|
|
2012
|
+
}));
|
|
1956
2013
|
}
|
|
1957
2014
|
if (options.formatters) {
|
|
1958
2015
|
configs.push(formatters(
|
|
@@ -1996,7 +2053,9 @@ var src_default = lincy;
|
|
|
1996
2053
|
GLOB_SRC,
|
|
1997
2054
|
GLOB_SRC_EXT,
|
|
1998
2055
|
GLOB_STYLE,
|
|
2056
|
+
GLOB_SVELTE,
|
|
1999
2057
|
GLOB_TESTS,
|
|
2058
|
+
GLOB_TOML,
|
|
2000
2059
|
GLOB_TS,
|
|
2001
2060
|
GLOB_TSX,
|
|
2002
2061
|
GLOB_VUE,
|
|
@@ -2023,6 +2082,7 @@ var src_default = lincy;
|
|
|
2023
2082
|
stylistic,
|
|
2024
2083
|
test,
|
|
2025
2084
|
toArray,
|
|
2085
|
+
toml,
|
|
2026
2086
|
typescript,
|
|
2027
2087
|
unicorn,
|
|
2028
2088
|
unocss,
|