@jsse/eslint-config 0.0.1

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.js ADDED
@@ -0,0 +1,2189 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // node_modules/.pnpm/natural-compare@1.4.0/node_modules/natural-compare/index.js
28
+ var require_natural_compare = __commonJS({
29
+ "node_modules/.pnpm/natural-compare@1.4.0/node_modules/natural-compare/index.js"(exports, module) {
30
+ "use strict";
31
+ var naturalCompare = function(a, b) {
32
+ var i, codeA, codeB = 1, posA = 0, posB = 0, alphabet = String.alphabet;
33
+ function getCode(str, pos, code) {
34
+ if (code) {
35
+ for (i = pos; code = getCode(str, i), code < 76 && code > 65; )
36
+ ++i;
37
+ return +str.slice(pos - 1, i);
38
+ }
39
+ code = alphabet && alphabet.indexOf(str.charAt(pos));
40
+ return code > -1 ? code + 76 : (code = str.charCodeAt(pos) || 0, code < 45 || code > 127) ? code : code < 46 ? 65 : code < 48 ? code - 1 : code < 58 ? code + 18 : code < 65 ? code - 11 : code < 91 ? code + 11 : code < 97 ? code - 37 : code < 123 ? code + 5 : code - 63;
41
+ }
42
+ if ((a += "") != (b += ""))
43
+ for (; codeB; ) {
44
+ codeA = getCode(a, posA++);
45
+ codeB = getCode(b, posB++);
46
+ if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
47
+ codeA = getCode(a, posA, posA);
48
+ codeB = getCode(b, posB, posA = i);
49
+ posB = i;
50
+ }
51
+ if (codeA != codeB)
52
+ return codeA < codeB ? -1 : 1;
53
+ }
54
+ return 0;
55
+ };
56
+ try {
57
+ module.exports = naturalCompare;
58
+ } catch (e) {
59
+ String.naturalCompare = naturalCompare;
60
+ }
61
+ }
62
+ });
63
+
64
+ // node_modules/.pnpm/eslint-plugin-sort-keys@2.3.5/node_modules/eslint-plugin-sort-keys/rules/sort-keys-fix.js
65
+ var require_sort_keys_fix = __commonJS({
66
+ "node_modules/.pnpm/eslint-plugin-sort-keys@2.3.5/node_modules/eslint-plugin-sort-keys/rules/sort-keys-fix.js"(exports, module) {
67
+ "use strict";
68
+ var naturalCompare = require_natural_compare();
69
+ module.exports = {
70
+ meta: {
71
+ type: "suggestion",
72
+ fixable: "code",
73
+ docs: {
74
+ description: "require object keys to be sorted",
75
+ category: "Stylistic Issues",
76
+ recommended: false,
77
+ url: "https://github.com/namnm/eslint-plugin-sort-keys"
78
+ },
79
+ schema: [
80
+ {
81
+ enum: ["asc", "desc"]
82
+ },
83
+ {
84
+ type: "object",
85
+ properties: {
86
+ caseSensitive: {
87
+ type: "boolean",
88
+ default: true
89
+ },
90
+ natural: {
91
+ type: "boolean",
92
+ default: false
93
+ },
94
+ minKeys: {
95
+ type: "integer",
96
+ minimum: 2,
97
+ default: 2
98
+ }
99
+ },
100
+ additionalProperties: false
101
+ }
102
+ ],
103
+ messages: {
104
+ sortKeys: "Expected object keys to be in {{natural}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'."
105
+ }
106
+ },
107
+ create(ctx) {
108
+ const order = ctx.options[0] || "asc";
109
+ const options = ctx.options[1];
110
+ const insensitive = (options && options.caseSensitive) === false;
111
+ const natural = Boolean(options && options.natural);
112
+ const isValidOrder = isValidOrders[order + (insensitive ? "I" : "") + (natural ? "N" : "")];
113
+ const minKeys = Number(options && options.minKeys) || 2;
114
+ let stack = null;
115
+ const SpreadElement = (node2) => {
116
+ if (node2.parent.type === "ObjectExpression") {
117
+ stack.prevName = null;
118
+ }
119
+ };
120
+ return {
121
+ ExperimentalSpreadProperty: SpreadElement,
122
+ SpreadElement,
123
+ ObjectExpression() {
124
+ stack = {
125
+ upper: stack,
126
+ prevName: null,
127
+ prevNode: null
128
+ };
129
+ },
130
+ "ObjectExpression:exit"() {
131
+ stack = stack.upper;
132
+ },
133
+ Property(node2) {
134
+ if (node2.parent.type === "ObjectPattern") {
135
+ return;
136
+ }
137
+ if (node2.parent.properties.length < minKeys) {
138
+ return;
139
+ }
140
+ const prevName = stack.prevName;
141
+ const prevNode = stack.prevNode;
142
+ const thisName = getPropertyName(node2);
143
+ if (thisName !== null) {
144
+ stack.prevName = thisName;
145
+ stack.prevNode = node2 || prevNode;
146
+ }
147
+ if (prevName === null || thisName === null) {
148
+ return;
149
+ }
150
+ if (!isValidOrder(prevName, thisName)) {
151
+ ctx.report({
152
+ node: node2,
153
+ loc: node2.key.loc,
154
+ messageId: "sortKeys",
155
+ data: {
156
+ thisName,
157
+ prevName,
158
+ order,
159
+ insensitive: insensitive ? "insensitive " : "",
160
+ natural: natural ? "natural " : ""
161
+ },
162
+ fix(fixer) {
163
+ if (node2.parent.__alreadySorted || node2.parent.properties.__alreadySorted) {
164
+ return [];
165
+ }
166
+ node2.parent.__alreadySorted = true;
167
+ node2.parent.properties.__alreadySorted = true;
168
+ const src = ctx.getSourceCode();
169
+ const props = node2.parent.properties;
170
+ const parts = [];
171
+ let part = [];
172
+ props.forEach((p) => {
173
+ if (!p.key) {
174
+ parts.push(part);
175
+ part = [];
176
+ } else {
177
+ part.push(p);
178
+ }
179
+ });
180
+ parts.push(part);
181
+ parts.forEach((part2) => {
182
+ part2.sort((p1, p2) => {
183
+ const n1 = getPropertyName(p1);
184
+ const n2 = getPropertyName(p2);
185
+ if (insensitive && n1.toLowerCase() === n2.toLowerCase()) {
186
+ return 0;
187
+ }
188
+ return isValidOrder(n1, n2) ? -1 : 1;
189
+ });
190
+ });
191
+ const fixes = [];
192
+ let newIndex = 0;
193
+ parts.forEach((part2) => {
194
+ part2.forEach((p) => {
195
+ moveProperty(p, props[newIndex], fixer, src).forEach(
196
+ (f) => fixes.push(f)
197
+ );
198
+ newIndex++;
199
+ });
200
+ newIndex++;
201
+ });
202
+ return fixes;
203
+ }
204
+ });
205
+ }
206
+ }
207
+ };
208
+ }
209
+ };
210
+ var moveProperty = (thisNode, toNode, fixer, src) => {
211
+ if (thisNode === toNode) {
212
+ return [];
213
+ }
214
+ const fixes = [];
215
+ fixes.push(fixer.replaceText(toNode, src.getText(thisNode)));
216
+ const prev = findTokenPrevLine(thisNode, src);
217
+ const cond = (c) => !prev || prev.loc.end.line !== c.loc.start.line;
218
+ const commentsBefore = src.getCommentsBefore(thisNode).filter(cond);
219
+ if (commentsBefore.length) {
220
+ const prevComments = src.getCommentsBefore(thisNode).filter((c) => !cond(c));
221
+ const b = prevComments.length ? prevComments[prevComments.length - 1].range[1] : prev ? prev.range[1] : commentsBefore[0].range[0];
222
+ const e = commentsBefore[commentsBefore.length - 1].range[1];
223
+ fixes.push(fixer.replaceTextRange([b, e], ""));
224
+ const toPrev = src.getTokenBefore(toNode, { includeComments: true });
225
+ const txt = src.text.substring(b, e);
226
+ fixes.push(fixer.insertTextAfter(toPrev, txt));
227
+ }
228
+ const next = findCommaSameLine(thisNode, src) || thisNode;
229
+ const commentsAfter = src.getCommentsAfter(next).filter((c) => thisNode.loc.end.line === c.loc.start.line);
230
+ if (commentsAfter.length) {
231
+ const b = next.range[1];
232
+ const e = commentsAfter[commentsAfter.length - 1].range[1];
233
+ fixes.push(fixer.replaceTextRange([b, e], ""));
234
+ const toNext = findCommaSameLine(toNode, src) || toNode;
235
+ const txt = src.text.substring(b, e);
236
+ fixes.push(fixer.insertTextAfter(toNext, txt));
237
+ }
238
+ return fixes;
239
+ };
240
+ var findTokenPrevLine = (node2, src) => {
241
+ let t = src.getTokenBefore(node2);
242
+ while (true) {
243
+ if (!t || t.range[0] < node2.parent.range[0]) {
244
+ return null;
245
+ }
246
+ if (t.loc.end.line < node2.loc.start.line) {
247
+ return t;
248
+ }
249
+ t = src.getTokenBefore(t);
250
+ }
251
+ };
252
+ var findCommaSameLine = (node2, src) => {
253
+ const t = src.getTokenAfter(node2);
254
+ return t && t.value === "," && node2.loc.end.line === t.loc.start.line ? t : null;
255
+ };
256
+ var isValidOrders = {
257
+ asc: (a, b) => a <= b,
258
+ ascI: (a, b) => a.toLowerCase() <= b.toLowerCase(),
259
+ ascN: (a, b) => naturalCompare(a, b) <= 0,
260
+ ascIN: (a, b) => naturalCompare(a.toLowerCase(), b.toLowerCase()) <= 0,
261
+ desc: (a, b) => isValidOrders.asc(b, a),
262
+ descI: (a, b) => isValidOrders.ascI(b, a),
263
+ descN: (a, b) => isValidOrders.ascN(b, a),
264
+ descIN: (a, b) => isValidOrders.ascIN(b, a)
265
+ };
266
+ var getPropertyName = (node2) => {
267
+ let prop;
268
+ switch (node2 && node2.type) {
269
+ case "Property":
270
+ case "MethodDefinition":
271
+ prop = node2.key;
272
+ break;
273
+ case "MemberExpression":
274
+ prop = node2.property;
275
+ break;
276
+ }
277
+ switch (prop && prop.type) {
278
+ case "Literal":
279
+ return String(prop.value);
280
+ case "TemplateLiteral":
281
+ if (prop.expressions.length === 0 && prop.quasis.length === 1) {
282
+ return prop.quasis[0].value.cooked;
283
+ }
284
+ break;
285
+ case "Identifier":
286
+ if (!node2.computed) {
287
+ return prop.name;
288
+ }
289
+ break;
290
+ }
291
+ return node2.key && node2.key.name || null;
292
+ };
293
+ }
294
+ });
295
+
296
+ // node_modules/.pnpm/eslint-plugin-sort-keys@2.3.5/node_modules/eslint-plugin-sort-keys/index.js
297
+ var require_eslint_plugin_sort_keys = __commonJS({
298
+ "node_modules/.pnpm/eslint-plugin-sort-keys@2.3.5/node_modules/eslint-plugin-sort-keys/index.js"(exports, module) {
299
+ "use strict";
300
+ module.exports.rules = {
301
+ "sort-keys-fix": require_sort_keys_fix()
302
+ };
303
+ }
304
+ });
305
+
306
+ // src/plugins.ts
307
+ var pluginSortKeys = __toESM(require_eslint_plugin_sort_keys(), 1);
308
+ import { default as default2 } from "@stylistic/eslint-plugin";
309
+ import { default as default3 } from "@typescript-eslint/eslint-plugin";
310
+ import * as parserTs from "@typescript-eslint/parser";
311
+ import { default as default4 } from "eslint-plugin-eslint-comments";
312
+ import * as pluginImport from "eslint-plugin-i";
313
+ import { default as default5 } from "eslint-plugin-jsdoc";
314
+ import * as pluginJsonc from "eslint-plugin-jsonc";
315
+ import { default as default6 } from "eslint-plugin-n";
316
+ import { default as default7 } from "eslint-plugin-no-only-tests";
317
+ import { default as default8 } from "eslint-plugin-react";
318
+ import { default as default9 } from "eslint-plugin-react-hooks";
319
+ import * as pluginReactRefresh from "eslint-plugin-react-refresh";
320
+ import { default as default10 } from "eslint-plugin-unicorn";
321
+ import { default as default11 } from "eslint-plugin-unused-imports";
322
+ import { default as default12 } from "eslint-plugin-tailwindcss";
323
+ import { default as default13 } from "eslint-plugin-vitest";
324
+ import { default as default14 } from "jsonc-eslint-parser";
325
+
326
+ // src/configs/comments.ts
327
+ function comments() {
328
+ return [
329
+ {
330
+ name: "jsse:eslint-comments",
331
+ plugins: {
332
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
333
+ "eslint-comments": default4
334
+ },
335
+ rules: {
336
+ "eslint-comments/no-aggregating-enable": "error",
337
+ "eslint-comments/no-duplicate-disable": "error",
338
+ "eslint-comments/no-unlimited-disable": "error",
339
+ "eslint-comments/no-unused-enable": "error"
340
+ }
341
+ }
342
+ ];
343
+ }
344
+
345
+ // src/globs.ts
346
+ var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
347
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
348
+ var GLOB_JS = "**/*.?([cm])js";
349
+ var GLOB_JSX = "**/*.?([cm])jsx";
350
+ var GLOB_TS = "**/*.?([cm])ts";
351
+ var GLOB_TSX = "**/*.?([cm])tsx";
352
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
353
+ var GLOB_CSS = "**/*.css";
354
+ var GLOB_LESS = "**/*.less";
355
+ var GLOB_SCSS = "**/*.scss";
356
+ var GLOB_JSON = "**/*.json";
357
+ var GLOB_JSON5 = "**/*.json5";
358
+ var GLOB_JSONC = "**/*.jsonc";
359
+ var GLOB_MARKDOWN = "**/*.md";
360
+ var GLOB_YAML = "**/*.y?(a)ml";
361
+ var GLOB_HTML = "**/*.htm?(l)";
362
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
363
+ var GLOB_TESTS = [
364
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
365
+ `**/*.spec.${GLOB_SRC_EXT}`,
366
+ `**/*.test.${GLOB_SRC_EXT}`,
367
+ `**/*.bench.${GLOB_SRC_EXT}`,
368
+ `**/*.benchmark.${GLOB_SRC_EXT}`
369
+ ];
370
+ var GLOB_ALL_SRC = [GLOB_SRC, GLOB_STYLE, GLOB_JSON, GLOB_JSON5, GLOB_MARKDOWN, GLOB_YAML, GLOB_HTML];
371
+ var GLOB_EXCLUDE = [
372
+ "**/node_modules",
373
+ "**/dist",
374
+ "**/package-lock.json",
375
+ "**/yarn.lock",
376
+ "**/pnpm-lock.yaml",
377
+ "**/bun.lockb",
378
+ "**/output",
379
+ "**/out",
380
+ "**/coverage",
381
+ "**/temp",
382
+ "**/.vitepress/cache",
383
+ "**/.nuxt",
384
+ "**/.next",
385
+ "**/.vercel",
386
+ "**/.changeset",
387
+ "**/.idea",
388
+ "**/.cache",
389
+ "**/.output",
390
+ "**/.vite-inspect",
391
+ "**/CHANGELOG*.md",
392
+ "**/*.min.*",
393
+ "**/LICENSE*",
394
+ "**/__snapshots__",
395
+ "**/auto-import?(s).d.ts",
396
+ "**/components.d.ts",
397
+ "**/scratch",
398
+ "**/tmp",
399
+ "**/temp"
400
+ ];
401
+
402
+ // src/configs/ignores.ts
403
+ function ignores() {
404
+ return [
405
+ {
406
+ ignores: GLOB_EXCLUDE
407
+ }
408
+ ];
409
+ }
410
+
411
+ // src/configs/imports.ts
412
+ function imports(options = {}) {
413
+ const { stylistic = true } = options;
414
+ return [
415
+ {
416
+ name: "jsse:imports",
417
+ plugins: {
418
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
419
+ import: pluginImport
420
+ },
421
+ rules: {
422
+ "import/first": "error",
423
+ "import/no-duplicates": "error",
424
+ "import/no-mutable-exports": "error",
425
+ "import/no-named-default": "error",
426
+ "import/no-self-import": "error",
427
+ "import/no-webpack-loader-syntax": "error",
428
+ "import/order": "error",
429
+ ...stylistic ? {
430
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
431
+ } : {}
432
+ }
433
+ }
434
+ ];
435
+ }
436
+
437
+ // src/configs/javascript.ts
438
+ import eslintjs from "@eslint/js";
439
+ import globals from "globals";
440
+ function javascript(options = {}) {
441
+ const { isInEditor: isInEditor2 = false, overrides = {} } = options;
442
+ return [
443
+ {
444
+ languageOptions: {
445
+ ecmaVersion: 2022,
446
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
447
+ globals: {
448
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
449
+ ...globals.browser,
450
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
451
+ ...globals.es2021,
452
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
453
+ ...globals.node,
454
+ document: "readonly",
455
+ navigator: "readonly",
456
+ window: "readonly"
457
+ },
458
+ parserOptions: {
459
+ ecmaFeatures: {
460
+ jsx: true
461
+ },
462
+ ecmaVersion: 2022,
463
+ sourceType: "module"
464
+ },
465
+ sourceType: "module"
466
+ },
467
+ linterOptions: {
468
+ reportUnusedDisableDirectives: options.reportUnusedDisableDirectives ?? true
469
+ },
470
+ name: "jsse:javascript",
471
+ plugins: {
472
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
473
+ "unused-imports": default11
474
+ },
475
+ rules: {
476
+ ...eslintjs.configs.recommended.rules,
477
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
478
+ "array-callback-return": "error",
479
+ "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
480
+ "block-scoped-var": "error",
481
+ "constructor-super": "error",
482
+ "default-case-last": "error",
483
+ "dot-notation": ["error", { allowKeywords: true }],
484
+ eqeqeq: ["error", "smart"],
485
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
486
+ "no-alert": "error",
487
+ "no-array-constructor": "error",
488
+ "no-async-promise-executor": "error",
489
+ "no-caller": "error",
490
+ "no-case-declarations": "error",
491
+ "no-class-assign": "error",
492
+ "no-compare-neg-zero": "error",
493
+ "no-cond-assign": ["error", "always"],
494
+ "no-console": ["error", { allow: ["warn", "error"] }],
495
+ "no-const-assign": "error",
496
+ "no-control-regex": "error",
497
+ "no-debugger": "error",
498
+ "no-delete-var": "error",
499
+ "no-dupe-args": "error",
500
+ "no-dupe-class-members": "error",
501
+ "no-dupe-keys": "error",
502
+ "no-duplicate-case": "error",
503
+ "no-empty": ["error", { allowEmptyCatch: true }],
504
+ "no-empty-character-class": "error",
505
+ "no-empty-pattern": "error",
506
+ "no-eval": "error",
507
+ "no-ex-assign": "error",
508
+ "no-extend-native": "error",
509
+ "no-extra-bind": "error",
510
+ "no-extra-boolean-cast": "error",
511
+ "no-fallthrough": "error",
512
+ "no-func-assign": "error",
513
+ "no-global-assign": "error",
514
+ "no-implied-eval": "error",
515
+ "no-import-assign": "error",
516
+ "no-invalid-regexp": "error",
517
+ "no-invalid-this": "error",
518
+ "no-irregular-whitespace": "error",
519
+ "no-iterator": "error",
520
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
521
+ "no-lone-blocks": "error",
522
+ "no-loss-of-precision": "error",
523
+ "no-misleading-character-class": "error",
524
+ "no-multi-str": "error",
525
+ "no-nested-ternary": "off",
526
+ "no-new": "error",
527
+ "no-new-func": "error",
528
+ "no-new-object": "error",
529
+ "no-new-symbol": "error",
530
+ "no-new-wrappers": "error",
531
+ "no-obj-calls": "error",
532
+ "no-octal": "error",
533
+ "no-octal-escape": "error",
534
+ "no-proto": "error",
535
+ "no-prototype-builtins": "error",
536
+ "no-redeclare": ["error", { builtinGlobals: false }],
537
+ "no-regex-spaces": "error",
538
+ "no-restricted-globals": [
539
+ "error",
540
+ { message: "Use `globalThis` instead.", name: "global" },
541
+ { message: "Use `globalThis` instead.", name: "self" }
542
+ ],
543
+ "no-restricted-properties": [
544
+ "error",
545
+ {
546
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
547
+ property: "__proto__"
548
+ },
549
+ {
550
+ message: "Use `Object.defineProperty` instead.",
551
+ property: "__defineGetter__"
552
+ },
553
+ {
554
+ message: "Use `Object.defineProperty` instead.",
555
+ property: "__defineSetter__"
556
+ },
557
+ {
558
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
559
+ property: "__lookupGetter__"
560
+ },
561
+ {
562
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
563
+ property: "__lookupSetter__"
564
+ }
565
+ ],
566
+ "no-restricted-syntax": [
567
+ "error",
568
+ "DebuggerStatement",
569
+ "LabeledStatement",
570
+ "WithStatement",
571
+ "TSEnumDeclaration[const=true]",
572
+ "TSExportAssignment"
573
+ ],
574
+ "no-self-assign": ["error", { props: true }],
575
+ "no-self-compare": "error",
576
+ "no-sequences": "error",
577
+ "no-shadow-restricted-names": "error",
578
+ "no-sparse-arrays": "error",
579
+ "no-template-curly-in-string": "error",
580
+ "no-this-before-super": "error",
581
+ "no-throw-literal": "error",
582
+ "no-undef": "error",
583
+ "no-undef-init": "error",
584
+ "no-unexpected-multiline": "error",
585
+ "no-unmodified-loop-condition": "error",
586
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
587
+ "no-unreachable": "error",
588
+ "no-unreachable-loop": "error",
589
+ "no-unsafe-finally": "error",
590
+ "no-unsafe-negation": "error",
591
+ "no-unused-expressions": [
592
+ "error",
593
+ {
594
+ allowShortCircuit: true,
595
+ allowTaggedTemplates: true,
596
+ allowTernary: true
597
+ }
598
+ ],
599
+ "no-unused-vars": [
600
+ "error",
601
+ {
602
+ args: "none",
603
+ caughtErrors: "none",
604
+ ignoreRestSiblings: true,
605
+ vars: "all"
606
+ }
607
+ ],
608
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
609
+ "no-useless-backreference": "error",
610
+ "no-useless-call": "error",
611
+ "no-useless-catch": "error",
612
+ "no-useless-computed-key": "error",
613
+ "no-useless-constructor": "error",
614
+ "no-useless-rename": "error",
615
+ "no-useless-return": "error",
616
+ "no-var": "error",
617
+ "no-void": "error",
618
+ "no-with": "error",
619
+ "object-shorthand": [
620
+ "error",
621
+ "always",
622
+ {
623
+ avoidQuotes: true,
624
+ ignoreConstructors: false
625
+ }
626
+ ],
627
+ "one-var": ["error", { initialized: "never" }],
628
+ "prefer-arrow-callback": [
629
+ "error",
630
+ {
631
+ allowNamedFunctions: false,
632
+ allowUnboundThis: true
633
+ }
634
+ ],
635
+ "prefer-const": [
636
+ "error",
637
+ {
638
+ destructuring: "all",
639
+ ignoreReadBeforeAssign: true
640
+ }
641
+ ],
642
+ "prefer-exponentiation-operator": "error",
643
+ "prefer-promise-reject-errors": "error",
644
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
645
+ "prefer-rest-params": "error",
646
+ "prefer-spread": "error",
647
+ "prefer-template": "error",
648
+ "sort-imports": [
649
+ "error",
650
+ {
651
+ allowSeparatedGroups: false,
652
+ ignoreCase: false,
653
+ ignoreDeclarationSort: true,
654
+ ignoreMemberSort: false,
655
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
656
+ }
657
+ ],
658
+ "symbol-description": "error",
659
+ "unicode-bom": ["error", "never"],
660
+ "unused-imports/no-unused-imports": isInEditor2 ? "off" : "error",
661
+ "unused-imports/no-unused-vars": [
662
+ "error",
663
+ {
664
+ args: "after-used",
665
+ argsIgnorePattern: "^_",
666
+ vars: "all",
667
+ varsIgnorePattern: "^_"
668
+ }
669
+ ],
670
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
671
+ "valid-typeof": ["error", { requireStringLiterals: true }],
672
+ "vars-on-top": "error",
673
+ yoda: ["error", "never"],
674
+ ...overrides
675
+ }
676
+ },
677
+ {
678
+ files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
679
+ name: "jsse:scripts-overrides",
680
+ rules: {
681
+ "no-console": "off"
682
+ }
683
+ }
684
+ ];
685
+ }
686
+
687
+ // src/configs/jsdoc.ts
688
+ function jsdoc(options = {}) {
689
+ const { stylistic = true } = options;
690
+ return [
691
+ {
692
+ name: "jsse:jsdoc",
693
+ plugins: {
694
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
695
+ jsdoc: default5
696
+ },
697
+ rules: {
698
+ "jsdoc/check-access": "warn",
699
+ "jsdoc/check-param-names": "warn",
700
+ "jsdoc/check-property-names": "warn",
701
+ "jsdoc/check-types": "warn",
702
+ "jsdoc/empty-tags": "warn",
703
+ "jsdoc/implements-on-classes": "warn",
704
+ "jsdoc/no-defaults": "warn",
705
+ "jsdoc/no-multi-asterisks": "warn",
706
+ "jsdoc/require-param-name": "warn",
707
+ "jsdoc/require-property": "warn",
708
+ "jsdoc/require-property-description": "warn",
709
+ "jsdoc/require-property-name": "warn",
710
+ "jsdoc/require-returns-check": "warn",
711
+ "jsdoc/require-returns-description": "warn",
712
+ "jsdoc/require-yields-check": "warn",
713
+ ...stylistic ? {
714
+ "jsdoc/check-alignment": "warn",
715
+ "jsdoc/multiline-blocks": "warn"
716
+ } : {}
717
+ }
718
+ }
719
+ ];
720
+ }
721
+
722
+ // src/configs/jsonc.ts
723
+ function jsonc(options = {}) {
724
+ const { stylistic = true, overrides = {} } = options;
725
+ const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
726
+ return [
727
+ {
728
+ name: "jsse:jsonc:setup",
729
+ plugins: {
730
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
731
+ jsonc: pluginJsonc
732
+ }
733
+ },
734
+ {
735
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
736
+ languageOptions: {
737
+ parser: default14
738
+ },
739
+ name: "jsse:jsonc:rules",
740
+ rules: {
741
+ "jsonc/no-bigint-literals": "error",
742
+ "jsonc/no-binary-expression": "error",
743
+ "jsonc/no-binary-numeric-literals": "error",
744
+ "jsonc/no-dupe-keys": "error",
745
+ "jsonc/no-escape-sequence-in-identifier": "error",
746
+ "jsonc/no-floating-decimal": "error",
747
+ "jsonc/no-hexadecimal-numeric-literals": "error",
748
+ "jsonc/no-infinity": "error",
749
+ "jsonc/no-multi-str": "error",
750
+ "jsonc/no-nan": "error",
751
+ "jsonc/no-number-props": "error",
752
+ "jsonc/no-numeric-separators": "error",
753
+ "jsonc/no-octal": "error",
754
+ "jsonc/no-octal-escape": "error",
755
+ "jsonc/no-octal-numeric-literals": "error",
756
+ "jsonc/no-parenthesized": "error",
757
+ "jsonc/no-plus-sign": "error",
758
+ "jsonc/no-regexp-literals": "error",
759
+ "jsonc/no-sparse-arrays": "error",
760
+ "jsonc/no-template-literals": "error",
761
+ "jsonc/no-undefined-value": "error",
762
+ "jsonc/no-unicode-codepoint-escapes": "error",
763
+ "jsonc/no-useless-escape": "error",
764
+ "jsonc/space-unary-ops": "error",
765
+ "jsonc/valid-json-number": "error",
766
+ "jsonc/vue-custom-block/no-parsing-error": "error",
767
+ ...stylistic ? {
768
+ "jsonc/array-bracket-spacing": ["error", "never"],
769
+ "jsonc/comma-dangle": ["error", "never"],
770
+ "jsonc/comma-style": ["error", "last"],
771
+ "jsonc/indent": ["error", indent],
772
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
773
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
774
+ "jsonc/object-curly-spacing": ["error", "always"],
775
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
776
+ "jsonc/quote-props": "error",
777
+ "jsonc/quotes": "error"
778
+ } : {},
779
+ ...overrides
780
+ }
781
+ }
782
+ ];
783
+ }
784
+
785
+ // src/configs/node.ts
786
+ function node() {
787
+ return [
788
+ {
789
+ name: "jsse:node",
790
+ plugins: {
791
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
792
+ node: default6
793
+ },
794
+ rules: {
795
+ "node/handle-callback-err": ["error", "^(err|error)$"],
796
+ "node/no-deprecated-api": "error",
797
+ "node/no-exports-assign": "error",
798
+ "node/no-new-require": "error",
799
+ "node/no-path-concat": "error",
800
+ "node/prefer-global/buffer": ["error", "never"],
801
+ "node/prefer-global/process": ["error", "never"],
802
+ "node/process-exit-as-throw": "error"
803
+ }
804
+ }
805
+ ];
806
+ }
807
+
808
+ // src/configs/ts/typescript-language-options.ts
809
+ import process from "process";
810
+ function parserOptionProject(tsconfigPath) {
811
+ if (typeof tsconfigPath === "string") {
812
+ return [tsconfigPath];
813
+ }
814
+ return tsconfigPath;
815
+ }
816
+ function typescriptLanguageOptions(options) {
817
+ const { parserOptions = {}, tsconfigPath, react: react2 } = options ?? {};
818
+ if (react2) {
819
+ return {
820
+ parser: parserTs,
821
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
822
+ parserOptions: {
823
+ ecmaFeatures: { jsx: true, modules: true },
824
+ jsxPragma: null,
825
+ sourceType: "module",
826
+ ...tsconfigPath ? {
827
+ project: parserOptionProject(tsconfigPath),
828
+ tsconfigRootDir: process.cwd()
829
+ } : {},
830
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
831
+ ...parserOptions
832
+ }
833
+ };
834
+ }
835
+ return {
836
+ parser: parserTs,
837
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
838
+ parserOptions: {
839
+ sourceType: "module",
840
+ ...tsconfigPath ? {
841
+ project: parserOptionProject(tsconfigPath),
842
+ tsconfigRootDir: process.cwd()
843
+ } : {},
844
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
845
+ ...parserOptions
846
+ }
847
+ };
848
+ }
849
+
850
+ // src/configs/react.ts
851
+ var reactRules = {
852
+ "react-hooks/exhaustive-deps": "error",
853
+ "react-hooks/rules-of-hooks": "error",
854
+ "react/boolean-prop-naming": [
855
+ "error",
856
+ {
857
+ rule: ["^(is|has)[A-Z]([A-Za-z0-9]?)+", "|^(debug|disabled|hidden|required|selected|highlight)$"].join(""),
858
+ validateNested: true
859
+ }
860
+ ],
861
+ "react/button-has-type": "error",
862
+ "react/function-component-definition": [
863
+ "error",
864
+ {
865
+ namedComponents: "function-declaration",
866
+ unnamedComponents: "arrow-function"
867
+ }
868
+ ],
869
+ "react/hook-use-state": "error",
870
+ "react/iframe-missing-sandbox": "error",
871
+ "react/jsx-boolean-value": "error",
872
+ "react/jsx-child-element-spacing": "error",
873
+ "react/jsx-closing-bracket-location": [
874
+ "error",
875
+ {
876
+ nonEmpty: "tag-aligned",
877
+ selfClosing: false
878
+ }
879
+ ],
880
+ "react/jsx-closing-tag-location": "error",
881
+ "react/jsx-curly-brace-presence": [
882
+ "error",
883
+ {
884
+ children: "never",
885
+ propElementValues: "always",
886
+ props: "never"
887
+ }
888
+ ],
889
+ "react/jsx-curly-newline": [
890
+ "error",
891
+ {
892
+ multiline: "consistent",
893
+ singleline: "forbid"
894
+ }
895
+ ],
896
+ "react/jsx-curly-spacing": ["error", "never"],
897
+ "react/jsx-equals-spacing": ["error", "never"],
898
+ "react/jsx-first-prop-new-line": "error",
899
+ "react/jsx-fragments": ["error", "syntax"],
900
+ "react/jsx-indent": ["error", 2],
901
+ "react/jsx-indent-props": ["error", 2],
902
+ "react/jsx-key": "warn",
903
+ "react/jsx-max-props-per-line": [
904
+ "error",
905
+ {
906
+ maximum: 3,
907
+ when: "multiline"
908
+ }
909
+ ],
910
+ "react/jsx-no-bind": [
911
+ "error",
912
+ {
913
+ allowArrowFunctions: true
914
+ }
915
+ ],
916
+ "react/jsx-no-comment-textnodes": "error",
917
+ "react/jsx-no-constructed-context-values": "error",
918
+ "react/jsx-no-duplicate-props": [
919
+ "error",
920
+ {
921
+ ignoreCase: true
922
+ }
923
+ ],
924
+ "react/jsx-no-script-url": "error",
925
+ "react/jsx-no-target-blank": [
926
+ "error",
927
+ {
928
+ forms: true,
929
+ warnOnSpreadAttributes: true
930
+ }
931
+ ],
932
+ "react/jsx-no-undef": "error",
933
+ "react/jsx-no-useless-fragment": "error",
934
+ "react/jsx-pascal-case": "error",
935
+ "react/jsx-props-no-multi-spaces": "error",
936
+ "react/jsx-sort-props": [
937
+ "error",
938
+ {
939
+ callbacksLast: true,
940
+ noSortAlphabetically: true,
941
+ reservedFirst: true,
942
+ shorthandFirst: true
943
+ }
944
+ ],
945
+ "react/jsx-tag-spacing": [
946
+ "error",
947
+ {
948
+ afterOpening: "never",
949
+ beforeClosing: "never",
950
+ beforeSelfClosing: "never",
951
+ closingSlash: "never"
952
+ }
953
+ ],
954
+ "react/jsx-uses-react": "error",
955
+ "react/jsx-uses-vars": "error",
956
+ "react/jsx-wrap-multilines": [
957
+ "error",
958
+ {
959
+ arrow: "parens-new-line",
960
+ assignment: "parens-new-line",
961
+ condition: "ignore",
962
+ declaration: "parens-new-line",
963
+ logical: "ignore",
964
+ prop: "ignore",
965
+ return: "parens-new-line"
966
+ }
967
+ ],
968
+ "react/no-access-state-in-setstate": "error",
969
+ "react/no-array-index-key": "error",
970
+ "react/no-arrow-function-lifecycle": "error",
971
+ "react/no-children-prop": "error",
972
+ "react/no-danger": "error",
973
+ "react/no-danger-with-children": "error",
974
+ "react/no-deprecated": "error",
975
+ "react/no-did-update-set-state": "error",
976
+ "react/no-direct-mutation-state": "error",
977
+ "react/no-find-dom-node": "error",
978
+ "react/no-invalid-html-attribute": "error",
979
+ "react/no-is-mounted": "error",
980
+ "react/no-namespace": "error",
981
+ "react/no-redundant-should-component-update": "error",
982
+ "react/no-render-return-value": "error",
983
+ "react/no-string-refs": [
984
+ "error",
985
+ {
986
+ noTemplateLiterals: true
987
+ }
988
+ ],
989
+ "react/no-this-in-sfc": "error",
990
+ "react/no-typos": "error",
991
+ "react/no-unescaped-entities": "error",
992
+ "react/no-unsafe": "error",
993
+ // "react/no-unused-prop-types": "error",
994
+ "react/no-unused-state": "error",
995
+ "react/prefer-read-only-props": "error",
996
+ // "react/prop-types": "error",
997
+ "react/react-in-jsx-scope": "off",
998
+ "react/require-default-props": [
999
+ "error",
1000
+ {
1001
+ forbidDefaultForRequired: true,
1002
+ ignoreFunctionalComponents: true
1003
+ }
1004
+ ],
1005
+ "react/self-closing-comp": "error",
1006
+ "react/state-in-constructor": ["error", "never"],
1007
+ "react/static-property-placement": "error",
1008
+ "react/style-prop-object": [
1009
+ "error",
1010
+ {
1011
+ allow: ["FormattedNumber"]
1012
+ }
1013
+ ],
1014
+ "react/void-dom-elements-no-children": "error"
1015
+ };
1016
+ function reactHooks() {
1017
+ return [
1018
+ {
1019
+ files: [GLOB_SRC],
1020
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1021
+ plugins: { "react-hooks": default9 },
1022
+ rules: {
1023
+ "react-hooks/exhaustive-deps": "error",
1024
+ "react-hooks/rules-of-hooks": "error"
1025
+ }
1026
+ }
1027
+ ];
1028
+ }
1029
+ function reactRefreshFlatConfigs() {
1030
+ return [
1031
+ {
1032
+ files: [GLOB_SRC],
1033
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1034
+ plugins: { "react-refresh": pluginReactRefresh },
1035
+ rules: {
1036
+ "react-refresh/only-export-components": "error"
1037
+ }
1038
+ },
1039
+ {
1040
+ files: ["**/*.stories.tsx"],
1041
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1042
+ plugins: { "react-refresh": pluginReactRefresh },
1043
+ rules: {
1044
+ "react-refresh/only-export-components": "off"
1045
+ }
1046
+ }
1047
+ ];
1048
+ }
1049
+ function reactRecomendedRules() {
1050
+ return {
1051
+ "react/display-name": 2,
1052
+ "react/jsx-key": 2,
1053
+ "react/jsx-no-comment-textnodes": 2,
1054
+ "react/jsx-no-duplicate-props": 2,
1055
+ "react/jsx-no-target-blank": 2,
1056
+ "react/jsx-no-undef": 2,
1057
+ "react/jsx-uses-react": 2,
1058
+ "react/jsx-uses-vars": 2,
1059
+ "react/no-children-prop": 2,
1060
+ "react/no-danger-with-children": 2,
1061
+ "react/no-deprecated": 2,
1062
+ "react/no-direct-mutation-state": 2,
1063
+ "react/no-find-dom-node": 2,
1064
+ "react/no-is-mounted": 2,
1065
+ "react/no-render-return-value": 2,
1066
+ "react/no-string-refs": 2,
1067
+ "react/no-unescaped-entities": 2,
1068
+ // this rule has a bug w/ typescript-eslint-parser
1069
+ // 'react/no-unknown-property': 2,
1070
+ "react/no-unsafe": 0,
1071
+ "react/prop-types": 1,
1072
+ "react/react-in-jsx-scope": 2,
1073
+ "react/require-render-return": 2
1074
+ };
1075
+ }
1076
+ function react(options) {
1077
+ const { parserOptions = {}, tsconfigPath, react: react2, reactRefresh } = options ?? {};
1078
+ const config = [
1079
+ {
1080
+ files: [GLOB_SRC],
1081
+ languageOptions: typescriptLanguageOptions({
1082
+ parserOptions,
1083
+ react: react2,
1084
+ tsconfigPath
1085
+ }),
1086
+ name: "jsse:react:setup",
1087
+ plugins: {
1088
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1089
+ react: default8,
1090
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1091
+ "react-hooks": default9
1092
+ }
1093
+ },
1094
+ {
1095
+ files: [GLOB_SRC],
1096
+ plugins: {
1097
+ // react: pluginReact,
1098
+ // },
1099
+ },
1100
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1101
+ rules: {
1102
+ ...reactRecomendedRules(),
1103
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1104
+ ...default8.configs["jsx-runtime"].rules,
1105
+ ...reactRules
1106
+ },
1107
+ settings: {
1108
+ react: {
1109
+ version: "detect"
1110
+ }
1111
+ }
1112
+ }
1113
+ ];
1114
+ if (reactRefresh) {
1115
+ config.push(...reactRefreshFlatConfigs());
1116
+ }
1117
+ return config;
1118
+ }
1119
+
1120
+ // src/configs/sort.ts
1121
+ function sortPackageJson() {
1122
+ return [
1123
+ {
1124
+ files: ["**/package.json"],
1125
+ name: "jsse:sort-package-json",
1126
+ rules: {
1127
+ "jsonc/sort-array-values": [
1128
+ "error",
1129
+ {
1130
+ order: { type: "asc" },
1131
+ pathPattern: "^files$"
1132
+ }
1133
+ ],
1134
+ "jsonc/sort-keys": [
1135
+ "error",
1136
+ {
1137
+ order: [
1138
+ "publisher",
1139
+ "name",
1140
+ "displayName",
1141
+ "type",
1142
+ "version",
1143
+ "private",
1144
+ "packageManager",
1145
+ "description",
1146
+ "author",
1147
+ "license",
1148
+ "funding",
1149
+ "homepage",
1150
+ "repository",
1151
+ "bugs",
1152
+ "keywords",
1153
+ "categories",
1154
+ "sideEffects",
1155
+ "exports",
1156
+ "main",
1157
+ "module",
1158
+ "unpkg",
1159
+ "jsdelivr",
1160
+ "types",
1161
+ "typesVersions",
1162
+ "bin",
1163
+ "icon",
1164
+ "files",
1165
+ "engines",
1166
+ "activationEvents",
1167
+ "contributes",
1168
+ "scripts",
1169
+ "peerDependencies",
1170
+ "peerDependenciesMeta",
1171
+ "dependencies",
1172
+ "optionalDependencies",
1173
+ "devDependencies",
1174
+ "pnpm",
1175
+ "overrides",
1176
+ "resolutions",
1177
+ "husky",
1178
+ "simple-git-hooks",
1179
+ "lint-staged",
1180
+ "eslintConfig"
1181
+ ],
1182
+ pathPattern: "^$"
1183
+ },
1184
+ {
1185
+ order: { type: "asc" },
1186
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1187
+ },
1188
+ {
1189
+ order: { type: "asc" },
1190
+ pathPattern: "^resolutions$"
1191
+ },
1192
+ {
1193
+ order: { type: "asc" },
1194
+ pathPattern: "^pnpm.overrides$"
1195
+ },
1196
+ {
1197
+ order: ["types", "import", "require", "default"],
1198
+ pathPattern: "^exports.*$"
1199
+ }
1200
+ ]
1201
+ }
1202
+ }
1203
+ ];
1204
+ }
1205
+ function sortTsconfig() {
1206
+ return [
1207
+ {
1208
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1209
+ name: "antfu:sort-tsconfig",
1210
+ rules: {
1211
+ "jsonc/sort-keys": [
1212
+ "error",
1213
+ {
1214
+ order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
1215
+ pathPattern: "^$"
1216
+ },
1217
+ {
1218
+ order: [
1219
+ /* Projects */
1220
+ "incremental",
1221
+ "composite",
1222
+ "tsBuildInfoFile",
1223
+ "disableSourceOfProjectReferenceRedirect",
1224
+ "disableSolutionSearching",
1225
+ "disableReferencedProjectLoad",
1226
+ /* Language and Environment */
1227
+ "target",
1228
+ "jsx",
1229
+ "jsxFactory",
1230
+ "jsxFragmentFactory",
1231
+ "jsxImportSource",
1232
+ "lib",
1233
+ "moduleDetection",
1234
+ "noLib",
1235
+ "reactNamespace",
1236
+ "useDefineForClassFields",
1237
+ "emitDecoratorMetadata",
1238
+ "experimentalDecorators",
1239
+ /* Modules */
1240
+ "baseUrl",
1241
+ "rootDir",
1242
+ "rootDirs",
1243
+ "customConditions",
1244
+ "module",
1245
+ "moduleResolution",
1246
+ "moduleSuffixes",
1247
+ "noResolve",
1248
+ "paths",
1249
+ "resolveJsonModule",
1250
+ "resolvePackageJsonExports",
1251
+ "resolvePackageJsonImports",
1252
+ "typeRoots",
1253
+ "types",
1254
+ "allowArbitraryExtensions",
1255
+ "allowImportingTsExtensions",
1256
+ "allowUmdGlobalAccess",
1257
+ /* JavaScript Support */
1258
+ "allowJs",
1259
+ "checkJs",
1260
+ "maxNodeModuleJsDepth",
1261
+ /* Type Checking */
1262
+ "strict",
1263
+ "strictBindCallApply",
1264
+ "strictFunctionTypes",
1265
+ "strictNullChecks",
1266
+ "strictPropertyInitialization",
1267
+ "allowUnreachableCode",
1268
+ "allowUnusedLabels",
1269
+ "alwaysStrict",
1270
+ "exactOptionalPropertyTypes",
1271
+ "noFallthroughCasesInSwitch",
1272
+ "noImplicitAny",
1273
+ "noImplicitOverride",
1274
+ "noImplicitReturns",
1275
+ "noImplicitThis",
1276
+ "noPropertyAccessFromIndexSignature",
1277
+ "noUncheckedIndexedAccess",
1278
+ "noUnusedLocals",
1279
+ "noUnusedParameters",
1280
+ "useUnknownInCatchVariables",
1281
+ /* Emit */
1282
+ "declaration",
1283
+ "declarationDir",
1284
+ "declarationMap",
1285
+ "downlevelIteration",
1286
+ "emitBOM",
1287
+ "emitDeclarationOnly",
1288
+ "importHelpers",
1289
+ "importsNotUsedAsValues",
1290
+ "inlineSourceMap",
1291
+ "inlineSources",
1292
+ "mapRoot",
1293
+ "newLine",
1294
+ "noEmit",
1295
+ "noEmitHelpers",
1296
+ "noEmitOnError",
1297
+ "outDir",
1298
+ "outFile",
1299
+ "preserveConstEnums",
1300
+ "preserveValueImports",
1301
+ "removeComments",
1302
+ "sourceMap",
1303
+ "sourceRoot",
1304
+ "stripInternal",
1305
+ /* Interop Constraints */
1306
+ "allowSyntheticDefaultImports",
1307
+ "esModuleInterop",
1308
+ "forceConsistentCasingInFileNames",
1309
+ "isolatedModules",
1310
+ "preserveSymlinks",
1311
+ "verbatimModuleSyntax",
1312
+ /* Completeness */
1313
+ "skipDefaultLibCheck",
1314
+ "skipLibCheck"
1315
+ ],
1316
+ pathPattern: "^compilerOptions$"
1317
+ }
1318
+ ]
1319
+ }
1320
+ }
1321
+ ];
1322
+ }
1323
+
1324
+ // src/utils.ts
1325
+ import process2 from "process";
1326
+ function combine(...configs) {
1327
+ return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
1328
+ }
1329
+ function renameRules(rules, from, to) {
1330
+ if (from === to) {
1331
+ return rules;
1332
+ }
1333
+ return Object.fromEntries(
1334
+ Object.entries(rules).map(([key, value]) => {
1335
+ if (key.startsWith(from)) {
1336
+ return [to + key.slice(from.length), value];
1337
+ }
1338
+ return [key, value];
1339
+ })
1340
+ );
1341
+ }
1342
+ function isCI() {
1343
+ return !!process2.env.CI;
1344
+ }
1345
+ function isInEditor() {
1346
+ return !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !isCI());
1347
+ }
1348
+
1349
+ // src/configs/test.ts
1350
+ function test(options = {}) {
1351
+ const { isInEditor: isInEditor2 = false, overrides = {} } = options;
1352
+ return [
1353
+ {
1354
+ name: "jsse:test:setup",
1355
+ plugins: {
1356
+ test: {
1357
+ ...default13,
1358
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1359
+ rules: {
1360
+ ...default13.rules,
1361
+ // extend `test/no-only-tests` rule
1362
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1363
+ ...default7.rules
1364
+ }
1365
+ }
1366
+ }
1367
+ },
1368
+ {
1369
+ files: GLOB_TESTS,
1370
+ name: "jsse:test:rules",
1371
+ rules: {
1372
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1373
+ "test/no-identical-title": "error",
1374
+ "test/no-only-tests": isInEditor2 ? "off" : isCI() ? "error" : "warn",
1375
+ "test/prefer-hooks-in-order": "error",
1376
+ "test/prefer-lowercase-title": "error",
1377
+ "unicorn/no-null": "off",
1378
+ ...overrides
1379
+ }
1380
+ }
1381
+ ];
1382
+ }
1383
+
1384
+ // src/configs/ts/typescript-rules.ts
1385
+ function typescriptRulesTypeAware() {
1386
+ return {
1387
+ "@typescript-eslint/await-thenable": "error",
1388
+ "@typescript-eslint/no-for-in-array": "error",
1389
+ "no-implied-eval": "off",
1390
+ "@typescript-eslint/consistent-type-exports": [
1391
+ "error",
1392
+ {
1393
+ fixMixedExportsWithInlineTypeSpecifier: true
1394
+ }
1395
+ ],
1396
+ "dot-notation": "off",
1397
+ "@typescript-eslint/dot-notation": [
1398
+ "error",
1399
+ {
1400
+ allowPattern: "^_",
1401
+ allowKeywords: true
1402
+ }
1403
+ ],
1404
+ "@typescript-eslint/no-implied-eval": "error",
1405
+ "@typescript-eslint/no-misused-promises": "error",
1406
+ "@typescript-eslint/no-unnecessary-qualifier": "error",
1407
+ "@typescript-eslint/no-unnecessary-type-arguments": "off",
1408
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
1409
+ "no-throw-literal": "off",
1410
+ "@typescript-eslint/no-throw-literal": "error",
1411
+ "@typescript-eslint/no-unsafe-argument": "error",
1412
+ "@typescript-eslint/no-unsafe-assignment": "error",
1413
+ "@typescript-eslint/no-unsafe-call": "error",
1414
+ "@typescript-eslint/no-unsafe-member-access": "error",
1415
+ "@typescript-eslint/no-unsafe-return": "error",
1416
+ "@typescript-eslint/restrict-plus-operands": "error",
1417
+ "@typescript-eslint/restrict-template-expressions": "error",
1418
+ "@typescript-eslint/unbound-method": "error",
1419
+ "@typescript-eslint/naming-convention": [
1420
+ "error",
1421
+ {
1422
+ selector: ["variable"],
1423
+ modifiers: ["global"],
1424
+ format: ["camelCase", "snake_case", "UPPER_CASE", "PascalCase"],
1425
+ leadingUnderscore: "allowSingleOrDouble",
1426
+ trailingUnderscore: "allow",
1427
+ filter: {
1428
+ regex: "[- ]",
1429
+ match: false
1430
+ }
1431
+ },
1432
+ {
1433
+ selector: [
1434
+ "classProperty",
1435
+ "objectLiteralProperty",
1436
+ "typeProperty",
1437
+ "classMethod",
1438
+ "objectLiteralMethod",
1439
+ "typeMethod",
1440
+ "accessor",
1441
+ "enumMember"
1442
+ ],
1443
+ format: null,
1444
+ modifiers: ["requiresQuotes"]
1445
+ },
1446
+ {
1447
+ selector: [
1448
+ "variable",
1449
+ "function",
1450
+ "classProperty",
1451
+ "objectLiteralProperty",
1452
+ "parameterProperty",
1453
+ "classMethod",
1454
+ "objectLiteralMethod",
1455
+ "typeMethod",
1456
+ "accessor"
1457
+ ],
1458
+ format: ["camelCase", "snake_case", "PascalCase"],
1459
+ leadingUnderscore: "allowSingleOrDouble",
1460
+ trailingUnderscore: "allow",
1461
+ filter: {
1462
+ // also allow when '/' is in object key
1463
+ regex: "^[0-9]|[- ]|[/]",
1464
+ match: false
1465
+ }
1466
+ },
1467
+ {
1468
+ selector: "typeLike",
1469
+ format: ["PascalCase"]
1470
+ },
1471
+ {
1472
+ selector: "variable",
1473
+ types: ["boolean"],
1474
+ format: ["PascalCase", "camelCase"],
1475
+ prefix: ["is", "has", "can", "should", "will", "did"]
1476
+ },
1477
+ {
1478
+ selector: "interface",
1479
+ format: ["PascalCase"]
1480
+ },
1481
+ {
1482
+ selector: "typeParameter",
1483
+ filter: "^T$|^[A-Z][a-zA-Z]+$",
1484
+ format: ["PascalCase"]
1485
+ }
1486
+ ],
1487
+ "@typescript-eslint/no-floating-promises": [
1488
+ "error",
1489
+ {
1490
+ ignoreVoid: true,
1491
+ ignoreIIFE: true
1492
+ }
1493
+ ]
1494
+ };
1495
+ }
1496
+ function typescriptRulesTypeOblivious() {
1497
+ return {
1498
+ eqeqeq: "error",
1499
+ camelcase: "off",
1500
+ yoda: "error",
1501
+ "arrow-parens": "off",
1502
+ "no-console": [
1503
+ "warn",
1504
+ {
1505
+ allow: [
1506
+ "log",
1507
+ "warn",
1508
+ "dir",
1509
+ "time",
1510
+ "timeEnd",
1511
+ "timeLog",
1512
+ "trace",
1513
+ "assert",
1514
+ "clear",
1515
+ "count",
1516
+ "countReset",
1517
+ "group",
1518
+ "groupEnd",
1519
+ "table",
1520
+ "debug",
1521
+ "info",
1522
+ "dirxml",
1523
+ "error",
1524
+ "groupCollapsed",
1525
+ "Console",
1526
+ "profile",
1527
+ "profileEnd",
1528
+ "timeStamp",
1529
+ "context"
1530
+ ]
1531
+ }
1532
+ ],
1533
+ "object-curly-spacing": "off",
1534
+ "@typescript-eslint/object-curly-spacing": "off",
1535
+ "@typescript-eslint/no-inferrable-types": "off",
1536
+ "@typescript-eslint/prefer-ts-expect-error": "error",
1537
+ "@typescript-eslint/consistent-type-imports": [
1538
+ "error",
1539
+ {
1540
+ prefer: "type-imports",
1541
+ fixStyle: "separate-type-imports"
1542
+ }
1543
+ ],
1544
+ "@typescript-eslint/adjacent-overload-signatures": "error",
1545
+ "@typescript-eslint/ban-types": [
1546
+ "warn",
1547
+ {
1548
+ extendDefaults: false,
1549
+ types: {
1550
+ String: {
1551
+ message: 'Use "string" instead',
1552
+ fixWith: "string"
1553
+ },
1554
+ Boolean: {
1555
+ message: 'Use "boolean" instead',
1556
+ fixWith: "boolean"
1557
+ },
1558
+ Number: {
1559
+ message: 'Use "number" instead',
1560
+ fixWith: "number"
1561
+ },
1562
+ BigInt: {
1563
+ message: "Use `bigint` instead.",
1564
+ fixWith: "bigint"
1565
+ },
1566
+ Object: {
1567
+ message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
1568
+ fixWith: "Record<string, unknown>"
1569
+ },
1570
+ object: {
1571
+ message: "The `object` type is hard to use. Use `Record<string, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
1572
+ fixWith: "Record<string, unknown>"
1573
+ },
1574
+ Symbol: {
1575
+ message: 'Use "symbol" instead',
1576
+ fixWith: "symbol"
1577
+ },
1578
+ Function: {
1579
+ message: 'The "Function" type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with "new".\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
1580
+ },
1581
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1582
+ "{}": {
1583
+ message: "The `{}` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead.",
1584
+ fixWith: "Record<string, unknown>"
1585
+ },
1586
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1587
+ "[]": "Don't use the empty array type `[]`. It only allows empty arrays. Use `SomeType[]` instead.",
1588
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1589
+ "[[]]": "Don't use `[[]]`. It only allows an array with a single element which is an empty array. Use `SomeType[][]` instead.",
1590
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1591
+ "[[[]]]": "Don't use `[[[]]]`. Use `SomeType[][][]` instead."
1592
+ }
1593
+ }
1594
+ ],
1595
+ "@typescript-eslint/consistent-type-assertions": "error",
1596
+ "@typescript-eslint/consistent-type-definitions": ["error", "type"],
1597
+ "@typescript-eslint/member-ordering": [
1598
+ "warn",
1599
+ {
1600
+ default: "never",
1601
+ classes: ["field", "constructor", "method"]
1602
+ }
1603
+ ],
1604
+ "no-array-constructor": "off",
1605
+ "@typescript-eslint/no-array-constructor": "error",
1606
+ "@typescript-eslint/no-explicit-any": "error",
1607
+ "@typescript-eslint/no-misused-new": "error",
1608
+ "@typescript-eslint/no-namespace": [
1609
+ "error",
1610
+ {
1611
+ allowDeclarations: false,
1612
+ allowDefinitionFiles: false
1613
+ }
1614
+ ],
1615
+ "no-unused-vars": "off",
1616
+ "@typescript-eslint/no-unused-vars": [
1617
+ "warn",
1618
+ {
1619
+ vars: "all",
1620
+ args: "none",
1621
+ argsIgnorePattern: "^_",
1622
+ varsIgnorePattern: "^_",
1623
+ caughtErrorsIgnorePattern: "^_"
1624
+ }
1625
+ ],
1626
+ "no-use-before-define": "off",
1627
+ "@typescript-eslint/no-use-before-define": [
1628
+ "error",
1629
+ {
1630
+ functions: false,
1631
+ classes: true,
1632
+ variables: true,
1633
+ enums: true,
1634
+ typedefs: true
1635
+ }
1636
+ ],
1637
+ "@typescript-eslint/prefer-namespace-keyword": "warn",
1638
+ "@typescript-eslint/typedef": [
1639
+ "warn",
1640
+ {
1641
+ arrayDestructuring: false,
1642
+ arrowParameter: false,
1643
+ memberVariableDeclaration: true,
1644
+ objectDestructuring: false,
1645
+ parameter: true,
1646
+ propertyDeclaration: true,
1647
+ variableDeclaration: false,
1648
+ variableDeclarationIgnoreFunction: true
1649
+ }
1650
+ ],
1651
+ "accessor-pairs": "error",
1652
+ "for-direction": "warn",
1653
+ "guard-for-in": "error",
1654
+ "max-lines": [
1655
+ "warn",
1656
+ {
1657
+ max: 2e3
1658
+ }
1659
+ ],
1660
+ "no-async-promise-executor": "error",
1661
+ "no-bitwise": [
1662
+ "warn",
1663
+ {
1664
+ allow: ["^", "<<", ">>", ">>>", "^=", "<<=", ">>=", ">>>=", "~"]
1665
+ }
1666
+ ],
1667
+ "no-caller": "error",
1668
+ "no-compare-neg-zero": "error",
1669
+ "no-cond-assign": "error",
1670
+ "no-constant-condition": "warn",
1671
+ "no-control-regex": "error",
1672
+ "no-debugger": "warn",
1673
+ "no-delete-var": "error",
1674
+ "no-duplicate-case": "error",
1675
+ "no-empty": "warn",
1676
+ "no-empty-character-class": "error",
1677
+ "no-empty-pattern": "warn",
1678
+ "no-eval": "warn",
1679
+ "no-ex-assign": "error",
1680
+ "no-extend-native": "error",
1681
+ "no-extra-boolean-cast": "warn",
1682
+ "no-extra-label": "warn",
1683
+ "no-fallthrough": "error",
1684
+ "no-func-assign": "warn",
1685
+ "no-implied-eval": "error",
1686
+ "no-invalid-regexp": "error",
1687
+ "no-label-var": "error",
1688
+ "no-lone-blocks": "warn",
1689
+ "no-misleading-character-class": "error",
1690
+ "no-multi-str": "error",
1691
+ "no-new": "warn",
1692
+ "no-new-func": "error",
1693
+ "no-new-wrappers": "warn",
1694
+ "no-octal": "error",
1695
+ "no-octal-escape": "error",
1696
+ "no-regex-spaces": "error",
1697
+ "no-return-assign": "error",
1698
+ "no-script-url": "warn",
1699
+ "no-self-assign": "error",
1700
+ "no-self-compare": "error",
1701
+ "no-sequences": "error",
1702
+ "no-shadow-restricted-names": "error",
1703
+ "no-sparse-arrays": "error",
1704
+ "no-unmodified-loop-condition": "warn",
1705
+ "no-unsafe-finally": "error",
1706
+ "no-unused-expressions": "off",
1707
+ "@typescript-eslint/no-unused-expressions": "error",
1708
+ "no-unused-labels": "error",
1709
+ "no-useless-catch": "warn",
1710
+ "no-useless-concat": "error",
1711
+ "no-var": "error",
1712
+ "no-void": [
1713
+ "error",
1714
+ {
1715
+ allowAsStatement: true
1716
+ }
1717
+ ],
1718
+ "no-with": "error",
1719
+ "prefer-const": "error",
1720
+ "require-atomic-updates": "error",
1721
+ "require-yield": "warn",
1722
+ strict: ["error", "never"],
1723
+ "use-isnan": "error",
1724
+ "no-useless-constructor": "off",
1725
+ "@typescript-eslint/no-useless-constructor": "error",
1726
+ "@typescript-eslint/no-unnecessary-type-constraint": "error",
1727
+ "@typescript-eslint/brace-style": [
1728
+ "error",
1729
+ "1tbs",
1730
+ {
1731
+ allowSingleLine: false
1732
+ }
1733
+ ],
1734
+ "comma-spacing": "off",
1735
+ "@typescript-eslint/comma-spacing": [
1736
+ "error",
1737
+ {
1738
+ before: false,
1739
+ after: true
1740
+ }
1741
+ ],
1742
+ "default-param-last": "off",
1743
+ "@typescript-eslint/default-param-last": "error",
1744
+ "func-call-spacing": "off",
1745
+ "@typescript-eslint/func-call-spacing": ["error", "never"],
1746
+ "keyword-spacing": "off",
1747
+ "@typescript-eslint/keyword-spacing": "error",
1748
+ "lines-between-class-members": "off",
1749
+ "@typescript-eslint/lines-between-class-members": [
1750
+ "error",
1751
+ "always",
1752
+ {
1753
+ exceptAfterSingleLine: true
1754
+ }
1755
+ ],
1756
+ "no-dupe-class-members": "off",
1757
+ "@typescript-eslint/no-dupe-class-members": "error",
1758
+ "no-empty-function": "off",
1759
+ "@typescript-eslint/no-empty-function": "error",
1760
+ "no-extra-parens": "off",
1761
+ "no-extra-semi": "off",
1762
+ "@typescript-eslint/no-extra-semi": "error",
1763
+ "no-loop-func": "off",
1764
+ "@typescript-eslint/no-loop-func": "error",
1765
+ "no-loss-of-precision": "off",
1766
+ "@typescript-eslint/no-loss-of-precision": "error",
1767
+ "no-redeclare": "off",
1768
+ "@typescript-eslint/no-redeclare": "error",
1769
+ "no-restricted-imports": "off",
1770
+ "@typescript-eslint/no-restricted-imports": [
1771
+ "error",
1772
+ {
1773
+ paths: ["error", "domain", "freelist", "smalloc", "punycode", "sys", "querystring", "colors"]
1774
+ }
1775
+ ],
1776
+ "padding-line-between-statements": "off",
1777
+ "@typescript-eslint/padding-line-between-statements": "off",
1778
+ quotes: "off",
1779
+ "@typescript-eslint/quotes": "off",
1780
+ "space-before-function-paren": "off",
1781
+ "@typescript-eslint/space-before-function-paren": "off",
1782
+ "space-infix-ops": "off",
1783
+ "@typescript-eslint/space-infix-ops": "error",
1784
+ semi: "off",
1785
+ "@typescript-eslint/semi": ["error", "always"],
1786
+ "space-before-blocks": "off",
1787
+ "@typescript-eslint/space-before-blocks": ["error", "always"],
1788
+ "no-undef": "off",
1789
+ "no-duplicate-imports": "off"
1790
+ };
1791
+ }
1792
+ function typescriptRules({ typeAware }) {
1793
+ return {
1794
+ ...typescriptRulesTypeOblivious(),
1795
+ ...typeAware ? typescriptRulesTypeAware() : {}
1796
+ };
1797
+ }
1798
+
1799
+ // src/configs/ts/typescript.ts
1800
+ function typescript(options) {
1801
+ const { componentExts = [], overrides = {}, parserOptions = {}, tsconfigPath, react: react2, prefix } = options ?? {};
1802
+ const tsPrefix = prefix?.from ?? "@typescript-eslint";
1803
+ const tsPrefixTo = prefix?.to ?? "ts";
1804
+ const tsrules = {
1805
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1806
+ ...default3.configs["eslint-recommended"].overrides[0].rules,
1807
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1808
+ ...default3.configs.strict.rules,
1809
+ "no-invalid-this": "off",
1810
+ ...typescriptRules(tsconfigPath ? { typeAware: true } : { typeAware: false }),
1811
+ ...overrides
1812
+ };
1813
+ return [
1814
+ {
1815
+ // Install the plugins without globs, so they can be configured separately.
1816
+ name: "jsse:typescript:setup",
1817
+ plugins: {
1818
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1819
+ import: pluginImport,
1820
+ [tsPrefixTo]: default3
1821
+ }
1822
+ },
1823
+ {
1824
+ name: "jsse:typescript:parser",
1825
+ // use ts parser for js files as well!
1826
+ files: [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)],
1827
+ languageOptions: typescriptLanguageOptions({
1828
+ parserOptions,
1829
+ react: react2,
1830
+ tsconfigPath
1831
+ })
1832
+ },
1833
+ {
1834
+ name: "jsse:typescript:rules",
1835
+ // only apply ts rules to ts files!
1836
+ files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
1837
+ rules: renameRules(tsrules, tsPrefix, tsPrefixTo)
1838
+ },
1839
+ {
1840
+ files: ["**/*.d.ts"],
1841
+ name: "jsse:typescript:dts-overrides",
1842
+ rules: {
1843
+ "eslint-comments/no-unlimited-disable": "off",
1844
+ "import/no-duplicates": "off",
1845
+ "no-restricted-syntax": ["error", "[declare=true]"],
1846
+ "unused-imports/no-unused-vars": "off"
1847
+ }
1848
+ },
1849
+ {
1850
+ files: ["**/*.{test,spec}.ts?(x)"],
1851
+ name: "jsse:typescript:tests-overrides",
1852
+ rules: {
1853
+ "no-unused-expressions": "off"
1854
+ }
1855
+ },
1856
+ {
1857
+ files: ["**/*.js", "**/*.cjs"],
1858
+ name: "jsse:typescript:javascript-overrides",
1859
+ rules: {
1860
+ "@typescript-eslint/no-require-imports": "off",
1861
+ "@typescript-eslint/no-var-requires": "off"
1862
+ }
1863
+ }
1864
+ ];
1865
+ }
1866
+
1867
+ // src/configs/unicorn.ts
1868
+ function unicornOff() {
1869
+ return {
1870
+ "unicorn/catch-error-name": "off",
1871
+ "unicorn/consistent-destructuring": "off",
1872
+ "unicorn/no-array-for-each": "off",
1873
+ "unicorn/no-array-reduce": "off",
1874
+ "unicorn/no-nested-ternary": "off",
1875
+ // conflicts with prettier
1876
+ "unicorn/no-process-exit": "off",
1877
+ "unicorn/prefer-module": "off",
1878
+ "unicorn/prefer-optional-catch-binding": "off",
1879
+ "unicorn/prefer-top-level-await": "off",
1880
+ "unicorn/prevent-abbreviations": "off"
1881
+ // Super insanely annoying rule
1882
+ };
1883
+ }
1884
+ function unicorn() {
1885
+ return [
1886
+ {
1887
+ name: "jsse:unicorn",
1888
+ plugins: {
1889
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1890
+ unicorn: default10
1891
+ },
1892
+ rules: {
1893
+ ...unicornOff(),
1894
+ "unicorn/better-regex": "error",
1895
+ "unicorn/custom-error-definition": "error",
1896
+ // Pass error message when throwing errors
1897
+ "unicorn/error-message": "error",
1898
+ // Uppercase regex escapes
1899
+ "unicorn/escape-case": "error",
1900
+ "unicorn/explicit-length-check": "error",
1901
+ "unicorn/filename-case": "error",
1902
+ "unicorn/new-for-builtins": "error",
1903
+ "unicorn/no-array-callback-reference": "error",
1904
+ "unicorn/no-array-method-this-argument": "error",
1905
+ "unicorn/no-array-push-push": "error",
1906
+ "unicorn/no-console-spaces": "error",
1907
+ "unicorn/no-for-loop": "error",
1908
+ "unicorn/no-hex-escape": "error",
1909
+ // Array.isArray instead of instanceof
1910
+ "unicorn/no-instanceof-array": "error",
1911
+ "unicorn/no-invalid-remove-event-listener": "error",
1912
+ "unicorn/no-lonely-if": "error",
1913
+ // conflicts with prettier
1914
+ // Ban `new Array` as `Array` constructor's params are ambiguous
1915
+ "unicorn/no-new-array": "error",
1916
+ // Prevent deprecated `new Buffer()`
1917
+ "unicorn/no-new-buffer": "error",
1918
+ "unicorn/no-static-only-class": "error",
1919
+ "unicorn/no-unnecessary-await": "error",
1920
+ // Keep regex literals safe!
1921
+ "unicorn/no-unsafe-regex": "error",
1922
+ "unicorn/no-zero-fractions": `error`,
1923
+ // Lowercase number formatting for octal, hex, binary (0x1ERROR instead of 0X1'error')
1924
+ "unicorn/number-literal-case": "error",
1925
+ "unicorn/prefer-add-event-listener": "error",
1926
+ "unicorn/prefer-array-find": "error",
1927
+ "unicorn/prefer-array-flat-map": "error",
1928
+ "unicorn/prefer-array-index-of": "error",
1929
+ "unicorn/prefer-array-some": "error",
1930
+ "unicorn/prefer-at": "error",
1931
+ "unicorn/prefer-blob-reading-methods": "error",
1932
+ "unicorn/prefer-date-now": "error",
1933
+ "unicorn/prefer-dom-node-append": "error",
1934
+ "unicorn/prefer-dom-node-dataset": "error",
1935
+ "unicorn/prefer-dom-node-remove": "error",
1936
+ // textContent instead of innerText
1937
+ "unicorn/prefer-dom-node-text-content": "error",
1938
+ // includes over indexOf when checking for existence
1939
+ "unicorn/prefer-includes": "error",
1940
+ "unicorn/prefer-keyboard-event-key": "error",
1941
+ "unicorn/prefer-math-trunc": "error",
1942
+ "unicorn/prefer-modern-dom-apis": "error",
1943
+ "unicorn/prefer-modern-math-apis": "error",
1944
+ "unicorn/prefer-negative-index": "error",
1945
+ // Prefer using the node: protocol
1946
+ "unicorn/prefer-node-protocol": "error",
1947
+ // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1948
+ "unicorn/prefer-number-properties": "error",
1949
+ "unicorn/prefer-prototype-methods": "error",
1950
+ "unicorn/prefer-query-selector": "error",
1951
+ "unicorn/prefer-reflect-apply": "error",
1952
+ "unicorn/prefer-regexp-test": "error",
1953
+ "unicorn/prefer-string-replace-all": "error",
1954
+ "unicorn/prefer-string-slice": "error",
1955
+ // String methods startsWith/endsWith instead of more complicated stuff
1956
+ "unicorn/prefer-string-starts-ends-with": "error",
1957
+ "unicorn/prefer-string-trim-start-end": "error",
1958
+ // Enforce throwing type error when throwing error while checking typeof
1959
+ "unicorn/prefer-type-error": "error",
1960
+ // Use new when throwing error
1961
+ "unicorn/throw-new-error": "error"
1962
+ }
1963
+ }
1964
+ ];
1965
+ }
1966
+
1967
+ // src/factory.ts
1968
+ import fs from "fs";
1969
+ import gitignore from "eslint-config-flat-gitignore";
1970
+ import { isPackageExists } from "local-pkg";
1971
+
1972
+ // src/configs/tailwind.ts
1973
+ function tailwind() {
1974
+ return [
1975
+ {
1976
+ name: "jsse:tailwind",
1977
+ plugins: {
1978
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1979
+ tailwindcss: default12
1980
+ },
1981
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1982
+ rules: {
1983
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1984
+ ...default12.configs.recommended.rules
1985
+ }
1986
+ }
1987
+ ];
1988
+ }
1989
+
1990
+ // src/factory.ts
1991
+ var flatConfigProps = [
1992
+ "files",
1993
+ "ignores",
1994
+ "languageOptions",
1995
+ "linterOptions",
1996
+ "processor",
1997
+ "plugins",
1998
+ "rules",
1999
+ "settings"
2000
+ ];
2001
+ function defaultOptions() {
2002
+ return {
2003
+ gitignore,
2004
+ isInEditor: isInEditor(),
2005
+ jsonc: true,
2006
+ off: [],
2007
+ reportUnusedDisableDirectives: true,
2008
+ stylistic: true,
2009
+ test: true,
2010
+ tsPrefix: "@typescript-eslint",
2011
+ typescript: isPackageExists("typescript")
2012
+ };
2013
+ }
2014
+ function opts(options = {}) {
2015
+ return {
2016
+ ...defaultOptions(),
2017
+ ...options
2018
+ };
2019
+ }
2020
+ function jsse(options = {}, ...userConfigs) {
2021
+ const {
2022
+ isInEditor: isInEditor2,
2023
+ typescript: enableTypeScript = isPackageExists("typescript"),
2024
+ gitignore: enableGitignore = true,
2025
+ overrides = {},
2026
+ componentExts = [],
2027
+ react: enableReact = isPackageExists("react"),
2028
+ reportUnusedDisableDirectives,
2029
+ tsPrefix,
2030
+ off
2031
+ } = opts(options);
2032
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2033
+ if (stylisticOptions && !("jsx" in stylisticOptions))
2034
+ stylisticOptions.jsx = options.jsx ?? true;
2035
+ const configs = [];
2036
+ if (enableGitignore && fs.existsSync(".gitignore")) {
2037
+ configs.push([gitignore()]);
2038
+ }
2039
+ configs.push(
2040
+ ignores(),
2041
+ javascript({
2042
+ isInEditor: isInEditor2,
2043
+ overrides: overrides.javascript,
2044
+ reportUnusedDisableDirectives
2045
+ }),
2046
+ comments(),
2047
+ node(),
2048
+ jsdoc({
2049
+ stylistic: stylisticOptions
2050
+ }),
2051
+ imports({
2052
+ stylistic: stylisticOptions
2053
+ }),
2054
+ unicorn()
2055
+ );
2056
+ if (enableTypeScript) {
2057
+ configs.push(
2058
+ typescript({
2059
+ ...typeof enableTypeScript === "boolean" ? {} : enableTypeScript,
2060
+ componentExts,
2061
+ overrides: overrides.typescript,
2062
+ prefix: {
2063
+ from: "@typescript-eslint",
2064
+ to: tsPrefix
2065
+ },
2066
+ react: enableReact
2067
+ })
2068
+ );
2069
+ }
2070
+ if (options.react) {
2071
+ configs.push(
2072
+ react({
2073
+ reactRefresh: options.reactRefresh
2074
+ })
2075
+ );
2076
+ }
2077
+ if (options.test) {
2078
+ configs.push(
2079
+ test({
2080
+ isInEditor: isInEditor2,
2081
+ overrides: overrides.test
2082
+ })
2083
+ );
2084
+ }
2085
+ if (options.jsonc ?? true) {
2086
+ configs.push(
2087
+ jsonc({
2088
+ overrides: overrides.jsonc,
2089
+ stylistic: stylisticOptions
2090
+ }),
2091
+ sortPackageJson(),
2092
+ sortTsconfig()
2093
+ );
2094
+ }
2095
+ if (options.tailwind) {
2096
+ configs.push(tailwind());
2097
+ }
2098
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
2099
+ if (key in options) {
2100
+ acc[key] = options[key];
2101
+ }
2102
+ return acc;
2103
+ }, {});
2104
+ if (Object.keys(fusedConfig).length > 0) {
2105
+ configs.push([fusedConfig]);
2106
+ }
2107
+ if (off.length > 0) {
2108
+ configs.push(
2109
+ off.map((rule) => ({
2110
+ files: ["**/*.{js,jsx,ts,tsx}"],
2111
+ rules: {
2112
+ [rule]: "off"
2113
+ }
2114
+ }))
2115
+ );
2116
+ }
2117
+ return combine(...configs, ...userConfigs);
2118
+ }
2119
+ export {
2120
+ GLOB_ALL_SRC,
2121
+ GLOB_CSS,
2122
+ GLOB_EXCLUDE,
2123
+ GLOB_HTML,
2124
+ GLOB_JS,
2125
+ GLOB_JSON,
2126
+ GLOB_JSON5,
2127
+ GLOB_JSONC,
2128
+ GLOB_JSX,
2129
+ GLOB_LESS,
2130
+ GLOB_MARKDOWN,
2131
+ GLOB_MARKDOWN_CODE,
2132
+ GLOB_SCSS,
2133
+ GLOB_SRC,
2134
+ GLOB_SRC_EXT,
2135
+ GLOB_STYLE,
2136
+ GLOB_TESTS,
2137
+ GLOB_TS,
2138
+ GLOB_TSX,
2139
+ GLOB_YAML,
2140
+ combine,
2141
+ comments,
2142
+ jsse as default,
2143
+ ignores,
2144
+ imports,
2145
+ isCI,
2146
+ isInEditor,
2147
+ javascript,
2148
+ jsdoc,
2149
+ jsonc,
2150
+ jsse,
2151
+ node,
2152
+ default14 as parserJsonc,
2153
+ parserTs,
2154
+ default4 as pluginEslintComments,
2155
+ pluginImport,
2156
+ default5 as pluginJsdoc,
2157
+ pluginJsonc,
2158
+ default7 as pluginNoOnlyTests,
2159
+ default6 as pluginNode,
2160
+ default8 as pluginReact,
2161
+ default9 as pluginReactHooks,
2162
+ pluginReactRefresh,
2163
+ pluginSortKeys,
2164
+ default2 as pluginStylistic,
2165
+ default12 as pluginTailwind,
2166
+ default3 as pluginTs,
2167
+ default10 as pluginUnicorn,
2168
+ default11 as pluginUnusedImports,
2169
+ default13 as pluginVitest,
2170
+ react,
2171
+ reactHooks,
2172
+ renameRules,
2173
+ sortPackageJson,
2174
+ sortTsconfig,
2175
+ test,
2176
+ typescript,
2177
+ unicorn
2178
+ };
2179
+ /*! Bundled license information:
2180
+
2181
+ natural-compare/index.js:
2182
+ (*
2183
+ * @version 1.4.0
2184
+ * @date 2015-10-26
2185
+ * @stability 3 - Stable
2186
+ * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
2187
+ * @license MIT License
2188
+ *)
2189
+ */