@lincy/eslint-config 5.0.0 → 5.1.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/README.md +1 -2
- package/dist/index.cjs +731 -677
- package/dist/index.d.cts +461 -160
- package/dist/index.d.ts +461 -160
- package/dist/index.js +746 -694
- package/package.json +20 -21
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
|
-
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
3
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
|
+
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
4
4
|
|
|
5
5
|
// src/plugins.ts
|
|
6
|
-
import { default as default2 } from "eslint-plugin-
|
|
7
|
-
import { default as default3 } from "
|
|
6
|
+
import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
|
|
7
|
+
import { default as default3 } from "eslint-plugin-antfu";
|
|
8
8
|
import * as pluginImport from "eslint-plugin-import-x";
|
|
9
9
|
import { default as default4 } from "eslint-plugin-n";
|
|
10
|
-
import { default as default5 } from "eslint-plugin-
|
|
11
|
-
import { default as default6 } from "eslint-plugin-
|
|
12
|
-
import { default as default7 } from "eslint-plugin-
|
|
10
|
+
import { default as default5 } from "eslint-plugin-perfectionist";
|
|
11
|
+
import { default as default6 } from "eslint-plugin-unicorn";
|
|
12
|
+
import { default as default7 } from "eslint-plugin-unused-imports";
|
|
13
13
|
|
|
14
14
|
// src/configs/comments.ts
|
|
15
15
|
async function comments() {
|
|
@@ -17,7 +17,7 @@ async function comments() {
|
|
|
17
17
|
{
|
|
18
18
|
name: "eslint/comments/rules",
|
|
19
19
|
plugins: {
|
|
20
|
-
"eslint-comments":
|
|
20
|
+
"eslint-comments": default2
|
|
21
21
|
},
|
|
22
22
|
rules: {
|
|
23
23
|
"eslint-comments/no-aggregating-enable": "error",
|
|
@@ -102,157 +102,550 @@ var GLOB_EXCLUDE = [
|
|
|
102
102
|
"**/components.d.ts"
|
|
103
103
|
];
|
|
104
104
|
|
|
105
|
-
// src/configs/
|
|
106
|
-
async function
|
|
107
|
-
const {
|
|
108
|
-
ignores: ignores2 = []
|
|
109
|
-
} = options;
|
|
105
|
+
// src/configs/disables.ts
|
|
106
|
+
async function disables() {
|
|
110
107
|
return [
|
|
111
108
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// src/configs/imports.ts
|
|
122
|
-
async function imports(options = {}) {
|
|
123
|
-
const {
|
|
124
|
-
stylistic: stylistic2 = true
|
|
125
|
-
} = options;
|
|
126
|
-
return [
|
|
109
|
+
files: [`scripts/${GLOB_SRC}`],
|
|
110
|
+
name: "eslint/disables/scripts",
|
|
111
|
+
rules: {
|
|
112
|
+
"no-console": "off",
|
|
113
|
+
"ts/explicit-function-return-type": "off"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
127
116
|
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
antfu: default2,
|
|
131
|
-
import: pluginImport
|
|
132
|
-
},
|
|
117
|
+
files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
118
|
+
name: "eslint/disables/cli",
|
|
133
119
|
rules: {
|
|
134
|
-
"
|
|
135
|
-
"antfu/no-import-dist": "error",
|
|
136
|
-
"antfu/no-import-node-modules-by-path": "error",
|
|
137
|
-
"import/first": "error",
|
|
138
|
-
"import/no-duplicates": "error",
|
|
139
|
-
"import/no-mutable-exports": "error",
|
|
140
|
-
"import/no-named-default": "error",
|
|
141
|
-
"import/no-self-import": "error",
|
|
142
|
-
"import/no-webpack-loader-syntax": "error",
|
|
143
|
-
"import/order": "error",
|
|
144
|
-
...stylistic2 ? {
|
|
145
|
-
"import/newline-after-import": ["error", { considerComments: true, count: 1 }]
|
|
146
|
-
} : {}
|
|
120
|
+
"no-console": "off"
|
|
147
121
|
}
|
|
148
122
|
},
|
|
149
123
|
{
|
|
150
124
|
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
151
|
-
name: "eslint/
|
|
125
|
+
name: "eslint/disables/bin",
|
|
152
126
|
rules: {
|
|
153
127
|
"antfu/no-import-dist": "off",
|
|
154
128
|
"antfu/no-import-node-modules-by-path": "off"
|
|
155
129
|
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
files: ["**/*.d.?([cm])ts"],
|
|
133
|
+
name: "eslint/disables/dts",
|
|
134
|
+
rules: {
|
|
135
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
136
|
+
"import/no-duplicates": "off",
|
|
137
|
+
"no-restricted-syntax": "off",
|
|
138
|
+
"unused-imports/no-unused-vars": "off"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
files: ["**/*.{test,spec}.([tj])s?(x)"],
|
|
143
|
+
name: "eslint/disables/test",
|
|
144
|
+
rules: {
|
|
145
|
+
"no-unused-expressions": "off"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
150
|
+
name: "eslint/disables/cjs",
|
|
151
|
+
rules: {
|
|
152
|
+
"ts/no-require-imports": "off"
|
|
153
|
+
}
|
|
156
154
|
}
|
|
157
155
|
];
|
|
158
156
|
}
|
|
159
157
|
|
|
160
|
-
// src/
|
|
161
|
-
import
|
|
162
|
-
|
|
158
|
+
// src/utils.ts
|
|
159
|
+
import process from "node:process";
|
|
160
|
+
import { fileURLToPath } from "node:url";
|
|
161
|
+
import { isPackageExists } from "local-pkg";
|
|
162
|
+
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
163
|
+
var isCwdInScope = isPackageExists("@antfu/eslint-config");
|
|
164
|
+
var parserPlain = {
|
|
165
|
+
meta: {
|
|
166
|
+
name: "parser-plain"
|
|
167
|
+
},
|
|
168
|
+
parseForESLint: (code) => ({
|
|
169
|
+
ast: {
|
|
170
|
+
body: [],
|
|
171
|
+
comments: [],
|
|
172
|
+
loc: { end: code.length, start: 0 },
|
|
173
|
+
range: [0, code.length],
|
|
174
|
+
tokens: [],
|
|
175
|
+
type: "Program"
|
|
176
|
+
},
|
|
177
|
+
scopeManager: null,
|
|
178
|
+
services: { isPlain: true },
|
|
179
|
+
visitorKeys: {
|
|
180
|
+
Program: []
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
};
|
|
184
|
+
async function combine(...configs2) {
|
|
185
|
+
const resolved = await Promise.all(configs2);
|
|
186
|
+
return resolved.flat();
|
|
187
|
+
}
|
|
188
|
+
function renameRules(rules, map) {
|
|
189
|
+
return Object.fromEntries(
|
|
190
|
+
Object.entries(rules).map(([key, value]) => {
|
|
191
|
+
for (const [from, to] of Object.entries(map)) {
|
|
192
|
+
if (key.startsWith(`${from}/`)) {
|
|
193
|
+
return [to + key.slice(from.length), value];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return [key, value];
|
|
197
|
+
})
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
function renamePluginInConfigs(configs2, map) {
|
|
201
|
+
return configs2.map((i) => {
|
|
202
|
+
const clone = { ...i };
|
|
203
|
+
if (clone.rules) {
|
|
204
|
+
clone.rules = renameRules(clone.rules, map);
|
|
205
|
+
}
|
|
206
|
+
if (clone.plugins) {
|
|
207
|
+
clone.plugins = Object.fromEntries(
|
|
208
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
209
|
+
if (key in map) {
|
|
210
|
+
return [map[key], value];
|
|
211
|
+
}
|
|
212
|
+
return [key, value];
|
|
213
|
+
})
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return clone;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function toArray(value) {
|
|
220
|
+
return Array.isArray(value) ? value : [value];
|
|
221
|
+
}
|
|
222
|
+
async function interopDefault(m) {
|
|
223
|
+
const resolved = await m;
|
|
224
|
+
return resolved.default || resolved;
|
|
225
|
+
}
|
|
226
|
+
function isPackageInScope(name) {
|
|
227
|
+
return isPackageExists(name, { paths: [scopeUrl] });
|
|
228
|
+
}
|
|
229
|
+
async function ensurePackages(packages) {
|
|
230
|
+
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
|
|
231
|
+
return;
|
|
232
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
233
|
+
if (nonExistingPackages.length === 0)
|
|
234
|
+
return;
|
|
235
|
+
const p = await import("@clack/prompts");
|
|
236
|
+
const result = await p.confirm({
|
|
237
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
238
|
+
});
|
|
239
|
+
if (result)
|
|
240
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
241
|
+
}
|
|
242
|
+
function isInEditorEnv() {
|
|
243
|
+
if (process.env.CI)
|
|
244
|
+
return false;
|
|
245
|
+
if (isInGitHooksOrLintStaged())
|
|
246
|
+
return false;
|
|
247
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
248
|
+
}
|
|
249
|
+
function isInGitHooksOrLintStaged() {
|
|
250
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/configs/stylistic.ts
|
|
254
|
+
var StylisticConfigDefaults = {
|
|
255
|
+
indent: 4,
|
|
256
|
+
jsx: true,
|
|
257
|
+
lessOpinionated: false,
|
|
258
|
+
quotes: "single",
|
|
259
|
+
semi: false
|
|
260
|
+
};
|
|
261
|
+
async function stylistic(options = {}) {
|
|
163
262
|
const {
|
|
164
|
-
|
|
165
|
-
|
|
263
|
+
overrides = {},
|
|
264
|
+
stylistic: stylistic2 = StylisticConfigDefaults
|
|
166
265
|
} = options;
|
|
266
|
+
const {
|
|
267
|
+
indent,
|
|
268
|
+
jsx: jsx2,
|
|
269
|
+
lessOpinionated,
|
|
270
|
+
quotes,
|
|
271
|
+
semi
|
|
272
|
+
} = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
|
|
273
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
274
|
+
const config = pluginStylistic.configs.customize({
|
|
275
|
+
flat: true,
|
|
276
|
+
indent,
|
|
277
|
+
jsx: jsx2,
|
|
278
|
+
pluginName: "style",
|
|
279
|
+
quotes,
|
|
280
|
+
semi
|
|
281
|
+
});
|
|
167
282
|
return [
|
|
168
283
|
{
|
|
169
|
-
|
|
170
|
-
ecmaVersion: 2022,
|
|
171
|
-
globals: {
|
|
172
|
-
...globals.browser,
|
|
173
|
-
...globals.es2021,
|
|
174
|
-
...globals.node,
|
|
175
|
-
document: "readonly",
|
|
176
|
-
navigator: "readonly",
|
|
177
|
-
window: "readonly"
|
|
178
|
-
},
|
|
179
|
-
parserOptions: {
|
|
180
|
-
ecmaFeatures: {
|
|
181
|
-
jsx: true
|
|
182
|
-
},
|
|
183
|
-
ecmaVersion: 2022,
|
|
184
|
-
sourceType: "module"
|
|
185
|
-
},
|
|
186
|
-
sourceType: "module"
|
|
187
|
-
},
|
|
188
|
-
linterOptions: {
|
|
189
|
-
reportUnusedDisableDirectives: true
|
|
190
|
-
},
|
|
191
|
-
name: "eslint/javascript/setup"
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
name: "eslint/javascript/rules",
|
|
284
|
+
name: "eslint/stylistic/rules",
|
|
195
285
|
plugins: {
|
|
196
|
-
|
|
197
|
-
|
|
286
|
+
antfu: default3,
|
|
287
|
+
style: pluginStylistic
|
|
198
288
|
},
|
|
199
289
|
rules: {
|
|
200
|
-
|
|
201
|
-
"
|
|
202
|
-
"
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
"
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
290
|
+
...config.rules,
|
|
291
|
+
"antfu/consistent-chaining": "error",
|
|
292
|
+
"antfu/consistent-list-newline": "off",
|
|
293
|
+
...lessOpinionated ? {
|
|
294
|
+
curly: ["error", "all"]
|
|
295
|
+
} : {
|
|
296
|
+
"antfu/curly": "error",
|
|
297
|
+
"antfu/if-newline": "error",
|
|
298
|
+
"antfu/top-level-function": "error"
|
|
299
|
+
},
|
|
300
|
+
// 覆盖`stylistic`默认规则
|
|
301
|
+
"style/brace-style": ["error", "stroustrup"],
|
|
302
|
+
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
303
|
+
"style/multiline-ternary": ["error", "never"],
|
|
304
|
+
...overrides
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/configs/formatters.ts
|
|
311
|
+
async function formatters(options = {}, stylistic2 = {}) {
|
|
312
|
+
const defaultIndent = 4;
|
|
313
|
+
if (options === true) {
|
|
314
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
315
|
+
options = {
|
|
316
|
+
css: false,
|
|
317
|
+
graphql: true,
|
|
318
|
+
html: true,
|
|
319
|
+
markdown: true,
|
|
320
|
+
svg: isPrettierPluginXmlInScope,
|
|
321
|
+
xml: isPrettierPluginXmlInScope
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
await ensurePackages([
|
|
325
|
+
"eslint-plugin-format",
|
|
326
|
+
options.xml || options.svg ? "@prettier/plugin-xml" : void 0
|
|
327
|
+
]);
|
|
328
|
+
const {
|
|
329
|
+
indent,
|
|
330
|
+
quotes,
|
|
331
|
+
semi
|
|
332
|
+
} = {
|
|
333
|
+
...StylisticConfigDefaults,
|
|
334
|
+
...stylistic2
|
|
335
|
+
};
|
|
336
|
+
const prettierOptions = Object.assign(
|
|
337
|
+
{
|
|
338
|
+
endOfLine: "lf",
|
|
339
|
+
printWidth: 200,
|
|
340
|
+
semi,
|
|
341
|
+
singleQuote: quotes === "single",
|
|
342
|
+
tabWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
343
|
+
trailingComma: "all",
|
|
344
|
+
useTabs: indent === "tab"
|
|
345
|
+
},
|
|
346
|
+
options.prettierOptions || {}
|
|
347
|
+
);
|
|
348
|
+
const prettierXmlOptions = {
|
|
349
|
+
xmlQuoteAttributes: "double",
|
|
350
|
+
xmlSelfClosingSpace: true,
|
|
351
|
+
xmlSortAttributesByKey: false,
|
|
352
|
+
xmlWhitespaceSensitivity: "ignore"
|
|
353
|
+
};
|
|
354
|
+
const dprintOptions = Object.assign(
|
|
355
|
+
{
|
|
356
|
+
indentWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
357
|
+
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
358
|
+
useTabs: indent === "tab"
|
|
359
|
+
},
|
|
360
|
+
options.dprintOptions || {}
|
|
361
|
+
);
|
|
362
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
363
|
+
const configs2 = [
|
|
364
|
+
{
|
|
365
|
+
name: "eslint/formatters/setup",
|
|
366
|
+
plugins: {
|
|
367
|
+
format: pluginFormat
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
];
|
|
371
|
+
if (options.css) {
|
|
372
|
+
configs2.push(
|
|
373
|
+
{
|
|
374
|
+
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
375
|
+
languageOptions: {
|
|
376
|
+
parser: parserPlain
|
|
377
|
+
},
|
|
378
|
+
name: "eslint/formatters/css",
|
|
379
|
+
rules: {
|
|
380
|
+
"format/prettier": [
|
|
381
|
+
"error",
|
|
382
|
+
{
|
|
383
|
+
...prettierOptions,
|
|
384
|
+
parser: "css"
|
|
385
|
+
}
|
|
386
|
+
]
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
files: [GLOB_SCSS],
|
|
391
|
+
languageOptions: {
|
|
392
|
+
parser: parserPlain
|
|
393
|
+
},
|
|
394
|
+
name: "eslint/formatters/scss",
|
|
395
|
+
rules: {
|
|
396
|
+
"format/prettier": [
|
|
397
|
+
"error",
|
|
398
|
+
{
|
|
399
|
+
...prettierOptions,
|
|
400
|
+
parser: "scss"
|
|
401
|
+
}
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
files: [GLOB_LESS],
|
|
407
|
+
languageOptions: {
|
|
408
|
+
parser: parserPlain
|
|
409
|
+
},
|
|
410
|
+
name: "eslint/formatters/less",
|
|
411
|
+
rules: {
|
|
412
|
+
"format/prettier": [
|
|
413
|
+
"error",
|
|
414
|
+
{
|
|
415
|
+
...prettierOptions,
|
|
416
|
+
parser: "less"
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
if (options.html) {
|
|
424
|
+
configs2.push({
|
|
425
|
+
files: [GLOB_HTML],
|
|
426
|
+
languageOptions: {
|
|
427
|
+
parser: parserPlain
|
|
428
|
+
},
|
|
429
|
+
name: "eslint/formatters/html",
|
|
430
|
+
rules: {
|
|
431
|
+
"format/prettier": [
|
|
432
|
+
"error",
|
|
433
|
+
{
|
|
434
|
+
...prettierOptions,
|
|
435
|
+
parser: "html"
|
|
436
|
+
}
|
|
437
|
+
]
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
if (options.svg) {
|
|
442
|
+
configs2.push({
|
|
443
|
+
files: [GLOB_SVG],
|
|
444
|
+
languageOptions: {
|
|
445
|
+
parser: parserPlain
|
|
446
|
+
},
|
|
447
|
+
name: "eslint/formatters/svg",
|
|
448
|
+
rules: {
|
|
449
|
+
"format/prettier": [
|
|
450
|
+
"error",
|
|
451
|
+
{
|
|
452
|
+
...prettierXmlOptions,
|
|
453
|
+
...prettierOptions,
|
|
454
|
+
parser: "xml",
|
|
455
|
+
plugins: [
|
|
456
|
+
"@prettier/plugin-xml"
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
if (options.markdown) {
|
|
464
|
+
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
465
|
+
configs2.push({
|
|
466
|
+
files: [GLOB_MARKDOWN],
|
|
467
|
+
languageOptions: {
|
|
468
|
+
parser: parserPlain
|
|
469
|
+
},
|
|
470
|
+
name: "eslint/formatters/markdown",
|
|
471
|
+
rules: {
|
|
472
|
+
[`format/${formater}`]: [
|
|
473
|
+
"error",
|
|
474
|
+
formater === "prettier" ? {
|
|
475
|
+
...prettierOptions,
|
|
476
|
+
embeddedLanguageFormatting: "off",
|
|
477
|
+
parser: "markdown"
|
|
478
|
+
} : {
|
|
479
|
+
...dprintOptions,
|
|
480
|
+
language: "markdown"
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
if (options.graphql) {
|
|
487
|
+
configs2.push({
|
|
488
|
+
files: [GLOB_GRAPHQL],
|
|
489
|
+
languageOptions: {
|
|
490
|
+
parser: parserPlain
|
|
491
|
+
},
|
|
492
|
+
name: "eslint/formatters/graphql",
|
|
493
|
+
rules: {
|
|
494
|
+
"format/prettier": [
|
|
495
|
+
"error",
|
|
496
|
+
{
|
|
497
|
+
...prettierOptions,
|
|
498
|
+
parser: "graphql"
|
|
499
|
+
}
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
return configs2;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// src/configs/ignores.ts
|
|
508
|
+
async function ignores(options = {}) {
|
|
509
|
+
const {
|
|
510
|
+
ignores: ignores2 = []
|
|
511
|
+
} = options;
|
|
512
|
+
return [
|
|
513
|
+
{
|
|
514
|
+
ignores: [
|
|
515
|
+
...GLOB_EXCLUDE,
|
|
516
|
+
...ignores2
|
|
517
|
+
],
|
|
518
|
+
name: "eslint/ignores"
|
|
519
|
+
}
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// src/configs/imports.ts
|
|
524
|
+
async function imports(options = {}) {
|
|
525
|
+
const {
|
|
526
|
+
stylistic: stylistic2 = true
|
|
527
|
+
} = options;
|
|
528
|
+
return [
|
|
529
|
+
{
|
|
530
|
+
name: "eslint/imports/rules",
|
|
531
|
+
plugins: {
|
|
532
|
+
antfu: default3,
|
|
533
|
+
import: pluginImport
|
|
534
|
+
},
|
|
535
|
+
rules: {
|
|
536
|
+
"antfu/import-dedupe": "error",
|
|
537
|
+
"antfu/no-import-dist": "error",
|
|
538
|
+
"antfu/no-import-node-modules-by-path": "error",
|
|
539
|
+
"import/first": "error",
|
|
540
|
+
"import/no-duplicates": "error",
|
|
541
|
+
"import/no-mutable-exports": "error",
|
|
542
|
+
"import/no-named-default": "error",
|
|
543
|
+
"import/no-self-import": "error",
|
|
544
|
+
"import/no-webpack-loader-syntax": "error",
|
|
545
|
+
...stylistic2 ? {
|
|
546
|
+
"import/newline-after-import": ["error", { considerComments: true, count: 1 }]
|
|
547
|
+
} : {}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
];
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// src/configs/javascript.ts
|
|
554
|
+
import globals from "globals";
|
|
555
|
+
async function javascript(options = {}) {
|
|
556
|
+
const {
|
|
557
|
+
isInEditor = false,
|
|
558
|
+
overrides = {}
|
|
559
|
+
} = options;
|
|
560
|
+
return [
|
|
561
|
+
{
|
|
562
|
+
languageOptions: {
|
|
563
|
+
ecmaVersion: 2022,
|
|
564
|
+
globals: {
|
|
565
|
+
...globals.browser,
|
|
566
|
+
...globals.es2021,
|
|
567
|
+
...globals.node,
|
|
568
|
+
document: "readonly",
|
|
569
|
+
navigator: "readonly",
|
|
570
|
+
window: "readonly"
|
|
571
|
+
},
|
|
572
|
+
parserOptions: {
|
|
573
|
+
ecmaFeatures: {
|
|
574
|
+
jsx: true
|
|
575
|
+
},
|
|
576
|
+
ecmaVersion: 2022,
|
|
577
|
+
sourceType: "module"
|
|
578
|
+
},
|
|
579
|
+
sourceType: "module"
|
|
580
|
+
},
|
|
581
|
+
linterOptions: {
|
|
582
|
+
reportUnusedDisableDirectives: true
|
|
583
|
+
},
|
|
584
|
+
name: "eslint/javascript/setup"
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
name: "eslint/javascript/rules",
|
|
588
|
+
plugins: {
|
|
589
|
+
"antfu": default3,
|
|
590
|
+
"unused-imports": default7
|
|
591
|
+
},
|
|
592
|
+
rules: {
|
|
593
|
+
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
594
|
+
"array-callback-return": "error",
|
|
595
|
+
"block-scoped-var": "error",
|
|
596
|
+
"constructor-super": "error",
|
|
597
|
+
"default-case-last": "error",
|
|
598
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
599
|
+
"eqeqeq": ["error", "smart"],
|
|
600
|
+
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
601
|
+
"no-alert": "error",
|
|
602
|
+
"no-array-constructor": "error",
|
|
603
|
+
"no-async-promise-executor": "error",
|
|
604
|
+
"no-caller": "error",
|
|
605
|
+
"no-case-declarations": "error",
|
|
606
|
+
"no-class-assign": "error",
|
|
607
|
+
"no-compare-neg-zero": "error",
|
|
608
|
+
"no-cond-assign": ["error", "always"],
|
|
609
|
+
// 'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
610
|
+
"no-console": "off",
|
|
611
|
+
"no-const-assign": "error",
|
|
612
|
+
"no-control-regex": "error",
|
|
613
|
+
"no-debugger": "error",
|
|
614
|
+
"no-delete-var": "error",
|
|
615
|
+
"no-dupe-args": "error",
|
|
616
|
+
"no-dupe-class-members": "error",
|
|
617
|
+
"no-dupe-keys": "error",
|
|
618
|
+
"no-duplicate-case": "error",
|
|
619
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
620
|
+
"no-empty-character-class": "error",
|
|
621
|
+
"no-empty-pattern": "error",
|
|
622
|
+
"no-eval": "error",
|
|
623
|
+
"no-ex-assign": "error",
|
|
624
|
+
"no-extend-native": "error",
|
|
625
|
+
"no-extra-bind": "error",
|
|
626
|
+
"no-extra-boolean-cast": "error",
|
|
627
|
+
"no-fallthrough": "error",
|
|
628
|
+
"no-func-assign": "error",
|
|
629
|
+
"no-global-assign": "error",
|
|
630
|
+
"no-implied-eval": "error",
|
|
631
|
+
"no-import-assign": "error",
|
|
632
|
+
"no-invalid-regexp": "error",
|
|
633
|
+
"no-irregular-whitespace": "error",
|
|
634
|
+
"no-iterator": "error",
|
|
635
|
+
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
636
|
+
"no-lone-blocks": "error",
|
|
637
|
+
"no-loss-of-precision": "error",
|
|
638
|
+
"no-misleading-character-class": "error",
|
|
639
|
+
"no-multi-str": "error",
|
|
640
|
+
"no-new": "error",
|
|
641
|
+
"no-new-func": "error",
|
|
642
|
+
"no-new-native-nonconstructor": "error",
|
|
643
|
+
"no-new-wrappers": "error",
|
|
644
|
+
"no-obj-calls": "error",
|
|
645
|
+
"no-octal": "error",
|
|
646
|
+
"no-octal-escape": "error",
|
|
647
|
+
"no-proto": "error",
|
|
648
|
+
"no-prototype-builtins": "error",
|
|
256
649
|
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
257
650
|
"no-regex-spaces": "error",
|
|
258
651
|
"no-restricted-globals": [
|
|
@@ -369,92 +762,10 @@ async function javascript(options = {}) {
|
|
|
369
762
|
"yoda": ["error", "never"],
|
|
370
763
|
...overrides
|
|
371
764
|
}
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
375
|
-
name: "eslint/scripts/disables",
|
|
376
|
-
rules: {
|
|
377
|
-
"no-console": "off"
|
|
378
|
-
}
|
|
379
765
|
}
|
|
380
766
|
];
|
|
381
767
|
}
|
|
382
768
|
|
|
383
|
-
// src/utils.ts
|
|
384
|
-
import process from "node:process";
|
|
385
|
-
import { fileURLToPath } from "node:url";
|
|
386
|
-
import { isPackageExists } from "local-pkg";
|
|
387
|
-
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
388
|
-
var isCwdInScope = isPackageExists("@antfu/eslint-config");
|
|
389
|
-
async function combine(...configs2) {
|
|
390
|
-
const resolved = await Promise.all(configs2);
|
|
391
|
-
return resolved.flat();
|
|
392
|
-
}
|
|
393
|
-
function renameRules(rules, map) {
|
|
394
|
-
return Object.fromEntries(
|
|
395
|
-
Object.entries(rules).map(([key, value]) => {
|
|
396
|
-
for (const [from, to] of Object.entries(map)) {
|
|
397
|
-
if (key.startsWith(`${from}/`)) {
|
|
398
|
-
return [to + key.slice(from.length), value];
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return [key, value];
|
|
402
|
-
})
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
function renamePluginInConfigs(configs2, map) {
|
|
406
|
-
return configs2.map((i) => {
|
|
407
|
-
const clone = { ...i };
|
|
408
|
-
if (clone.rules) {
|
|
409
|
-
clone.rules = renameRules(clone.rules, map);
|
|
410
|
-
}
|
|
411
|
-
if (clone.plugins) {
|
|
412
|
-
clone.plugins = Object.fromEntries(
|
|
413
|
-
Object.entries(clone.plugins).map(([key, value]) => {
|
|
414
|
-
if (key in map) {
|
|
415
|
-
return [map[key], value];
|
|
416
|
-
}
|
|
417
|
-
return [key, value];
|
|
418
|
-
})
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
return clone;
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
function toArray(value) {
|
|
425
|
-
return Array.isArray(value) ? value : [value];
|
|
426
|
-
}
|
|
427
|
-
async function interopDefault(m) {
|
|
428
|
-
const resolved = await m;
|
|
429
|
-
return resolved.default || resolved;
|
|
430
|
-
}
|
|
431
|
-
function isPackageInScope(name) {
|
|
432
|
-
return isPackageExists(name, { paths: [scopeUrl] });
|
|
433
|
-
}
|
|
434
|
-
async function ensurePackages(packages) {
|
|
435
|
-
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
|
|
436
|
-
return;
|
|
437
|
-
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
438
|
-
if (nonExistingPackages.length === 0)
|
|
439
|
-
return;
|
|
440
|
-
const p = await import("@clack/prompts");
|
|
441
|
-
const result = await p.confirm({
|
|
442
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
443
|
-
});
|
|
444
|
-
if (result)
|
|
445
|
-
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
446
|
-
}
|
|
447
|
-
function isInEditorEnv() {
|
|
448
|
-
if (process.env.CI)
|
|
449
|
-
return false;
|
|
450
|
-
if (isInGitHooksOrLintStaged())
|
|
451
|
-
return false;
|
|
452
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
453
|
-
}
|
|
454
|
-
function isInGitHooksOrLintStaged() {
|
|
455
|
-
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
456
|
-
}
|
|
457
|
-
|
|
458
769
|
// src/configs/jsdoc.ts
|
|
459
770
|
async function jsdoc(options = {}) {
|
|
460
771
|
const {
|
|
@@ -530,417 +841,148 @@ async function jsonc(options = {}) {
|
|
|
530
841
|
"jsonc/no-multi-str": "error",
|
|
531
842
|
"jsonc/no-nan": "error",
|
|
532
843
|
"jsonc/no-number-props": "error",
|
|
533
|
-
"jsonc/no-numeric-separators": "error",
|
|
534
|
-
"jsonc/no-octal": "error",
|
|
535
|
-
"jsonc/no-octal-escape": "error",
|
|
536
|
-
"jsonc/no-octal-numeric-literals": "error",
|
|
537
|
-
"jsonc/no-parenthesized": "error",
|
|
538
|
-
"jsonc/no-plus-sign": "error",
|
|
539
|
-
"jsonc/no-regexp-literals": "error",
|
|
540
|
-
"jsonc/no-sparse-arrays": "error",
|
|
541
|
-
"jsonc/no-template-literals": "error",
|
|
542
|
-
"jsonc/no-undefined-value": "error",
|
|
543
|
-
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
544
|
-
"jsonc/no-useless-escape": "error",
|
|
545
|
-
"jsonc/space-unary-ops": "error",
|
|
546
|
-
"jsonc/valid-json-number": "error",
|
|
547
|
-
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
548
|
-
...stylistic2 ? {
|
|
549
|
-
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
550
|
-
"jsonc/comma-dangle": ["error", "never"],
|
|
551
|
-
"jsonc/comma-style": ["error", "last"],
|
|
552
|
-
"jsonc/indent": ["error", 2],
|
|
553
|
-
"jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
554
|
-
"jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
|
|
555
|
-
"jsonc/object-curly-spacing": ["error", "always"],
|
|
556
|
-
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
557
|
-
"jsonc/quote-props": "error",
|
|
558
|
-
"jsonc/quotes": "error"
|
|
559
|
-
} : {},
|
|
560
|
-
...overrides
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
];
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// src/configs/jsx.ts
|
|
567
|
-
async function jsx() {
|
|
568
|
-
return [
|
|
569
|
-
{
|
|
570
|
-
files: [GLOB_JSX, GLOB_TSX],
|
|
571
|
-
languageOptions: {
|
|
572
|
-
parserOptions: {
|
|
573
|
-
ecmaFeatures: {
|
|
574
|
-
jsx: true
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
name: "eslint/jsx/setup"
|
|
579
|
-
}
|
|
580
|
-
];
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// src/configs/markdown.ts
|
|
584
|
-
import * as parserPlain from "eslint-parser-plain";
|
|
585
|
-
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
586
|
-
async function markdown(options = {}) {
|
|
587
|
-
const {
|
|
588
|
-
componentExts = [],
|
|
589
|
-
files = [GLOB_MARKDOWN],
|
|
590
|
-
overrides = {}
|
|
591
|
-
} = options;
|
|
592
|
-
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
593
|
-
return [
|
|
594
|
-
{
|
|
595
|
-
name: "eslint/markdown/setup",
|
|
596
|
-
plugins: {
|
|
597
|
-
markdown: markdown2
|
|
598
|
-
}
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
files,
|
|
602
|
-
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
603
|
-
name: "eslint/markdown/processor",
|
|
604
|
-
processor: mergeProcessors([
|
|
605
|
-
markdown2.processors.markdown,
|
|
606
|
-
processorPassThrough
|
|
607
|
-
])
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
files,
|
|
611
|
-
languageOptions: {
|
|
612
|
-
parser: parserPlain
|
|
613
|
-
},
|
|
614
|
-
name: "eslint/markdown/parser"
|
|
615
|
-
},
|
|
616
|
-
{
|
|
617
|
-
files: [
|
|
618
|
-
GLOB_MARKDOWN_CODE,
|
|
619
|
-
...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
620
|
-
],
|
|
621
|
-
languageOptions: {
|
|
622
|
-
parserOptions: {
|
|
623
|
-
ecmaFeatures: {
|
|
624
|
-
impliedStrict: true
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
},
|
|
628
|
-
name: "eslint/markdown/disables",
|
|
629
|
-
rules: {
|
|
630
|
-
"import/newline-after-import": "off",
|
|
631
|
-
"no-alert": "off",
|
|
632
|
-
"no-console": "off",
|
|
633
|
-
"no-labels": "off",
|
|
634
|
-
"no-lone-blocks": "off",
|
|
635
|
-
"no-restricted-syntax": "off",
|
|
636
|
-
"no-undef": "off",
|
|
637
|
-
"no-unused-expressions": "off",
|
|
638
|
-
"no-unused-labels": "off",
|
|
639
|
-
"no-unused-vars": "off",
|
|
640
|
-
"node/prefer-global/process": "off",
|
|
641
|
-
"style/comma-dangle": "off",
|
|
642
|
-
"style/eol-last": "off",
|
|
643
|
-
"ts/consistent-type-imports": "off",
|
|
644
|
-
"ts/no-namespace": "off",
|
|
645
|
-
"ts/no-redeclare": "off",
|
|
646
|
-
"ts/no-require-imports": "off",
|
|
647
|
-
"ts/no-unused-expressions": "off",
|
|
648
|
-
"ts/no-unused-vars": "off",
|
|
649
|
-
"ts/no-use-before-define": "off",
|
|
650
|
-
"ts/no-var-requires": "off",
|
|
651
|
-
"unicode-bom": "off",
|
|
652
|
-
"unused-imports/no-unused-imports": "off",
|
|
653
|
-
"unused-imports/no-unused-vars": "off",
|
|
654
|
-
// Type aware rules
|
|
655
|
-
...{
|
|
656
|
-
"ts/await-thenable": "off",
|
|
657
|
-
"ts/dot-notation": "off",
|
|
658
|
-
"ts/no-floating-promises": "off",
|
|
659
|
-
"ts/no-for-in-array": "off",
|
|
660
|
-
"ts/no-implied-eval": "off",
|
|
661
|
-
"ts/no-misused-promises": "off",
|
|
662
|
-
"ts/no-unnecessary-type-assertion": "off",
|
|
663
|
-
"ts/no-unsafe-argument": "off",
|
|
664
|
-
"ts/no-unsafe-assignment": "off",
|
|
665
|
-
"ts/no-unsafe-call": "off",
|
|
666
|
-
"ts/no-unsafe-member-access": "off",
|
|
667
|
-
"ts/no-unsafe-return": "off",
|
|
668
|
-
"ts/restrict-plus-operands": "off",
|
|
669
|
-
"ts/restrict-template-expressions": "off",
|
|
670
|
-
"ts/unbound-method": "off"
|
|
671
|
-
},
|
|
844
|
+
"jsonc/no-numeric-separators": "error",
|
|
845
|
+
"jsonc/no-octal": "error",
|
|
846
|
+
"jsonc/no-octal-escape": "error",
|
|
847
|
+
"jsonc/no-octal-numeric-literals": "error",
|
|
848
|
+
"jsonc/no-parenthesized": "error",
|
|
849
|
+
"jsonc/no-plus-sign": "error",
|
|
850
|
+
"jsonc/no-regexp-literals": "error",
|
|
851
|
+
"jsonc/no-sparse-arrays": "error",
|
|
852
|
+
"jsonc/no-template-literals": "error",
|
|
853
|
+
"jsonc/no-undefined-value": "error",
|
|
854
|
+
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
855
|
+
"jsonc/no-useless-escape": "error",
|
|
856
|
+
"jsonc/space-unary-ops": "error",
|
|
857
|
+
"jsonc/valid-json-number": "error",
|
|
858
|
+
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
859
|
+
...stylistic2 ? {
|
|
860
|
+
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
861
|
+
"jsonc/comma-dangle": ["error", "never"],
|
|
862
|
+
"jsonc/comma-style": ["error", "last"],
|
|
863
|
+
"jsonc/indent": ["error", 2],
|
|
864
|
+
"jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
865
|
+
"jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
|
|
866
|
+
"jsonc/object-curly-spacing": ["error", "always"],
|
|
867
|
+
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
868
|
+
"jsonc/quote-props": "error",
|
|
869
|
+
"jsonc/quotes": "error"
|
|
870
|
+
} : {},
|
|
672
871
|
...overrides
|
|
673
872
|
}
|
|
674
873
|
}
|
|
675
874
|
];
|
|
676
875
|
}
|
|
677
876
|
|
|
678
|
-
// src/configs/
|
|
679
|
-
async function
|
|
877
|
+
// src/configs/jsx.ts
|
|
878
|
+
async function jsx() {
|
|
680
879
|
return [
|
|
681
880
|
{
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
881
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
882
|
+
languageOptions: {
|
|
883
|
+
parserOptions: {
|
|
884
|
+
ecmaFeatures: {
|
|
885
|
+
jsx: true
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
name: "eslint/jsx/setup"
|
|
686
890
|
}
|
|
687
891
|
];
|
|
688
892
|
}
|
|
689
893
|
|
|
690
|
-
// src/configs/
|
|
894
|
+
// src/configs/markdown.ts
|
|
895
|
+
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
691
896
|
import * as parserPlain2 from "eslint-parser-plain";
|
|
692
|
-
|
|
693
|
-
// src/configs/stylistic.ts
|
|
694
|
-
var StylisticConfigDefaults = {
|
|
695
|
-
indent: 4,
|
|
696
|
-
jsx: true,
|
|
697
|
-
lessOpinionated: false,
|
|
698
|
-
quotes: "single",
|
|
699
|
-
semi: false
|
|
700
|
-
};
|
|
701
|
-
async function stylistic(options = {}) {
|
|
897
|
+
async function markdown(options = {}) {
|
|
702
898
|
const {
|
|
703
|
-
|
|
704
|
-
|
|
899
|
+
componentExts = [],
|
|
900
|
+
files = [GLOB_MARKDOWN],
|
|
901
|
+
overrides = {}
|
|
705
902
|
} = options;
|
|
706
|
-
const
|
|
707
|
-
indent,
|
|
708
|
-
jsx: jsx2,
|
|
709
|
-
lessOpinionated,
|
|
710
|
-
quotes,
|
|
711
|
-
semi
|
|
712
|
-
} = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
|
|
713
|
-
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
714
|
-
const config = pluginStylistic.configs.customize({
|
|
715
|
-
flat: true,
|
|
716
|
-
indent,
|
|
717
|
-
jsx: jsx2,
|
|
718
|
-
pluginName: "style",
|
|
719
|
-
quotes,
|
|
720
|
-
semi
|
|
721
|
-
});
|
|
903
|
+
const markdown2 = await interopDefault(import("@eslint/markdown"));
|
|
722
904
|
return [
|
|
723
905
|
{
|
|
724
|
-
name: "eslint/
|
|
725
|
-
plugins: {
|
|
726
|
-
antfu: default2,
|
|
727
|
-
style: pluginStylistic
|
|
728
|
-
},
|
|
729
|
-
rules: {
|
|
730
|
-
...config.rules,
|
|
731
|
-
"antfu/consistent-list-newline": "off",
|
|
732
|
-
...lessOpinionated ? {
|
|
733
|
-
curly: ["error", "all"]
|
|
734
|
-
} : {
|
|
735
|
-
"antfu/curly": "error",
|
|
736
|
-
"antfu/if-newline": "error",
|
|
737
|
-
"antfu/top-level-function": "error"
|
|
738
|
-
},
|
|
739
|
-
// 覆盖`stylistic`默认规则
|
|
740
|
-
"style/brace-style": ["error", "stroustrup"],
|
|
741
|
-
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
742
|
-
"style/multiline-ternary": ["error", "never"],
|
|
743
|
-
...overrides
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
];
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
// src/configs/formatters.ts
|
|
750
|
-
async function formatters(options = {}, stylistic2 = {}) {
|
|
751
|
-
const defaultIndent = 4;
|
|
752
|
-
if (options === true) {
|
|
753
|
-
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
754
|
-
options = {
|
|
755
|
-
css: false,
|
|
756
|
-
graphql: true,
|
|
757
|
-
html: true,
|
|
758
|
-
markdown: true,
|
|
759
|
-
svg: isPrettierPluginXmlInScope,
|
|
760
|
-
xml: isPrettierPluginXmlInScope
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
await ensurePackages([
|
|
764
|
-
"eslint-plugin-format",
|
|
765
|
-
options.xml || options.svg ? "@prettier/plugin-xml" : void 0
|
|
766
|
-
]);
|
|
767
|
-
const {
|
|
768
|
-
indent,
|
|
769
|
-
quotes,
|
|
770
|
-
semi
|
|
771
|
-
} = {
|
|
772
|
-
...StylisticConfigDefaults,
|
|
773
|
-
...stylistic2
|
|
774
|
-
};
|
|
775
|
-
const prettierOptions = Object.assign(
|
|
776
|
-
{
|
|
777
|
-
endOfLine: "lf",
|
|
778
|
-
printWidth: 200,
|
|
779
|
-
semi,
|
|
780
|
-
singleQuote: quotes === "single",
|
|
781
|
-
tabWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
782
|
-
trailingComma: "all",
|
|
783
|
-
useTabs: indent === "tab"
|
|
784
|
-
},
|
|
785
|
-
options.prettierOptions || {}
|
|
786
|
-
);
|
|
787
|
-
const prettierXmlOptions = {
|
|
788
|
-
xmlQuoteAttributes: "double",
|
|
789
|
-
xmlSelfClosingSpace: true,
|
|
790
|
-
xmlSortAttributesByKey: false,
|
|
791
|
-
xmlWhitespaceSensitivity: "ignore"
|
|
792
|
-
};
|
|
793
|
-
const dprintOptions = Object.assign(
|
|
794
|
-
{
|
|
795
|
-
indentWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
796
|
-
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
797
|
-
useTabs: indent === "tab"
|
|
798
|
-
},
|
|
799
|
-
options.dprintOptions || {}
|
|
800
|
-
);
|
|
801
|
-
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
802
|
-
const configs2 = [
|
|
803
|
-
{
|
|
804
|
-
name: "eslint/formatters/setup",
|
|
906
|
+
name: "eslint/markdown/setup",
|
|
805
907
|
plugins: {
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
"error",
|
|
821
|
-
{
|
|
822
|
-
...prettierOptions,
|
|
823
|
-
parser: "css"
|
|
824
|
-
}
|
|
825
|
-
]
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
|
-
{
|
|
829
|
-
files: [GLOB_SCSS],
|
|
830
|
-
languageOptions: {
|
|
831
|
-
parser: parserPlain2
|
|
832
|
-
},
|
|
833
|
-
name: "eslint/formatters/scss",
|
|
834
|
-
rules: {
|
|
835
|
-
"format/prettier": [
|
|
836
|
-
"error",
|
|
837
|
-
{
|
|
838
|
-
...prettierOptions,
|
|
839
|
-
parser: "scss"
|
|
840
|
-
}
|
|
841
|
-
]
|
|
842
|
-
}
|
|
843
|
-
},
|
|
844
|
-
{
|
|
845
|
-
files: [GLOB_LESS],
|
|
846
|
-
languageOptions: {
|
|
847
|
-
parser: parserPlain2
|
|
848
|
-
},
|
|
849
|
-
name: "eslint/formatters/less",
|
|
850
|
-
rules: {
|
|
851
|
-
"format/prettier": [
|
|
852
|
-
"error",
|
|
853
|
-
{
|
|
854
|
-
...prettierOptions,
|
|
855
|
-
parser: "less"
|
|
856
|
-
}
|
|
857
|
-
]
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
);
|
|
861
|
-
}
|
|
862
|
-
if (options.html) {
|
|
863
|
-
configs2.push({
|
|
864
|
-
files: [GLOB_HTML],
|
|
865
|
-
languageOptions: {
|
|
866
|
-
parser: parserPlain2
|
|
867
|
-
},
|
|
868
|
-
name: "eslint/formatters/html",
|
|
869
|
-
rules: {
|
|
870
|
-
"format/prettier": [
|
|
871
|
-
"error",
|
|
872
|
-
{
|
|
873
|
-
...prettierOptions,
|
|
874
|
-
parser: "html"
|
|
875
|
-
}
|
|
876
|
-
]
|
|
877
|
-
}
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
if (options.svg) {
|
|
881
|
-
configs2.push({
|
|
882
|
-
files: [GLOB_SVG],
|
|
883
|
-
languageOptions: {
|
|
884
|
-
parser: parserPlain2
|
|
885
|
-
},
|
|
886
|
-
name: "eslint/formatters/svg",
|
|
887
|
-
rules: {
|
|
888
|
-
"format/prettier": [
|
|
889
|
-
"error",
|
|
890
|
-
{
|
|
891
|
-
...prettierXmlOptions,
|
|
892
|
-
...prettierOptions,
|
|
893
|
-
parser: "xml",
|
|
894
|
-
plugins: [
|
|
895
|
-
"@prettier/plugin-xml"
|
|
896
|
-
]
|
|
897
|
-
}
|
|
898
|
-
]
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
if (options.markdown) {
|
|
903
|
-
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
904
|
-
configs2.push({
|
|
905
|
-
files: [GLOB_MARKDOWN],
|
|
908
|
+
markdown: markdown2
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
files,
|
|
913
|
+
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
914
|
+
name: "eslint/markdown/processor",
|
|
915
|
+
processor: mergeProcessors([
|
|
916
|
+
markdown2.processors.markdown,
|
|
917
|
+
processorPassThrough
|
|
918
|
+
])
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
files,
|
|
906
922
|
languageOptions: {
|
|
907
923
|
parser: parserPlain2
|
|
908
924
|
},
|
|
909
|
-
name: "eslint/
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
parser: "markdown"
|
|
917
|
-
} : {
|
|
918
|
-
...dprintOptions,
|
|
919
|
-
language: "markdown"
|
|
920
|
-
}
|
|
921
|
-
]
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
if (options.graphql) {
|
|
926
|
-
configs2.push({
|
|
927
|
-
files: [GLOB_GRAPHQL],
|
|
925
|
+
name: "eslint/markdown/parser"
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
files: [
|
|
929
|
+
GLOB_MARKDOWN_CODE,
|
|
930
|
+
...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
931
|
+
],
|
|
928
932
|
languageOptions: {
|
|
929
|
-
|
|
933
|
+
parserOptions: {
|
|
934
|
+
ecmaFeatures: {
|
|
935
|
+
impliedStrict: true
|
|
936
|
+
}
|
|
937
|
+
}
|
|
930
938
|
},
|
|
931
|
-
name: "eslint/
|
|
939
|
+
name: "eslint/markdown/disables",
|
|
932
940
|
rules: {
|
|
933
|
-
"
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
941
|
+
"import/newline-after-import": "off",
|
|
942
|
+
"no-alert": "off",
|
|
943
|
+
"no-console": "off",
|
|
944
|
+
"no-labels": "off",
|
|
945
|
+
"no-lone-blocks": "off",
|
|
946
|
+
"no-restricted-syntax": "off",
|
|
947
|
+
"no-undef": "off",
|
|
948
|
+
"no-unused-expressions": "off",
|
|
949
|
+
"no-unused-labels": "off",
|
|
950
|
+
"no-unused-vars": "off",
|
|
951
|
+
"node/prefer-global/process": "off",
|
|
952
|
+
"style/comma-dangle": "off",
|
|
953
|
+
"style/eol-last": "off",
|
|
954
|
+
"ts/consistent-type-imports": "off",
|
|
955
|
+
"ts/no-namespace": "off",
|
|
956
|
+
"ts/no-redeclare": "off",
|
|
957
|
+
"ts/no-require-imports": "off",
|
|
958
|
+
"ts/no-unused-expressions": "off",
|
|
959
|
+
"ts/no-unused-vars": "off",
|
|
960
|
+
"ts/no-use-before-define": "off",
|
|
961
|
+
"unicode-bom": "off",
|
|
962
|
+
"unused-imports/no-unused-imports": "off",
|
|
963
|
+
"unused-imports/no-unused-vars": "off",
|
|
964
|
+
// Type aware rules
|
|
965
|
+
...{
|
|
966
|
+
"ts/await-thenable": "off",
|
|
967
|
+
"ts/dot-notation": "off",
|
|
968
|
+
"ts/no-floating-promises": "off",
|
|
969
|
+
"ts/no-for-in-array": "off",
|
|
970
|
+
"ts/no-implied-eval": "off",
|
|
971
|
+
"ts/no-misused-promises": "off",
|
|
972
|
+
"ts/no-unnecessary-type-assertion": "off",
|
|
973
|
+
"ts/no-unsafe-argument": "off",
|
|
974
|
+
"ts/no-unsafe-assignment": "off",
|
|
975
|
+
"ts/no-unsafe-call": "off",
|
|
976
|
+
"ts/no-unsafe-member-access": "off",
|
|
977
|
+
"ts/no-unsafe-return": "off",
|
|
978
|
+
"ts/restrict-plus-operands": "off",
|
|
979
|
+
"ts/restrict-template-expressions": "off",
|
|
980
|
+
"ts/unbound-method": "off"
|
|
981
|
+
},
|
|
982
|
+
...overrides
|
|
940
983
|
}
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
return configs2;
|
|
984
|
+
}
|
|
985
|
+
];
|
|
944
986
|
}
|
|
945
987
|
|
|
946
988
|
// src/configs/node.ts
|
|
@@ -965,6 +1007,39 @@ async function node() {
|
|
|
965
1007
|
];
|
|
966
1008
|
}
|
|
967
1009
|
|
|
1010
|
+
// src/configs/perfectionist.ts
|
|
1011
|
+
async function perfectionist() {
|
|
1012
|
+
return [
|
|
1013
|
+
{
|
|
1014
|
+
name: "eslint/perfectionist/setup",
|
|
1015
|
+
plugins: {
|
|
1016
|
+
perfectionist: default5
|
|
1017
|
+
},
|
|
1018
|
+
rules: {
|
|
1019
|
+
"perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
|
|
1020
|
+
"perfectionist/sort-imports": ["error", {
|
|
1021
|
+
groups: [
|
|
1022
|
+
"type",
|
|
1023
|
+
["parent-type", "sibling-type", "index-type"],
|
|
1024
|
+
"builtin",
|
|
1025
|
+
"external",
|
|
1026
|
+
["internal", "internal-type"],
|
|
1027
|
+
["parent", "sibling", "index"],
|
|
1028
|
+
"side-effect",
|
|
1029
|
+
"object",
|
|
1030
|
+
"unknown"
|
|
1031
|
+
],
|
|
1032
|
+
// newlinesBetween: 'ignore',
|
|
1033
|
+
order: "asc",
|
|
1034
|
+
type: "natural"
|
|
1035
|
+
}],
|
|
1036
|
+
"perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
|
|
1037
|
+
"perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
];
|
|
1041
|
+
}
|
|
1042
|
+
|
|
968
1043
|
// src/configs/react.ts
|
|
969
1044
|
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
970
1045
|
var ReactRefreshAllowConstantExportPackages = [
|
|
@@ -1399,6 +1474,65 @@ async function test(options = {}) {
|
|
|
1399
1474
|
];
|
|
1400
1475
|
}
|
|
1401
1476
|
|
|
1477
|
+
// src/configs/toml.ts
|
|
1478
|
+
async function toml(options = {}) {
|
|
1479
|
+
const {
|
|
1480
|
+
files = [GLOB_TOML],
|
|
1481
|
+
overrides = {},
|
|
1482
|
+
stylistic: stylistic2 = true
|
|
1483
|
+
} = options;
|
|
1484
|
+
const {
|
|
1485
|
+
indent = 4
|
|
1486
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1487
|
+
const [
|
|
1488
|
+
pluginToml,
|
|
1489
|
+
parserToml
|
|
1490
|
+
] = await Promise.all([
|
|
1491
|
+
interopDefault(import("eslint-plugin-toml")),
|
|
1492
|
+
interopDefault(import("toml-eslint-parser"))
|
|
1493
|
+
]);
|
|
1494
|
+
return [
|
|
1495
|
+
{
|
|
1496
|
+
name: "eslint/toml/setup",
|
|
1497
|
+
plugins: {
|
|
1498
|
+
toml: pluginToml
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
{
|
|
1502
|
+
files,
|
|
1503
|
+
languageOptions: {
|
|
1504
|
+
parser: parserToml
|
|
1505
|
+
},
|
|
1506
|
+
name: "eslint/toml/rules",
|
|
1507
|
+
rules: {
|
|
1508
|
+
"style/spaced-comment": "off",
|
|
1509
|
+
"toml/comma-style": "error",
|
|
1510
|
+
"toml/keys-order": "error",
|
|
1511
|
+
"toml/no-space-dots": "error",
|
|
1512
|
+
"toml/no-unreadable-number-separator": "error",
|
|
1513
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
1514
|
+
"toml/precision-of-integer": "error",
|
|
1515
|
+
"toml/tables-order": "error",
|
|
1516
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1517
|
+
...stylistic2 ? {
|
|
1518
|
+
"toml/array-bracket-newline": "error",
|
|
1519
|
+
"toml/array-bracket-spacing": "error",
|
|
1520
|
+
"toml/array-element-newline": "error",
|
|
1521
|
+
"toml/indent": ["error", indent === "tab" ? 4 : indent],
|
|
1522
|
+
"toml/inline-table-curly-spacing": "error",
|
|
1523
|
+
"toml/key-spacing": "error",
|
|
1524
|
+
"toml/padding-line-between-pairs": "error",
|
|
1525
|
+
"toml/padding-line-between-tables": "error",
|
|
1526
|
+
"toml/quoted-keys": "error",
|
|
1527
|
+
"toml/spaced-comment": "error",
|
|
1528
|
+
"toml/table-bracket-spacing": "error"
|
|
1529
|
+
} : {},
|
|
1530
|
+
...overrides
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
];
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1402
1536
|
// src/configs/typescript.ts
|
|
1403
1537
|
import process2 from "node:process";
|
|
1404
1538
|
async function typescript(options = {}) {
|
|
@@ -1475,7 +1609,7 @@ async function typescript(options = {}) {
|
|
|
1475
1609
|
// Install the plugins without globs, so they can be configured separately.
|
|
1476
1610
|
name: "eslint/typescript/setup",
|
|
1477
1611
|
plugins: {
|
|
1478
|
-
antfu:
|
|
1612
|
+
antfu: default3,
|
|
1479
1613
|
ts: pluginTs
|
|
1480
1614
|
}
|
|
1481
1615
|
},
|
|
@@ -1499,7 +1633,6 @@ async function typescript(options = {}) {
|
|
|
1499
1633
|
{ "@typescript-eslint": "ts" }
|
|
1500
1634
|
),
|
|
1501
1635
|
"no-dupe-class-members": "off",
|
|
1502
|
-
"no-loss-of-precision": "off",
|
|
1503
1636
|
"no-redeclare": "off",
|
|
1504
1637
|
"no-use-before-define": "off",
|
|
1505
1638
|
"no-useless-constructor": "off",
|
|
@@ -1517,7 +1650,6 @@ async function typescript(options = {}) {
|
|
|
1517
1650
|
"ts/no-extraneous-class": "off",
|
|
1518
1651
|
"ts/no-import-type-side-effects": "error",
|
|
1519
1652
|
"ts/no-invalid-void-type": "off",
|
|
1520
|
-
"ts/no-loss-of-precision": "error",
|
|
1521
1653
|
"ts/no-non-null-assertion": "off",
|
|
1522
1654
|
"ts/no-redeclare": "error",
|
|
1523
1655
|
"ts/no-require-imports": "error",
|
|
@@ -1545,32 +1677,7 @@ async function typescript(options = {}) {
|
|
|
1545
1677
|
...typeAwareRules,
|
|
1546
1678
|
...overrides
|
|
1547
1679
|
}
|
|
1548
|
-
}] : []
|
|
1549
|
-
{
|
|
1550
|
-
files: ["**/*.d.?([cm])ts"],
|
|
1551
|
-
name: "eslint/typescript/disables/dts",
|
|
1552
|
-
rules: {
|
|
1553
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
1554
|
-
"import/no-duplicates": "off",
|
|
1555
|
-
"no-restricted-syntax": "off",
|
|
1556
|
-
"unused-imports/no-unused-vars": "off"
|
|
1557
|
-
}
|
|
1558
|
-
},
|
|
1559
|
-
{
|
|
1560
|
-
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1561
|
-
name: "eslint/typescript/disables/test",
|
|
1562
|
-
rules: {
|
|
1563
|
-
"no-unused-expressions": "off"
|
|
1564
|
-
}
|
|
1565
|
-
},
|
|
1566
|
-
{
|
|
1567
|
-
files: ["**/*.js", "**/*.cjs"],
|
|
1568
|
-
name: "eslint/typescript/disables/cjs",
|
|
1569
|
-
rules: {
|
|
1570
|
-
"ts/no-require-imports": "off",
|
|
1571
|
-
"ts/no-var-requires": "off"
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1680
|
+
}] : []
|
|
1574
1681
|
];
|
|
1575
1682
|
}
|
|
1576
1683
|
|
|
@@ -1580,12 +1687,11 @@ async function unicorn(options = {}) {
|
|
|
1580
1687
|
{
|
|
1581
1688
|
name: "eslint/unicorn/rules",
|
|
1582
1689
|
plugins: {
|
|
1583
|
-
unicorn:
|
|
1690
|
+
unicorn: default6
|
|
1584
1691
|
},
|
|
1585
1692
|
rules: {
|
|
1586
|
-
...options.allRecommended ?
|
|
1693
|
+
...options.allRecommended ? default6.configs["flat/recommended"].rules : {
|
|
1587
1694
|
"unicorn/consistent-empty-array-spread": "error",
|
|
1588
|
-
"unicorn/consistent-function-scoping": "error",
|
|
1589
1695
|
"unicorn/error-message": "error",
|
|
1590
1696
|
"unicorn/escape-case": "error",
|
|
1591
1697
|
"unicorn/new-for-builtins": "error",
|
|
@@ -1874,65 +1980,6 @@ async function yaml(options = {}) {
|
|
|
1874
1980
|
];
|
|
1875
1981
|
}
|
|
1876
1982
|
|
|
1877
|
-
// src/configs/toml.ts
|
|
1878
|
-
async function toml(options = {}) {
|
|
1879
|
-
const {
|
|
1880
|
-
files = [GLOB_TOML],
|
|
1881
|
-
overrides = {},
|
|
1882
|
-
stylistic: stylistic2 = true
|
|
1883
|
-
} = options;
|
|
1884
|
-
const {
|
|
1885
|
-
indent = 4
|
|
1886
|
-
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1887
|
-
const [
|
|
1888
|
-
pluginToml,
|
|
1889
|
-
parserToml
|
|
1890
|
-
] = await Promise.all([
|
|
1891
|
-
interopDefault(import("eslint-plugin-toml")),
|
|
1892
|
-
interopDefault(import("toml-eslint-parser"))
|
|
1893
|
-
]);
|
|
1894
|
-
return [
|
|
1895
|
-
{
|
|
1896
|
-
name: "eslint/toml/setup",
|
|
1897
|
-
plugins: {
|
|
1898
|
-
toml: pluginToml
|
|
1899
|
-
}
|
|
1900
|
-
},
|
|
1901
|
-
{
|
|
1902
|
-
files,
|
|
1903
|
-
languageOptions: {
|
|
1904
|
-
parser: parserToml
|
|
1905
|
-
},
|
|
1906
|
-
name: "eslint/toml/rules",
|
|
1907
|
-
rules: {
|
|
1908
|
-
"style/spaced-comment": "off",
|
|
1909
|
-
"toml/comma-style": "error",
|
|
1910
|
-
"toml/keys-order": "error",
|
|
1911
|
-
"toml/no-space-dots": "error",
|
|
1912
|
-
"toml/no-unreadable-number-separator": "error",
|
|
1913
|
-
"toml/precision-of-fractional-seconds": "error",
|
|
1914
|
-
"toml/precision-of-integer": "error",
|
|
1915
|
-
"toml/tables-order": "error",
|
|
1916
|
-
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1917
|
-
...stylistic2 ? {
|
|
1918
|
-
"toml/array-bracket-newline": "error",
|
|
1919
|
-
"toml/array-bracket-spacing": "error",
|
|
1920
|
-
"toml/array-element-newline": "error",
|
|
1921
|
-
"toml/indent": ["error", indent === "tab" ? 4 : indent],
|
|
1922
|
-
"toml/inline-table-curly-spacing": "error",
|
|
1923
|
-
"toml/key-spacing": "error",
|
|
1924
|
-
"toml/padding-line-between-pairs": "error",
|
|
1925
|
-
"toml/padding-line-between-tables": "error",
|
|
1926
|
-
"toml/quoted-keys": "error",
|
|
1927
|
-
"toml/spaced-comment": "error",
|
|
1928
|
-
"toml/table-bracket-spacing": "error"
|
|
1929
|
-
} : {},
|
|
1930
|
-
...overrides
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
];
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
1983
|
// src/factory.ts
|
|
1937
1984
|
var flatConfigProps = [
|
|
1938
1985
|
"name",
|
|
@@ -2120,6 +2167,9 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2120
2167
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2121
2168
|
));
|
|
2122
2169
|
}
|
|
2170
|
+
configs2.push(
|
|
2171
|
+
disables()
|
|
2172
|
+
);
|
|
2123
2173
|
if ("files" in options) {
|
|
2124
2174
|
throw new Error("[@lincy/eslint-config] \u7B2C\u4E00\u4E2A\u53C2\u6570\u4E0D\u5E94\u5305\u542B\u201Cfiles\u201D\u5C5E\u6027\uFF0C\u56E0\u4E3A\u9009\u9879\u5E94\u8BE5\u662F\u5168\u5C40\u7684\u3002\u8BF7\u5C06\u5176\u653E\u5728\u7B2C\u4E8C\u4E2A\u6216\u66F4\u540E\u9762\u7684\u914D\u7F6E\u4E2D\u3002");
|
|
2125
2175
|
}
|
|
@@ -2179,6 +2229,7 @@ export {
|
|
|
2179
2229
|
comments,
|
|
2180
2230
|
src_default as default,
|
|
2181
2231
|
defaultPluginRenaming,
|
|
2232
|
+
disables,
|
|
2182
2233
|
ensurePackages,
|
|
2183
2234
|
formatters,
|
|
2184
2235
|
ignores,
|
|
@@ -2194,6 +2245,7 @@ export {
|
|
|
2194
2245
|
lincy,
|
|
2195
2246
|
markdown,
|
|
2196
2247
|
node,
|
|
2248
|
+
parserPlain,
|
|
2197
2249
|
perfectionist,
|
|
2198
2250
|
react,
|
|
2199
2251
|
regexp,
|