@jsse/eslint-config 0.7.8 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./chunk-DJK8HYOj.js";
2
- import { n as SLOW_RULES, r as VERSION, t as DEBUG } from "./const-B5rVjoUA.js";
1
+ import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-DJK8HYOj.js";
2
+ import { n as SLOW_RULES, r as VERSION, t as DEBUG } from "./const-DLdnBwQY.js";
3
3
  import { builtinModules, createRequire } from "node:module";
4
4
  import process$1 from "node:process";
5
5
  import fs, { realpathSync, statSync } from "node:fs";
@@ -25,7 +25,7 @@ import createCommand from "eslint-plugin-command/config";
25
25
  import eslintjs from "@eslint/js";
26
26
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
27
27
  import tseslint from "typescript-eslint";
28
- //#region node_modules/.pnpm/acorn@8.16.0/node_modules/acorn/dist/acorn.mjs
28
+ //#region node_modules/.pnpm/acorn@8.17.0/node_modules/acorn/dist/acorn.mjs
29
29
  var astralIdentifierCodes = [
30
30
  509,
31
31
  0,
@@ -1243,6 +1243,7 @@ function getLineInfo(input, offset) {
1243
1243
  var defaultOptions$1 = {
1244
1244
  ecmaVersion: null,
1245
1245
  sourceType: "script",
1246
+ strict: false,
1246
1247
  onInsertedSemicolon: null,
1247
1248
  onTrailingComma: null,
1248
1249
  allowReserved: null,
@@ -1335,7 +1336,7 @@ var Parser = function Parser(options, input, startPos) {
1335
1336
  this.context = this.initialContext();
1336
1337
  this.exprAllowed = true;
1337
1338
  this.inModule = options.sourceType === "module";
1338
- this.strict = this.inModule || this.strictDirective(this.pos);
1339
+ this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
1339
1340
  this.potentialArrowAt = -1;
1340
1341
  this.potentialArrowInForAwait = false;
1341
1342
  this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
@@ -1361,9 +1362,12 @@ var prototypeAccessors = {
1361
1362
  inClassStaticBlock: { configurable: true }
1362
1363
  };
1363
1364
  Parser.prototype.parse = function parse() {
1365
+ var this$1$1 = this;
1364
1366
  var node = this.options.program || this.startNode();
1365
1367
  this.nextToken();
1366
- return this.parseTopLevel(node);
1368
+ return this.catchStackOverflow(function() {
1369
+ return this$1$1.parseTopLevel(node);
1370
+ });
1367
1371
  };
1368
1372
  prototypeAccessors.inFunction.get = function() {
1369
1373
  return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
@@ -1466,6 +1470,14 @@ pp$9.eatContextual = function(name) {
1466
1470
  this.next();
1467
1471
  return true;
1468
1472
  };
1473
+ pp$9.catchStackOverflow = function(f) {
1474
+ try {
1475
+ return f();
1476
+ } catch (e) {
1477
+ if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message))) this.raise(this.start, "Not enough stack space to parse input");
1478
+ else throw e;
1479
+ }
1480
+ };
1469
1481
  pp$9.expectContextual = function(name) {
1470
1482
  if (!this.eatContextual(name)) this.unexpected();
1471
1483
  };
@@ -1521,10 +1533,10 @@ pp$9.isSimpleAssignTarget = function(expr) {
1521
1533
  };
1522
1534
  var pp$8 = Parser.prototype;
1523
1535
  pp$8.parseTopLevel = function(node) {
1524
- var exports = Object.create(null);
1536
+ var exports$1 = Object.create(null);
1525
1537
  if (!node.body) node.body = [];
1526
1538
  while (this.type !== types$1.eof) {
1527
- var stmt = this.parseStatement(null, true, exports);
1539
+ var stmt = this.parseStatement(null, true, exports$1);
1528
1540
  node.body.push(stmt);
1529
1541
  }
1530
1542
  if (this.inModule) for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) {
@@ -1585,7 +1597,13 @@ pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
1585
1597
  while (isIdentifierChar(ch = this.fullCharCodeAt(next)));
1586
1598
  if (ch === 92) return true;
1587
1599
  var id = this.input.slice(idStart, next);
1588
- if (keywordRelationalOperator.test(id) || isFor && id === "of") return false;
1600
+ if (keywordRelationalOperator.test(id)) return false;
1601
+ if (isFor && !isAwaitUsing && id === "of") {
1602
+ skipWhiteSpace.lastIndex = next;
1603
+ var skipAfterOf = skipWhiteSpace.exec(this.input);
1604
+ next = next + skipAfterOf[0].length;
1605
+ if (this.input.charCodeAt(next) !== 61 || (ch = this.input.charCodeAt(next + 1)) === 61 || ch === 62) return false;
1606
+ }
1589
1607
  return true;
1590
1608
  };
1591
1609
  pp$8.isAwaitUsing = function(isFor) {
@@ -1594,7 +1612,7 @@ pp$8.isAwaitUsing = function(isFor) {
1594
1612
  pp$8.isUsing = function(isFor) {
1595
1613
  return this.isUsingKeyword(false, isFor);
1596
1614
  };
1597
- pp$8.parseStatement = function(context, topLevel, exports) {
1615
+ pp$8.parseStatement = function(context, topLevel, exports$1) {
1598
1616
  var starttype = this.type, node = this.startNode(), kind;
1599
1617
  if (this.isLet(context)) {
1600
1618
  starttype = types$1._var;
@@ -1638,7 +1656,7 @@ pp$8.parseStatement = function(context, topLevel, exports) {
1638
1656
  if (!topLevel) this.raise(this.start, "'import' and 'export' may only appear at the top level");
1639
1657
  if (!this.inModule) this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
1640
1658
  }
1641
- return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports);
1659
+ return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1);
1642
1660
  default:
1643
1661
  if (this.isAsyncFunction()) {
1644
1662
  if (context) this.unexpected();
@@ -1648,6 +1666,7 @@ pp$8.parseStatement = function(context, topLevel, exports) {
1648
1666
  var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null;
1649
1667
  if (usingKind) {
1650
1668
  if (!this.allowUsing) this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
1669
+ if (context) this.raise(this.start, "Using declaration is not allowed in single-statement positions");
1651
1670
  if (usingKind === "await using") {
1652
1671
  if (!this.canAwait) this.raise(this.start, "Await using cannot appear outside of async function");
1653
1672
  this.next();
@@ -1751,9 +1770,10 @@ pp$8.parseForStatement = function(node) {
1751
1770
  };
1752
1771
  pp$8.parseForAfterInit = function(node, init, awaitAt) {
1753
1772
  if ((this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init.declarations.length === 1) {
1754
- if (this.options.ecmaVersion >= 9) if (this.type === types$1._in) {
1755
- if (awaitAt > -1) this.unexpected(awaitAt);
1756
- } else node.await = awaitAt > -1;
1773
+ if (this.type === types$1._in) {
1774
+ if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) this.raise(this.start, "Using declaration is not allowed in for-in loops");
1775
+ if (this.options.ecmaVersion >= 9 && awaitAt > -1) this.unexpected(awaitAt);
1776
+ } else if (this.options.ecmaVersion >= 9) node.await = awaitAt > -1;
1757
1777
  return this.parseForIn(node, init);
1758
1778
  }
1759
1779
  if (awaitAt > -1) this.unexpected(awaitAt);
@@ -2153,10 +2173,10 @@ function checkKeyName(node, name) {
2153
2173
  var key = node.key;
2154
2174
  return !computed && (key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name);
2155
2175
  }
2156
- pp$8.parseExportAllDeclaration = function(node, exports) {
2176
+ pp$8.parseExportAllDeclaration = function(node, exports$1) {
2157
2177
  if (this.options.ecmaVersion >= 11) if (this.eatContextual("as")) {
2158
2178
  node.exported = this.parseModuleExportName();
2159
- this.checkExport(exports, node.exported, this.lastTokStart);
2179
+ this.checkExport(exports$1, node.exported, this.lastTokStart);
2160
2180
  } else node.exported = null;
2161
2181
  this.expectContextual("from");
2162
2182
  if (this.type !== types$1.string) this.unexpected();
@@ -2165,24 +2185,24 @@ pp$8.parseExportAllDeclaration = function(node, exports) {
2165
2185
  this.semicolon();
2166
2186
  return this.finishNode(node, "ExportAllDeclaration");
2167
2187
  };
2168
- pp$8.parseExport = function(node, exports) {
2188
+ pp$8.parseExport = function(node, exports$1) {
2169
2189
  this.next();
2170
- if (this.eat(types$1.star)) return this.parseExportAllDeclaration(node, exports);
2190
+ if (this.eat(types$1.star)) return this.parseExportAllDeclaration(node, exports$1);
2171
2191
  if (this.eat(types$1._default)) {
2172
- this.checkExport(exports, "default", this.lastTokStart);
2192
+ this.checkExport(exports$1, "default", this.lastTokStart);
2173
2193
  node.declaration = this.parseExportDefaultDeclaration();
2174
2194
  return this.finishNode(node, "ExportDefaultDeclaration");
2175
2195
  }
2176
2196
  if (this.shouldParseExportStatement()) {
2177
2197
  node.declaration = this.parseExportDeclaration(node);
2178
- if (node.declaration.type === "VariableDeclaration") this.checkVariableExport(exports, node.declaration.declarations);
2179
- else this.checkExport(exports, node.declaration.id, node.declaration.id.start);
2198
+ if (node.declaration.type === "VariableDeclaration") this.checkVariableExport(exports$1, node.declaration.declarations);
2199
+ else this.checkExport(exports$1, node.declaration.id, node.declaration.id.start);
2180
2200
  node.specifiers = [];
2181
2201
  node.source = null;
2182
2202
  if (this.options.ecmaVersion >= 16) node.attributes = [];
2183
2203
  } else {
2184
2204
  node.declaration = null;
2185
- node.specifiers = this.parseExportSpecifiers(exports);
2205
+ node.specifiers = this.parseExportSpecifiers(exports$1);
2186
2206
  if (this.eatContextual("from")) {
2187
2207
  if (this.type !== types$1.string) this.unexpected();
2188
2208
  node.source = this.parseExprAtom();
@@ -2220,45 +2240,45 @@ pp$8.parseExportDefaultDeclaration = function() {
2220
2240
  return declaration;
2221
2241
  }
2222
2242
  };
2223
- pp$8.checkExport = function(exports, name, pos) {
2224
- if (!exports) return;
2243
+ pp$8.checkExport = function(exports$1, name, pos) {
2244
+ if (!exports$1) return;
2225
2245
  if (typeof name !== "string") name = name.type === "Identifier" ? name.name : name.value;
2226
- if (hasOwn(exports, name)) this.raiseRecoverable(pos, "Duplicate export '" + name + "'");
2227
- exports[name] = true;
2246
+ if (hasOwn(exports$1, name)) this.raiseRecoverable(pos, "Duplicate export '" + name + "'");
2247
+ exports$1[name] = true;
2228
2248
  };
2229
- pp$8.checkPatternExport = function(exports, pat) {
2249
+ pp$8.checkPatternExport = function(exports$1, pat) {
2230
2250
  var type = pat.type;
2231
- if (type === "Identifier") this.checkExport(exports, pat, pat.start);
2251
+ if (type === "Identifier") this.checkExport(exports$1, pat, pat.start);
2232
2252
  else if (type === "ObjectPattern") for (var i = 0, list = pat.properties; i < list.length; i += 1) {
2233
2253
  var prop = list[i];
2234
- this.checkPatternExport(exports, prop);
2254
+ this.checkPatternExport(exports$1, prop);
2235
2255
  }
2236
2256
  else if (type === "ArrayPattern") for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
2237
2257
  var elt = list$1[i$1];
2238
- if (elt) this.checkPatternExport(exports, elt);
2258
+ if (elt) this.checkPatternExport(exports$1, elt);
2239
2259
  }
2240
- else if (type === "Property") this.checkPatternExport(exports, pat.value);
2241
- else if (type === "AssignmentPattern") this.checkPatternExport(exports, pat.left);
2242
- else if (type === "RestElement") this.checkPatternExport(exports, pat.argument);
2260
+ else if (type === "Property") this.checkPatternExport(exports$1, pat.value);
2261
+ else if (type === "AssignmentPattern") this.checkPatternExport(exports$1, pat.left);
2262
+ else if (type === "RestElement") this.checkPatternExport(exports$1, pat.argument);
2243
2263
  };
2244
- pp$8.checkVariableExport = function(exports, decls) {
2245
- if (!exports) return;
2264
+ pp$8.checkVariableExport = function(exports$1, decls) {
2265
+ if (!exports$1) return;
2246
2266
  for (var i = 0, list = decls; i < list.length; i += 1) {
2247
2267
  var decl = list[i];
2248
- this.checkPatternExport(exports, decl.id);
2268
+ this.checkPatternExport(exports$1, decl.id);
2249
2269
  }
2250
2270
  };
2251
2271
  pp$8.shouldParseExportStatement = function() {
2252
2272
  return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
2253
2273
  };
2254
- pp$8.parseExportSpecifier = function(exports) {
2274
+ pp$8.parseExportSpecifier = function(exports$1) {
2255
2275
  var node = this.startNode();
2256
2276
  node.local = this.parseModuleExportName();
2257
2277
  node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
2258
- this.checkExport(exports, node.exported, node.exported.start);
2278
+ this.checkExport(exports$1, node.exported, node.exported.start);
2259
2279
  return this.finishNode(node, "ExportSpecifier");
2260
2280
  };
2261
- pp$8.parseExportSpecifiers = function(exports) {
2281
+ pp$8.parseExportSpecifiers = function(exports$1) {
2262
2282
  var nodes = [], first = true;
2263
2283
  this.expect(types$1.braceL);
2264
2284
  while (!this.eat(types$1.braceR)) {
@@ -2266,7 +2286,7 @@ pp$8.parseExportSpecifiers = function(exports) {
2266
2286
  this.expect(types$1.comma);
2267
2287
  if (this.afterTrailingComma(types$1.braceR)) break;
2268
2288
  } else first = false;
2269
- nodes.push(this.parseExportSpecifier(exports));
2289
+ nodes.push(this.parseExportSpecifier(exports$1));
2270
2290
  }
2271
2291
  return nodes;
2272
2292
  };
@@ -2697,15 +2717,18 @@ pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
2697
2717
  other[kind] = true;
2698
2718
  };
2699
2719
  pp$5.parseExpression = function(forInit, refDestructuringErrors) {
2700
- var startPos = this.start, startLoc = this.startLoc;
2701
- var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
2702
- if (this.type === types$1.comma) {
2703
- var node = this.startNodeAt(startPos, startLoc);
2704
- node.expressions = [expr];
2705
- while (this.eat(types$1.comma)) node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors));
2706
- return this.finishNode(node, "SequenceExpression");
2707
- }
2708
- return expr;
2720
+ var this$1$1 = this;
2721
+ return this.catchStackOverflow(function() {
2722
+ var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
2723
+ var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
2724
+ if (this$1$1.type === types$1.comma) {
2725
+ var node = this$1$1.startNodeAt(startPos, startLoc);
2726
+ node.expressions = [expr];
2727
+ while (this$1$1.eat(types$1.comma)) node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors));
2728
+ return this$1$1.finishNode(node, "SequenceExpression");
2729
+ }
2730
+ return expr;
2731
+ });
2709
2732
  };
2710
2733
  pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
2711
2734
  if (this.isContextual("yield")) if (this.inGenerator) return this.parseYield(forInit);
@@ -2749,7 +2772,7 @@ pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
2749
2772
  var startPos = this.start, startLoc = this.startLoc;
2750
2773
  var expr = this.parseExprOps(forInit, refDestructuringErrors);
2751
2774
  if (this.checkExpressionErrors(refDestructuringErrors)) return expr;
2752
- if (this.eat(types$1.question)) {
2775
+ if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
2753
2776
  var node = this.startNodeAt(startPos, startLoc);
2754
2777
  node.test = expr;
2755
2778
  node.consequent = this.parseMaybeAssign();
@@ -3128,6 +3151,7 @@ pp$5.parseNew = function() {
3128
3151
  }
3129
3152
  var startPos = this.start, startLoc = this.startLoc;
3130
3153
  node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
3154
+ if (node.callee.type === "Super") this.raiseRecoverable(startPos, "Invalid use of 'super'");
3131
3155
  if (this.eat(types$1.parenL)) node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false);
3132
3156
  else node.arguments = empty;
3133
3157
  return this.finishNode(node, "NewExpression");
@@ -5084,7 +5108,7 @@ pp.readWord = function() {
5084
5108
  };
5085
5109
  Parser.acorn = {
5086
5110
  Parser,
5087
- version: "8.16.0",
5111
+ version: "8.17.0",
5088
5112
  defaultOptions: defaultOptions$1,
5089
5113
  Position,
5090
5114
  SourceLocation,
@@ -6824,6 +6848,101 @@ const eslintComments = async () => [{
6824
6848
  }
6825
6849
  }];
6826
6850
  //#endregion
6851
+ //#region src/configs/react-hooks.ts
6852
+ const reactHooks = async () => {
6853
+ const pluginReactHooks = await interopDefault(import("eslint-plugin-react-hooks"));
6854
+ return [{
6855
+ files: [GLOB_SRC],
6856
+ name: "jsse/react-hooks/rules",
6857
+ plugins: { "react-hooks": pluginReactHooks },
6858
+ rules: {
6859
+ "react-hooks/exhaustive-deps": "error",
6860
+ "react-hooks/rules-of-hooks": "error",
6861
+ ...pluginReactHooks.configs.recommended.rules
6862
+ },
6863
+ settings: { react: { version: "detect" } }
6864
+ }];
6865
+ };
6866
+ //#endregion
6867
+ //#region src/configs/ts/typescript-language-options.ts
6868
+ function typescriptLanguageOptions(options) {
6869
+ const { componentExts = [], react, tsconfig } = options || {};
6870
+ const tsOptions = tsconfig ? {
6871
+ project: Array.isArray(tsconfig) ? tsconfig : [tsconfig],
6872
+ tsconfigRootDir: process$1.cwd()
6873
+ } : {};
6874
+ return {
6875
+ parser: parserTs,
6876
+ parserOptions: {
6877
+ ecmaFeatures: react ? {
6878
+ jsx: true,
6879
+ modules: true
6880
+ } : void 0,
6881
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
6882
+ sourceType: "module",
6883
+ ...tsOptions,
6884
+ jsxPragma: react ? "React" : void 0
6885
+ }
6886
+ };
6887
+ }
6888
+ //#endregion
6889
+ //#region src/configs/eslint-react.ts
6890
+ async function importReactPlugins() {
6891
+ const [pluginReact, pluginReactRefresh] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin")), interopDefault(import("eslint-plugin-react-refresh"))]);
6892
+ return {
6893
+ pluginReact,
6894
+ pluginReactRefresh
6895
+ };
6896
+ }
6897
+ const eslintReact = async (options) => {
6898
+ const { componentExts, parserOptions = {}, react, reactRefresh, tsconfig } = options ?? {};
6899
+ const { pluginReact, pluginReactRefresh } = await importReactPlugins();
6900
+ const coreReactPlugins = pluginReact.configs.all.plugins;
6901
+ const reactHooksConfig = await reactHooks();
6902
+ const config = [
6903
+ {
6904
+ files: [GLOB_SRC],
6905
+ languageOptions: typescriptLanguageOptions({
6906
+ componentExts,
6907
+ parserOptions,
6908
+ react,
6909
+ tsconfig
6910
+ }),
6911
+ name: "jsse/react/setup",
6912
+ plugins: {
6913
+ "@eslint-react": coreReactPlugins["@eslint-react"],
6914
+ "react-refresh": pluginReactRefresh
6915
+ }
6916
+ },
6917
+ {
6918
+ files: [GLOB_SRC],
6919
+ name: "jsse/react/rules",
6920
+ rules: {
6921
+ ...pluginReact.configs.recommended.rules,
6922
+ "react/dom-no-string-style-prop": "off",
6923
+ "react/dom-no-unknown-property": "off"
6924
+ },
6925
+ settings: { react: { version: "detect" } }
6926
+ },
6927
+ ...reactHooksConfig,
6928
+ {
6929
+ files: [GLOB_JSX, GLOB_TSX],
6930
+ name: "jsse/react/disables",
6931
+ rules: { "unicorn/no-null": "off" }
6932
+ }
6933
+ ];
6934
+ if (reactRefresh) config.push({
6935
+ files: [GLOB_SRC],
6936
+ name: "jsse/react/refresh",
6937
+ rules: { "react-refresh/only-export-components": "error" }
6938
+ }, {
6939
+ files: ["**/*.stories.tsx"],
6940
+ name: "jsse/react-refresh/stories",
6941
+ rules: { "react-refresh/only-export-components": "off" }
6942
+ });
6943
+ return config;
6944
+ };
6945
+ //#endregion
6827
6946
  //#region src/configs/ignores.ts
6828
6947
  const ignores = async () => {
6829
6948
  return [{
@@ -6845,10 +6964,10 @@ const imports = async (options) => {
6845
6964
  "import/no-mutable-exports": "error",
6846
6965
  "import/no-named-default": "error",
6847
6966
  "import/order": "off",
6848
- ...stylistic ? { "import/newline-after-import": ["error", {
6967
+ ...stylistic && { "import/newline-after-import": ["error", {
6849
6968
  considerComments: false,
6850
6969
  count: 1
6851
- }] } : {}
6970
+ }] }
6852
6971
  }
6853
6972
  }];
6854
6973
  };
@@ -11249,7 +11368,7 @@ const jsonc = async (options) => {
11249
11368
  "jsonc/space-unary-ops": "error",
11250
11369
  "jsonc/valid-json-number": "error",
11251
11370
  "jsonc/vue-custom-block/no-parsing-error": "error",
11252
- ...stylistic ? {
11371
+ ...stylistic && {
11253
11372
  "jsonc/array-bracket-spacing": ["error", "never"],
11254
11373
  "jsonc/comma-dangle": ["error", "never"],
11255
11374
  "jsonc/comma-style": ["error", "last"],
@@ -11266,7 +11385,7 @@ const jsonc = async (options) => {
11266
11385
  "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
11267
11386
  "jsonc/quote-props": "error",
11268
11387
  "jsonc/quotes": "error"
11269
- } : {},
11388
+ },
11270
11389
  ...overrides
11271
11390
  }
11272
11391
  }];
@@ -11424,7 +11543,7 @@ function typescriptRules(props) {
11424
11543
  return {
11425
11544
  ...rulesFromPreset,
11426
11545
  ...typescriptRulesTypeOblivious(),
11427
- ...normalized.typeAware ? typescriptRulesTypeAware() : {}
11546
+ ...normalized.typeAware && typescriptRulesTypeAware()
11428
11547
  };
11429
11548
  }
11430
11549
  //#endregion
@@ -11754,240 +11873,6 @@ const prettier = async () => {
11754
11873
  }];
11755
11874
  };
11756
11875
  //#endregion
11757
- //#region src/configs/ts/typescript-language-options.ts
11758
- function typescriptLanguageOptions(options) {
11759
- const { componentExts = [], react, tsconfig } = options || {};
11760
- const tsOptions = tsconfig ? {
11761
- project: Array.isArray(tsconfig) ? tsconfig : [tsconfig],
11762
- tsconfigRootDir: process$1.cwd()
11763
- } : {};
11764
- return {
11765
- parser: parserTs,
11766
- parserOptions: {
11767
- ecmaFeatures: react ? {
11768
- jsx: true,
11769
- modules: true
11770
- } : void 0,
11771
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
11772
- sourceType: "module",
11773
- ...tsOptions,
11774
- jsxPragma: react ? "React" : void 0
11775
- }
11776
- };
11777
- }
11778
- //#endregion
11779
- //#region src/configs/react.ts
11780
- function reactRules() {
11781
- return {
11782
- "react-hooks/exhaustive-deps": "error",
11783
- "react-hooks/rules-of-hooks": "error",
11784
- "react/boolean-prop-naming": ["error", {
11785
- rule: ["^(is|has)[A-Z]([A-Za-z0-9]?)+", "|^(debug|disabled|hidden|required|selected|highlight)$"].join(""),
11786
- validateNested: true
11787
- }],
11788
- "react/button-has-type": "error",
11789
- "react/function-component-definition": ["error", {
11790
- namedComponents: "function-declaration",
11791
- unnamedComponents: "arrow-function"
11792
- }],
11793
- "react/hook-use-state": "error",
11794
- "react/iframe-missing-sandbox": "error",
11795
- "react/jsx-boolean-value": "error",
11796
- "react/jsx-child-element-spacing": "error",
11797
- "react/jsx-closing-bracket-location": ["error", {
11798
- nonEmpty: "tag-aligned",
11799
- selfClosing: false
11800
- }],
11801
- "react/jsx-closing-tag-location": "error",
11802
- "react/jsx-curly-brace-presence": ["error", {
11803
- children: "never",
11804
- propElementValues: "always",
11805
- props: "never"
11806
- }],
11807
- "react/jsx-curly-newline": ["error", {
11808
- multiline: "consistent",
11809
- singleline: "forbid"
11810
- }],
11811
- "react/jsx-curly-spacing": ["error", "never"],
11812
- "react/jsx-equals-spacing": ["error", "never"],
11813
- "react/jsx-first-prop-new-line": "error",
11814
- "react/jsx-fragments": ["error", "syntax"],
11815
- "react/jsx-indent": ["error", 2],
11816
- "react/jsx-indent-props": ["error", 2],
11817
- "react/jsx-key": "warn",
11818
- "react/jsx-max-props-per-line": ["error", {
11819
- maximum: 3,
11820
- when: "multiline"
11821
- }],
11822
- "react/jsx-no-bind": ["error", { allowArrowFunctions: true }],
11823
- "react/jsx-no-comment-textnodes": "error",
11824
- "react/jsx-no-constructed-context-values": "error",
11825
- "react/jsx-no-duplicate-props": ["error", { ignoreCase: true }],
11826
- "react/jsx-no-script-url": "error",
11827
- "react/jsx-no-target-blank": ["error", {
11828
- allowReferrer: true,
11829
- forms: true,
11830
- warnOnSpreadAttributes: true
11831
- }],
11832
- "react/jsx-no-undef": "error",
11833
- "react/jsx-no-useless-fragment": "error",
11834
- "react/jsx-pascal-case": "error",
11835
- "react/jsx-props-no-multi-spaces": "error",
11836
- "react/jsx-sort-props": ["error", {
11837
- callbacksLast: true,
11838
- noSortAlphabetically: true,
11839
- reservedFirst: true,
11840
- shorthandFirst: true
11841
- }],
11842
- "react/jsx-tag-spacing": ["error", {
11843
- afterOpening: "never",
11844
- beforeClosing: "never",
11845
- beforeSelfClosing: "never",
11846
- closingSlash: "never"
11847
- }],
11848
- "react/jsx-uses-react": "error",
11849
- "react/jsx-uses-vars": "error",
11850
- "react/jsx-wrap-multilines": ["error", {
11851
- arrow: "parens-new-line",
11852
- assignment: "parens-new-line",
11853
- condition: "ignore",
11854
- declaration: "parens-new-line",
11855
- logical: "ignore",
11856
- prop: "ignore",
11857
- return: "parens-new-line"
11858
- }],
11859
- "react/no-array-index-key": "error",
11860
- "react/no-arrow-function-lifecycle": "error",
11861
- "react/no-children-prop": "error",
11862
- "react/no-danger": "error",
11863
- "react/no-danger-with-children": "error",
11864
- "react/no-deprecated": "error",
11865
- "react/no-did-update-set-state": "error",
11866
- "react/no-direct-mutation-state": "error",
11867
- "react/no-find-dom-node": "error",
11868
- "react/no-invalid-html-attribute": "error",
11869
- "react/no-is-mounted": "error",
11870
- "react/no-namespace": "error",
11871
- "react/no-redundant-should-component-update": "error",
11872
- "react/no-render-return-value": "error",
11873
- "react/no-string-refs": ["error", { noTemplateLiterals: true }],
11874
- "react/no-this-in-sfc": "error",
11875
- "react/no-typos": "error",
11876
- "react/no-unescaped-entities": "error",
11877
- "react/no-unsafe": "error",
11878
- "react/no-unstable-nested-components": "error",
11879
- "react/no-unused-state": "error",
11880
- "react/prefer-read-only-props": "error",
11881
- "react/react-in-jsx-scope": "off",
11882
- "react/require-default-props": ["error", {
11883
- forbidDefaultForRequired: true,
11884
- ignoreFunctionalComponents: true
11885
- }],
11886
- "react/self-closing-comp": "error",
11887
- "react/state-in-constructor": ["error", "never"],
11888
- "react/static-property-placement": "error",
11889
- "react/style-prop-object": ["error", { allow: ["FormattedNumber"] }],
11890
- "react/void-dom-elements-no-children": "error"
11891
- };
11892
- }
11893
- /**
11894
- * Stupid prop types causes test error
11895
- * @returns React recommended rules
11896
- */
11897
- function reactRecomendedRules() {
11898
- return {
11899
- "react/display-name": 0,
11900
- "react/jsx-key": 2,
11901
- "react/jsx-no-comment-textnodes": 2,
11902
- "react/jsx-no-duplicate-props": 2,
11903
- "react/jsx-no-target-blank": 2,
11904
- "react/jsx-no-undef": 2,
11905
- "react/jsx-uses-react": 2,
11906
- "react/jsx-uses-vars": 2,
11907
- "react/no-children-prop": 2,
11908
- "react/no-danger-with-children": 2,
11909
- "react/no-deprecated": 2,
11910
- "react/no-direct-mutation-state": 0,
11911
- "react/no-find-dom-node": 2,
11912
- "react/no-is-mounted": 2,
11913
- "react/no-render-return-value": 2,
11914
- "react/no-string-refs": 2,
11915
- "react/no-unescaped-entities": 2,
11916
- "react/no-unsafe": 0,
11917
- "react/prop-types": 1,
11918
- "react/react-in-jsx-scope": 2,
11919
- "react/require-render-return": 2
11920
- };
11921
- }
11922
- async function importReactPlugins() {
11923
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
11924
- interopDefault(import("eslint-plugin-react")),
11925
- interopDefault(import("eslint-plugin-react-hooks")),
11926
- interopDefault(import("eslint-plugin-react-refresh"))
11927
- ]);
11928
- return {
11929
- pluginReact,
11930
- pluginReactHooks,
11931
- pluginReactRefresh
11932
- };
11933
- }
11934
- const react = async (options) => {
11935
- const { componentExts, parserOptions = {}, react, reactRefresh, tsconfig } = options ?? {};
11936
- const { pluginReact, pluginReactHooks, pluginReactRefresh } = await importReactPlugins();
11937
- const config = [
11938
- {
11939
- files: [GLOB_SRC],
11940
- languageOptions: typescriptLanguageOptions({
11941
- componentExts,
11942
- parserOptions,
11943
- react,
11944
- tsconfig
11945
- }),
11946
- name: "jsse/react/setup",
11947
- plugins: {
11948
- react: pluginReact,
11949
- "react-hooks": pluginReactHooks,
11950
- "react-refresh": pluginReactRefresh
11951
- }
11952
- },
11953
- {
11954
- files: [GLOB_SRC],
11955
- name: "jsse/react/rules",
11956
- rules: {
11957
- ...reactRecomendedRules(),
11958
- ...pluginReact.configs["jsx-runtime"].rules,
11959
- ...reactRules()
11960
- },
11961
- settings: { react: { version: "detect" } }
11962
- },
11963
- {
11964
- files: [GLOB_SRC],
11965
- name: "jsse/react-hooks/rules",
11966
- rules: {
11967
- "react-hooks/exhaustive-deps": "error",
11968
- "react-hooks/rules-of-hooks": "error",
11969
- ...pluginReactHooks.configs.recommended.rules
11970
- },
11971
- settings: { react: { version: "detect" } }
11972
- },
11973
- {
11974
- files: [GLOB_JSX, GLOB_TSX],
11975
- name: "jsse/react/disables",
11976
- rules: { "unicorn/no-null": "off" }
11977
- }
11978
- ];
11979
- if (reactRefresh) config.push({
11980
- files: [GLOB_SRC],
11981
- name: "jsse/react/refresh",
11982
- rules: { "react-refresh/only-export-components": "error" }
11983
- }, {
11984
- files: ["**/*.stories.tsx"],
11985
- name: "jsse/react-refresh/stories",
11986
- rules: { "react-refresh/only-export-components": "off" }
11987
- });
11988
- return config;
11989
- };
11990
- //#endregion
11991
11876
  //#region src/configs/sort-package-json.ts
11992
11877
  /**
11993
11878
  * Sort package.json
@@ -12239,7 +12124,7 @@ const stylistic = async (options) => {
12239
12124
  avoidEscape: true
12240
12125
  }
12241
12126
  ],
12242
- ...jsx ? jsxStylistic() : {}
12127
+ ...jsx && jsxStylistic()
12243
12128
  }
12244
12129
  }];
12245
12130
  };
@@ -12256,20 +12141,20 @@ function typescriptParser(options) {
12256
12141
  dbg("ts parser-options using `projectService`project service");
12257
12142
  return {
12258
12143
  files,
12259
- ...ignores.length > 0 ? { ignores } : {},
12144
+ ...ignores.length > 0 && { ignores },
12260
12145
  languageOptions: {
12261
12146
  parser: parserTs,
12262
12147
  parserOptions: {
12263
12148
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
12264
12149
  jsxPragma: react ? "React" : void 0,
12265
12150
  sourceType: "module",
12266
- ...typeAware ? {
12151
+ ...typeAware && {
12267
12152
  projectService: {
12268
12153
  allowDefaultProject: ["./*.js"],
12269
12154
  defaultProject: (typeof tsconfig === "string" ? tsconfig : tsconfig?.[0]) ?? "tsconfig.json"
12270
12155
  },
12271
12156
  tsconfigRootDir: process$1.cwd()
12272
- } : {},
12157
+ },
12273
12158
  ...parserOptionsOverride
12274
12159
  }
12275
12160
  },
@@ -12279,17 +12164,17 @@ function typescriptParser(options) {
12279
12164
  dbg("ts parser-options NOT using `projectService`project service - using `project`");
12280
12165
  return {
12281
12166
  files,
12282
- ...ignores.length > 0 ? { ignores } : {},
12167
+ ...ignores.length > 0 && { ignores },
12283
12168
  languageOptions: {
12284
12169
  parser: parserTs,
12285
12170
  parserOptions: {
12286
12171
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
12287
12172
  jsxPragma: react ? "React" : void 0,
12288
12173
  sourceType: "module",
12289
- ...typeAware ? {
12174
+ ...typeAware && {
12290
12175
  project: Array.isArray(tsconfig) ? tsconfig : [tsconfig],
12291
12176
  tsconfigRootDir: process$1.cwd().replaceAll("\\", "/")
12292
- } : {},
12177
+ },
12293
12178
  ...parserOptionsOverride
12294
12179
  }
12295
12180
  },
@@ -12395,6 +12280,7 @@ const typescript = async (options) => {
12395
12280
  function unicornOff() {
12396
12281
  return {
12397
12282
  "unicorn/catch-error-name": "off",
12283
+ "unicorn/comment-content": "off",
12398
12284
  "unicorn/consistent-destructuring": "off",
12399
12285
  "unicorn/no-array-reduce": "off",
12400
12286
  "unicorn/no-nested-ternary": "off",
@@ -12526,7 +12412,7 @@ const yml = async (options) => {
12526
12412
  "yaml/no-irregular-whitespace": "error",
12527
12413
  "yaml/plain-scalar": "error",
12528
12414
  "yaml/vue-custom-block/no-parsing-error": "error",
12529
- ...stylistic ? {
12415
+ ...stylistic && {
12530
12416
  "yaml/block-mapping-question-indicator-newline": "error",
12531
12417
  "yaml/block-sequence-hyphen-indicator-newline": "error",
12532
12418
  "yaml/flow-mapping-curly-newline": "error",
@@ -12541,7 +12427,7 @@ const yml = async (options) => {
12541
12427
  prefer: quotes
12542
12428
  }],
12543
12429
  "yaml/spaced-comment": "error"
12544
- } : {},
12430
+ },
12545
12431
  ...overrides
12546
12432
  }
12547
12433
  }];
@@ -12620,7 +12506,7 @@ function normalizeOptions(options = {}) {
12620
12506
  /**
12621
12507
  * Construct an array of ESLint flat config items.
12622
12508
  * @param options Configuration options `@jsse/eslint-config` & ESLint Flat Config
12623
- * @param userConfigs Additional user eslint configs to merge in
12509
+ * @param userConfigs Additional user ESLint configs to merge in
12624
12510
  * @returns Array of ESLint flat config items
12625
12511
  */
12626
12512
  async function jsse(options = {}, ...userConfigs) {
@@ -12671,7 +12557,7 @@ async function jsse(options = {}, ...userConfigs) {
12671
12557
  const tsconfigProvided = typeof typescriptOptions === "object" && !!typescriptOptions.tsconfig;
12672
12558
  const effectiveTypeAware = options.typeAware === void 0 ? tsconfigProvided : typeAware;
12673
12559
  const tscfg = typescript({
12674
- ...typeof typescriptOptions === "boolean" ? {} : typescriptOptions,
12560
+ ...typeof typescriptOptions !== "boolean" && typescriptOptions,
12675
12561
  componentExts,
12676
12562
  overrides: overrides.typescript,
12677
12563
  prefix: {
@@ -12691,7 +12577,7 @@ async function jsse(options = {}, ...userConfigs) {
12691
12577
  const ymlConfig = yml();
12692
12578
  configs.push(ymlConfig);
12693
12579
  }
12694
- if (enableReact) configs.push(react({ reactRefresh: normalizedOptions.reactRefresh !== false }));
12580
+ if (enableReact) configs.push(eslintReact({ reactRefresh: normalizedOptions.reactRefresh !== false }));
12695
12581
  if (enablePrettier) configs.push(prettier());
12696
12582
  if (stylisticOptions) configs.push(stylistic(stylisticOptions === true ? {} : stylisticOptions));
12697
12583
  if (enableTest) configs.push(vitest({
@@ -12711,7 +12597,7 @@ async function jsse(options = {}, ...userConfigs) {
12711
12597
  }
12712
12598
  if (tailwindOptions) console.error("Tailwind configuration is deprecated...");
12713
12599
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
12714
- if (key in options) acc[key] = options[key];
12600
+ if (Object.hasOwn(options, key)) acc[key] = options[key];
12715
12601
  return acc;
12716
12602
  }, {});
12717
12603
  if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);