@sxzz/eslint-config 3.0.0 → 3.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/index.cjs +743 -0
- package/package.json +19 -16
- package/src/jsonc.js +1 -0
- package/src/shared.js +1 -1
package/index.cjs
ADDED
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all2) => {
|
|
9
|
+
for (var name in all2)
|
|
10
|
+
__defProp(target, name, { get: all2[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// index.js
|
|
31
|
+
var eslint_config_exports = {};
|
|
32
|
+
__export(eslint_config_exports, {
|
|
33
|
+
all: () => all,
|
|
34
|
+
antfuPlugin: () => import_eslint_plugin_antfu.default,
|
|
35
|
+
basic: () => basic,
|
|
36
|
+
eslintComments: () => eslintComments,
|
|
37
|
+
getVueVersion: () => getVueVersion,
|
|
38
|
+
importPlugin: () => import_eslint_plugin_import.default,
|
|
39
|
+
imports: () => imports,
|
|
40
|
+
js: () => js,
|
|
41
|
+
jsonc: () => jsonc,
|
|
42
|
+
jsx: () => jsx,
|
|
43
|
+
markdown: () => markdown,
|
|
44
|
+
pkgOrder: () => pkgOrder,
|
|
45
|
+
prettier: () => prettier,
|
|
46
|
+
reactivityTransform: () => reactivityTransform,
|
|
47
|
+
sxzz: () => sxzz,
|
|
48
|
+
tsParser: () => import_parser.default,
|
|
49
|
+
tsPlugin: () => import_eslint_plugin2.default,
|
|
50
|
+
typescript: () => typescript,
|
|
51
|
+
unicorn: () => unicorn,
|
|
52
|
+
unicornPlugin: () => import_eslint_plugin_unicorn.default,
|
|
53
|
+
vue: () => vue,
|
|
54
|
+
vueParser: () => import_vue_eslint_parser.default,
|
|
55
|
+
vuePlugin: () => import_eslint_plugin_vue.default,
|
|
56
|
+
yml: () => yml
|
|
57
|
+
});
|
|
58
|
+
module.exports = __toCommonJS(eslint_config_exports);
|
|
59
|
+
|
|
60
|
+
// src/eslint-comments.js
|
|
61
|
+
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
62
|
+
var eslintComments = [
|
|
63
|
+
{
|
|
64
|
+
plugins: {
|
|
65
|
+
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
66
|
+
},
|
|
67
|
+
rules: {
|
|
68
|
+
...import_eslint_plugin_eslint_comments.default.configs.recommended.rules,
|
|
69
|
+
"eslint-comments/disable-enable-pair": [
|
|
70
|
+
"error",
|
|
71
|
+
{ allowWholeFile: true }
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
// src/js.js
|
|
78
|
+
var import_globals = __toESM(require("globals"), 1);
|
|
79
|
+
var import_js = __toESM(require("@eslint/js"), 1);
|
|
80
|
+
var import_eslint_plugin_import = __toESM(require("eslint-plugin-import"), 1);
|
|
81
|
+
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
82
|
+
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
83
|
+
|
|
84
|
+
// src/shared.js
|
|
85
|
+
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
86
|
+
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
87
|
+
var GLOB_TS = "**/*.?([cm])ts";
|
|
88
|
+
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
89
|
+
var GLOB_JSON = "**/*.json";
|
|
90
|
+
var GLOB_JSON5 = "**/*.json5";
|
|
91
|
+
var GLOB_JSONC = "**/*.jsonc";
|
|
92
|
+
var GLOB_MARKDOWN = "**/*.md";
|
|
93
|
+
var GLOB_VUE = "**/*.vue";
|
|
94
|
+
var GLOB_YAML = "**/*.y?(a)ml";
|
|
95
|
+
var GLOB_NODE_MODULES = (
|
|
96
|
+
/** @type {const} */
|
|
97
|
+
"**/node_modules"
|
|
98
|
+
);
|
|
99
|
+
var GLOB_DIST = (
|
|
100
|
+
/** @type {const} */
|
|
101
|
+
"**/dist"
|
|
102
|
+
);
|
|
103
|
+
var GLOB_LOCKFILE = (
|
|
104
|
+
/** @type {const} */
|
|
105
|
+
[
|
|
106
|
+
"**/package-lock.json",
|
|
107
|
+
"**/yarn.lock",
|
|
108
|
+
"**/pnpm-lock.yaml"
|
|
109
|
+
]
|
|
110
|
+
);
|
|
111
|
+
var GLOB_EXCLUDE = (
|
|
112
|
+
/** @type {const} */
|
|
113
|
+
[
|
|
114
|
+
GLOB_NODE_MODULES,
|
|
115
|
+
GLOB_DIST,
|
|
116
|
+
...GLOB_LOCKFILE,
|
|
117
|
+
"**/output",
|
|
118
|
+
"**/coverage",
|
|
119
|
+
"**/temp",
|
|
120
|
+
"**/fixtures",
|
|
121
|
+
"**/.vitepress/cache",
|
|
122
|
+
"**/.nuxt",
|
|
123
|
+
"**/.vercel",
|
|
124
|
+
"**/.changeset",
|
|
125
|
+
"**/.idea",
|
|
126
|
+
"**/.output",
|
|
127
|
+
"**/.vite-inspect",
|
|
128
|
+
"**/CHANGELOG*.md",
|
|
129
|
+
"**/*.min.*",
|
|
130
|
+
"**/LICENSE*",
|
|
131
|
+
"**/__snapshots__",
|
|
132
|
+
"**/auto-import?(s).d.ts",
|
|
133
|
+
"**/components.d.ts"
|
|
134
|
+
]
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// src/js.js
|
|
138
|
+
var js = [
|
|
139
|
+
import_js.default.configs.recommended,
|
|
140
|
+
{
|
|
141
|
+
languageOptions: {
|
|
142
|
+
globals: {
|
|
143
|
+
...import_globals.default.browser,
|
|
144
|
+
...import_globals.default.es2021,
|
|
145
|
+
...import_globals.default.node
|
|
146
|
+
},
|
|
147
|
+
sourceType: "module"
|
|
148
|
+
},
|
|
149
|
+
rules: {
|
|
150
|
+
"no-unused-vars": ["error", { args: "none", ignoreRestSiblings: true }],
|
|
151
|
+
"no-constant-condition": "warn",
|
|
152
|
+
"no-debugger": "warn",
|
|
153
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
154
|
+
"no-restricted-syntax": [
|
|
155
|
+
"error",
|
|
156
|
+
"ForInStatement",
|
|
157
|
+
"LabeledStatement",
|
|
158
|
+
"WithStatement"
|
|
159
|
+
],
|
|
160
|
+
"no-return-await": "warn",
|
|
161
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
162
|
+
"sort-imports": [
|
|
163
|
+
"error",
|
|
164
|
+
{
|
|
165
|
+
ignoreCase: false,
|
|
166
|
+
ignoreDeclarationSort: true,
|
|
167
|
+
ignoreMemberSort: false,
|
|
168
|
+
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
|
|
169
|
+
allowSeparatedGroups: false
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"no-var": "error",
|
|
173
|
+
"prefer-const": [
|
|
174
|
+
"warn",
|
|
175
|
+
{ destructuring: "all", ignoreReadBeforeAssign: true }
|
|
176
|
+
],
|
|
177
|
+
"prefer-arrow-callback": [
|
|
178
|
+
"error",
|
|
179
|
+
{ allowNamedFunctions: false, allowUnboundThis: true }
|
|
180
|
+
],
|
|
181
|
+
"object-shorthand": [
|
|
182
|
+
"error",
|
|
183
|
+
"always",
|
|
184
|
+
{ ignoreConstructors: false, avoidQuotes: true }
|
|
185
|
+
],
|
|
186
|
+
"prefer-rest-params": "error",
|
|
187
|
+
"prefer-spread": "error",
|
|
188
|
+
"prefer-template": "error",
|
|
189
|
+
"require-await": "error",
|
|
190
|
+
"array-callback-return": "error",
|
|
191
|
+
"block-scoped-var": "error",
|
|
192
|
+
eqeqeq: ["error", "smart"],
|
|
193
|
+
"no-alert": "warn",
|
|
194
|
+
"no-case-declarations": "error",
|
|
195
|
+
"no-fallthrough": ["warn", { commentPattern: "break[\\s\\w]*omitted" }],
|
|
196
|
+
"no-multi-str": "error",
|
|
197
|
+
"no-with": "error",
|
|
198
|
+
"no-void": "error",
|
|
199
|
+
"no-duplicate-imports": "error",
|
|
200
|
+
"no-unused-expressions": [
|
|
201
|
+
"error",
|
|
202
|
+
{
|
|
203
|
+
allowShortCircuit: true,
|
|
204
|
+
allowTernary: true,
|
|
205
|
+
allowTaggedTemplates: true
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"no-lonely-if": "error",
|
|
209
|
+
"prefer-exponentiation-operator": "error"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
files: ["**/scripts/*", "**/cli.*"],
|
|
214
|
+
rules: {
|
|
215
|
+
"no-console": "off"
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
files: ["**/*.{test,spec}.js?(x)"],
|
|
220
|
+
rules: {
|
|
221
|
+
"no-unused-expressions": "off"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
var jsx = [
|
|
226
|
+
{
|
|
227
|
+
files: ["**/*.jsx"],
|
|
228
|
+
languageOptions: {
|
|
229
|
+
parserOptions: {
|
|
230
|
+
ecmaFeatures: {
|
|
231
|
+
jsx: true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
];
|
|
237
|
+
var imports = [
|
|
238
|
+
{
|
|
239
|
+
plugins: {
|
|
240
|
+
import: import_eslint_plugin_import.default,
|
|
241
|
+
antfu: import_eslint_plugin_antfu.default
|
|
242
|
+
},
|
|
243
|
+
settings: {
|
|
244
|
+
"import/resolver": {
|
|
245
|
+
node: { extensions: [".js", ".mjs", ".ts", ".mts", ".d.ts"] }
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
rules: {
|
|
249
|
+
"import/first": "error",
|
|
250
|
+
"import/no-mutable-exports": "error",
|
|
251
|
+
"import/no-duplicates": "error",
|
|
252
|
+
"import/order": [
|
|
253
|
+
"error",
|
|
254
|
+
{
|
|
255
|
+
groups: [
|
|
256
|
+
"builtin",
|
|
257
|
+
"external",
|
|
258
|
+
"internal",
|
|
259
|
+
"parent",
|
|
260
|
+
"sibling",
|
|
261
|
+
"index",
|
|
262
|
+
"object",
|
|
263
|
+
"type"
|
|
264
|
+
],
|
|
265
|
+
pathGroups: [{ pattern: "@/**", group: "internal" }],
|
|
266
|
+
pathGroupsExcludedImportTypes: ["type"]
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"import/no-default-export": "error",
|
|
270
|
+
"antfu/import-dedupe": "error",
|
|
271
|
+
"antfu/prefer-inline-type-import": "error"
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
files: [
|
|
276
|
+
`**/*config*.${GLOB_SRC_EXT}`,
|
|
277
|
+
`**/views/${GLOB_SRC}`,
|
|
278
|
+
`**/pages/${GLOB_SRC}`,
|
|
279
|
+
`**/{index,vite,esbuild,rollup,webpack,rspack}.ts`,
|
|
280
|
+
"**/*.d.ts",
|
|
281
|
+
`${GLOB_MARKDOWN}/**`
|
|
282
|
+
],
|
|
283
|
+
plugins: {
|
|
284
|
+
import: import_eslint_plugin_import.default
|
|
285
|
+
},
|
|
286
|
+
rules: {
|
|
287
|
+
"import/no-default-export": "off"
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
];
|
|
291
|
+
var unicorn = [
|
|
292
|
+
{
|
|
293
|
+
plugins: {
|
|
294
|
+
unicorn: import_eslint_plugin_unicorn.default
|
|
295
|
+
},
|
|
296
|
+
rules: {
|
|
297
|
+
"unicorn/better-regex": "error",
|
|
298
|
+
"unicorn/custom-error-definition": "error",
|
|
299
|
+
"unicorn/error-message": "error",
|
|
300
|
+
"unicorn/escape-case": "error",
|
|
301
|
+
"unicorn/explicit-length-check": "error",
|
|
302
|
+
"unicorn/import-index": "error",
|
|
303
|
+
"unicorn/new-for-builtins": "error",
|
|
304
|
+
"unicorn/no-array-callback-reference": "error",
|
|
305
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
306
|
+
"unicorn/no-array-push-push": "error",
|
|
307
|
+
"unicorn/no-console-spaces": "error",
|
|
308
|
+
"unicorn/no-for-loop": "error",
|
|
309
|
+
"unicorn/no-hex-escape": "error",
|
|
310
|
+
"unicorn/no-instanceof-array": "error",
|
|
311
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
312
|
+
"unicorn/no-lonely-if": "error",
|
|
313
|
+
"unicorn/no-new-array": "error",
|
|
314
|
+
"unicorn/no-new-buffer": "error",
|
|
315
|
+
"unicorn/no-unnecessary-await": "error",
|
|
316
|
+
"unicorn/no-unsafe-regex": "off",
|
|
317
|
+
"unicorn/number-literal-case": "error",
|
|
318
|
+
"unicorn/prefer-add-event-listener": "error",
|
|
319
|
+
"unicorn/prefer-array-find": "error",
|
|
320
|
+
"unicorn/prefer-array-flat-map": "error",
|
|
321
|
+
"unicorn/prefer-array-index-of": "error",
|
|
322
|
+
"unicorn/prefer-array-some": "error",
|
|
323
|
+
"unicorn/prefer-at": "error",
|
|
324
|
+
"unicorn/prefer-blob-reading-methods": "error",
|
|
325
|
+
"unicorn/prefer-date-now": "error",
|
|
326
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
327
|
+
"unicorn/prefer-dom-node-dataset": "error",
|
|
328
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
329
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
330
|
+
"unicorn/prefer-includes": "error",
|
|
331
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
332
|
+
"unicorn/prefer-math-trunc": "error",
|
|
333
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
334
|
+
"unicorn/prefer-negative-index": "error",
|
|
335
|
+
"unicorn/prefer-node-protocol": "error",
|
|
336
|
+
"unicorn/prefer-number-properties": "error",
|
|
337
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
338
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
339
|
+
"unicorn/prefer-query-selector": "error",
|
|
340
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
341
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
342
|
+
"unicorn/prefer-string-slice": "error",
|
|
343
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
344
|
+
"unicorn/prefer-string-trim-start-end": "error",
|
|
345
|
+
"unicorn/prefer-type-error": "error",
|
|
346
|
+
"unicorn/throw-new-error": "error"
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
];
|
|
350
|
+
|
|
351
|
+
// src/jsonc.js
|
|
352
|
+
var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
|
|
353
|
+
var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
|
|
354
|
+
var jsonc = [
|
|
355
|
+
{
|
|
356
|
+
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
357
|
+
plugins: {
|
|
358
|
+
jsonc: import_eslint_plugin_jsonc.default
|
|
359
|
+
},
|
|
360
|
+
languageOptions: {
|
|
361
|
+
parser: import_jsonc_eslint_parser.default
|
|
362
|
+
},
|
|
363
|
+
rules: {
|
|
364
|
+
...import_eslint_plugin_jsonc.configs["recommended-with-jsonc"].rules,
|
|
365
|
+
"jsonc/quote-props": "off",
|
|
366
|
+
"jsonc/quotes": "off"
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
];
|
|
370
|
+
var pkgOrder = [
|
|
371
|
+
{
|
|
372
|
+
files: ["**/package.json"],
|
|
373
|
+
rules: {
|
|
374
|
+
"jsonc/sort-keys": [
|
|
375
|
+
"error",
|
|
376
|
+
{
|
|
377
|
+
pathPattern: "^$",
|
|
378
|
+
order: [
|
|
379
|
+
"name",
|
|
380
|
+
"version",
|
|
381
|
+
"private",
|
|
382
|
+
"packageManager",
|
|
383
|
+
"description",
|
|
384
|
+
"type",
|
|
385
|
+
"keywords",
|
|
386
|
+
"license",
|
|
387
|
+
"homepage",
|
|
388
|
+
"bugs",
|
|
389
|
+
"repository",
|
|
390
|
+
"author",
|
|
391
|
+
"contributors",
|
|
392
|
+
"funding",
|
|
393
|
+
"files",
|
|
394
|
+
"main",
|
|
395
|
+
"module",
|
|
396
|
+
"types",
|
|
397
|
+
"exports",
|
|
398
|
+
"typesVersions",
|
|
399
|
+
"unpkg",
|
|
400
|
+
"jsdelivr",
|
|
401
|
+
"browser",
|
|
402
|
+
"bin",
|
|
403
|
+
"man",
|
|
404
|
+
"directories",
|
|
405
|
+
"publishConfig",
|
|
406
|
+
"scripts",
|
|
407
|
+
"peerDependencies",
|
|
408
|
+
"peerDependenciesMeta",
|
|
409
|
+
"optionalDependencies",
|
|
410
|
+
"dependencies",
|
|
411
|
+
"devDependencies",
|
|
412
|
+
"engines",
|
|
413
|
+
"config",
|
|
414
|
+
"overrides",
|
|
415
|
+
"pnpm",
|
|
416
|
+
"husky",
|
|
417
|
+
"lint-staged",
|
|
418
|
+
"eslintConfig",
|
|
419
|
+
"prettier"
|
|
420
|
+
]
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$",
|
|
424
|
+
order: { type: "asc" }
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
];
|
|
430
|
+
|
|
431
|
+
// src/markdown.js
|
|
432
|
+
var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
|
|
433
|
+
var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
434
|
+
var markdown = [
|
|
435
|
+
{
|
|
436
|
+
files: [GLOB_MARKDOWN],
|
|
437
|
+
plugins: {
|
|
438
|
+
markdown: import_eslint_plugin_markdown.default
|
|
439
|
+
},
|
|
440
|
+
processor: "markdown/markdown"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
|
|
444
|
+
languageOptions: {
|
|
445
|
+
parserOptions: {
|
|
446
|
+
ecmaFeatures: {
|
|
447
|
+
impliedStrict: true
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
plugins: {
|
|
452
|
+
"@typescript-eslint": import_eslint_plugin.default
|
|
453
|
+
},
|
|
454
|
+
rules: {
|
|
455
|
+
...import_eslint_plugin_markdown.default.configs.recommended.overrides[1].rules,
|
|
456
|
+
"@typescript-eslint/no-redeclare": "off",
|
|
457
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
458
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
459
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
460
|
+
"no-alert": "off",
|
|
461
|
+
"no-console": "off",
|
|
462
|
+
"no-restricted-imports": "off",
|
|
463
|
+
"no-undef": "off",
|
|
464
|
+
"no-unused-expressions": "off",
|
|
465
|
+
"no-unused-vars": "off"
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
];
|
|
469
|
+
|
|
470
|
+
// src/prettier.js
|
|
471
|
+
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
|
|
472
|
+
var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
|
|
473
|
+
var prettierConflictRules = { ...import_eslint_config_prettier.default.rules };
|
|
474
|
+
delete prettierConflictRules["vue/html-self-closing"];
|
|
475
|
+
var prettier = [
|
|
476
|
+
{
|
|
477
|
+
plugins: {
|
|
478
|
+
prettier: import_eslint_plugin_prettier.default
|
|
479
|
+
},
|
|
480
|
+
rules: {
|
|
481
|
+
...prettierConflictRules,
|
|
482
|
+
...import_eslint_plugin_prettier.default.configs.recommended.rules,
|
|
483
|
+
"prettier/prettier": "warn"
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
];
|
|
487
|
+
|
|
488
|
+
// src/typescript.js
|
|
489
|
+
var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
|
|
490
|
+
var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
491
|
+
var typescript = [
|
|
492
|
+
{
|
|
493
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
494
|
+
languageOptions: {
|
|
495
|
+
parser: import_parser.default,
|
|
496
|
+
parserOptions: {
|
|
497
|
+
sourceType: "module"
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
plugins: {
|
|
501
|
+
"@typescript-eslint": import_eslint_plugin2.default
|
|
502
|
+
},
|
|
503
|
+
rules: {
|
|
504
|
+
...import_eslint_plugin2.default.configs["eslint-recommended"].overrides[0].rules,
|
|
505
|
+
...import_eslint_plugin2.default.configs["recommended"].rules,
|
|
506
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
507
|
+
"@typescript-eslint/no-redeclare": "error",
|
|
508
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
509
|
+
"@typescript-eslint/ban-types": "off",
|
|
510
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
511
|
+
"error",
|
|
512
|
+
{ fixStyle: "inline-type-imports", disallowTypeAnnotations: false }
|
|
513
|
+
],
|
|
514
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
515
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
516
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
517
|
+
"@typescript-eslint/prefer-as-const": "warn"
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
files: ["**/*.d.ts"],
|
|
522
|
+
rules: {
|
|
523
|
+
"import/no-duplicates": "off"
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
files: ["**/*.{test,spec}.ts?(x)"],
|
|
528
|
+
rules: {
|
|
529
|
+
"no-unused-expressions": "off"
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
534
|
+
rules: {
|
|
535
|
+
"@typescript-eslint/no-var-requires": "off"
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
];
|
|
539
|
+
|
|
540
|
+
// src/vue.js
|
|
541
|
+
var import_local_pkg = require("local-pkg");
|
|
542
|
+
var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
|
|
543
|
+
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
544
|
+
var import_eslint_plugin3 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
545
|
+
function getVueVersion() {
|
|
546
|
+
const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [process.cwd()] });
|
|
547
|
+
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
|
|
548
|
+
return +pkg.version[0];
|
|
549
|
+
}
|
|
550
|
+
return 3;
|
|
551
|
+
}
|
|
552
|
+
var isVue3 = getVueVersion() === 3;
|
|
553
|
+
var reactivityTransform = [
|
|
554
|
+
{
|
|
555
|
+
languageOptions: {
|
|
556
|
+
globals: {
|
|
557
|
+
$: "readonly",
|
|
558
|
+
$$: "readonly",
|
|
559
|
+
$ref: "readonly",
|
|
560
|
+
$computed: "readonly",
|
|
561
|
+
$shallowRef: "readonly",
|
|
562
|
+
$toRef: "readonly",
|
|
563
|
+
$customRef: "readonly"
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
plugins: {
|
|
567
|
+
vue: import_eslint_plugin_vue.default
|
|
568
|
+
},
|
|
569
|
+
rules: {
|
|
570
|
+
"vue/no-setup-props-destructure": "off"
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
];
|
|
574
|
+
var vueCustomRules = {
|
|
575
|
+
"vue/max-attributes-per-line": "off",
|
|
576
|
+
"vue/no-v-html": "off",
|
|
577
|
+
"vue/multi-word-component-names": "off",
|
|
578
|
+
"vue/require-prop-types": "off",
|
|
579
|
+
"vue/require-default-prop": "off",
|
|
580
|
+
"vue/html-self-closing": [
|
|
581
|
+
"error",
|
|
582
|
+
{
|
|
583
|
+
html: {
|
|
584
|
+
void: "always",
|
|
585
|
+
normal: "always",
|
|
586
|
+
component: "always"
|
|
587
|
+
},
|
|
588
|
+
svg: "always",
|
|
589
|
+
math: "always"
|
|
590
|
+
}
|
|
591
|
+
],
|
|
592
|
+
"vue/component-tags-order": [
|
|
593
|
+
"error",
|
|
594
|
+
{ order: ["script", "template", "style"] }
|
|
595
|
+
],
|
|
596
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
597
|
+
"vue/no-useless-v-bind": "error",
|
|
598
|
+
"vue/no-unused-refs": "error",
|
|
599
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
600
|
+
"vue/prefer-template": "error",
|
|
601
|
+
"vue/eqeqeq": ["error", "smart"],
|
|
602
|
+
"vue/no-constant-condition": "warn",
|
|
603
|
+
"vue/object-shorthand": [
|
|
604
|
+
"error",
|
|
605
|
+
"always",
|
|
606
|
+
{
|
|
607
|
+
ignoreConstructors: false,
|
|
608
|
+
avoidQuotes: true
|
|
609
|
+
}
|
|
610
|
+
],
|
|
611
|
+
"vue/no-loss-of-precision": "error",
|
|
612
|
+
"vue/no-empty-pattern": "error"
|
|
613
|
+
};
|
|
614
|
+
var vue3Rules = {
|
|
615
|
+
...import_eslint_plugin_vue.default.configs["base"].rules,
|
|
616
|
+
...import_eslint_plugin_vue.default.configs["vue3-essential"].rules,
|
|
617
|
+
...import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules,
|
|
618
|
+
...import_eslint_plugin_vue.default.configs["vue3-recommended"].rules
|
|
619
|
+
};
|
|
620
|
+
var vue2Rules = {
|
|
621
|
+
...import_eslint_plugin_vue.default.configs["base"].rules,
|
|
622
|
+
...import_eslint_plugin_vue.default.configs["essential"].rules,
|
|
623
|
+
...import_eslint_plugin_vue.default.configs["strongly-recommended"].rules,
|
|
624
|
+
...import_eslint_plugin_vue.default.configs["recommended"].rules
|
|
625
|
+
};
|
|
626
|
+
var vue = [
|
|
627
|
+
{
|
|
628
|
+
files: [GLOB_VUE],
|
|
629
|
+
plugins: {
|
|
630
|
+
vue: import_eslint_plugin_vue.default,
|
|
631
|
+
"@typescript-eslint": import_eslint_plugin3.default
|
|
632
|
+
},
|
|
633
|
+
languageOptions: {
|
|
634
|
+
parser: import_vue_eslint_parser.default,
|
|
635
|
+
parserOptions: {
|
|
636
|
+
parser: "@typescript-eslint/parser",
|
|
637
|
+
sourceType: "module",
|
|
638
|
+
extraFileExtensions: [".vue"],
|
|
639
|
+
ecmaFeatures: {
|
|
640
|
+
jsx: true
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
processor: import_eslint_plugin_vue.default.processors[".vue"],
|
|
645
|
+
rules: {
|
|
646
|
+
...typescript[0].rules
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
plugins: {
|
|
651
|
+
vue: import_eslint_plugin_vue.default
|
|
652
|
+
},
|
|
653
|
+
rules: {
|
|
654
|
+
...isVue3 ? vue3Rules : vue2Rules,
|
|
655
|
+
...vueCustomRules
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
...reactivityTransform
|
|
659
|
+
];
|
|
660
|
+
|
|
661
|
+
// src/yml.js
|
|
662
|
+
var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
|
|
663
|
+
var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
|
|
664
|
+
var yml = [
|
|
665
|
+
{
|
|
666
|
+
files: [GLOB_YAML],
|
|
667
|
+
plugins: {
|
|
668
|
+
yml: import_eslint_plugin_yml.default
|
|
669
|
+
},
|
|
670
|
+
languageOptions: {
|
|
671
|
+
parser: import_yaml_eslint_parser.default
|
|
672
|
+
},
|
|
673
|
+
rules: {
|
|
674
|
+
...import_eslint_plugin_yml.configs.standard.rules,
|
|
675
|
+
...import_eslint_plugin_yml.configs.prettier.rules,
|
|
676
|
+
"yml/no-empty-mapping-value": "off"
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
];
|
|
680
|
+
|
|
681
|
+
// src/presets.js
|
|
682
|
+
var basic = [
|
|
683
|
+
// @ts-ignore
|
|
684
|
+
{ ignores: GLOB_EXCLUDE },
|
|
685
|
+
...js,
|
|
686
|
+
...jsx,
|
|
687
|
+
...typescript,
|
|
688
|
+
...imports,
|
|
689
|
+
...unicorn,
|
|
690
|
+
...jsonc,
|
|
691
|
+
...pkgOrder,
|
|
692
|
+
...yml,
|
|
693
|
+
...eslintComments
|
|
694
|
+
];
|
|
695
|
+
var all = [...vue, ...basic, ...prettier];
|
|
696
|
+
function sxzz(config = [], {
|
|
697
|
+
vue: enableVue = true,
|
|
698
|
+
prettier: enablePrettier = true,
|
|
699
|
+
markdown: enableMarkdown = true
|
|
700
|
+
} = {}) {
|
|
701
|
+
const configs3 = [];
|
|
702
|
+
configs3.push(...basic);
|
|
703
|
+
if (enableVue !== false) {
|
|
704
|
+
configs3.push(...vue);
|
|
705
|
+
}
|
|
706
|
+
if (enableMarkdown !== false) {
|
|
707
|
+
configs3.push(...markdown);
|
|
708
|
+
}
|
|
709
|
+
if (enablePrettier !== false) {
|
|
710
|
+
configs3.push(...prettier);
|
|
711
|
+
}
|
|
712
|
+
if (Object.keys(config).length > 0) {
|
|
713
|
+
configs3.push(...Array.isArray(config) ? config : [config]);
|
|
714
|
+
}
|
|
715
|
+
return configs3;
|
|
716
|
+
}
|
|
717
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
718
|
+
0 && (module.exports = {
|
|
719
|
+
all,
|
|
720
|
+
antfuPlugin,
|
|
721
|
+
basic,
|
|
722
|
+
eslintComments,
|
|
723
|
+
getVueVersion,
|
|
724
|
+
importPlugin,
|
|
725
|
+
imports,
|
|
726
|
+
js,
|
|
727
|
+
jsonc,
|
|
728
|
+
jsx,
|
|
729
|
+
markdown,
|
|
730
|
+
pkgOrder,
|
|
731
|
+
prettier,
|
|
732
|
+
reactivityTransform,
|
|
733
|
+
sxzz,
|
|
734
|
+
tsParser,
|
|
735
|
+
tsPlugin,
|
|
736
|
+
typescript,
|
|
737
|
+
unicorn,
|
|
738
|
+
unicornPlugin,
|
|
739
|
+
vue,
|
|
740
|
+
vueParser,
|
|
741
|
+
vuePlugin,
|
|
742
|
+
yml
|
|
743
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sxzz/eslint-config",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"packageManager": "pnpm@8.6.
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"packageManager": "pnpm@8.6.3",
|
|
5
5
|
"description": "ESLint config for @sxzz.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -15,14 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"index.js",
|
|
18
|
+
"index.cjs",
|
|
18
19
|
"src"
|
|
19
20
|
],
|
|
20
21
|
"main": "./index.js",
|
|
21
22
|
"module": "./index.js",
|
|
22
|
-
"types": "./index.d.ts",
|
|
23
23
|
"exports": {
|
|
24
|
-
"
|
|
25
|
-
"require": "./index.js",
|
|
24
|
+
"require": "./index.cjs",
|
|
26
25
|
"import": "./index.js"
|
|
27
26
|
},
|
|
28
27
|
"publishConfig": {
|
|
@@ -32,37 +31,41 @@
|
|
|
32
31
|
"eslint": "^8.0.0"
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"@eslint/js": "^8.
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
37
|
-
"@typescript-eslint/parser": "^5.
|
|
34
|
+
"@eslint/js": "^8.43.0",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
|
36
|
+
"@typescript-eslint/parser": "^5.60.0",
|
|
38
37
|
"eslint-config-prettier": "^8.8.0",
|
|
39
|
-
"eslint-define-config": "^1.
|
|
38
|
+
"eslint-define-config": "^1.21.0",
|
|
40
39
|
"eslint-plugin-antfu": "^0.39.5",
|
|
41
40
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
42
41
|
"eslint-plugin-import": "^2.27.5",
|
|
43
|
-
"eslint-plugin-jsonc": "^2.
|
|
42
|
+
"eslint-plugin-jsonc": "^2.9.0",
|
|
44
43
|
"eslint-plugin-markdown": "^3.0.0",
|
|
45
44
|
"eslint-plugin-prettier": "^4.2.1",
|
|
46
45
|
"eslint-plugin-unicorn": "^47.0.0",
|
|
47
|
-
"eslint-plugin-vue": "^9.
|
|
48
|
-
"eslint-plugin-yml": "^1.
|
|
46
|
+
"eslint-plugin-vue": "^9.15.1",
|
|
47
|
+
"eslint-plugin-yml": "^1.8.0",
|
|
49
48
|
"globals": "^13.20.0",
|
|
50
49
|
"jsonc-eslint-parser": "^2.3.0",
|
|
51
50
|
"local-pkg": "^0.4.3",
|
|
52
51
|
"prettier": "^2.8.8",
|
|
53
|
-
"vue-eslint-parser": "^9.3.
|
|
52
|
+
"vue-eslint-parser": "^9.3.1",
|
|
54
53
|
"yaml-eslint-parser": "^1.2.2"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"
|
|
56
|
+
"@sxzz/prettier-config": "^1.0.1",
|
|
57
|
+
"@types/node": "^18.16.18",
|
|
58
|
+
"bumpp": "^9.1.1",
|
|
59
|
+
"eslint": "^8.43.0",
|
|
60
|
+
"tsup": "^7.0.0",
|
|
60
61
|
"typescript": "^5.1.3"
|
|
61
62
|
},
|
|
62
63
|
"engines": {
|
|
63
64
|
"node": ">=16.14.0"
|
|
64
65
|
},
|
|
66
|
+
"prettier": "@sxzz/prettier-config",
|
|
65
67
|
"scripts": {
|
|
68
|
+
"build": "tsup",
|
|
66
69
|
"lint": "eslint .",
|
|
67
70
|
"lint:fix": "pnpm run lint --fix",
|
|
68
71
|
"release": "bumpp && pnpm publish"
|
package/src/jsonc.js
CHANGED