@moso/eslint-config 3.3.0 → 3.5.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.
Files changed (3) hide show
  1. package/dist/index.d.mts +819 -394
  2. package/dist/index.mjs +117 -127
  3. package/package.json +43 -42
package/dist/index.mjs CHANGED
@@ -109,11 +109,7 @@ const isInGitHooksOrLintStaged = () => Boolean(process.env.GIT_PARAMS) || Boolea
109
109
  *
110
110
  * @returns `true` only for editor processes outside CI, git hooks, and lint-staged.
111
111
  */
112
- const isInEditorEnv = () => {
113
- if (Boolean(process.env.CI)) return false;
114
- if (isInGitHooksOrLintStaged()) return false;
115
- return Boolean(process.env.VSCODE_PID) || Boolean(process.env.VSCODE_CWD) || Boolean(process.env.JETBRAINS_IDE) || Boolean(process.env.VIM) || Boolean(process.env.NVIM);
116
- };
112
+ const isInEditorEnv = () => !Boolean(process.env.CI) && !isInGitHooksOrLintStaged() && (Boolean(process.env.VSCODE_PID) || Boolean(process.env.VSCODE_CWD) || Boolean(process.env.JETBRAINS_IDE) || Boolean(process.env.VIM) || Boolean(process.env.NVIM));
117
113
  /**
118
114
  * Normalize a factory option that accepts `boolean | string | number | object`
119
115
  * down to its object form.
@@ -220,10 +216,7 @@ const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeURL] });
220
216
  /**
221
217
  * Whether an install prompt could ever be shown: a TTY outside CI.
222
218
  */
223
- const isInteractive = () => {
224
- if (Boolean(process.env.CI)) return false;
225
- return process.stdout.isTTY;
226
- };
219
+ const isInteractive = () => !Boolean(process.env.CI) && process.stdout.isTTY;
227
220
  /**
228
221
  * Offer to install missing packages through an interactive prompt.
229
222
  * Only called from `loadPackages` after it has verified the session is interactive,
@@ -322,15 +315,15 @@ const astro = async (options) => {
322
315
  //#region src/configs/baseline.ts
323
316
  const defaultIgnoreFeatures = ["functions-caller-arguments"];
324
317
  const baseline = async (options) => {
325
- const { baseline, files, filesTypeAware, hasDOM, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
318
+ const { baseline = "widely", files, filesTypeAware, hasDOM, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
326
319
  const isTypeAware = typescript && typeof projectRoot === "string" && parserOptions?.projectService !== false;
327
320
  const [baselinePlugin] = await loadPackages(["eslint-plugin-baseline-js"]);
328
321
  const baselineRule = (typeAware) => ({ "baseline-js/use-baseline": ["warn", {
329
- available: baseline ?? "widely",
322
+ available: baseline,
330
323
  ignoreFeatures: [...defaultIgnoreFeatures, ...ignoreFeatures ?? []],
331
324
  ignoreNodeTypes,
332
325
  includeJsBuiltins: { preset: typeAware ? "type-aware" : "auto" },
333
- includeWebApis: hasDOM === false ? false : { preset: typeAware ? "type-aware" : "auto" }
326
+ includeWebApis: hasDOM !== false && { preset: typeAware ? "type-aware" : "auto" }
334
327
  }] });
335
328
  return [
336
329
  {
@@ -668,7 +661,8 @@ const comments = async (options) => {
668
661
  //#endregion
669
662
  //#region src/configs/functional.ts
670
663
  const functional = async (options) => {
671
- const { filesTypeAware, functionalEnforcement, ignoreNamePattern, mode, overrides, stylistic } = options;
664
+ const { filesTypeAware, functionalEnforcement, ignoreNamePattern, mode, overrides, parserOptions, stylistic } = options;
665
+ const isTypeAware = parserOptions.projectService !== false;
672
666
  const [functionalPlugin] = await loadPackages(["eslint-plugin-functional"]);
673
667
  const stylisticEnabled = stylistic !== false;
674
668
  const commonRules = {
@@ -765,7 +759,7 @@ const functional = async (options) => {
765
759
  }
766
760
  }, {
767
761
  name: "moso/functional/disable-type-aware",
768
- ignores: filesTypeAware,
762
+ ...isTypeAware && { ignores: filesTypeAware },
769
763
  rules: {
770
764
  ...(assert.ok(!Array.isArray(functionalPlugin.configs.disableTypeChecked)), functionalPlugin.configs.disableTypeChecked.rules),
771
765
  "functional/no-let": ["error", {
@@ -874,8 +868,7 @@ const getFixer = (token, pattern) => {
874
868
  */
875
869
  const getReturnExpression = (node) => {
876
870
  if (node.type !== AST_NODE_TYPES.AwaitExpression) return node;
877
- if (closest(node, AST_NODE_TYPES.TryStatement)) return node;
878
- return node.argument;
871
+ return closest(node, AST_NODE_TYPES.TryStatement) ? node : node.argument;
879
872
  };
880
873
  /**
881
874
  * Extract the user-visible text of a token for pattern scanning:
@@ -902,10 +895,7 @@ const functionLikeTypes = /* @__PURE__ */ new Set([
902
895
  /**
903
896
  * Whether `node` is a function declaration, function expression, or arrow function.
904
897
  */
905
- const isFunctionLike = (node) => {
906
- if (!node) return false;
907
- return functionLikeTypes.has(node.type);
908
- };
898
+ const isFunctionLike = (node) => node ? functionLikeTypes.has(node.type) : false;
909
899
  /**
910
900
  * Whether `node` is an identifier matching `name` given as an exact string,
911
901
  * a list of accepted names, or a predicate over the identifier's name.
@@ -913,8 +903,7 @@ const isFunctionLike = (node) => {
913
903
  const isIdentifierName = (node, name) => {
914
904
  if (!isIdentifier(node)) return false;
915
905
  if (typeof name === "string") return node.name === name;
916
- if (typeof name === "function") return Boolean(name(node.name));
917
- return name?.includes(node.name) ?? false;
906
+ return typeof name === "function" ? Boolean(name(node.name)) : name?.includes(node.name) ?? false;
918
907
  };
919
908
  /**
920
909
  * Check if both identifiers have the same name.
@@ -925,17 +914,10 @@ const isSameIdentifier = (a, b) => a?.type === AST_NODE_TYPES.Identifier && b?.t
925
914
  * returns its own parameter unchanged, in either expression form (`(x) => x`)
926
915
  * or block form (`(x) => { return x }`).
927
916
  */
928
- const isIdentifierFunction = (node) => {
929
- if (!isFunctionLike(node)) return false;
930
- if (node.params.length !== 1) return false;
931
- if (node.params[0].type !== AST_NODE_TYPES.Identifier) return false;
932
- if (isSameIdentifier(node.params[0], node.body)) return true;
933
- return node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 1 && node.body.body[0].type === AST_NODE_TYPES.ReturnStatement && isSameIdentifier(node.params[0], node.body.body[0].argument);
934
- };
917
+ const isIdentifierFunction = (node) => isFunctionLike(node) && node.params.length === 1 && node.params[0].type === AST_NODE_TYPES.Identifier && (isSameIdentifier(node.params[0], node.body) || node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 1 && node.body.body[0].type === AST_NODE_TYPES.ReturnStatement && isSameIdentifier(node.params[0], node.body.body[0].argument));
935
918
  const isLiteralValue = (node, value) => {
936
919
  if (node?.type !== AST_NODE_TYPES.Literal) return false;
937
- if (typeof value === "string") return node.value === value;
938
- return typeof node.value === "string" && value.test(node.value);
920
+ return typeof value === "string" ? node.value === value : typeof node.value === "string" && value.test(node.value);
939
921
  };
940
922
  const makeProgramListener = (pattern, onReport) => ({ Program: (program) => {
941
923
  const tokens = program.tokens ?? [];
@@ -1003,13 +985,9 @@ const ruleAvoidBarrelFiles = createRule({
1003
985
  declarationCount: declarationCount + 1,
1004
986
  exportCount
1005
987
  };
1006
- if (statement.declaration.type === AST_NODE_TYPES.ObjectExpression) return {
1007
- declarationCount,
1008
- exportCount: exportCount + statement.declaration.properties.length
1009
- };
1010
988
  return {
1011
989
  declarationCount,
1012
- exportCount: exportCount + 1
990
+ exportCount: exportCount + (statement.declaration.type === AST_NODE_TYPES.ObjectExpression ? statement.declaration.properties.length : 1)
1013
991
  };
1014
992
  }
1015
993
  return {
@@ -1072,8 +1050,7 @@ const ruleNoForceCastViaTopType = createRule({
1072
1050
  messages: { noForceCast: "Do not cast this expression to another type by `as {{type}} as T`." }
1073
1051
  },
1074
1052
  create: (context) => ({ TSAsExpression: (node) => {
1075
- if (!isTopType(node.typeAnnotation)) return;
1076
- if (!isCastToAnotherType(node.parent)) return;
1053
+ if (!isTopType(node.typeAnnotation) || !isCastToAnotherType(node.parent)) return;
1077
1054
  const type = node.typeAnnotation.type === AST_NODE_TYPES.TSAnyKeyword ? "any" : "unknown";
1078
1055
  context.report({
1079
1056
  node,
@@ -1216,10 +1193,7 @@ const ruleNoInvisibleCharacters = createRule({
1216
1193
  });
1217
1194
  //#endregion
1218
1195
  //#region src/rules/no-redundant-variable/no-redundant-variable.ts
1219
- const isRedundantVariable = (node, exit) => {
1220
- if (!node) return false;
1221
- return node.type === AST_NODE_TYPES.VariableDeclaration && node.declarations.length === 1 && node.declarations[0].init !== null && isSameIdentifier(exit.argument, node.declarations[0].id);
1222
- };
1196
+ const isRedundantVariable = (node, exit) => node ? node.type === AST_NODE_TYPES.VariableDeclaration && node.declarations.length === 1 && node.declarations[0].init !== null && isSameIdentifier(exit.argument, node.declarations[0].id) : false;
1223
1197
  const isRedundantVariableFixer = (source, variable, id, init, exit) => (fixer) => {
1224
1198
  const replaced = getReturnExpression(init);
1225
1199
  const modified = wrap(source.getText(replaced), (input) => {
@@ -1363,7 +1337,7 @@ const ruleNoUnneededArrayFlatMap = createRule({
1363
1337
  });
1364
1338
  //#endregion
1365
1339
  //#region src/rules/package.json
1366
- var version = "3.3.0";
1340
+ var version = "3.5.0";
1367
1341
  //#endregion
1368
1342
  //#region src/rules/prefer-early-return/prefer-early-return.ts
1369
1343
  const isTriggering = (node, maximumStatements) => {
@@ -1480,12 +1454,7 @@ const arrayHighOrderFunctions = /* @__PURE__ */ new Set([
1480
1454
  "reduce",
1481
1455
  "reduceRight"
1482
1456
  ]);
1483
- const isArrayHigherOrderFunction = (node) => {
1484
- if (node?.type !== AST_NODE_TYPES.MemberExpression) return false;
1485
- if (node.computed) return false;
1486
- if (node.property.type !== AST_NODE_TYPES.Identifier) return false;
1487
- return arrayHighOrderFunctions.has(node.property.name) && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
1488
- };
1457
+ const isArrayHigherOrderFunction = (node) => node?.type === AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === AST_NODE_TYPES.Identifier && arrayHighOrderFunctions.has(node.property.name) && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
1489
1458
  const rulePreferReduceOverChaining = createRule({
1490
1459
  name: "prefer-reduce-over-chaining",
1491
1460
  meta: {
@@ -1541,20 +1510,17 @@ const parseFunctions = [
1541
1510
  const indexNamePattern = /^(?:[ijk]|idx|index)$/iu;
1542
1511
  const indexSuffixPattern = /(?:Idx|Index)$/u;
1543
1512
  const isConsoleAssert = (statement) => {
1544
- if (statement.type !== AST_NODE_TYPES.ExpressionStatement) return false;
1545
- if (statement.expression.type !== AST_NODE_TYPES.CallExpression) return false;
1513
+ if (statement.type !== AST_NODE_TYPES.ExpressionStatement || statement.expression.type !== AST_NODE_TYPES.CallExpression) return false;
1546
1514
  const { callee } = statement.expression;
1547
1515
  return callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && isIdentifierName(callee.object, "console") && isIdentifierName(callee.property, "assert");
1548
1516
  };
1549
1517
  const isConsumedDirectly = (node) => {
1550
1518
  const { parent } = node;
1551
- if (parent.type === AST_NODE_TYPES.BinaryExpression) return arithmeticOperators.has(parent.operator);
1552
- return parent.type === AST_NODE_TYPES.MemberExpression && parent.computed && parent.property === node;
1519
+ return parent.type === AST_NODE_TYPES.BinaryExpression ? arithmeticOperators.has(parent.operator) : parent.type === AST_NODE_TYPES.MemberExpression && parent.computed && parent.property === node;
1553
1520
  };
1554
1521
  const isGuardedIndex = (node) => {
1555
1522
  const { parent } = node;
1556
- if (parent.type === AST_NODE_TYPES.TSNonNullExpression) return true;
1557
- return parent.type === AST_NODE_TYPES.LogicalExpression && parent.operator === "??" && parent.left === node;
1523
+ return parent.type === AST_NODE_TYPES.TSNonNullExpression || parent.type === AST_NODE_TYPES.LogicalExpression && parent.operator === "??" && parent.left === node;
1558
1524
  };
1559
1525
  const isMathCall = (node, methods) => {
1560
1526
  const { callee } = node;
@@ -1562,9 +1528,7 @@ const isMathCall = (node, methods) => {
1562
1528
  };
1563
1529
  const isWriteTarget = (node) => {
1564
1530
  const { parent } = node;
1565
- if (parent.type === AST_NODE_TYPES.AssignmentExpression) return parent.left === node;
1566
- if (parent.type === AST_NODE_TYPES.UpdateExpression) return true;
1567
- return parent.type === AST_NODE_TYPES.UnaryExpression && parent.operator === "delete";
1531
+ return parent.type === AST_NODE_TYPES.AssignmentExpression && parent.left === node || parent.type === AST_NODE_TYPES.UpdateExpression || parent.type === AST_NODE_TYPES.UnaryExpression && parent.operator === "delete";
1568
1532
  };
1569
1533
  const assertedNames = (node, sourceCode) => {
1570
1534
  if (node.body.type !== AST_NODE_TYPES.BlockStatement) return /* @__PURE__ */ new Set();
@@ -1577,14 +1541,12 @@ const assertedNames = (node, sourceCode) => {
1577
1541
  };
1578
1542
  const looksLikeIndex = (node) => {
1579
1543
  if (node.type === AST_NODE_TYPES.BinaryExpression) return arithmeticOperators.has(node.operator);
1580
- if (node.type === AST_NODE_TYPES.CallExpression) return isMathCall(node);
1581
- return isIdentifierName(node, (name) => indexNamePattern.test(name) || indexSuffixPattern.test(name));
1544
+ return node.type === AST_NODE_TYPES.CallExpression ? isMathCall(node) : isIdentifierName(node, (name) => indexNamePattern.test(name) || indexSuffixPattern.test(name));
1582
1545
  };
1583
1546
  const numberParameterNames = (node) => {
1584
1547
  const mut_names = /* @__PURE__ */ new Set();
1585
1548
  for (const parameter of node.params) {
1586
- if (parameter.type !== AST_NODE_TYPES.Identifier) continue;
1587
- if (parameter.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES.TSNumberKeyword) continue;
1549
+ if (parameter.type !== AST_NODE_TYPES.Identifier || parameter.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES.TSNumberKeyword) continue;
1588
1550
  mut_names.add(parameter.name);
1589
1551
  }
1590
1552
  return mut_names;
@@ -1634,12 +1596,9 @@ const rulePreferStrictNumberGuards = createRule({
1634
1596
  };
1635
1597
  const exitFunction = () => mut_scopes.pop();
1636
1598
  const reportUnencodedInput = (node) => {
1637
- if (!enabled.has("encode-input-rule")) return;
1638
- if (node.type !== AST_NODE_TYPES.Identifier) return;
1599
+ if (!enabled.has("encode-input-rule") || node.type !== AST_NODE_TYPES.Identifier) return;
1639
1600
  const scope = mut_scopes.at(-1);
1640
- if (!scope) return;
1641
- if (!scope.numberParams.has(node.name)) return;
1642
- if (scope.asserted.has(node.name)) return;
1601
+ if (!scope || !scope.numberParams.has(node.name) || scope.asserted.has(node.name)) return;
1643
1602
  context.report({
1644
1603
  node,
1645
1604
  messageId: "encodeInputRule",
@@ -1685,22 +1644,16 @@ const rulePreferStrictNumberGuards = createRule({
1685
1644
  "FunctionExpression": enterFunction,
1686
1645
  "FunctionExpression:exit": exitFunction,
1687
1646
  "LogicalExpression": (node) => {
1688
- if (!enabled.has("write-explicit-condition")) return;
1689
- if (node.operator !== "||") return;
1690
- if (node.right.type !== AST_NODE_TYPES.Literal) return;
1691
- if (typeof node.right.value !== "number") return;
1647
+ if (!enabled.has("write-explicit-condition") || node.operator !== "||" || node.right.type !== AST_NODE_TYPES.Literal || typeof node.right.value !== "number") return;
1692
1648
  context.report({
1693
1649
  node,
1694
1650
  messageId: "writeExplicitCondition"
1695
1651
  });
1696
1652
  },
1697
1653
  "MemberExpression": (node) => {
1698
- if (!node.computed) return;
1699
- if (node.property.type === AST_NODE_TYPES.Literal) return;
1654
+ if (!node.computed || node.property.type === AST_NODE_TYPES.Literal) return;
1700
1655
  reportUnencodedInput(node.property);
1701
- if (!enabled.has("guard-array-index")) return;
1702
- if (!looksLikeIndex(node.property)) return;
1703
- if (isGuardedIndex(node) || isWriteTarget(node)) return;
1656
+ if (!enabled.has("guard-array-index") || !looksLikeIndex(node.property) || isGuardedIndex(node) || isWriteTarget(node)) return;
1704
1657
  context.report({
1705
1658
  node,
1706
1659
  messageId: "guardArrayIndex"
@@ -2168,7 +2121,7 @@ const jsdoc = async (options) => {
2168
2121
  ],
2169
2122
  "jsdoc/valid-types": "error",
2170
2123
  ...!lessOpinionated && {
2171
- "jsdoc/check-indentation": "warn",
2124
+ "jsdoc/check-indentation": ["warn", { allowNoSpaceAfterAsterisk: true }],
2172
2125
  "jsdoc/no-bad-blocks": ["warn", { ignore: [
2173
2126
  "ts-check",
2174
2127
  "ts-expect-error",
@@ -2982,12 +2935,35 @@ const regexp = async (options) => {
2982
2935
  "no-invalid-regexp": "off",
2983
2936
  "no-useless-backreference": "off",
2984
2937
  ...(assert.ok(!Array.isArray(regexpPlugin.configs["flat/recommended"])), regexpPlugin.configs["flat/recommended"].rules),
2938
+ "regexp/no-super-linear-backtracking": "error",
2985
2939
  "regexp/strict": "off",
2986
2940
  ...overrides
2987
2941
  }
2988
2942
  }];
2989
2943
  };
2990
2944
  //#endregion
2945
+ //#region src/configs/security.ts
2946
+ const security = async (options) => {
2947
+ const { overrides, severity } = options;
2948
+ const [securityPlugin] = await loadPackages(["eslint-plugin-security"]);
2949
+ const recommended = securityPlugin.configs?.["recommended"];
2950
+ const baseRules = severity === "lite" ? recommended?.rules : Object.fromEntries(Object.keys(recommended?.rules ?? {}).map((key) => [key, "error"]));
2951
+ return [{
2952
+ name: "moso/security",
2953
+ plugins: { security: memoize(securityPlugin, "eslint-plugin-security") },
2954
+ rules: {
2955
+ ...baseRules,
2956
+ "security/detect-unsafe-regex": "off",
2957
+ ...severity !== "strict" && {
2958
+ "security/detect-non-literal-fs-filename": "off",
2959
+ "security/detect-non-literal-regexp": "off",
2960
+ "security/detect-object-injection": "off"
2961
+ },
2962
+ ...overrides
2963
+ }
2964
+ }];
2965
+ };
2966
+ //#endregion
2991
2967
  //#region src/configs/sort.ts
2992
2968
  /**
2993
2969
  * Sort package.json
@@ -3708,45 +3684,47 @@ const typescript = async (options) => {
3708
3684
  "@typescript-eslint/no-useless-constructor": "error",
3709
3685
  "@typescript-eslint/parameter-properties": "off",
3710
3686
  ...functionalEnforcement !== "none" && mode !== "library" && {
3711
- "functional/no-mixed-types": "error",
3712
- "functional/prefer-property-signatures": "error",
3713
- "functional/readonly-type": "error",
3714
- "functional/type-declaration-immutability": ["error", { rules: [
3715
- {
3716
- identifiers: "I?Immutable.+",
3717
- immutability: "Immutable",
3718
- comparator: "AtLeast"
3719
- },
3720
- {
3721
- identifiers: "I?ReadonlyDeep.+",
3722
- immutability: "ReadonlyDeep",
3723
- comparator: "AtLeast"
3724
- },
3725
- {
3726
- identifiers: "I?Readonly.+",
3727
- immutability: "ReadonlyShallow",
3728
- comparator: "AtLeast",
3729
- fixer: [{
3730
- pattern: "^(Array|Map|Set)<(.+)>$",
3731
- replace: "Readonly$1<$2>"
3732
- }, {
3733
- pattern: "^(.+)$",
3734
- replace: "Readonly<$1>"
3735
- }]
3736
- },
3737
- {
3738
- identifiers: "I?Mutable.+",
3739
- immutability: "Mutable",
3740
- comparator: "AtMost",
3741
- fixer: [{
3742
- pattern: "^Readonly(Array|Map|Set)<(.+)>$",
3743
- replace: "$1<$2>"
3744
- }, {
3745
- pattern: "^Readonly<(.+)>$",
3746
- replace: "$1"
3747
- }]
3748
- }
3749
- ] }],
3687
+ ...isTypeAware && {
3688
+ "functional/no-mixed-types": "error",
3689
+ "functional/prefer-property-signatures": "error",
3690
+ "functional/readonly-type": "error",
3691
+ "functional/type-declaration-immutability": ["error", { rules: [
3692
+ {
3693
+ identifiers: "I?Immutable.+",
3694
+ immutability: "Immutable",
3695
+ comparator: "AtLeast"
3696
+ },
3697
+ {
3698
+ identifiers: "I?ReadonlyDeep.+",
3699
+ immutability: "ReadonlyDeep",
3700
+ comparator: "AtLeast"
3701
+ },
3702
+ {
3703
+ identifiers: "I?Readonly.+",
3704
+ immutability: "ReadonlyShallow",
3705
+ comparator: "AtLeast",
3706
+ fixer: [{
3707
+ pattern: "^(Array|Map|Set)<(.+)>$",
3708
+ replace: "Readonly$1<$2>"
3709
+ }, {
3710
+ pattern: "^(.+)$",
3711
+ replace: "Readonly<$1>"
3712
+ }]
3713
+ },
3714
+ {
3715
+ identifiers: "I?Mutable.+",
3716
+ immutability: "Mutable",
3717
+ comparator: "AtMost",
3718
+ fixer: [{
3719
+ pattern: "^Readonly(Array|Map|Set)<(.+)>$",
3720
+ replace: "$1<$2>"
3721
+ }, {
3722
+ pattern: "^Readonly<(.+)>$",
3723
+ replace: "$1"
3724
+ }]
3725
+ }
3726
+ ] }]
3727
+ },
3750
3728
  "@typescript-eslint/naming-convention": [
3751
3729
  "error",
3752
3730
  {
@@ -4211,6 +4189,7 @@ const unicorn = async (options) => {
4211
4189
  "unicorn/try-complexity": ["error", { max: 3 }],
4212
4190
  "unicorn/consistent-boolean-name": "off",
4213
4191
  "unicorn/consistent-compound-words": "off",
4192
+ "unicorn/consistent-conditional-object-spread": "off",
4214
4193
  "unicorn/consistent-export-decorator-position": "off",
4215
4194
  "unicorn/default-export-style": "off",
4216
4195
  "unicorn/empty-brace-spaces": "off",
@@ -4223,6 +4202,7 @@ const unicorn = async (options) => {
4223
4202
  "unicorn/logical-assignment-operators": "off",
4224
4203
  "unicorn/max-nested-calls": "off",
4225
4204
  "unicorn/name-replacements": "off",
4205
+ "unicorn/no-asterisk-prefix-in-documentation-comments": "off",
4226
4206
  "unicorn/no-array-concat-in-loop": "off",
4227
4207
  "unicorn/no-array-fill-with-reference-type": "off",
4228
4208
  "unicorn/no-array-reduce": "off",
@@ -4239,6 +4219,7 @@ const unicorn = async (options) => {
4239
4219
  "unicorn/no-invalid-well-known-symbol-methods": "off",
4240
4220
  "unicorn/no-late-current-target-access": "off",
4241
4221
  "unicorn/no-late-event-control": "off",
4222
+ "unicorn/no-leading-empty-lines": "off",
4242
4223
  "unicorn/no-lonely-if": "off",
4243
4224
  "unicorn/no-mismatched-map-key": "off",
4244
4225
  "unicorn/no-named-default": "off",
@@ -4273,6 +4254,7 @@ const unicorn = async (options) => {
4273
4254
  "unicorn/prefer-promise-try": "off",
4274
4255
  "unicorn/prefer-promise-with-resolvers": "off",
4275
4256
  "unicorn/prefer-prototype-methods": "off",
4257
+ "unicorn/prefer-short-escape-sequences": "off",
4276
4258
  "unicorn/prefer-single-replace": "off",
4277
4259
  "unicorn/prefer-split-limit": "off",
4278
4260
  "unicorn/prefer-string-raw": "off",
@@ -4618,27 +4600,28 @@ async function moso(options = {}, ...userConfigs) {
4618
4600
  if (options.typescript !== void 0) throw new Error(message);
4619
4601
  console.warn(message);
4620
4602
  }
4621
- const typescriptOptions = typescriptUnsupported ? false : typescriptRequested;
4603
+ const typescriptOptions = !typescriptUnsupported && typescriptRequested;
4622
4604
  const astroOptions = options.astro ?? anyPackageExists(AstroPackages);
4623
4605
  const nextjsOptions = options.nextjs ?? anyPackageExists(NextJSPackages);
4624
4606
  const reactOptions = options.react ?? anyPackageExists(ReactPackages);
4625
4607
  const tailwindOptions = options.tailwind ?? packageExists("tailwindcss");
4626
4608
  const vueOptions = options.vue ?? anyPackageExists(VuePackages);
4627
4609
  const componentExts = vueOptions === false ? [...componentExtsOption] : [.../* @__PURE__ */ new Set([...componentExtsOption, "vue"])];
4628
- const baselineOptions = options.baseline === false ? false : typeof options.baseline === "object" ? options.baseline : typeof options.baseline === "string" || typeof options.baseline === "number" ? { baseline: options.baseline } : {};
4629
- const e18eOptions = options.e18e === false ? false : typeof options.e18e === "object" ? options.e18e : options.e18e === true ? {} : options.lessOpinionated === true ? false : {};
4610
+ const baselineOptions = options.baseline !== false && (typeof options.baseline === "object" ? options.baseline : typeof options.baseline === "string" || typeof options.baseline === "number" ? { baseline: options.baseline } : {});
4611
+ const e18eOptions = options.e18e !== false && (typeof options.e18e === "object" ? options.e18e : (options.e18e === true || options.lessOpinionated !== true) && {});
4630
4612
  const functionalEnforcement = typeof options.functional === "string" ? options.functional : typeof options.functional === "object" ? options.functional.functionalEnforcement ?? "lite" : options.functional ? "recommended" : options.functional === false || options.lessOpinionated === true ? "none" : "lite";
4631
4613
  const hasTypeScript = Boolean(typescriptOptions);
4632
4614
  const hasDOM = options.mode !== "library" || Boolean(astroOptions) || Boolean(nextjsOptions) || Boolean(reactOptions) || Boolean(vueOptions);
4633
4615
  const ignoreOptions = typeof options.ignores === "object" ? options.ignores : {};
4634
4616
  const modeOptions = typeof options.mode === "string" ? options.mode : "none";
4635
4617
  const perfectionistOptions = typeof options.perfectionist === "boolean" ? options.perfectionist : options.lessOpinionated !== true;
4636
- const stylisticOptions = options.stylistic === false ? false : {
4618
+ const securityOptions = typeof options.security === "string" ? options.security : typeof options.security === "object" ? options.security.severity ?? "moderate" : options.security === false ? "none" : "moderate";
4619
+ const stylisticOptions = options.stylistic !== false && {
4637
4620
  ...StylisticConfigDefaults,
4638
- jsx: typeof jsxOptions === "boolean" ? jsxOptions : true,
4621
+ jsx: jsxOptions !== false,
4639
4622
  ...typeof options.stylistic === "object" && options.stylistic
4640
4623
  };
4641
- const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, unsafe: typescriptUnsafe, useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
4624
+ const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, unsafe: typescriptUnsafe = "warn", useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
4642
4625
  const deprecatedProjectRoot = options.projectRoot;
4643
4626
  if (deprecatedProjectRoot !== void 0) console.warn("[@moso/eslint-config] The top-level `projectRoot` option is deprecated. Move it inside the `typescript` options instead: `typescript: { projectRoot: import.meta.dirname }`.");
4644
4627
  const projectRootOptions = typeof typescriptProjectRoot === "string" ? checkFilePath(typescriptProjectRoot) : typeof deprecatedProjectRoot === "string" ? checkFilePath(deprecatedProjectRoot) : void 0;
@@ -4659,10 +4642,10 @@ async function moso(options = {}, ...userConfigs) {
4659
4642
  parserOptions: {
4660
4643
  tsconfigRootDir: projectRootOptions,
4661
4644
  ...parserOptions,
4662
- projectService: projectRootOptions === void 0 || parserOptions?.projectService === false ? false : useDefaultDefaultProject === false ? projectServiceUserConfig : {
4663
- allowDefaultProject: [GLOB_ROOT_JS, GLOB_ROOT_JSX],
4645
+ projectService: projectRootOptions !== void 0 && parserOptions?.projectService !== false && (useDefaultDefaultProject === false ? projectServiceUserConfig : {
4646
+ allowDefaultProject: ["?(.)*.?([cm])js", "?(.)*.?([cm])jsx"],
4664
4647
  ...projectServiceUserConfig
4665
- }
4648
+ })
4666
4649
  }
4667
4650
  };
4668
4651
  const functionalConfigOptions = {
@@ -4687,6 +4670,11 @@ async function moso(options = {}, ...userConfigs) {
4687
4670
  stylistic: stylisticOptions,
4688
4671
  typescript: hasTypeScript
4689
4672
  }));
4673
+ if (securityOptions !== "none") mut_configs.push(security({
4674
+ ...resolveSubOptions(options, "security"),
4675
+ overrides: getOverrides(options, "security"),
4676
+ severity: securityOptions
4677
+ }));
4690
4678
  mut_configs.push(javascript({
4691
4679
  ...functionalConfigOptions,
4692
4680
  isInEditor,
@@ -4822,7 +4810,7 @@ async function moso(options = {}, ...userConfigs) {
4822
4810
  overrides: getOverrides(options, "typescript"),
4823
4811
  projectRoot: projectRootOptions,
4824
4812
  stylistic: stylisticOptions,
4825
- unsafe: typescriptUnsafe ?? "warn"
4813
+ unsafe: typescriptUnsafe
4826
4814
  }));
4827
4815
  if (vueOptions !== false) mut_configs.push(vue({
4828
4816
  ...typescriptConfigOptions,
@@ -4886,6 +4874,7 @@ const full = {
4886
4874
  reactRefresh: { allowConstantExport: true }
4887
4875
  },
4888
4876
  regexp: true,
4877
+ security: true,
4889
4878
  stylistic: true,
4890
4879
  tailwind: {
4891
4880
  entryPoint: "src/styles/app.css",
@@ -4919,6 +4908,7 @@ const off = {
4919
4908
  promise: false,
4920
4909
  react: false,
4921
4910
  regexp: false,
4911
+ security: false,
4922
4912
  stylistic: false,
4923
4913
  tailwind: false,
4924
4914
  test: false,
@@ -4929,4 +4919,4 @@ const off = {
4929
4919
  yaml: false
4930
4920
  };
4931
4921
  //#endregion
4932
- export { GLOB_AI, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS_IN_JS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MJS, GLOB_NODE_MODULES, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, astro, baseline, checkFilePath, combine, comments, moso as default, moso, disables, e18e, flattenRules, full, functional, getOverrides, globalIgnores, ignores, imports, interopDefault, isInEditorEnv, javascript, jsdoc, jsonc, jsx, memoize, nextjs, node, off, perfectionist, promise, react, regexp, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, tailwind, test, toml, typescript, unicorn, vue, vueInlineElements, yaml };
4922
+ export { GLOB_AI, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS_IN_JS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MJS, GLOB_NODE_MODULES, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, astro, baseline, checkFilePath, combine, comments, moso as default, moso, disables, e18e, flattenRules, full, functional, getOverrides, globalIgnores, ignores, imports, interopDefault, isInEditorEnv, javascript, jsdoc, jsonc, jsx, memoize, nextjs, node, off, perfectionist, promise, react, regexp, resolveSubOptions, security, sortPackageJson, sortTsconfig, stylistic, tailwind, test, toml, typescript, unicorn, vue, vueInlineElements, yaml };