@jimmy.codes/eslint-config 6.23.0 → 6.24.1

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
@@ -75,20 +75,38 @@ export default defineConfig({
75
75
  });
76
76
  ```
77
77
 
78
+ ### TypeScript Configuration
79
+
80
+ TypeScript also supports some configuration options. If options are provided then TypeScript support is enabled.
81
+
82
+ #### Configure Erasable Syntax Only
83
+
84
+ Enable rules scoped to TypeScript’s new erasable syntax only mode (TypeScript 5.8+):
85
+
86
+ ```ts
87
+ import { defineConfig } from "@jimmy.codes/eslint-config";
88
+
89
+ export default defineConfig({
90
+ typescript: {
91
+ erasableSyntaxOnly: true,
92
+ },
93
+ });
94
+ ```
95
+
78
96
  ### Vitest Configuration
79
97
 
80
98
  Vitest also supports some configuration options. If options are provided then Vitest support is enabled.
81
99
 
82
100
  #### Configure Vitest Globals
83
101
 
84
- Control how [Vitest globals configuration](https://vitest.dev/config/globals.html) (`describe`, `it`, `expect`, etc.) are handled:
102
+ Control how [Vitest globals configuration](https://vitest.dev/config/globals.html) are handled:
85
103
 
86
104
  ```ts
87
105
  import { defineConfig } from "@jimmy.codes/eslint-config";
88
106
 
89
107
  export default defineConfig({
90
108
  vitest: {
91
- globals: "explicit", // Require explicit imports from 'vitest'
109
+ globals: "explicit",
92
110
  },
93
111
  });
94
112
  ```
@@ -101,7 +119,7 @@ Options:
101
119
 
102
120
  #### Configure Type Testing
103
121
 
104
- Indicate whether [Vitest's type testing utilities](https://vitest.dev/guide/testing-types.html) (`expectTypeOf`, `assertType`) are being used:
122
+ Indicate whether [Vitest's type testing utilities](https://vitest.dev/guide/testing-types.html) are being used:
105
123
 
106
124
  ```ts
107
125
  import { defineConfig } from "@jimmy.codes/eslint-config";
@@ -5,8 +5,8 @@ import globals from "globals";
5
5
  //#region src/configs/astro.ts
6
6
  async function astroConfig() {
7
7
  const files = [GLOB_ASTRO];
8
- const { configs: tsConfigs, parser: tsParser } = await import("typescript-eslint");
9
- const [astroPlugin, astroParser, jsxA11yPlugin] = await Promise.all([
8
+ const [tsPlugin, astroPlugin, astroParser, jsxA11yPlugin] = await Promise.all([
9
+ import("typescript-eslint"),
10
10
  import("eslint-plugin-astro"),
11
11
  import("astro-eslint-parser"),
12
12
  interopDefault(import("eslint-plugin-jsx-a11y"))
@@ -23,7 +23,7 @@ async function astroConfig() {
23
23
  parser: astroParser,
24
24
  parserOptions: {
25
25
  extraFileExtensions: [".astro"],
26
- parser: tsParser
26
+ parser: tsPlugin.parser
27
27
  },
28
28
  sourceType: "module"
29
29
  },
@@ -55,7 +55,7 @@ async function astroConfig() {
55
55
  projectService: false
56
56
  } },
57
57
  name: "jimmy.codes/astro/disable-type-checked",
58
- rules: tsConfigs.disableTypeChecked.rules
58
+ rules: tsPlugin.configs.disableTypeChecked.rules
59
59
  },
60
60
  {
61
61
  name: "jimmy.codes/astro/imports",
@@ -0,0 +1,14 @@
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 };
package/dist/index.d.mts CHANGED
@@ -1785,6 +1785,26 @@ interface RuleOptions {
1785
1785
  * @see https://eslint.org/docs/latest/rules/eqeqeq
1786
1786
  */
1787
1787
  'eqeqeq'?: Linter.RuleEntry<Eqeqeq>;
1788
+ /**
1789
+ * Avoid using TypeScript's enums.
1790
+ * @see https://github.com/JoshuaKGoldberg/eslint-plugin-erasable-syntax-only/blob/main/docs/rules/enums.md
1791
+ */
1792
+ 'erasable-syntax-only/enums'?: Linter.RuleEntry<[]>;
1793
+ /**
1794
+ * Avoid using TypeScript's import aliases.
1795
+ * @see https://github.com/JoshuaKGoldberg/eslint-plugin-erasable-syntax-only/blob/main/docs/rules/import-aliases.md
1796
+ */
1797
+ 'erasable-syntax-only/import-aliases'?: Linter.RuleEntry<[]>;
1798
+ /**
1799
+ * Avoid using TypeScript's namespaces.
1800
+ * @see https://github.com/JoshuaKGoldberg/eslint-plugin-erasable-syntax-only/blob/main/docs/rules/namespaces.md
1801
+ */
1802
+ 'erasable-syntax-only/namespaces'?: Linter.RuleEntry<[]>;
1803
+ /**
1804
+ * Avoid using TypeScript's class parameter properties.
1805
+ * @see https://github.com/JoshuaKGoldberg/eslint-plugin-erasable-syntax-only/blob/main/docs/rules/parameter-properties.md
1806
+ */
1807
+ 'erasable-syntax-only/parameter-properties'?: Linter.RuleEntry<[]>;
1788
1808
  /**
1789
1809
  * Enforce `for` loop update clause moving the counter in the right direction
1790
1810
  * @see https://eslint.org/docs/latest/rules/for-direction
@@ -14033,6 +14053,7 @@ type PerfectionistSortVariableDeclarations = [] | [{
14033
14053
  // ----- playwright/expect-expect -----
14034
14054
  type PlaywrightExpectExpect = [] | [{
14035
14055
  assertFunctionNames?: [] | [string];
14056
+ assertFunctionPatterns?: [] | [string];
14036
14057
  }];
14037
14058
  // ----- playwright/max-expects -----
14038
14059
  type PlaywrightMaxExpects = [] | [{
@@ -15006,24 +15027,30 @@ interface LinterConfigOverrides {
15006
15027
  type TypedConfigItem = Prettify<Override<Base, LinterConfigOverrides>>;
15007
15028
  interface VitestOptions {
15008
15029
  /**
15009
- * How to handle Vitest global APIs (describe, it, expect, etc.).
15030
+ * How to handle [Vitest global APIs](https://vitest.dev/config/globals.html).
15010
15031
  *
15011
15032
  * - 'explicit': Require explicit imports from 'vitest'
15012
15033
  * - 'implicit': Use implicit global APIs (vitest config globals: true)
15013
15034
  * - 'either': Allow both styles (default)
15014
15035
  *
15015
- * @see https://vitest.dev/config/globals.html
15016
- *
15017
15036
  * @default 'either'
15018
15037
  */
15019
15038
  globals?: "either" | "explicit" | "implicit";
15020
15039
  /**
15021
- * Indicate whether [Vitest's type testing utilities](https://vitest.dev/guide/testing-types.html) (`expectTypeOf`, `assertType`) are being used
15040
+ * Indicate whether [Vitest's type testing utilities](https://vitest.dev/guide/testing-types.html) are being used.
15022
15041
  *
15023
15042
  * @default false
15024
15043
  */
15025
15044
  typecheck?: boolean;
15026
15045
  }
15046
+ interface TypeScriptOptions {
15047
+ /**
15048
+ * Enable rules for [erasable syntax only](https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option).
15049
+ *
15050
+ * @default false
15051
+ */
15052
+ erasableSyntaxOnly?: boolean;
15053
+ }
15027
15054
  interface Options {
15028
15055
  /**
15029
15056
  * Are astro rules enabled?
@@ -15105,7 +15132,7 @@ interface Options {
15105
15132
  *
15106
15133
  * @default false
15107
15134
  */
15108
- typescript?: boolean;
15135
+ typescript?: boolean | TypeScriptOptions;
15109
15136
  /**
15110
15137
  * Are Vitest rules enabled?
15111
15138
  *
package/dist/index.mjs CHANGED
@@ -504,12 +504,12 @@ 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-CMkBsIGI.mjs")),
507
+ isTypescriptEnabled && unwrap(import("./typescript-1X7EkO5M.mjs"), typescript),
508
508
  isReactEnabled && unwrap(import("./react-DY8zODCu.mjs")),
509
509
  isTanstackQueryEnabled && unwrap(import("./tanstack-query-DG6a41GH.mjs")),
510
- isAstroEnabled && unwrap(import("./astro-DNtOkeq5.mjs")),
510
+ isAstroEnabled && unwrap(import("./astro-BBEJB2KF.mjs")),
511
511
  isJestEnabled && unwrap(import("./jest-DgTHyrfz.mjs")),
512
- isVitestEnabled && unwrap(import("./vitest-C4QXivmM.mjs"), vitest),
512
+ isVitestEnabled && unwrap(import("./vitest-YdRMuvTR.mjs"), vitest),
513
513
  isTestingLibraryEnabled && unwrap(import("./testing-library-oE675dT3.mjs")),
514
514
  isPlaywrightEnabled && unwrap(import("./playwright-CM4et1Wx.mjs")),
515
515
  isStorybookEnabled && unwrap(import("./storybook-CyxpG33Q.mjs")),
@@ -1,4 +1,6 @@
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
4
 
3
5
  //#region src/rules/typescript.ts
4
6
  const disabledEslintRules = {
@@ -35,8 +37,9 @@ const typescriptRules = {
35
37
 
36
38
  //#endregion
37
39
  //#region src/configs/typescript.ts
38
- async function typescriptConfig() {
40
+ async function typescriptConfig(options) {
39
41
  const { configs } = await import("typescript-eslint");
42
+ const extractedOptions = extractOptions(options);
40
43
  return [
41
44
  ...configs.strictTypeChecked,
42
45
  ...configs.stylisticTypeChecked.filter((config) => {
@@ -66,7 +69,17 @@ async function typescriptConfig() {
66
69
  "@typescript-eslint/no-unsafe-argument": "off",
67
70
  "@typescript-eslint/no-unsafe-assignment": "off"
68
71
  }
69
- }
72
+ },
73
+ ...extractedOptions?.erasableSyntaxOnly ? [{
74
+ name: "jimmy.codes/typescript/erasable-syntax-only",
75
+ plugins: { "erasable-syntax-only": await interopDefault(import("eslint-plugin-erasable-syntax-only")) },
76
+ rules: {
77
+ "erasable-syntax-only/enums": "error",
78
+ "erasable-syntax-only/import-aliases": "error",
79
+ "erasable-syntax-only/namespaces": "error",
80
+ "erasable-syntax-only/parameter-properties": "error"
81
+ }
82
+ }] : []
70
83
  ];
71
84
  }
72
85
 
@@ -1,5 +1,6 @@
1
1
  import { f as GLOB_TYPE_TESTS, l as GLOB_TESTS, r as GLOB_E2E } from "./globs-uKx5b8lV.mjs";
2
2
  import { t as interopDefault } from "./interop-default-Bn64p66u.mjs";
3
+ import { t as extractOptions } from "./extract-options-mq3SNxbU.mjs";
3
4
 
4
5
  //#region src/rules/vitest.ts
5
6
  const vitestRules = async (options) => {
@@ -61,19 +62,6 @@ const vitestRules = async (options) => {
61
62
  };
62
63
  };
63
64
 
64
- //#endregion
65
- //#region src/utils/extract-options.ts
66
- /**
67
- * A simple utility to derive options for configurations when one option is a boolean.
68
- *
69
- * @param options - The options to derive.
70
- *
71
- * @returns The extracted options or `undefined` if the input was a boolean.
72
- */
73
- const extractOptions = (options) => {
74
- if (typeof options !== "boolean") return options;
75
- };
76
-
77
65
  //#endregion
78
66
  //#region src/configs/vitest.ts
79
67
  async function vitestConfig(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jimmy.codes/eslint-config",
3
- "version": "6.23.0",
3
+ "version": "6.24.1",
4
4
  "description": "A simple, modern ESLint config that covers most use cases.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,19 +41,20 @@
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.4",
44
+ "@next/eslint-plugin-next": "^16.0.6",
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
48
  "@typescript-eslint/parser": "^8.48.0",
49
49
  "@typescript-eslint/utils": "^8.48.0",
50
- "@vitest/eslint-plugin": "^1.5.0",
50
+ "@vitest/eslint-plugin": "^1.5.1",
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",
54
54
  "eslint-import-resolver-typescript": "^4.4.4",
55
55
  "eslint-plugin-arrow-return-style-x": "^1.2.6",
56
56
  "eslint-plugin-astro": "^1.5.0",
57
+ "eslint-plugin-erasable-syntax-only": "0.4.0",
57
58
  "eslint-plugin-import-x": "^4.16.1",
58
59
  "eslint-plugin-jest": "^29.2.1",
59
60
  "eslint-plugin-jest-dom": "^5.5.0",
@@ -61,7 +62,7 @@
61
62
  "eslint-plugin-jsx-a11y": "^6.10.2",
62
63
  "eslint-plugin-n": "^17.23.1",
63
64
  "eslint-plugin-perfectionist": "^4.15.1",
64
- "eslint-plugin-playwright": "^2.3.0",
65
+ "eslint-plugin-playwright": "^2.4.0",
65
66
  "eslint-plugin-react-compiler": "19.1.0-rc.2",
66
67
  "eslint-plugin-react-dom": "^2.3.9",
67
68
  "eslint-plugin-react-hooks": "^7.0.1",