@jiakun-zhao/eslint-config 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -1
- package/dist/index.mjs +99 -133
- package/generated-rules.d.ts +15716 -0
- package/oxfmt.mjs +7 -0
- package/package.json +47 -41
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -2,14 +2,17 @@ import { composer } from "eslint-flat-config-utils";
|
|
|
2
2
|
import pluginStylistic from "@stylistic/eslint-plugin";
|
|
3
3
|
import pluginTypescript from "@typescript-eslint/eslint-plugin";
|
|
4
4
|
import pluginUnocss from "@unocss/eslint-plugin";
|
|
5
|
+
import * as parserPlain from "eslint-parser-plain";
|
|
5
6
|
import pluginAntfu from "eslint-plugin-antfu";
|
|
6
7
|
import pluginCommand from "eslint-plugin-command";
|
|
7
8
|
import pluginImportX from "eslint-plugin-import-x";
|
|
8
|
-
import pluginJsonc from "eslint-plugin-jsonc";
|
|
9
9
|
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
10
10
|
import * as pluginRegExp from "eslint-plugin-regexp";
|
|
11
11
|
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
12
12
|
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
13
|
+
import { messages, reportDifferences } from "eslint-formatting-reporter";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { createSyncFn } from "synckit";
|
|
13
16
|
import gitignore from "eslint-config-flat-gitignore";
|
|
14
17
|
import globals from "globals";
|
|
15
18
|
|
|
@@ -48,52 +51,6 @@ const ignores$1 = [
|
|
|
48
51
|
"**/auto-import?(s).d.ts",
|
|
49
52
|
"**/components.d.ts"
|
|
50
53
|
];
|
|
51
|
-
const packageJsonTopLevelOrder = [
|
|
52
|
-
"publisher",
|
|
53
|
-
"name",
|
|
54
|
-
"displayName",
|
|
55
|
-
"type",
|
|
56
|
-
"version",
|
|
57
|
-
"private",
|
|
58
|
-
"packageManager",
|
|
59
|
-
"description",
|
|
60
|
-
"author",
|
|
61
|
-
"contributors",
|
|
62
|
-
"license",
|
|
63
|
-
"funding",
|
|
64
|
-
"homepage",
|
|
65
|
-
"repository",
|
|
66
|
-
"bugs",
|
|
67
|
-
"keywords",
|
|
68
|
-
"categories",
|
|
69
|
-
"sideEffects",
|
|
70
|
-
"exports",
|
|
71
|
-
"main",
|
|
72
|
-
"module",
|
|
73
|
-
"unpkg",
|
|
74
|
-
"jsdelivr",
|
|
75
|
-
"types",
|
|
76
|
-
"typesVersions",
|
|
77
|
-
"bin",
|
|
78
|
-
"icon",
|
|
79
|
-
"files",
|
|
80
|
-
"engines",
|
|
81
|
-
"activationEvents",
|
|
82
|
-
"contributes",
|
|
83
|
-
"scripts",
|
|
84
|
-
"peerDependencies",
|
|
85
|
-
"peerDependenciesMeta",
|
|
86
|
-
"dependencies",
|
|
87
|
-
"optionalDependencies",
|
|
88
|
-
"devDependencies",
|
|
89
|
-
"pnpm",
|
|
90
|
-
"overrides",
|
|
91
|
-
"resolutions",
|
|
92
|
-
"husky",
|
|
93
|
-
"simple-git-hooks",
|
|
94
|
-
"lint-staged",
|
|
95
|
-
"eslintConfig"
|
|
96
|
-
];
|
|
97
54
|
|
|
98
55
|
//#endregion
|
|
99
56
|
//#region src/configs/antfu.ts
|
|
@@ -111,7 +68,6 @@ function antfu() {
|
|
|
111
68
|
//#endregion
|
|
112
69
|
//#region src/utils.ts
|
|
113
70
|
const tsParser = findParser(pluginTypescript);
|
|
114
|
-
const jsoncParser = findParser(pluginJsonc);
|
|
115
71
|
function findParser(plugin) {
|
|
116
72
|
const configs = Object.values(plugin.configs ?? {}).flat();
|
|
117
73
|
for (const config of configs) {
|
|
@@ -120,17 +76,17 @@ function findParser(plugin) {
|
|
|
120
76
|
}
|
|
121
77
|
throw new Error(`Can not find parser in ${plugin.meta?.name}`);
|
|
122
78
|
}
|
|
123
|
-
async function findDynamicPlugin(name
|
|
79
|
+
async function findDynamicPlugin(name, key = "default") {
|
|
124
80
|
try {
|
|
125
|
-
return (await import(name
|
|
81
|
+
return (await import(name))[key];
|
|
126
82
|
} catch {
|
|
127
83
|
return null;
|
|
128
84
|
}
|
|
129
85
|
}
|
|
130
86
|
function createRule(rule) {
|
|
131
|
-
const { name
|
|
87
|
+
const { name, ...rest } = rule;
|
|
132
88
|
rest.meta.docs ??= {};
|
|
133
|
-
rest.meta.docs.url = `https://example.com/${name
|
|
89
|
+
rest.meta.docs.url = `https://example.com/${name}`;
|
|
134
90
|
return rest;
|
|
135
91
|
}
|
|
136
92
|
|
|
@@ -151,7 +107,7 @@ async function astro() {
|
|
|
151
107
|
}]
|
|
152
108
|
});
|
|
153
109
|
}
|
|
154
|
-
function createSharedAstroConfig(plugin, rules
|
|
110
|
+
function createSharedAstroConfig(plugin, rules = {}) {
|
|
155
111
|
return {
|
|
156
112
|
files: ["**/*.astro"],
|
|
157
113
|
languageOptions: {
|
|
@@ -164,7 +120,7 @@ function createSharedAstroConfig(plugin, rules$1 = {}) {
|
|
|
164
120
|
name: "astro",
|
|
165
121
|
plugins: { astro: plugin },
|
|
166
122
|
processor: plugin.processors?.["client-side-ts"],
|
|
167
|
-
rules
|
|
123
|
+
rules
|
|
168
124
|
};
|
|
169
125
|
}
|
|
170
126
|
|
|
@@ -178,6 +134,89 @@ function command() {
|
|
|
178
134
|
};
|
|
179
135
|
}
|
|
180
136
|
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region package.json
|
|
139
|
+
var name$4 = "@jiakun-zhao/eslint-config";
|
|
140
|
+
var version = "4.3.0";
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/format/oxfmt.ts
|
|
144
|
+
let format$1;
|
|
145
|
+
var oxfmt_default = {
|
|
146
|
+
meta: {
|
|
147
|
+
type: "layout",
|
|
148
|
+
docs: {
|
|
149
|
+
description: "Use oxfmt to format code",
|
|
150
|
+
category: "Stylistic"
|
|
151
|
+
},
|
|
152
|
+
fixable: "whitespace",
|
|
153
|
+
messages
|
|
154
|
+
},
|
|
155
|
+
create(context) {
|
|
156
|
+
if (!format$1) format$1 = createSyncFn(import.meta.resolve(join(name$4, "oxfmt")));
|
|
157
|
+
return { Program() {
|
|
158
|
+
const sourceCode = context.sourceCode.text;
|
|
159
|
+
const result = format$1(context.filename, sourceCode, {
|
|
160
|
+
singleQuote: true,
|
|
161
|
+
semi: false
|
|
162
|
+
});
|
|
163
|
+
if (result.errors.length > 0) {
|
|
164
|
+
console.error(result.errors);
|
|
165
|
+
context.report({
|
|
166
|
+
loc: {
|
|
167
|
+
start: {
|
|
168
|
+
line: 1,
|
|
169
|
+
column: 0
|
|
170
|
+
},
|
|
171
|
+
end: {
|
|
172
|
+
line: 1,
|
|
173
|
+
column: 0
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
message: `Failed to format the code: ${result.errors}`
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
reportDifferences(context, sourceCode, result.code);
|
|
181
|
+
} };
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/format/index.ts
|
|
187
|
+
var format_default = {
|
|
188
|
+
meta: {
|
|
189
|
+
name: "format",
|
|
190
|
+
version
|
|
191
|
+
},
|
|
192
|
+
rules: { oxfmt: oxfmt_default }
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/configs/format.ts
|
|
197
|
+
function format() {
|
|
198
|
+
return [{
|
|
199
|
+
name: "format",
|
|
200
|
+
files: [
|
|
201
|
+
"**/*.json",
|
|
202
|
+
"**/*.jsonc",
|
|
203
|
+
"**/*.json5",
|
|
204
|
+
"**/*.yaml",
|
|
205
|
+
"**/*.toml",
|
|
206
|
+
"**/*.html",
|
|
207
|
+
"**/*.css",
|
|
208
|
+
"**/*.scss",
|
|
209
|
+
"**/*.sass",
|
|
210
|
+
"**/*.less",
|
|
211
|
+
"**/*.md",
|
|
212
|
+
"**/*.mdx"
|
|
213
|
+
],
|
|
214
|
+
languageOptions: { parser: parserPlain },
|
|
215
|
+
plugins: { format: format_default },
|
|
216
|
+
rules: { "format/oxfmt": "warn" }
|
|
217
|
+
}];
|
|
218
|
+
}
|
|
219
|
+
|
|
181
220
|
//#endregion
|
|
182
221
|
//#region src/configs/ignores.ts
|
|
183
222
|
function ignores(options) {
|
|
@@ -416,37 +455,6 @@ function javascript() {
|
|
|
416
455
|
};
|
|
417
456
|
}
|
|
418
457
|
|
|
419
|
-
//#endregion
|
|
420
|
-
//#region src/configs/jsonc.ts
|
|
421
|
-
function jsonc() {
|
|
422
|
-
return [{
|
|
423
|
-
files: [
|
|
424
|
-
"**/*.json",
|
|
425
|
-
"**/*.jsonc",
|
|
426
|
-
"**/*.json5"
|
|
427
|
-
],
|
|
428
|
-
languageOptions: { parser: jsoncParser },
|
|
429
|
-
name: "jsonc",
|
|
430
|
-
plugins: { jsonc: pluginJsonc },
|
|
431
|
-
rules: {
|
|
432
|
-
"jsonc/array-bracket-newline": ["warn", "consistent"],
|
|
433
|
-
"jsonc/array-bracket-spacing": ["warn", "never"],
|
|
434
|
-
"jsonc/array-element-newline": ["warn", "consistent"],
|
|
435
|
-
"jsonc/comma-dangle": ["warn", "never"],
|
|
436
|
-
"jsonc/comma-style": ["warn", "last"],
|
|
437
|
-
"jsonc/indent": ["warn", indent],
|
|
438
|
-
"jsonc/key-spacing": "warn",
|
|
439
|
-
"jsonc/no-sparse-arrays": "warn",
|
|
440
|
-
"jsonc/object-curly-newline": ["warn", { consistent: true }],
|
|
441
|
-
"jsonc/object-curly-spacing": ["warn", "always"]
|
|
442
|
-
}
|
|
443
|
-
}];
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
//#endregion
|
|
447
|
-
//#region package.json
|
|
448
|
-
var version = "4.2.0";
|
|
449
|
-
|
|
450
458
|
//#endregion
|
|
451
459
|
//#region src/mine/astro-multi-top-level-element-indent.ts
|
|
452
460
|
const name$3 = "astro-multi-top-level-element-indent";
|
|
@@ -626,53 +634,11 @@ function overrides() {
|
|
|
626
634
|
"mts",
|
|
627
635
|
"cts"
|
|
628
636
|
];
|
|
629
|
-
return [
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
name: "override/jsonc-sort",
|
|
637
|
-
files: ["**/.vscode/settings.json", "**/tsconfig.json"],
|
|
638
|
-
rules: {
|
|
639
|
-
"jsonc/sort-array-values": ["warn", {
|
|
640
|
-
order: { type: "asc" },
|
|
641
|
-
pathPattern: ".*"
|
|
642
|
-
}],
|
|
643
|
-
"jsonc/sort-keys": ["warn", {
|
|
644
|
-
order: { type: "asc" },
|
|
645
|
-
pathPattern: ".*"
|
|
646
|
-
}]
|
|
647
|
-
}
|
|
648
|
-
},
|
|
649
|
-
{
|
|
650
|
-
name: "override/package-json",
|
|
651
|
-
files: ["**/package.json"],
|
|
652
|
-
rules: {
|
|
653
|
-
"style/no-multiple-empty-lines": ["warn", { max: 0 }],
|
|
654
|
-
"jsonc/sort-array-values": ["warn", {
|
|
655
|
-
order: { type: "asc" },
|
|
656
|
-
pathPattern: "^files$"
|
|
657
|
-
}],
|
|
658
|
-
"jsonc/sort-keys": [
|
|
659
|
-
"warn",
|
|
660
|
-
{
|
|
661
|
-
order: packageJsonTopLevelOrder,
|
|
662
|
-
pathPattern: "^$"
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
order: { type: "asc" },
|
|
666
|
-
pathPattern: "^(?:exports|scripts)"
|
|
667
|
-
},
|
|
668
|
-
{
|
|
669
|
-
order: { type: "asc" },
|
|
670
|
-
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
671
|
-
}
|
|
672
|
-
]
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
];
|
|
637
|
+
return [{
|
|
638
|
+
name: "override/sort-config-files",
|
|
639
|
+
files: [...configFileNames.reduce((acc, cur) => [...acc, ...extensions.map((ext) => `${cur}.config.${ext}`)], [])],
|
|
640
|
+
rules: { "perfectionist/sort-objects": "warn" }
|
|
641
|
+
}];
|
|
676
642
|
}
|
|
677
643
|
|
|
678
644
|
//#endregion
|
|
@@ -1169,7 +1135,7 @@ async function vue() {
|
|
|
1169
1135
|
//#endregion
|
|
1170
1136
|
//#region src/index.ts
|
|
1171
1137
|
function src_default(options = {}) {
|
|
1172
|
-
return composer(ignores(options),
|
|
1138
|
+
return composer(ignores(options), javascript(), typescript(), astro(), vue(), stylistic(), mine(), unusedImports(), perfectionist(), antfu(), importX(), unicorn(), regexp(), command(), unocss(), overrides(), format());
|
|
1173
1139
|
}
|
|
1174
1140
|
|
|
1175
1141
|
//#endregion
|