@jimmy.codes/eslint-config 6.24.1 → 6.26.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/README.md CHANGED
@@ -81,7 +81,7 @@ TypeScript also supports some configuration options. If options are provided the
81
81
 
82
82
  #### Configure Erasable Syntax Only
83
83
 
84
- Enable rules scoped to TypeScripts new erasable syntax only mode (TypeScript 5.8+):
84
+ Enable rules scoped to [TypeScript's new erasable syntax only mode (TypeScript 5.8+)](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-8.html#the---erasablesyntaxonly-option):
85
85
 
86
86
  ```ts
87
87
  import { defineConfig } from "@jimmy.codes/eslint-config";
@@ -131,6 +131,71 @@ export default defineConfig({
131
131
  });
132
132
  ```
133
133
 
134
+ ### Framework-Specific Rule Overrides
135
+
136
+ Many framework integrations support rule overrides, allowing you to fine-tune specific rules without affecting your entire config:
137
+
138
+ ```ts
139
+ import { defineConfig } from "@jimmy.codes/eslint-config";
140
+
141
+ export default defineConfig({
142
+ react: {
143
+ overrides: {
144
+ "react-x/no-array-index-key": "warn",
145
+ "jsx-a11y/anchor-is-valid": "off",
146
+ },
147
+ },
148
+ playwright: {
149
+ overrides: {
150
+ "playwright/no-focused-test": "error",
151
+ },
152
+ },
153
+ jest: {
154
+ overrides: {
155
+ "jest/expect-expect": "off",
156
+ },
157
+ },
158
+ testingLibrary: {
159
+ overrides: {
160
+ "testing-library/prefer-screen-queries": "warn",
161
+ },
162
+ },
163
+ nextjs: {
164
+ overrides: {
165
+ "@next/next/no-img-element": "off",
166
+ },
167
+ },
168
+ storybook: {
169
+ overrides: {
170
+ "storybook/no-uninstalled-addons": "warn",
171
+ },
172
+ },
173
+ tanstackQuery: {
174
+ overrides: {
175
+ "@tanstack/query/exhaustive-deps": "error",
176
+ },
177
+ },
178
+ astro: {
179
+ overrides: {
180
+ "astro/no-set-html-directive": "off",
181
+ },
182
+ },
183
+ vitest: {
184
+ overrides: {
185
+ "vitest/no-conditional-expect": "warn",
186
+ },
187
+ },
188
+ typescript: {
189
+ overrides: {
190
+ "@typescript-eslint/explicit-function-return-type": "error",
191
+ },
192
+ },
193
+ });
194
+ ```
195
+
196
+ > [!TIP]
197
+ > Framework-specific overrides are scoped to only rules with the appropriate plugin prefix (e.g., `vitest/*` for Vitest, `react-x/*` for React). For broader rule overrides across specific file patterns, use the `overrides` array.
198
+
134
199
  ### Override Specific Rules
135
200
 
136
201
  ```ts
@@ -1,9 +1,10 @@
1
1
  import { t as GLOB_ASTRO } from "./globs-uKx5b8lV.mjs";
2
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
2
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
3
3
  import globals from "globals";
4
4
 
5
5
  //#region src/configs/astro.ts
6
- async function astroConfig() {
6
+ async function astroConfig(options) {
7
+ const extractedOptions = extractOptions(options);
7
8
  const files = [GLOB_ASTRO];
8
9
  const [tsPlugin, astroPlugin, astroParser, jsxA11yPlugin] = await Promise.all([
9
10
  import("typescript-eslint"),
@@ -44,7 +45,8 @@ async function astroConfig() {
44
45
  "astro/no-exports-from-components": "off",
45
46
  "astro/no-unsafe-inline-scripts": "error",
46
47
  "astro/no-unused-define-vars-in-style": "error",
47
- "astro/valid-compile": "error"
48
+ "astro/valid-compile": "error",
49
+ ...extractedOptions?.overrides
48
50
  }
49
51
  },
50
52
  {
@@ -65,4 +67,19 @@ async function astroConfig() {
65
67
  }
66
68
 
67
69
  //#endregion
68
- export { astroConfig as default };
70
+ //#region src/utils/upwarn.ts
71
+ /**
72
+ * Converts all ESLint rules set to `"warn"` into `"error"`.
73
+ *
74
+ * @param rules - A partial set of ESLint rules.
75
+ *
76
+ * @returns A new rules object with all `"warn"` values changed to `"error"`.
77
+ */
78
+ const upwarn = (rules = {}) => {
79
+ return Object.fromEntries(Object.entries(rules).map(([rule, option]) => {
80
+ return [rule, option === "warn" ? "error" : option];
81
+ }));
82
+ };
83
+
84
+ //#endregion
85
+ export { astroConfig as default, upwarn as t };
package/dist/index.d.mts CHANGED
@@ -14370,6 +14370,7 @@ type ReactXNoUnstableDefaultProps = [] | [{
14370
14370
  }];
14371
14371
  // ----- react-x/no-useless-fragment -----
14372
14372
  type ReactXNoUselessFragment = [] | [{
14373
+ allowEmptyFragment?: boolean;
14373
14374
  allowExpressions?: boolean;
14374
14375
  }];
14375
14376
  // ----- regexp/hexadecimal-escape -----
@@ -15019,6 +15020,9 @@ type Base = Linter.Config<Linter.RulesRecord & Rules>;
15019
15020
  type MaybeReadonly<T> = Readonly<T> | T;
15020
15021
  type Override<T, R> = Omit<T, keyof R> & R;
15021
15022
  type Prettify<T> = { [K in keyof T]: T[K] } & {};
15023
+ type ExtractPrefix<T> = T extends `${infer Prefix}/${infer Rest}` ? Rest extends `${string}/${string}` ? `${Prefix}/${ExtractPrefix<Rest>}` : Prefix : never;
15024
+ type ValidPrefixes<T> = ExtractPrefix<keyof T>;
15025
+ type RulesWithPrefix<T, Prefix$1 extends ValidPrefixes<T>> = { [K in keyof T as K extends `${Prefix$1}${string}` ? K : never]: T[K] };
15022
15026
  interface LinterConfigOverrides {
15023
15027
  files?: MaybeReadonly<Base["files"]>;
15024
15028
  ignores?: MaybeReadonly<Base["ignores"]>;
@@ -15036,6 +15040,10 @@ interface VitestOptions {
15036
15040
  * @default 'either'
15037
15041
  */
15038
15042
  globals?: "either" | "explicit" | "implicit";
15043
+ /**
15044
+ * Additional rules to override Vitest defaults.
15045
+ */
15046
+ overrides?: RulesWithPrefix<RuleOptions, "vitest">;
15039
15047
  /**
15040
15048
  * Indicate whether [Vitest's type testing utilities](https://vitest.dev/guide/testing-types.html) are being used.
15041
15049
  *
@@ -15050,14 +15058,69 @@ interface TypeScriptOptions {
15050
15058
  * @default false
15051
15059
  */
15052
15060
  erasableSyntaxOnly?: boolean;
15061
+ /**
15062
+ * Additional rules to override TypeScript defaults.
15063
+ */
15064
+ overrides?: RulesWithPrefix<RuleOptions, "@typescript-eslint" | "erasable-syntax-only">;
15065
+ }
15066
+ interface AstroOptions {
15067
+ /**
15068
+ * Additional rules to override Astro defaults.
15069
+ */
15070
+ overrides?: RulesWithPrefix<RuleOptions, "astro" | "jsx-a11y">;
15071
+ }
15072
+ interface JestOptions {
15073
+ /**
15074
+ * Additional rules to override Jest defaults.
15075
+ */
15076
+ overrides?: RulesWithPrefix<RuleOptions, "jest">;
15077
+ }
15078
+ interface NextJSOptions {
15079
+ /**
15080
+ * Additional rules to override Next.js defaults.
15081
+ */
15082
+ overrides?: RulesWithPrefix<RuleOptions, "@next/next">;
15083
+ }
15084
+ interface PlaywrightOptions {
15085
+ /**
15086
+ * Additional rules to override Playwright defaults.
15087
+ */
15088
+ overrides?: RulesWithPrefix<RuleOptions, "playwright">;
15089
+ }
15090
+ interface ReactOptions {
15091
+ /**
15092
+ * Additional rules to override React defaults.
15093
+ */
15094
+ overrides?: RulesWithPrefix<RuleOptions, "jsx-a11y" | "react-compiler" | "react-dom" | "react-hooks" | "react-hooks-extra" | "react-naming-convention" | "react-refresh" | "react-web-api" | "react-x">;
15095
+ }
15096
+ interface StorybookOptions {
15097
+ /**
15098
+ * Additional rules to override Storybook defaults.
15099
+ */
15100
+ overrides?: RulesWithPrefix<RuleOptions, "storybook">;
15101
+ }
15102
+ interface TanstackQueryOptions {
15103
+ /**
15104
+ * Additional rules to override TanStack Query defaults.
15105
+ */
15106
+ overrides?: RulesWithPrefix<RuleOptions, "@tanstack/query">;
15107
+ }
15108
+ interface TestingLibraryOptions {
15109
+ /**
15110
+ * Additional rules to override Testing Library defaults.
15111
+ */
15112
+ overrides?: RulesWithPrefix<RuleOptions, "jest-dom" | "testing-library">;
15053
15113
  }
15054
15114
  interface Options {
15055
15115
  /**
15056
- * Are astro rules enabled?
15116
+ * Are Astro rules enabled?
15117
+ *
15118
+ * Pass `true` to enable with defaults, or an `AstroOptions` object
15119
+ * to enable and customize overrides.
15057
15120
  *
15058
15121
  * @default false
15059
15122
  */
15060
- astro?: boolean;
15123
+ astro?: AstroOptions | boolean;
15061
15124
  /**
15062
15125
  * Automatically enables rules based on installed dependencies.
15063
15126
  * For example, if `react` is installed, React-specific rules will be applied.
@@ -15081,15 +15144,21 @@ interface Options {
15081
15144
  /**
15082
15145
  * Are Jest rules enabled?
15083
15146
  *
15147
+ * Pass `true` to enable with defaults, or an `JestOptions` object
15148
+ * to enable and customize overrides.
15149
+ *
15084
15150
  * @default false
15085
15151
  */
15086
- jest?: boolean;
15152
+ jest?: boolean | JestOptions;
15087
15153
  /**
15088
15154
  * Are Next.js rules enabled?
15089
15155
  *
15156
+ * Pass `true` to enable with defaults, or a `NextJSOptions` object
15157
+ * to enable and customize overrides.
15158
+ *
15090
15159
  * @default false
15091
15160
  */
15092
- nextjs?: boolean;
15161
+ nextjs?: boolean | NextJSOptions;
15093
15162
  /**
15094
15163
  * Additional configs to extend or override rules.
15095
15164
  * Accepts ESLint configuration objects.
@@ -15100,42 +15169,63 @@ interface Options {
15100
15169
  /**
15101
15170
  * Are playwright rules enabled?
15102
15171
  *
15172
+ * Pass `true` to enable with defaults, or a `PlaywrightOptions` object
15173
+ * to enable and customize overrides.
15174
+ *
15103
15175
  * @default false
15104
15176
  */
15105
- playwright?: boolean;
15177
+ playwright?: boolean | PlaywrightOptions;
15106
15178
  /**
15107
15179
  * Are React rules enabled?
15108
15180
  *
15181
+ * Pass `true` to enable with defaults, or a `ReactOptions` object
15182
+ * to enable and customize overrides.
15183
+ *
15109
15184
  * @default false
15110
15185
  */
15111
- react?: boolean;
15186
+ react?: boolean | ReactOptions;
15112
15187
  /**
15113
15188
  * Are Storybook rules enabled?
15114
15189
  *
15190
+ * Pass `true` to enable with defaults, or a `StorybookOptions` object
15191
+ * to enable and customize overrides.
15192
+ *
15115
15193
  * @default false
15116
15194
  */
15117
- storybook?: boolean;
15195
+ storybook?: boolean | StorybookOptions;
15118
15196
  /**
15119
15197
  * Are TanStack Query rules enabled?
15120
15198
  *
15199
+ * Pass `true` to enable with defaults, or a `TanstackQueryOptions` object
15200
+ * to enable and customize overrides.
15201
+ *
15121
15202
  * @default false
15122
15203
  */
15123
- tanstackQuery?: boolean;
15204
+ tanstackQuery?: boolean | TanstackQueryOptions;
15124
15205
  /**
15125
15206
  * Are Testing Library rules enabled?
15126
15207
  *
15208
+ * Pass `true` to enable with defaults, or a `TestingLibraryOptions` object
15209
+ * to enable and customize overrides.
15210
+ *
15127
15211
  * @default false
15128
15212
  */
15129
- testingLibrary?: boolean;
15213
+ testingLibrary?: boolean | TestingLibraryOptions;
15130
15214
  /**
15131
15215
  * Are TypeScript rules enabled?
15132
15216
  *
15217
+ * Pass `true` to enable with defaults, or a `TypeScriptOptions` object
15218
+ * to enable and customize overrides.
15219
+ *
15133
15220
  * @default false
15134
15221
  */
15135
15222
  typescript?: boolean | TypeScriptOptions;
15136
15223
  /**
15137
15224
  * Are Vitest rules enabled?
15138
15225
  *
15226
+ * Pass `true` to enable with defaults, or a `VitestOptions` object
15227
+ * to enable and customize overrides.
15228
+ *
15139
15229
  * @default false
15140
15230
  */
15141
15231
  vitest?: boolean | VitestOptions;
@@ -15169,4 +15259,4 @@ declare const defineConfig: ({
15169
15259
  vitest
15170
15260
  }?: Options, ...moreOverrides: Linter.Config[] | TypedConfigItem[]) => Promise<any[]>;
15171
15261
  //#endregion
15172
- export { type Options, type TypedConfigItem, type VitestOptions, defineConfig };
15262
+ export { type AstroOptions, type JestOptions, type NextJSOptions, type Options, type PlaywrightOptions, type ReactOptions, type StorybookOptions, type TanstackQueryOptions as TanStackQueryOptions, type TestingLibraryOptions, type TypeScriptOptions, type TypedConfigItem, type VitestOptions, defineConfig };
package/dist/index.mjs CHANGED
@@ -504,16 +504,16 @@ const defineConfig = async ({ astro = false, autoDetect = true, gitignore = fals
504
504
  stylisticConfig()
505
505
  ];
506
506
  const featureConfigs = await Promise.all([
507
- isTypescriptEnabled && unwrap(import("./typescript-1X7EkO5M.mjs"), typescript),
508
- isReactEnabled && unwrap(import("./react-DY8zODCu.mjs")),
509
- isTanstackQueryEnabled && unwrap(import("./tanstack-query-DG6a41GH.mjs")),
510
- isAstroEnabled && unwrap(import("./astro-BBEJB2KF.mjs")),
511
- isJestEnabled && unwrap(import("./jest-DgTHyrfz.mjs")),
512
- isVitestEnabled && unwrap(import("./vitest-YdRMuvTR.mjs"), vitest),
513
- isTestingLibraryEnabled && unwrap(import("./testing-library-oE675dT3.mjs")),
514
- isPlaywrightEnabled && unwrap(import("./playwright-CM4et1Wx.mjs")),
515
- isStorybookEnabled && unwrap(import("./storybook-CyxpG33Q.mjs")),
516
- isNextjsEnabled && unwrap(import("./nextjs-VPeisXpq.mjs"))
507
+ isTypescriptEnabled && unwrap(import("./typescript-CNtyo5Lg.mjs"), typescript),
508
+ isReactEnabled && unwrap(import("./react-6Ule3BqW.mjs"), react),
509
+ isTanstackQueryEnabled && unwrap(import("./tanstack-query-BVXIAVcv.mjs"), tanstackQuery),
510
+ isAstroEnabled && unwrap(import("./astro-BnZ2LIR3.mjs"), astro),
511
+ isJestEnabled && unwrap(import("./jest-BxCbmb4w.mjs"), jest),
512
+ isVitestEnabled && unwrap(import("./vitest-BiF4sMhO.mjs"), vitest),
513
+ isTestingLibraryEnabled && unwrap(import("./testing-library-BFsBlKXl.mjs"), testingLibrary),
514
+ isPlaywrightEnabled && unwrap(import("./playwright-ChDf6HhZ.mjs"), playwright),
515
+ isStorybookEnabled && unwrap(import("./storybook-BfbeHUhi.mjs"), storybook),
516
+ isNextjsEnabled && unwrap(import("./nextjs-_AmGd366.mjs"), nextjs)
517
517
  ]);
518
518
  return [
519
519
  ...gitignore ? [gitignoreConfig({ strict: false })] : [],
@@ -1,3 +1,16 @@
1
+ //#region src/utils/extract-options.ts
2
+ /**
3
+ * A simple utility to derive options for configurations when one option is a boolean.
4
+ *
5
+ * @param options - The options to derive.
6
+ *
7
+ * @returns The extracted options or `undefined` if the input was a boolean.
8
+ */
9
+ const extractOptions = (options) => {
10
+ if (typeof options !== "boolean") return options;
11
+ };
12
+
13
+ //#endregion
1
14
  //#region src/utils/interop-default.ts
2
15
  /**
3
16
  * Utility to safely fetch an imported `ESLint` plugin.
@@ -14,4 +27,4 @@ const interopDefault = async (module) => {
14
27
  };
15
28
 
16
29
  //#endregion
17
- export { interopDefault as t };
30
+ export { extractOptions as n, interopDefault as t };
@@ -1,8 +1,8 @@
1
1
  import { l as GLOB_TESTS, r as GLOB_E2E } from "./globs-uKx5b8lV.mjs";
2
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
2
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
3
3
 
4
4
  //#region src/rules/jest.ts
5
- const jestRules = async () => {
5
+ const jestRules = async (options) => {
6
6
  const jestPlugin = await interopDefault(import("eslint-plugin-jest"));
7
7
  return {
8
8
  ...jestPlugin.configs["flat/recommended"].rules,
@@ -43,19 +43,21 @@ const jestRules = async () => {
43
43
  "jest/require-to-throw-message": "error",
44
44
  "jest/require-top-level-describe": "off",
45
45
  "jest/unbound-method": "off",
46
- "jest/valid-title": ["error", { mustMatch: { it: "^should" } }]
46
+ "jest/valid-title": ["error", { mustMatch: { it: "^should" } }],
47
+ ...options?.overrides
47
48
  };
48
49
  };
49
50
 
50
51
  //#endregion
51
52
  //#region src/configs/jest.ts
52
- async function jestConfig() {
53
+ async function jestConfig(options) {
54
+ const extractedOptions = extractOptions(options);
53
55
  return [{
54
56
  files: GLOB_TESTS,
55
57
  ignores: GLOB_E2E,
56
58
  ...(await interopDefault(import("eslint-plugin-jest"))).configs["flat/recommended"],
57
59
  name: "jimmy.codes/jest",
58
- rules: await jestRules()
60
+ rules: await jestRules(extractedOptions)
59
61
  }];
60
62
  }
61
63
 
@@ -0,0 +1,27 @@
1
+ import { s as GLOB_NEXTJS } from "./globs-uKx5b8lV.mjs";
2
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
3
+ import { t as upwarn } from "./astro-BnZ2LIR3.mjs";
4
+
5
+ //#region src/rules/nextjs.ts
6
+ const nextjsRules = async (options) => {
7
+ return {
8
+ ...upwarn((await interopDefault(import("@next/eslint-plugin-next"))).configs.recommended.rules),
9
+ ...options?.overrides
10
+ };
11
+ };
12
+
13
+ //#endregion
14
+ //#region src/configs/nextjs.ts
15
+ async function nextjsConfig(options) {
16
+ const extractedOptions = extractOptions(options);
17
+ const nextjsPlugin = await interopDefault(import("@next/eslint-plugin-next"));
18
+ return [{
19
+ files: GLOB_NEXTJS,
20
+ name: "jimmy.codes/nextjs",
21
+ plugins: { "@next/next": nextjsPlugin },
22
+ rules: await nextjsRules(extractedOptions)
23
+ }];
24
+ }
25
+
26
+ //#endregion
27
+ export { nextjsConfig as default };
@@ -1,8 +1,8 @@
1
1
  import { c as GLOB_PLAYWRIGHT } from "./globs-uKx5b8lV.mjs";
2
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
2
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
3
3
 
4
4
  //#region src/rules/playwright.ts
5
- const playwrightRules = async () => {
5
+ const playwrightRules = async (options) => {
6
6
  return {
7
7
  ...(await interopDefault(import("eslint-plugin-playwright"))).configs["flat/recommended"].rules,
8
8
  "playwright/expect-expect": "error",
@@ -27,18 +27,20 @@ const playwrightRules = async () => {
27
27
  "playwright/prefer-to-have-count": "error",
28
28
  "playwright/prefer-to-have-length": "error",
29
29
  "playwright/require-to-throw-message": "error",
30
- "playwright/valid-title": "off"
30
+ "playwright/valid-title": "off",
31
+ ...options?.overrides
31
32
  };
32
33
  };
33
34
 
34
35
  //#endregion
35
36
  //#region src/configs/playwright.ts
36
- async function playwrightConfig() {
37
+ async function playwrightConfig(options) {
38
+ const extractedOptions = extractOptions(options);
37
39
  return [{
38
40
  ...(await interopDefault(import("eslint-plugin-playwright"))).configs["flat/recommended"],
39
41
  files: GLOB_PLAYWRIGHT,
40
42
  name: "jimmy.codes/playwright",
41
- rules: await playwrightRules()
43
+ rules: await playwrightRules(extractedOptions)
42
44
  }];
43
45
  }
44
46
 
@@ -1,7 +1,7 @@
1
1
  import { d as GLOB_TSX, o as GLOB_JSX } from "./globs-uKx5b8lV.mjs";
2
2
  import { l as hasTypescript, r as hasNext, u as hasVite } from "./has-dependency-BreXO1rF.mjs";
3
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
4
- import { t as upwarn } from "./upwarn-BWFMaOyK.mjs";
3
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
4
+ import { t as upwarn } from "./astro-BnZ2LIR3.mjs";
5
5
  import globals from "globals";
6
6
 
7
7
  //#region src/rules/react.ts
@@ -20,7 +20,7 @@ const nextAllowedExportNames = [
20
20
  "viewport",
21
21
  "generateViewport"
22
22
  ];
23
- const reactRules = async () => {
23
+ const reactRules = async (options) => {
24
24
  const [{ configs: reactConfigs }, { flatConfigs: jsxA11yConfigs }, { configs: reactDomConfigs }, { configs: reactHooksExtraConfigs }, { configs: reactWebApiConfigs }, { configs: reactNamingConventionConfigs }] = await Promise.all([
25
25
  interopDefault(import("eslint-plugin-react-x")),
26
26
  interopDefault(import("eslint-plugin-jsx-a11y")),
@@ -76,13 +76,15 @@ const reactRules = async () => {
76
76
  "react-x/jsx-shorthand-boolean": "error",
77
77
  "react-x/jsx-shorthand-fragment": "error",
78
78
  "react-x/no-missing-context-display-name": "error",
79
- "react-x/prefer-namespace-import": "error"
79
+ "react-x/prefer-namespace-import": "error",
80
+ ...options?.overrides
80
81
  };
81
82
  };
82
83
 
83
84
  //#endregion
84
85
  //#region src/configs/react.ts
85
- async function reactConfig() {
86
+ async function reactConfig(options) {
87
+ const extractedOptions = extractOptions(options);
86
88
  const [reactPlugin, jsxA11yPlugin, reactHooksPlugin, reactRefreshPlugin, reactCompilerPlugin, reactHooksExtraPlugin, reactDomPlugin, reactWebApiPlugin, reactNamingConventionPlugin] = await Promise.all([
87
89
  interopDefault(import("eslint-plugin-react-x")),
88
90
  interopDefault(import("eslint-plugin-jsx-a11y")),
@@ -115,7 +117,7 @@ async function reactConfig() {
115
117
  "react-web-api": reactWebApiPlugin,
116
118
  "react-x": reactPlugin
117
119
  },
118
- rules: await reactRules(),
120
+ rules: await reactRules(extractedOptions),
119
121
  settings: { react: { version: "detect" } }
120
122
  }];
121
123
  }
@@ -1,8 +1,9 @@
1
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
2
- import { t as upwarn } from "./upwarn-BWFMaOyK.mjs";
1
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
2
+ import { t as upwarn } from "./astro-BnZ2LIR3.mjs";
3
3
 
4
4
  //#region src/configs/storybook.ts
5
- async function storybookConfig() {
5
+ async function storybookConfig(options) {
6
+ const extractedOptions = extractOptions(options);
6
7
  const { configs } = await interopDefault(import("eslint-plugin-storybook"));
7
8
  const [setup, storiesConfig, mainConfig] = configs["flat/recommended"];
8
9
  return [
@@ -17,7 +18,8 @@ async function storybookConfig() {
17
18
  ...upwarn(storiesConfig?.rules),
18
19
  "import-x/no-anonymous-default-export": "off",
19
20
  "storybook/meta-satisfies-type": "error",
20
- "unicorn/no-anonymous-default-export": "off"
21
+ "unicorn/no-anonymous-default-export": "off",
22
+ ...extractedOptions?.overrides
21
23
  }
22
24
  },
23
25
  {
@@ -1,8 +1,9 @@
1
1
  import { d as GLOB_TSX, o as GLOB_JSX } from "./globs-uKx5b8lV.mjs";
2
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
2
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
3
3
 
4
4
  //#region src/configs/tanstack-query.ts
5
- async function tanstackQueryConfig() {
5
+ async function tanstackQueryConfig(options) {
6
+ const extractedOptions = extractOptions(options);
6
7
  const queryPlugin = await interopDefault(import("@tanstack/eslint-plugin-query"));
7
8
  return [{
8
9
  files: [GLOB_JSX, GLOB_TSX],
@@ -15,7 +16,8 @@ async function tanstackQueryConfig() {
15
16
  "@tanstack/query/no-rest-destructuring": "error",
16
17
  "@tanstack/query/no-unstable-deps": "error",
17
18
  "@tanstack/query/no-void-query-fn": "error",
18
- "@tanstack/query/stable-query-client": "error"
19
+ "@tanstack/query/stable-query-client": "error",
20
+ ...extractedOptions?.overrides
19
21
  }
20
22
  }];
21
23
  }
@@ -1,19 +1,21 @@
1
1
  import { l as GLOB_TESTS, r as GLOB_E2E } from "./globs-uKx5b8lV.mjs";
2
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
2
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
3
3
 
4
4
  //#region src/rules/testing-library.ts
5
- const testingLibraryRules = async () => {
5
+ const testingLibraryRules = async (options) => {
6
6
  const [jestDom, testingLibrary] = await Promise.all([import("eslint-plugin-jest-dom"), interopDefault(import("eslint-plugin-testing-library"))]);
7
7
  return {
8
8
  ...testingLibrary.configs["flat/react"].rules,
9
9
  ...jestDom.configs["flat/recommended"].rules,
10
- "testing-library/no-test-id-queries": "error"
10
+ "testing-library/no-test-id-queries": "error",
11
+ ...options?.overrides
11
12
  };
12
13
  };
13
14
 
14
15
  //#endregion
15
16
  //#region src/configs/testing-library.ts
16
- async function testingLibraryConfig() {
17
+ async function testingLibraryConfig(options) {
18
+ const extractedOptions = extractOptions(options);
17
19
  const [jestDom, testingLibrary] = await Promise.all([import("eslint-plugin-jest-dom"), interopDefault(import("eslint-plugin-testing-library"))]);
18
20
  return [{
19
21
  files: GLOB_TESTS,
@@ -23,7 +25,7 @@ async function testingLibraryConfig() {
23
25
  "jest-dom": jestDom,
24
26
  "testing-library": testingLibrary
25
27
  },
26
- rules: await testingLibraryRules()
28
+ rules: await testingLibraryRules(extractedOptions)
27
29
  }];
28
30
  }
29
31
 
@@ -1,38 +1,40 @@
1
1
  import { a as GLOB_JS, l as GLOB_TESTS, o as GLOB_JSX } from "./globs-uKx5b8lV.mjs";
2
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
3
- import { t as extractOptions } from "./extract-options-mq3SNxbU.mjs";
2
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
4
3
 
5
4
  //#region src/rules/typescript.ts
6
5
  const disabledEslintRules = {
7
6
  "no-unused-private-class-members": "off",
8
7
  "no-use-before-define": "off"
9
8
  };
10
- const typescriptRules = {
11
- ...disabledEslintRules,
12
- "@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: false }],
13
- "@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "separate-type-imports" }],
14
- "@typescript-eslint/no-deprecated": "warn",
15
- "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: { attributes: false } }],
16
- "@typescript-eslint/no-unnecessary-type-conversion": "error",
17
- "@typescript-eslint/no-unused-private-class-members": "error",
18
- "@typescript-eslint/no-unused-vars": ["error", {
19
- args: "all",
20
- argsIgnorePattern: "^_",
21
- caughtErrors: "all",
22
- caughtErrorsIgnorePattern: "^_",
23
- destructuredArrayIgnorePattern: "^_",
24
- ignoreRestSiblings: true,
25
- varsIgnorePattern: "^_"
26
- }],
27
- "@typescript-eslint/no-use-before-define": ["error", {
28
- allowNamedExports: false,
29
- classes: false,
30
- functions: false,
31
- variables: true
32
- }],
33
- "@typescript-eslint/no-useless-empty-export": "error",
34
- "@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
35
- "@typescript-eslint/switch-exhaustiveness-check": "error"
9
+ const typescriptRules = (options) => {
10
+ return {
11
+ ...disabledEslintRules,
12
+ "@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: false }],
13
+ "@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "separate-type-imports" }],
14
+ "@typescript-eslint/no-deprecated": "warn",
15
+ "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: { attributes: false } }],
16
+ "@typescript-eslint/no-unnecessary-type-conversion": "error",
17
+ "@typescript-eslint/no-unused-private-class-members": "error",
18
+ "@typescript-eslint/no-unused-vars": ["error", {
19
+ args: "all",
20
+ argsIgnorePattern: "^_",
21
+ caughtErrors: "all",
22
+ caughtErrorsIgnorePattern: "^_",
23
+ destructuredArrayIgnorePattern: "^_",
24
+ ignoreRestSiblings: true,
25
+ varsIgnorePattern: "^_"
26
+ }],
27
+ "@typescript-eslint/no-use-before-define": ["error", {
28
+ allowNamedExports: false,
29
+ classes: false,
30
+ functions: false,
31
+ variables: true
32
+ }],
33
+ "@typescript-eslint/no-useless-empty-export": "error",
34
+ "@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
35
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
36
+ ...options?.overrides
37
+ };
36
38
  };
37
39
 
38
40
  //#endregion
@@ -51,7 +53,7 @@ async function typescriptConfig(options) {
51
53
  tsconfigRootDir: process.cwd()
52
54
  } },
53
55
  name: "jimmy.codes/typescript",
54
- rules: typescriptRules
56
+ rules: typescriptRules(extractedOptions)
55
57
  },
56
58
  {
57
59
  files: [GLOB_JS, GLOB_JSX],
@@ -1,6 +1,5 @@
1
1
  import { f as GLOB_TYPE_TESTS, l as GLOB_TESTS, r as GLOB_E2E } from "./globs-uKx5b8lV.mjs";
2
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
3
- import { t as extractOptions } from "./extract-options-mq3SNxbU.mjs";
2
+ import { n as extractOptions, t as interopDefault } from "./interop-default-CKeWA-H9.mjs";
4
3
 
5
4
  //#region src/rules/vitest.ts
6
5
  const vitestRules = async (options) => {
@@ -58,7 +57,8 @@ const vitestRules = async (options) => {
58
57
  "vitest/require-to-throw-message": "error",
59
58
  "vitest/require-top-level-describe": "off",
60
59
  "vitest/valid-title": ["error", { mustMatch: { it: "^should" } }],
61
- "vitest/warn-todo": "warn"
60
+ "vitest/warn-todo": "warn",
61
+ ...options?.overrides
62
62
  };
63
63
  };
64
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jimmy.codes/eslint-config",
3
- "version": "6.24.1",
3
+ "version": "6.26.0",
4
4
  "description": "A simple, modern ESLint config that covers most use cases.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,13 +41,13 @@
41
41
  "dependencies": {
42
42
  "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
43
43
  "@eslint/js": "^9.39.1",
44
- "@next/eslint-plugin-next": "^16.0.6",
44
+ "@next/eslint-plugin-next": "^16.0.10",
45
45
  "@stylistic/eslint-plugin": "^5.6.1",
46
46
  "@tanstack/eslint-plugin-query": "^5.91.2",
47
47
  "@types/eslint": "9.6.1",
48
- "@typescript-eslint/parser": "^8.48.0",
49
- "@typescript-eslint/utils": "^8.48.0",
50
- "@vitest/eslint-plugin": "^1.5.1",
48
+ "@typescript-eslint/parser": "^8.49.0",
49
+ "@typescript-eslint/utils": "^8.49.0",
50
+ "@vitest/eslint-plugin": "^1.5.2",
51
51
  "astro-eslint-parser": "^1.2.2",
52
52
  "eslint-config-flat-gitignore": "^2.1.0",
53
53
  "eslint-config-prettier": "^10.1.8",
@@ -58,26 +58,26 @@
58
58
  "eslint-plugin-import-x": "^4.16.1",
59
59
  "eslint-plugin-jest": "^29.2.1",
60
60
  "eslint-plugin-jest-dom": "^5.5.0",
61
- "eslint-plugin-jsdoc": "^61.4.1",
61
+ "eslint-plugin-jsdoc": "^61.5.0",
62
62
  "eslint-plugin-jsx-a11y": "^6.10.2",
63
63
  "eslint-plugin-n": "^17.23.1",
64
64
  "eslint-plugin-perfectionist": "^4.15.1",
65
65
  "eslint-plugin-playwright": "^2.4.0",
66
66
  "eslint-plugin-react-compiler": "19.1.0-rc.2",
67
- "eslint-plugin-react-dom": "^2.3.9",
67
+ "eslint-plugin-react-dom": "^2.3.13",
68
68
  "eslint-plugin-react-hooks": "^7.0.1",
69
- "eslint-plugin-react-hooks-extra": "^2.3.9",
70
- "eslint-plugin-react-naming-convention": "^2.3.9",
69
+ "eslint-plugin-react-hooks-extra": "^2.3.13",
70
+ "eslint-plugin-react-naming-convention": "^2.3.13",
71
71
  "eslint-plugin-react-refresh": "0.4.24",
72
- "eslint-plugin-react-web-api": "^2.3.9",
73
- "eslint-plugin-react-x": "^2.3.9",
72
+ "eslint-plugin-react-web-api": "^2.3.13",
73
+ "eslint-plugin-react-x": "^2.3.13",
74
74
  "eslint-plugin-regexp": "^2.10.0",
75
75
  "eslint-plugin-storybook": "0.12.0",
76
- "eslint-plugin-testing-library": "^7.13.5",
76
+ "eslint-plugin-testing-library": "^7.13.6",
77
77
  "eslint-plugin-unicorn": "^62.0.0",
78
78
  "globals": "^16.5.0",
79
79
  "local-pkg": "^1.1.2",
80
- "typescript-eslint": "^8.48.0"
80
+ "typescript-eslint": "^8.49.0"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "eslint": "^9.10.0"
@@ -1,14 +0,0 @@
1
- //#region src/utils/extract-options.ts
2
- /**
3
- * A simple utility to derive options for configurations when one option is a boolean.
4
- *
5
- * @param options - The options to derive.
6
- *
7
- * @returns The extracted options or `undefined` if the input was a boolean.
8
- */
9
- const extractOptions = (options) => {
10
- if (typeof options !== "boolean") return options;
11
- };
12
-
13
- //#endregion
14
- export { extractOptions as t };
@@ -1,23 +0,0 @@
1
- import { s as GLOB_NEXTJS } from "./globs-uKx5b8lV.mjs";
2
- import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
3
- import { t as upwarn } from "./upwarn-BWFMaOyK.mjs";
4
-
5
- //#region src/rules/nextjs.ts
6
- const nextjsRules = async () => {
7
- return upwarn((await interopDefault(import("@next/eslint-plugin-next"))).configs.recommended.rules);
8
- };
9
-
10
- //#endregion
11
- //#region src/configs/nextjs.ts
12
- async function nextjsConfig() {
13
- const nextjsPlugin = await interopDefault(import("@next/eslint-plugin-next"));
14
- return [{
15
- files: GLOB_NEXTJS,
16
- name: "jimmy.codes/nextjs",
17
- plugins: { "@next/next": nextjsPlugin },
18
- rules: await nextjsRules()
19
- }];
20
- }
21
-
22
- //#endregion
23
- export { nextjsConfig as default };
@@ -1,16 +0,0 @@
1
- //#region src/utils/upwarn.ts
2
- /**
3
- * Converts all ESLint rules set to `"warn"` into `"error"`.
4
- *
5
- * @param rules - A partial set of ESLint rules.
6
- *
7
- * @returns A new rules object with all `"warn"` values changed to `"error"`.
8
- */
9
- const upwarn = (rules = {}) => {
10
- return Object.fromEntries(Object.entries(rules).map(([rule, option]) => {
11
- return [rule, option === "warn" ? "error" : option];
12
- }));
13
- };
14
-
15
- //#endregion
16
- export { upwarn as t };