@moso/eslint-config 3.2.0 → 3.4.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 +561 -381
  2. package/dist/index.mjs +75 -96
  3. package/package.json +38 -38
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,7 +315,7 @@ 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, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
318
+ const { baseline, 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", {
@@ -330,7 +323,7 @@ const baseline = async (options) => {
330
323
  ignoreFeatures: [...defaultIgnoreFeatures, ...ignoreFeatures ?? []],
331
324
  ignoreNodeTypes,
332
325
  includeJsBuiltins: { preset: typeAware ? "type-aware" : "auto" },
333
- includeWebApis: { preset: typeAware ? "type-aware" : "auto" }
326
+ includeWebApis: hasDOM !== false && { preset: typeAware ? "type-aware" : "auto" }
334
327
  }] });
335
328
  return [
336
329
  {
@@ -874,8 +867,7 @@ const getFixer = (token, pattern) => {
874
867
  */
875
868
  const getReturnExpression = (node) => {
876
869
  if (node.type !== AST_NODE_TYPES.AwaitExpression) return node;
877
- if (closest(node, AST_NODE_TYPES.TryStatement)) return node;
878
- return node.argument;
870
+ return closest(node, AST_NODE_TYPES.TryStatement) ? node : node.argument;
879
871
  };
880
872
  /**
881
873
  * Extract the user-visible text of a token for pattern scanning:
@@ -902,10 +894,7 @@ const functionLikeTypes = /* @__PURE__ */ new Set([
902
894
  /**
903
895
  * Whether `node` is a function declaration, function expression, or arrow function.
904
896
  */
905
- const isFunctionLike = (node) => {
906
- if (!node) return false;
907
- return functionLikeTypes.has(node.type);
908
- };
897
+ const isFunctionLike = (node) => node ? functionLikeTypes.has(node.type) : false;
909
898
  /**
910
899
  * Whether `node` is an identifier matching `name` given as an exact string,
911
900
  * a list of accepted names, or a predicate over the identifier's name.
@@ -913,8 +902,7 @@ const isFunctionLike = (node) => {
913
902
  const isIdentifierName = (node, name) => {
914
903
  if (!isIdentifier(node)) return false;
915
904
  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;
905
+ return typeof name === "function" ? Boolean(name(node.name)) : name?.includes(node.name) ?? false;
918
906
  };
919
907
  /**
920
908
  * Check if both identifiers have the same name.
@@ -925,17 +913,10 @@ const isSameIdentifier = (a, b) => a?.type === AST_NODE_TYPES.Identifier && b?.t
925
913
  * returns its own parameter unchanged, in either expression form (`(x) => x`)
926
914
  * or block form (`(x) => { return x }`).
927
915
  */
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
- };
916
+ 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
917
  const isLiteralValue = (node, value) => {
936
918
  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);
919
+ return typeof value === "string" ? node.value === value : typeof node.value === "string" && value.test(node.value);
939
920
  };
940
921
  const makeProgramListener = (pattern, onReport) => ({ Program: (program) => {
941
922
  const tokens = program.tokens ?? [];
@@ -1003,13 +984,9 @@ const ruleAvoidBarrelFiles = createRule({
1003
984
  declarationCount: declarationCount + 1,
1004
985
  exportCount
1005
986
  };
1006
- if (statement.declaration.type === AST_NODE_TYPES.ObjectExpression) return {
1007
- declarationCount,
1008
- exportCount: exportCount + statement.declaration.properties.length
1009
- };
1010
987
  return {
1011
988
  declarationCount,
1012
- exportCount: exportCount + 1
989
+ exportCount: exportCount + (statement.declaration.type === AST_NODE_TYPES.ObjectExpression ? statement.declaration.properties.length : 1)
1013
990
  };
1014
991
  }
1015
992
  return {
@@ -1072,8 +1049,7 @@ const ruleNoForceCastViaTopType = createRule({
1072
1049
  messages: { noForceCast: "Do not cast this expression to another type by `as {{type}} as T`." }
1073
1050
  },
1074
1051
  create: (context) => ({ TSAsExpression: (node) => {
1075
- if (!isTopType(node.typeAnnotation)) return;
1076
- if (!isCastToAnotherType(node.parent)) return;
1052
+ if (!isTopType(node.typeAnnotation) || !isCastToAnotherType(node.parent)) return;
1077
1053
  const type = node.typeAnnotation.type === AST_NODE_TYPES.TSAnyKeyword ? "any" : "unknown";
1078
1054
  context.report({
1079
1055
  node,
@@ -1216,16 +1192,8 @@ const ruleNoInvisibleCharacters = createRule({
1216
1192
  });
1217
1193
  //#endregion
1218
1194
  //#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
- };
1223
- const isSelfReferencing = (source, variable) => {
1224
- const { init } = variable.declarations[0];
1225
- return source.getDeclaredVariables(variable).some(({ references }) => references.some(({ identifier }) => identifier.range[0] >= init.range[0] && identifier.range[1] <= init.range[1]));
1226
- };
1227
- const isRedundantVariableFixer = (source, variable, exit) => (fixer) => {
1228
- const { init, id } = variable.declarations[0];
1195
+ 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;
1196
+ const isRedundantVariableFixer = (source, variable, id, init, exit) => (fixer) => {
1229
1197
  const replaced = getReturnExpression(init);
1230
1198
  const modified = wrap(source.getText(replaced), (input) => {
1231
1199
  if (!id.typeAnnotation) return input;
@@ -1235,6 +1203,7 @@ const isRedundantVariableFixer = (source, variable, exit) => (fixer) => {
1235
1203
  return [fixer.remove(variable), fixer.replaceText(exit.argument, modified)];
1236
1204
  };
1237
1205
  const isReturnStatement = (node) => node.type === AST_NODE_TYPES.ReturnStatement && isIdentifier(node.argument);
1206
+ const isSelfReferencing = (source, variable, init) => source.getDeclaredVariables(variable).some(({ references }) => references.some(({ identifier }) => identifier.range[0] >= init.range[0] && identifier.range[1] <= init.range[1]));
1238
1207
  const ruleNoRedundantVariables = createRule({
1239
1208
  name: "no-redundant-variable",
1240
1209
  meta: {
@@ -1255,11 +1224,14 @@ const ruleNoRedundantVariables = createRule({
1255
1224
  mut_previous = statement;
1256
1225
  continue;
1257
1226
  }
1258
- if (isRedundantVariable(mut_previous, statement) && !isSelfReferencing(context.sourceCode, mut_previous)) context.report({
1259
- node: statement,
1260
- messageId: "noRedundantVar",
1261
- fix: isRedundantVariableFixer(context.sourceCode, mut_previous, statement)
1262
- });
1227
+ if (isRedundantVariable(mut_previous, statement)) {
1228
+ const { id, init } = mut_previous.declarations[0];
1229
+ if (init && !isSelfReferencing(context.sourceCode, mut_previous, init)) context.report({
1230
+ node: statement,
1231
+ messageId: "noRedundantVar",
1232
+ fix: isRedundantVariableFixer(context.sourceCode, mut_previous, id, init, statement)
1233
+ });
1234
+ }
1263
1235
  return;
1264
1236
  }
1265
1237
  } })
@@ -1364,7 +1336,7 @@ const ruleNoUnneededArrayFlatMap = createRule({
1364
1336
  });
1365
1337
  //#endregion
1366
1338
  //#region src/rules/package.json
1367
- var version = "3.2.0";
1339
+ var version = "3.4.0";
1368
1340
  //#endregion
1369
1341
  //#region src/rules/prefer-early-return/prefer-early-return.ts
1370
1342
  const isTriggering = (node, maximumStatements) => {
@@ -1481,12 +1453,7 @@ const arrayHighOrderFunctions = /* @__PURE__ */ new Set([
1481
1453
  "reduce",
1482
1454
  "reduceRight"
1483
1455
  ]);
1484
- const isArrayHigherOrderFunction = (node) => {
1485
- if (node?.type !== AST_NODE_TYPES.MemberExpression) return false;
1486
- if (node.computed) return false;
1487
- if (node.property.type !== AST_NODE_TYPES.Identifier) return false;
1488
- return arrayHighOrderFunctions.has(node.property.name) && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
1489
- };
1456
+ 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;
1490
1457
  const rulePreferReduceOverChaining = createRule({
1491
1458
  name: "prefer-reduce-over-chaining",
1492
1459
  meta: {
@@ -1542,20 +1509,17 @@ const parseFunctions = [
1542
1509
  const indexNamePattern = /^(?:[ijk]|idx|index)$/iu;
1543
1510
  const indexSuffixPattern = /(?:Idx|Index)$/u;
1544
1511
  const isConsoleAssert = (statement) => {
1545
- if (statement.type !== AST_NODE_TYPES.ExpressionStatement) return false;
1546
- if (statement.expression.type !== AST_NODE_TYPES.CallExpression) return false;
1512
+ if (statement.type !== AST_NODE_TYPES.ExpressionStatement || statement.expression.type !== AST_NODE_TYPES.CallExpression) return false;
1547
1513
  const { callee } = statement.expression;
1548
1514
  return callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && isIdentifierName(callee.object, "console") && isIdentifierName(callee.property, "assert");
1549
1515
  };
1550
1516
  const isConsumedDirectly = (node) => {
1551
1517
  const { parent } = node;
1552
- if (parent.type === AST_NODE_TYPES.BinaryExpression) return arithmeticOperators.has(parent.operator);
1553
- return parent.type === AST_NODE_TYPES.MemberExpression && parent.computed && parent.property === node;
1518
+ return parent.type === AST_NODE_TYPES.BinaryExpression ? arithmeticOperators.has(parent.operator) : parent.type === AST_NODE_TYPES.MemberExpression && parent.computed && parent.property === node;
1554
1519
  };
1555
1520
  const isGuardedIndex = (node) => {
1556
1521
  const { parent } = node;
1557
- if (parent.type === AST_NODE_TYPES.TSNonNullExpression) return true;
1558
- return parent.type === AST_NODE_TYPES.LogicalExpression && parent.operator === "??" && parent.left === node;
1522
+ return parent.type === AST_NODE_TYPES.TSNonNullExpression || parent.type === AST_NODE_TYPES.LogicalExpression && parent.operator === "??" && parent.left === node;
1559
1523
  };
1560
1524
  const isMathCall = (node, methods) => {
1561
1525
  const { callee } = node;
@@ -1563,9 +1527,7 @@ const isMathCall = (node, methods) => {
1563
1527
  };
1564
1528
  const isWriteTarget = (node) => {
1565
1529
  const { parent } = node;
1566
- if (parent.type === AST_NODE_TYPES.AssignmentExpression) return parent.left === node;
1567
- if (parent.type === AST_NODE_TYPES.UpdateExpression) return true;
1568
- return parent.type === AST_NODE_TYPES.UnaryExpression && parent.operator === "delete";
1530
+ 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";
1569
1531
  };
1570
1532
  const assertedNames = (node, sourceCode) => {
1571
1533
  if (node.body.type !== AST_NODE_TYPES.BlockStatement) return /* @__PURE__ */ new Set();
@@ -1578,14 +1540,12 @@ const assertedNames = (node, sourceCode) => {
1578
1540
  };
1579
1541
  const looksLikeIndex = (node) => {
1580
1542
  if (node.type === AST_NODE_TYPES.BinaryExpression) return arithmeticOperators.has(node.operator);
1581
- if (node.type === AST_NODE_TYPES.CallExpression) return isMathCall(node);
1582
- return isIdentifierName(node, (name) => indexNamePattern.test(name) || indexSuffixPattern.test(name));
1543
+ return node.type === AST_NODE_TYPES.CallExpression ? isMathCall(node) : isIdentifierName(node, (name) => indexNamePattern.test(name) || indexSuffixPattern.test(name));
1583
1544
  };
1584
1545
  const numberParameterNames = (node) => {
1585
1546
  const mut_names = /* @__PURE__ */ new Set();
1586
1547
  for (const parameter of node.params) {
1587
- if (parameter.type !== AST_NODE_TYPES.Identifier) continue;
1588
- if (parameter.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES.TSNumberKeyword) continue;
1548
+ if (parameter.type !== AST_NODE_TYPES.Identifier || parameter.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES.TSNumberKeyword) continue;
1589
1549
  mut_names.add(parameter.name);
1590
1550
  }
1591
1551
  return mut_names;
@@ -1635,12 +1595,9 @@ const rulePreferStrictNumberGuards = createRule({
1635
1595
  };
1636
1596
  const exitFunction = () => mut_scopes.pop();
1637
1597
  const reportUnencodedInput = (node) => {
1638
- if (!enabled.has("encode-input-rule")) return;
1639
- if (node.type !== AST_NODE_TYPES.Identifier) return;
1598
+ if (!enabled.has("encode-input-rule") || node.type !== AST_NODE_TYPES.Identifier) return;
1640
1599
  const scope = mut_scopes.at(-1);
1641
- if (!scope) return;
1642
- if (!scope.numberParams.has(node.name)) return;
1643
- if (scope.asserted.has(node.name)) return;
1600
+ if (!scope || !scope.numberParams.has(node.name) || scope.asserted.has(node.name)) return;
1644
1601
  context.report({
1645
1602
  node,
1646
1603
  messageId: "encodeInputRule",
@@ -1686,22 +1643,16 @@ const rulePreferStrictNumberGuards = createRule({
1686
1643
  "FunctionExpression": enterFunction,
1687
1644
  "FunctionExpression:exit": exitFunction,
1688
1645
  "LogicalExpression": (node) => {
1689
- if (!enabled.has("write-explicit-condition")) return;
1690
- if (node.operator !== "||") return;
1691
- if (node.right.type !== AST_NODE_TYPES.Literal) return;
1692
- if (typeof node.right.value !== "number") return;
1646
+ if (!enabled.has("write-explicit-condition") || node.operator !== "||" || node.right.type !== AST_NODE_TYPES.Literal || typeof node.right.value !== "number") return;
1693
1647
  context.report({
1694
1648
  node,
1695
1649
  messageId: "writeExplicitCondition"
1696
1650
  });
1697
1651
  },
1698
1652
  "MemberExpression": (node) => {
1699
- if (!node.computed) return;
1700
- if (node.property.type === AST_NODE_TYPES.Literal) return;
1653
+ if (!node.computed || node.property.type === AST_NODE_TYPES.Literal) return;
1701
1654
  reportUnencodedInput(node.property);
1702
- if (!enabled.has("guard-array-index")) return;
1703
- if (!looksLikeIndex(node.property)) return;
1704
- if (isGuardedIndex(node) || isWriteTarget(node)) return;
1655
+ if (!enabled.has("guard-array-index") || !looksLikeIndex(node.property) || isGuardedIndex(node) || isWriteTarget(node)) return;
1705
1656
  context.report({
1706
1657
  node,
1707
1658
  messageId: "guardArrayIndex"
@@ -2132,7 +2083,6 @@ const jsdoc = async (options) => {
2132
2083
  "jsdoc/multiline-blocks": stylisticEnabled,
2133
2084
  "jsdoc/no-defaults": "warn",
2134
2085
  "jsdoc/no-multi-asterisks": "error",
2135
- "jsdoc/no-undefined-types": ["error", { disableReporting: true }],
2136
2086
  "jsdoc/reject-any-type": "error",
2137
2087
  "jsdoc/reject-function-type": "error",
2138
2088
  "jsdoc/require-jsdoc": ["warn", {
@@ -2160,7 +2110,7 @@ const jsdoc = async (options) => {
2160
2110
  "jsdoc/require-yields-check": "error",
2161
2111
  "jsdoc/require-yields-type": "error",
2162
2112
  "jsdoc/tag-lines": [
2163
- "warn",
2113
+ stylisticEnabled,
2164
2114
  "never",
2165
2115
  {
2166
2116
  applyToEndTag: false,
@@ -2171,7 +2121,6 @@ const jsdoc = async (options) => {
2171
2121
  "jsdoc/valid-types": "error",
2172
2122
  ...!lessOpinionated && {
2173
2123
  "jsdoc/check-indentation": "warn",
2174
- "jsdoc/check-line-alignment": "error",
2175
2124
  "jsdoc/no-bad-blocks": ["warn", { ignore: [
2176
2125
  "ts-check",
2177
2126
  "ts-expect-error",
@@ -4163,8 +4112,34 @@ const typescript = async (options) => {
4163
4112
  };
4164
4113
  //#endregion
4165
4114
  //#region src/configs/unicorn.ts
4115
+ const DOMRules = [
4116
+ "unicorn/better-dom-traversing",
4117
+ "unicorn/dom-node-dataset",
4118
+ "unicorn/no-blob-to-file",
4119
+ "unicorn/no-canvas-to-image",
4120
+ "unicorn/no-document-cookie",
4121
+ "unicorn/no-incorrect-query-selector",
4122
+ "unicorn/no-invalid-remove-event-listener",
4123
+ "unicorn/no-selector-as-dom-name",
4124
+ "unicorn/no-transition-all",
4125
+ "unicorn/no-unsafe-dom-html",
4126
+ "unicorn/prefer-add-event-listener",
4127
+ "unicorn/prefer-add-event-listener-options",
4128
+ "unicorn/prefer-classlist-toggle",
4129
+ "unicorn/prefer-dom-node-append",
4130
+ "unicorn/prefer-dom-node-html-methods",
4131
+ "unicorn/prefer-dom-node-replace-children",
4132
+ "unicorn/prefer-dom-node-text-content",
4133
+ "unicorn/prefer-keyboard-event-key",
4134
+ "unicorn/prefer-modern-dom-apis",
4135
+ "unicorn/prefer-observer-apis",
4136
+ "unicorn/prefer-path2d",
4137
+ "unicorn/prefer-query-selector",
4138
+ "unicorn/prefer-scoped-selector",
4139
+ "unicorn/require-passive-events"
4140
+ ];
4166
4141
  const unicorn = async (options) => {
4167
- const { files, lessOpinionated, overrides } = options;
4142
+ const { files, hasDOM, lessOpinionated, overrides } = options;
4168
4143
  const [unicornPlugin] = await loadPackages(["eslint-plugin-unicorn"]);
4169
4144
  return [{
4170
4145
  name: "moso/unicorn/setup",
@@ -4265,6 +4240,7 @@ const unicorn = async (options) => {
4265
4240
  "unicorn/require-module-specifiers": "off",
4266
4241
  "unicorn/single-line-block-comment-style": "off"
4267
4242
  },
4243
+ ...hasDOM === false && { ...Object.fromEntries(DOMRules.map((rule) => [rule, "off"])) },
4268
4244
  ...overrides
4269
4245
  }
4270
4246
  }];
@@ -4594,23 +4570,24 @@ async function moso(options = {}, ...userConfigs) {
4594
4570
  if (options.typescript !== void 0) throw new Error(message);
4595
4571
  console.warn(message);
4596
4572
  }
4597
- const typescriptOptions = typescriptUnsupported ? false : typescriptRequested;
4573
+ const typescriptOptions = !typescriptUnsupported && typescriptRequested;
4598
4574
  const astroOptions = options.astro ?? anyPackageExists(AstroPackages);
4599
4575
  const nextjsOptions = options.nextjs ?? anyPackageExists(NextJSPackages);
4600
4576
  const reactOptions = options.react ?? anyPackageExists(ReactPackages);
4601
4577
  const tailwindOptions = options.tailwind ?? packageExists("tailwindcss");
4602
4578
  const vueOptions = options.vue ?? anyPackageExists(VuePackages);
4603
4579
  const componentExts = vueOptions === false ? [...componentExtsOption] : [.../* @__PURE__ */ new Set([...componentExtsOption, "vue"])];
4604
- const baselineOptions = options.baseline === false ? false : typeof options.baseline === "object" ? options.baseline : typeof options.baseline === "string" || typeof options.baseline === "number" ? { baseline: options.baseline } : {};
4605
- const e18eOptions = options.e18e === false ? false : typeof options.e18e === "object" ? options.e18e : options.e18e === true ? {} : options.lessOpinionated === true ? false : {};
4580
+ const baselineOptions = options.baseline !== false && (typeof options.baseline === "object" ? options.baseline : typeof options.baseline === "string" || typeof options.baseline === "number" ? { baseline: options.baseline } : {});
4581
+ const e18eOptions = options.e18e !== false && (typeof options.e18e === "object" ? options.e18e : (options.e18e === true || options.lessOpinionated !== true) && {});
4606
4582
  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";
4607
4583
  const hasTypeScript = Boolean(typescriptOptions);
4584
+ const hasDOM = options.mode !== "library" || Boolean(astroOptions) || Boolean(nextjsOptions) || Boolean(reactOptions) || Boolean(vueOptions);
4608
4585
  const ignoreOptions = typeof options.ignores === "object" ? options.ignores : {};
4609
4586
  const modeOptions = typeof options.mode === "string" ? options.mode : "none";
4610
4587
  const perfectionistOptions = typeof options.perfectionist === "boolean" ? options.perfectionist : options.lessOpinionated !== true;
4611
- const stylisticOptions = options.stylistic === false ? false : {
4588
+ const stylisticOptions = options.stylistic !== false && {
4612
4589
  ...StylisticConfigDefaults,
4613
- jsx: typeof jsxOptions === "boolean" ? jsxOptions : true,
4590
+ jsx: jsxOptions !== false,
4614
4591
  ...typeof options.stylistic === "object" && options.stylistic
4615
4592
  };
4616
4593
  const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, unsafe: typescriptUnsafe, useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
@@ -4634,10 +4611,10 @@ async function moso(options = {}, ...userConfigs) {
4634
4611
  parserOptions: {
4635
4612
  tsconfigRootDir: projectRootOptions,
4636
4613
  ...parserOptions,
4637
- projectService: projectRootOptions === void 0 || parserOptions?.projectService === false ? false : useDefaultDefaultProject === false ? projectServiceUserConfig : {
4638
- allowDefaultProject: [GLOB_ROOT_JS, GLOB_ROOT_JSX],
4614
+ projectService: projectRootOptions !== void 0 && parserOptions?.projectService !== false && (useDefaultDefaultProject === false ? projectServiceUserConfig : {
4615
+ allowDefaultProject: ["?(.)*.?([cm])js", "?(.)*.?([cm])jsx"],
4639
4616
  ...projectServiceUserConfig
4640
- }
4617
+ })
4641
4618
  }
4642
4619
  };
4643
4620
  const functionalConfigOptions = {
@@ -4685,6 +4662,7 @@ async function moso(options = {}, ...userConfigs) {
4685
4662
  if (options.regexp !== false) mut_configs.push(regexp({ overrides: getOverrides(options, "regexp") }));
4686
4663
  if (options.unicorn !== false) mut_configs.push(unicorn({
4687
4664
  files: [GLOB_SRC],
4665
+ hasDOM,
4688
4666
  lessOpinionated: options.lessOpinionated,
4689
4667
  overrides: getOverrides(options, "unicorn")
4690
4668
  }));
@@ -4703,6 +4681,7 @@ async function moso(options = {}, ...userConfigs) {
4703
4681
  ...astroOptions === false ? [] : [GLOB_ASTRO]
4704
4682
  ],
4705
4683
  filesTypeAware: [GLOB_TS, GLOB_TSX],
4684
+ hasDOM,
4706
4685
  overrides: getOverrides(options, "baseline"),
4707
4686
  projectRoot: projectRootOptions,
4708
4687
  typescript: hasTypeScript
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moso/eslint-config",
3
3
  "type": "module",
4
- "version": "3.2.0",
4
+ "version": "3.4.0",
5
5
  "description": "@moso's sharable ESLint config",
6
6
  "author": {
7
7
  "name": "Morten Sørensen",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "scripts": {
48
48
  "build": "bun run typegen && tsdown --clean --dts",
49
- "build:inspector": "bun run build && bunx @eslint/config-inspector build --config eslint-inspector.config.ts --out-dir ./.eslint-config-inspector",
49
+ "build:inspector": "bun run build && bunx @eslint/config-inspector build --stats --config eslint-inspector.config.ts --out-dir ./.eslint-config-inspector",
50
50
  "dev": "bunx @eslint/config-inspector --config eslint-inspector.config.ts",
51
51
  "lint": "eslint",
52
52
  "prepack": "bun run build",
@@ -62,16 +62,16 @@
62
62
  "src/rules"
63
63
  ],
64
64
  "peerDependencies": {
65
- "@eslint-react/eslint-plugin": "^5.19.0",
66
- "@next/eslint-plugin-next": "^16.3.4",
67
- "astro-eslint-parser": "^3.1.0",
65
+ "@eslint-react/eslint-plugin": "^5.20.8",
66
+ "@next/eslint-plugin-next": "^16.3.6",
67
+ "astro-eslint-parser": "^3.2.0",
68
68
  "eslint": "^10.0.0",
69
- "eslint-plugin-astro": "^3.1.0",
69
+ "eslint-plugin-astro": "^3.2.1",
70
70
  "eslint-plugin-better-tailwindcss": "^4.7.0",
71
- "eslint-plugin-erasable-syntax-only": "^0.7.1",
71
+ "eslint-plugin-erasable-syntax-only": "^0.7.2",
72
72
  "eslint-plugin-jsx-a11y": "^6.10.2",
73
73
  "eslint-plugin-react-hooks": "^7.1.1",
74
- "eslint-plugin-react-refresh": "^0.5.6",
74
+ "eslint-plugin-react-refresh": "^0.5.7",
75
75
  "eslint-plugin-react-you-might-not-need-an-effect": "^1.0.2",
76
76
  "eslint-plugin-vue": "^10.11.0",
77
77
  "eslint-plugin-vuejs-accessibility": "^2.6.0",
@@ -119,32 +119,32 @@
119
119
  }
120
120
  },
121
121
  "dependencies": {
122
- "@antfu/install-pkg": "^2.0.1",
123
- "@clack/prompts": "^1.7.0",
124
- "@e18e/eslint-plugin": "^0.8.0",
125
- "@eslint-community/eslint-plugin-eslint-comments": "^4.7.2",
122
+ "@antfu/install-pkg": "^2.1.0",
123
+ "@clack/prompts": "^1.8.1",
124
+ "@e18e/eslint-plugin": "^0.8.1",
125
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
126
126
  "@eslint/js": "^10.0.1",
127
127
  "@stylistic/eslint-plugin": "^5.10.0",
128
- "@typescript-eslint/eslint-plugin": "^8.69.0",
129
- "@typescript-eslint/parser": "^8.69.0",
130
- "@typescript-eslint/utils": "^8.69.0",
128
+ "@typescript-eslint/eslint-plugin": "^8.70.1",
129
+ "@typescript-eslint/parser": "^8.70.1",
130
+ "@typescript-eslint/utils": "^8.70.1",
131
131
  "@vitest/eslint-plugin": "^1.6.27",
132
132
  "eslint-config-flat-gitignore": "^2.4.0",
133
133
  "eslint-flat-config-utils": "^3.2.0",
134
134
  "eslint-merge-processors": "^2.0.0",
135
- "eslint-plugin-baseline-js": "^0.7.1",
136
- "eslint-plugin-de-morgan": "^2.1.3",
137
- "eslint-plugin-functional": "^10.0.0",
135
+ "eslint-plugin-baseline-js": "^0.7.2",
136
+ "eslint-plugin-de-morgan": "^2.2.0",
137
+ "eslint-plugin-functional": "^10.0.1",
138
138
  "eslint-plugin-import-lite": "^0.6.0",
139
- "eslint-plugin-jsdoc": "^64.3.6",
139
+ "eslint-plugin-jsdoc": "^64.5.4",
140
140
  "eslint-plugin-jsonc": "^3.4.2",
141
141
  "eslint-plugin-n": "^18.3.0",
142
142
  "eslint-plugin-no-only-tests": "^3.4.0",
143
- "eslint-plugin-perfectionist": "^5.11.0",
143
+ "eslint-plugin-perfectionist": "^5.12.1",
144
144
  "eslint-plugin-promise": "^7.3.0",
145
- "eslint-plugin-regexp": "^3.3.0",
145
+ "eslint-plugin-regexp": "^3.3.1",
146
146
  "eslint-plugin-toml": "^1.5.0",
147
- "eslint-plugin-unicorn": "^74.0.0",
147
+ "eslint-plugin-unicorn": "^76.0.0",
148
148
  "eslint-plugin-unused-imports": "^4.4.1",
149
149
  "eslint-plugin-yml": "^3.8.1",
150
150
  "eslint-processor-vue-blocks": "^2.0.0",
@@ -156,27 +156,27 @@
156
156
  "yaml-eslint-parser": "^2.1.0"
157
157
  },
158
158
  "devDependencies": {
159
- "@eslint-react/eslint-plugin": "^5.19.0",
159
+ "@eslint-react/eslint-plugin": "^5.20.8",
160
160
  "@eslint/compat": "^2.1.1",
161
- "@eslint/config-inspector": "^3.4.0",
162
- "@moso/eslint-plugin": "3.1.0",
163
- "@next/eslint-plugin-next": "^16.3.4",
164
- "@socketsecurity/bun-security-scanner": "^1.1.2",
161
+ "@eslint/config-inspector": "^3.5.0",
162
+ "@moso/eslint-plugin": "3.3.0",
163
+ "@next/eslint-plugin-next": "^16.3.6",
164
+ "@socketsecurity/bun-security-scanner": "^1.1.3",
165
165
  "@types/eslint-plugin-jsx-a11y": "^6.10.1",
166
- "@types/node": "^26.4.1",
167
- "@typescript-eslint/rule-tester": "^8.69.0",
168
- "@vitest/coverage-v8": "^5.0.0",
169
- "astro-eslint-parser": "^3.1.0",
166
+ "@types/node": "^26.6.3",
167
+ "@typescript-eslint/rule-tester": "^8.70.1",
168
+ "@vitest/coverage-v8": "^5.0.2",
169
+ "astro-eslint-parser": "^3.2.0",
170
170
  "bumpp": "^12.3.0",
171
- "eslint": "^10.10.0",
172
- "eslint-plugin-astro": "^3.1.0",
171
+ "eslint": "^10.11.0",
172
+ "eslint-plugin-astro": "^3.2.1",
173
173
  "eslint-plugin-better-tailwindcss": "^4.7.0",
174
- "eslint-plugin-erasable-syntax-only": "^0.7.1",
174
+ "eslint-plugin-erasable-syntax-only": "^0.7.2",
175
175
  "eslint-plugin-jsx-a11y": "^6.10.2",
176
176
  "eslint-plugin-react-hooks": "^7.1.1",
177
- "eslint-plugin-react-refresh": "^0.5.6",
177
+ "eslint-plugin-react-refresh": "^0.5.7",
178
178
  "eslint-plugin-react-you-might-not-need-an-effect": "^1.0.2",
179
- "eslint-plugin-vue": "^10.10.0",
179
+ "eslint-plugin-vue": "^10.11.1",
180
180
  "eslint-plugin-vuejs-accessibility": "^2.6.0",
181
181
  "eslint-typegen": "^2.3.1",
182
182
  "jiti": "^2.7.0",
@@ -184,9 +184,9 @@
184
184
  "simple-git-hooks": "^2.14.0",
185
185
  "ts-dedent": "^2.3.0",
186
186
  "tsdown": "^0.23.0",
187
- "tsx": "^4.23.13",
187
+ "tsx": "^4.23.15",
188
188
  "typescript": "^6.0.3",
189
- "vitest": "^5.0.0"
189
+ "vitest": "^5.0.2"
190
190
  },
191
191
  "simple-git-hooks": {
192
192
  "pre-commit": "bunx nano-staged"