@moso/eslint-config 3.2.0 → 3.3.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.d.mts CHANGED
@@ -1671,6 +1671,11 @@ interface RuleOptions {
1671
1671
  * @see https://typescript-eslint.io/rules/no-for-in-array
1672
1672
  */
1673
1673
  '@typescript-eslint/no-for-in-array'?: Linter.RuleEntry<[]>;
1674
+ /**
1675
+ * Disallow type operations that resolve to the "empty object" type
1676
+ * @see https://typescript-eslint.io/rules/no-generated-empty-object-type
1677
+ */
1678
+ '@typescript-eslint/no-generated-empty-object-type'?: Linter.RuleEntry<[]>;
1674
1679
  /**
1675
1680
  * Disallow the use of `eval()`-like functions
1676
1681
  * @see https://typescript-eslint.io/rules/no-implied-eval
@@ -8458,10 +8463,12 @@ type EslintCommunityEslintCommentsDisableEnablePair = [] | [{
8458
8463
  type EslintCommunityEslintCommentsNoRestrictedDisable = string[];
8459
8464
  // ----- @eslint-community/eslint-comments/no-use -----
8460
8465
  type EslintCommunityEslintCommentsNoUse = [] | [{
8461
- allow?: ("eslint" | "eslint-disable" | "eslint-disable-line" | "eslint-disable-next-line" | "eslint-enable" | "eslint-env" | "exported" | "global" | "globals")[];
8466
+ additionalDirectives?: string[];
8467
+ allow?: string[];
8462
8468
  }];
8463
8469
  // ----- @eslint-community/eslint-comments/require-description -----
8464
8470
  type EslintCommunityEslintCommentsRequireDescription = [] | [{
8471
+ additionalDirectives?: string[];
8465
8472
  ignore?: ("eslint" | "eslint-disable" | "eslint-disable-line" | "eslint-disable-next-line" | "eslint-enable" | "eslint-env" | "exported" | "global" | "globals")[];
8466
8473
  }];
8467
8474
  // ----- @eslint-react/dom-no-unknown-property -----
@@ -21344,6 +21351,20 @@ type OptionsFunctional = {
21344
21351
  */
21345
21352
  ignoreNamePattern?: string[];
21346
21353
  };
21354
+ type OptionsHasDOM = {
21355
+ /**
21356
+ * Whether the linted code can reach the DOM and Web APIs.
21357
+ * Resolved by the factory.
21358
+ *
21359
+ * `false` when `mode` is `'library'` and no framework is auto-detected.
21360
+ *
21361
+ * When `false`, `baseline()` skips its Web API checks
21362
+ * and the DOM-only `unicorn()` rules are disabled.
21363
+ *
21364
+ * @default true
21365
+ */
21366
+ hasDOM?: boolean;
21367
+ };
21347
21368
  type OptionsHasTypeScript = {
21348
21369
  typescript?: boolean;
21349
21370
  };
@@ -21690,7 +21711,7 @@ type TypedFlatConfigItem = Omit<(ConfigWithExtends | Linter.Config), "ignores" |
21690
21711
  export declare const astro: (options: Readonly<OptionsAstro & OptionsLessOpinionated & OptionsOverrides & OptionsTypeScriptParserOptions & Required<OptionsFiles & OptionsHasTypeScript & RequiredOptionsStylistic>>) => Promise<TypedFlatConfigItem[]>;
21691
21712
  //#endregion
21692
21713
  //#region src/configs/baseline.d.ts
21693
- export declare const baseline: (options: Readonly<OptionsBaseline & OptionsTypeScriptParserOptions & OptionsTypeScriptWithTypes & Required<OptionsFiles & OptionsHasTypeScript>>) => Promise<TypedFlatConfigItem[]>;
21714
+ export declare const baseline: (options: Readonly<OptionsBaseline & OptionsHasDOM & OptionsTypeScriptParserOptions & OptionsTypeScriptWithTypes & Required<OptionsFiles & OptionsHasTypeScript>>) => Promise<TypedFlatConfigItem[]>;
21694
21715
  //#endregion
21695
21716
  //#region src/configs/disables.d.ts
21696
21717
  export declare const disables: (functionalEnabled?: boolean) => Promise<TypedFlatConfigItem[]>;
@@ -21771,7 +21792,7 @@ export declare const toml: (options: Readonly<OptionsOverrides & Required<Option
21771
21792
  export declare const typescript: (options: Readonly<OptionsLessOpinionated & OptionsOverrides & OptionsStylistic & OptionsTypeScriptErasableOnly & OptionsTypeScriptWithTypes & Required<OptionsComponentExts & OptionsFiles & OptionsFunctional & OptionsMode & OptionsTypeScriptParserOptions>>) => Promise<TypedFlatConfigItem[]>;
21772
21793
  //#endregion
21773
21794
  //#region src/configs/unicorn.d.ts
21774
- export declare const unicorn: (options: Readonly<OptionsLessOpinionated & OptionsOverrides & Required<OptionsFiles>>) => Promise<TypedFlatConfigItem[]>;
21795
+ export declare const unicorn: (options: Readonly<OptionsHasDOM & OptionsLessOpinionated & OptionsOverrides & Required<OptionsFiles>>) => Promise<TypedFlatConfigItem[]>;
21775
21796
  //#endregion
21776
21797
  //#region src/configs/vue.d.ts
21777
21798
  export declare const vue: (options: Readonly<OptionsOverrides & OptionsTypeScriptWithTypes & OptionsVue & Required<OptionsFiles & OptionsHasTypeScript & OptionsTypeScriptParserOptions & RequiredOptionsStylistic>>) => Promise<TypedFlatConfigItem[]>;
@@ -21903,4 +21924,4 @@ export declare const memoize: <T extends ESLint.Plugin>(plugin: T, key: string)
21903
21924
  */
21904
21925
  export declare const vueInlineElements: ReadonlyArray<string>;
21905
21926
  //#endregion
21906
- export { type Awaitable, type ConfigNames, type ConfigOptions, type CoreOptions, type FrameworkOptions, type LanguageOptions, type OptionsAstro, type OptionsBaseline, type OptionsComponentExts, type OptionsConfig, type OptionsE18e, type OptionsFiles, type OptionsFunctional, type OptionsHasTypeScript, type OptionsIgnores, type OptionsIsInEditor, type OptionsJSDoc, type OptionsJSX, type OptionsLessOpinionated, type OptionsMode, type OptionsNextJS, type OptionsNode, type OptionsOverrides, type OptionsPerfectionist, type OptionsProjectRoot, type OptionsReact, type OptionsStylistic, type OptionsTailwind, type OptionsTypeScript, type OptionsTypeScriptErasableOnly, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsVue, type ProjectMode, type RequiredOptionsStylistic, type RequiredOptionsTailwind, type ResolvedOptions, type RuleOptions as Rules, type StyleOptions, type StylisticConfig, type TypedFlatConfigItem, moso as default };
21927
+ export { type Awaitable, type ConfigNames, type ConfigOptions, type CoreOptions, type FrameworkOptions, type LanguageOptions, type OptionsAstro, type OptionsBaseline, type OptionsComponentExts, type OptionsConfig, type OptionsE18e, type OptionsFiles, type OptionsFunctional, type OptionsHasDOM, type OptionsHasTypeScript, type OptionsIgnores, type OptionsIsInEditor, type OptionsJSDoc, type OptionsJSX, type OptionsLessOpinionated, type OptionsMode, type OptionsNextJS, type OptionsNode, type OptionsOverrides, type OptionsPerfectionist, type OptionsProjectRoot, type OptionsReact, type OptionsStylistic, type OptionsTailwind, type OptionsTypeScript, type OptionsTypeScriptErasableOnly, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsVue, type ProjectMode, type RequiredOptionsStylistic, type RequiredOptionsTailwind, type ResolvedOptions, type RuleOptions as Rules, type StyleOptions, type StylisticConfig, type TypedFlatConfigItem, moso as default };
package/dist/index.mjs CHANGED
@@ -322,7 +322,7 @@ const astro = async (options) => {
322
322
  //#region src/configs/baseline.ts
323
323
  const defaultIgnoreFeatures = ["functions-caller-arguments"];
324
324
  const baseline = async (options) => {
325
- const { baseline, files, filesTypeAware, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
325
+ const { baseline, files, filesTypeAware, hasDOM, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
326
326
  const isTypeAware = typescript && typeof projectRoot === "string" && parserOptions?.projectService !== false;
327
327
  const [baselinePlugin] = await loadPackages(["eslint-plugin-baseline-js"]);
328
328
  const baselineRule = (typeAware) => ({ "baseline-js/use-baseline": ["warn", {
@@ -330,7 +330,7 @@ const baseline = async (options) => {
330
330
  ignoreFeatures: [...defaultIgnoreFeatures, ...ignoreFeatures ?? []],
331
331
  ignoreNodeTypes,
332
332
  includeJsBuiltins: { preset: typeAware ? "type-aware" : "auto" },
333
- includeWebApis: { preset: typeAware ? "type-aware" : "auto" }
333
+ includeWebApis: hasDOM === false ? false : { preset: typeAware ? "type-aware" : "auto" }
334
334
  }] });
335
335
  return [
336
336
  {
@@ -1220,12 +1220,7 @@ const isRedundantVariable = (node, exit) => {
1220
1220
  if (!node) return false;
1221
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
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];
1223
+ const isRedundantVariableFixer = (source, variable, id, init, exit) => (fixer) => {
1229
1224
  const replaced = getReturnExpression(init);
1230
1225
  const modified = wrap(source.getText(replaced), (input) => {
1231
1226
  if (!id.typeAnnotation) return input;
@@ -1235,6 +1230,7 @@ const isRedundantVariableFixer = (source, variable, exit) => (fixer) => {
1235
1230
  return [fixer.remove(variable), fixer.replaceText(exit.argument, modified)];
1236
1231
  };
1237
1232
  const isReturnStatement = (node) => node.type === AST_NODE_TYPES.ReturnStatement && isIdentifier(node.argument);
1233
+ 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
1234
  const ruleNoRedundantVariables = createRule({
1239
1235
  name: "no-redundant-variable",
1240
1236
  meta: {
@@ -1255,11 +1251,14 @@ const ruleNoRedundantVariables = createRule({
1255
1251
  mut_previous = statement;
1256
1252
  continue;
1257
1253
  }
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
- });
1254
+ if (isRedundantVariable(mut_previous, statement)) {
1255
+ const { id, init } = mut_previous.declarations[0];
1256
+ if (init && !isSelfReferencing(context.sourceCode, mut_previous, init)) context.report({
1257
+ node: statement,
1258
+ messageId: "noRedundantVar",
1259
+ fix: isRedundantVariableFixer(context.sourceCode, mut_previous, id, init, statement)
1260
+ });
1261
+ }
1263
1262
  return;
1264
1263
  }
1265
1264
  } })
@@ -1364,7 +1363,7 @@ const ruleNoUnneededArrayFlatMap = createRule({
1364
1363
  });
1365
1364
  //#endregion
1366
1365
  //#region src/rules/package.json
1367
- var version = "3.2.0";
1366
+ var version = "3.3.0";
1368
1367
  //#endregion
1369
1368
  //#region src/rules/prefer-early-return/prefer-early-return.ts
1370
1369
  const isTriggering = (node, maximumStatements) => {
@@ -2132,7 +2131,6 @@ const jsdoc = async (options) => {
2132
2131
  "jsdoc/multiline-blocks": stylisticEnabled,
2133
2132
  "jsdoc/no-defaults": "warn",
2134
2133
  "jsdoc/no-multi-asterisks": "error",
2135
- "jsdoc/no-undefined-types": ["error", { disableReporting: true }],
2136
2134
  "jsdoc/reject-any-type": "error",
2137
2135
  "jsdoc/reject-function-type": "error",
2138
2136
  "jsdoc/require-jsdoc": ["warn", {
@@ -2160,7 +2158,7 @@ const jsdoc = async (options) => {
2160
2158
  "jsdoc/require-yields-check": "error",
2161
2159
  "jsdoc/require-yields-type": "error",
2162
2160
  "jsdoc/tag-lines": [
2163
- "warn",
2161
+ stylisticEnabled,
2164
2162
  "never",
2165
2163
  {
2166
2164
  applyToEndTag: false,
@@ -2171,7 +2169,6 @@ const jsdoc = async (options) => {
2171
2169
  "jsdoc/valid-types": "error",
2172
2170
  ...!lessOpinionated && {
2173
2171
  "jsdoc/check-indentation": "warn",
2174
- "jsdoc/check-line-alignment": "error",
2175
2172
  "jsdoc/no-bad-blocks": ["warn", { ignore: [
2176
2173
  "ts-check",
2177
2174
  "ts-expect-error",
@@ -4163,8 +4160,34 @@ const typescript = async (options) => {
4163
4160
  };
4164
4161
  //#endregion
4165
4162
  //#region src/configs/unicorn.ts
4163
+ const DOMRules = [
4164
+ "unicorn/better-dom-traversing",
4165
+ "unicorn/dom-node-dataset",
4166
+ "unicorn/no-blob-to-file",
4167
+ "unicorn/no-canvas-to-image",
4168
+ "unicorn/no-document-cookie",
4169
+ "unicorn/no-incorrect-query-selector",
4170
+ "unicorn/no-invalid-remove-event-listener",
4171
+ "unicorn/no-selector-as-dom-name",
4172
+ "unicorn/no-transition-all",
4173
+ "unicorn/no-unsafe-dom-html",
4174
+ "unicorn/prefer-add-event-listener",
4175
+ "unicorn/prefer-add-event-listener-options",
4176
+ "unicorn/prefer-classlist-toggle",
4177
+ "unicorn/prefer-dom-node-append",
4178
+ "unicorn/prefer-dom-node-html-methods",
4179
+ "unicorn/prefer-dom-node-replace-children",
4180
+ "unicorn/prefer-dom-node-text-content",
4181
+ "unicorn/prefer-keyboard-event-key",
4182
+ "unicorn/prefer-modern-dom-apis",
4183
+ "unicorn/prefer-observer-apis",
4184
+ "unicorn/prefer-path2d",
4185
+ "unicorn/prefer-query-selector",
4186
+ "unicorn/prefer-scoped-selector",
4187
+ "unicorn/require-passive-events"
4188
+ ];
4166
4189
  const unicorn = async (options) => {
4167
- const { files, lessOpinionated, overrides } = options;
4190
+ const { files, hasDOM, lessOpinionated, overrides } = options;
4168
4191
  const [unicornPlugin] = await loadPackages(["eslint-plugin-unicorn"]);
4169
4192
  return [{
4170
4193
  name: "moso/unicorn/setup",
@@ -4265,6 +4288,7 @@ const unicorn = async (options) => {
4265
4288
  "unicorn/require-module-specifiers": "off",
4266
4289
  "unicorn/single-line-block-comment-style": "off"
4267
4290
  },
4291
+ ...hasDOM === false && { ...Object.fromEntries(DOMRules.map((rule) => [rule, "off"])) },
4268
4292
  ...overrides
4269
4293
  }
4270
4294
  }];
@@ -4605,6 +4629,7 @@ async function moso(options = {}, ...userConfigs) {
4605
4629
  const e18eOptions = options.e18e === false ? false : typeof options.e18e === "object" ? options.e18e : options.e18e === true ? {} : options.lessOpinionated === true ? false : {};
4606
4630
  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
4631
  const hasTypeScript = Boolean(typescriptOptions);
4632
+ const hasDOM = options.mode !== "library" || Boolean(astroOptions) || Boolean(nextjsOptions) || Boolean(reactOptions) || Boolean(vueOptions);
4608
4633
  const ignoreOptions = typeof options.ignores === "object" ? options.ignores : {};
4609
4634
  const modeOptions = typeof options.mode === "string" ? options.mode : "none";
4610
4635
  const perfectionistOptions = typeof options.perfectionist === "boolean" ? options.perfectionist : options.lessOpinionated !== true;
@@ -4685,6 +4710,7 @@ async function moso(options = {}, ...userConfigs) {
4685
4710
  if (options.regexp !== false) mut_configs.push(regexp({ overrides: getOverrides(options, "regexp") }));
4686
4711
  if (options.unicorn !== false) mut_configs.push(unicorn({
4687
4712
  files: [GLOB_SRC],
4713
+ hasDOM,
4688
4714
  lessOpinionated: options.lessOpinionated,
4689
4715
  overrides: getOverrides(options, "unicorn")
4690
4716
  }));
@@ -4703,6 +4729,7 @@ async function moso(options = {}, ...userConfigs) {
4703
4729
  ...astroOptions === false ? [] : [GLOB_ASTRO]
4704
4730
  ],
4705
4731
  filesTypeAware: [GLOB_TS, GLOB_TSX],
4732
+ hasDOM,
4706
4733
  overrides: getOverrides(options, "baseline"),
4707
4734
  projectRoot: projectRootOptions,
4708
4735
  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.3.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",
@@ -63,7 +63,7 @@
63
63
  ],
64
64
  "peerDependencies": {
65
65
  "@eslint-react/eslint-plugin": "^5.19.0",
66
- "@next/eslint-plugin-next": "^16.3.4",
66
+ "@next/eslint-plugin-next": "^16.3.5",
67
67
  "astro-eslint-parser": "^3.1.0",
68
68
  "eslint": "^10.0.0",
69
69
  "eslint-plugin-astro": "^3.1.0",
@@ -120,14 +120,14 @@
120
120
  },
121
121
  "dependencies": {
122
122
  "@antfu/install-pkg": "^2.0.1",
123
- "@clack/prompts": "^1.7.0",
123
+ "@clack/prompts": "^1.8.0",
124
124
  "@e18e/eslint-plugin": "^0.8.0",
125
- "@eslint-community/eslint-plugin-eslint-comments": "^4.7.2",
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.0",
129
+ "@typescript-eslint/parser": "^8.70.0",
130
+ "@typescript-eslint/utils": "^8.70.0",
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",
@@ -136,7 +136,7 @@
136
136
  "eslint-plugin-de-morgan": "^2.1.3",
137
137
  "eslint-plugin-functional": "^10.0.0",
138
138
  "eslint-plugin-import-lite": "^0.6.0",
139
- "eslint-plugin-jsdoc": "^64.3.6",
139
+ "eslint-plugin-jsdoc": "^64.3.10",
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",
@@ -158,13 +158,13 @@
158
158
  "devDependencies": {
159
159
  "@eslint-react/eslint-plugin": "^5.19.0",
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",
161
+ "@eslint/config-inspector": "^3.4.1",
162
+ "@moso/eslint-plugin": "3.2.0",
163
+ "@next/eslint-plugin-next": "^16.3.5",
164
164
  "@socketsecurity/bun-security-scanner": "^1.1.2",
165
165
  "@types/eslint-plugin-jsx-a11y": "^6.10.1",
166
- "@types/node": "^26.4.1",
167
- "@typescript-eslint/rule-tester": "^8.69.0",
166
+ "@types/node": "^26.5.1",
167
+ "@typescript-eslint/rule-tester": "^8.70.0",
168
168
  "@vitest/coverage-v8": "^5.0.0",
169
169
  "astro-eslint-parser": "^3.1.0",
170
170
  "bumpp": "^12.3.0",
@@ -176,7 +176,7 @@
176
176
  "eslint-plugin-react-hooks": "^7.1.1",
177
177
  "eslint-plugin-react-refresh": "^0.5.6",
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.0",
180
180
  "eslint-plugin-vuejs-accessibility": "^2.6.0",
181
181
  "eslint-typegen": "^2.3.1",
182
182
  "jiti": "^2.7.0",