Skip to content

Commit 8a541e0

Browse files
authored
docs: replace tseslint.config with defineConfig (#1214)
1 parent 07ab70f commit 8a541e0

File tree

13 files changed

+219
-193
lines changed

13 files changed

+219
-193
lines changed

.pkgs/configs/eslint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-deprecated */
12
import js from "@eslint/js";
23
import stylistic from "@stylistic/eslint-plugin";
34
import pluginDeMorgan from "eslint-plugin-de-morgan";

.pkgs/configs/eslint.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-deprecated */
12
import js from "@eslint/js";
23
import stylistic from "@stylistic/eslint-plugin";
34
import pluginDeMorgan from "eslint-plugin-de-morgan";

README.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,40 +69,42 @@ npm install --save-dev typescript-eslint @eslint-react/eslint-plugin
6969
```js
7070
// eslint.config.js
7171

72-
// @ts-check
7372
import eslintReact from "@eslint-react/eslint-plugin";
7473
import eslintJs from "@eslint/js";
74+
import { defineConfig } from "eslint/config";
7575
import tseslint from "typescript-eslint";
7676

77-
export default tseslint.config({
78-
files: ["**/*.ts", "**/*.tsx"],
79-
80-
// Extend recommended rule sets from:
81-
// 1. ESLint JS's recommended rules
82-
// 2. TypeScript ESLint recommended rules
83-
// 3. ESLint React's recommended-typescript rules
84-
extends: [
85-
eslintJs.configs.recommended,
86-
tseslint.configs.recommended,
87-
eslintReact.configs["recommended-typescript"],
88-
],
89-
90-
// Configure language/parsing options
91-
languageOptions: {
92-
// Use TypeScript ESLint parser for TypeScript files
93-
parser: tseslint.parser,
94-
parserOptions: {
95-
// Enable project service for better TypeScript integration
96-
projectService: true,
97-
tsconfigRootDir: import.meta.dirname,
77+
export default defineConfig([
78+
{
79+
files: ["**/*.ts", "**/*.tsx"],
80+
81+
// Extend recommended rule sets from:
82+
// 1. ESLint JS's recommended rules
83+
// 2. TypeScript ESLint recommended rules
84+
// 3. ESLint React's recommended-typescript rules
85+
extends: [
86+
eslintJs.configs.recommended,
87+
tseslint.configs.recommended,
88+
eslintReact.configs["recommended-typescript"],
89+
],
90+
91+
// Configure language/parsing options
92+
languageOptions: {
93+
// Use TypeScript ESLint parser for TypeScript files
94+
parser: tseslint.parser,
95+
parserOptions: {
96+
// Enable project service for better TypeScript integration
97+
projectService: true,
98+
tsconfigRootDir: import.meta.dirname,
99+
},
98100
},
99-
},
100101

101-
// Custom rule overrides (modify rule levels or disable rules)
102-
rules: {
103-
"@eslint-react/no-missing-key": "warn",
102+
// Custom rule overrides (modify rule levels or disable rules)
103+
rules: {
104+
"@eslint-react/no-missing-key": "warn",
105+
},
104106
},
105-
});
107+
]);
106108
```
107109

108110
[Full Installation Guide ↗](https://eslint-react.xyz/docs/getting-started/typescript)

apps/website/content/docs/getting-started/typescript.mdx

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,49 +23,50 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
2323
<Step>
2424
## Configure ESLint
2525

26-
```js title="eslint.config.js"
27-
// @ts-check
28-
import eslintJs from "@eslint/js";
26+
```ts title="eslint.config.js"
2927
import eslintReact from "@eslint-react/eslint-plugin";
28+
import eslintJs from "@eslint/js";
29+
import { defineConfig } from "eslint/config";
3030
import tseslint from "typescript-eslint";
3131

32-
export default tseslint.config({
33-
files: ["**/*.ts", "**/*.tsx"],
34-
35-
// Extend recommended rule sets from:
36-
// 1. ESLint JS's recommended rules
37-
// 2. TypeScript ESLint recommended rules
38-
// 3. ESLint React's recommended-typescript rules
39-
extends: [
40-
eslintJs.configs.recommended,
41-
tseslint.configs.recommended,
42-
eslintReact.configs["recommended-typescript"],
43-
],
44-
45-
// Configure language/parsing options
46-
languageOptions: {
47-
// Use TypeScript ESLint parser for TypeScript files
48-
parser: tseslint.parser,
49-
parserOptions: {
50-
// Enable project service for better TypeScript integration
51-
projectService: true,
52-
tsconfigRootDir: import.meta.dirname,
32+
export default defineConfig([
33+
{
34+
files: ["**/*.ts", "**/*.tsx"],
35+
36+
// Extend recommended rule sets from:
37+
// 1. ESLint JS's recommended rules
38+
// 2. TypeScript ESLint recommended rules
39+
// 3. ESLint React's recommended-typescript rules
40+
extends: [
41+
eslintJs.configs.recommended,
42+
tseslint.configs.recommended,
43+
eslintReact.configs["recommended-typescript"],
44+
],
45+
46+
// Configure language/parsing options
47+
languageOptions: {
48+
// Use TypeScript ESLint parser for TypeScript files
49+
parser: tseslint.parser,
50+
parserOptions: {
51+
// Enable project service for better TypeScript integration
52+
projectService: true,
53+
tsconfigRootDir: import.meta.dirname,
54+
},
5355
},
54-
},
5556

56-
// Custom rule overrides (modify rule levels or disable rules)
57-
rules: {
58-
"@eslint-react/no-missing-key": "warn",
57+
// Custom rule overrides (modify rule levels or disable rules)
58+
rules: {
59+
"@eslint-react/no-missing-key": "warn",
60+
},
5961
},
60-
});
62+
]);
6163
```
6264
</Step>
6365

6466
<Step>
6567
## Configure [Project Config](/docs/glossary#project-config) (Optional)
6668

6769
```ts title="eslint.config.js"
68-
// @ts-check
6970
import tseslint from "typescript-eslint";
7071

7172
export default [

apps/website/eslint.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { recommended as fastImportRecommended } from "eslint-plugin-fast-import"
66
import pluginReactHooks from "eslint-plugin-react-hooks";
77
import pluginReactRefresh from "eslint-plugin-react-refresh";
88
import { globalIgnores } from "eslint/config";
9+
import { defineConfig } from "eslint/config";
910
import url from "node:url";
1011
import tseslint from "typescript-eslint";
1112

@@ -26,7 +27,7 @@ const GLOB_IGNORES = [
2627

2728
const dirname = url.fileURLToPath(new URL(".", import.meta.url));
2829

29-
export default tseslint.config(
30+
export default defineConfig([
3031
gitignore(),
3132
globalIgnores(GLOB_IGNORES),
3233
{
@@ -107,4 +108,4 @@ export default tseslint.config(
107108
"no-undef": "off",
108109
},
109110
},
110-
);
111+
] as never);

eslint.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import markdown from "@eslint/markdown";
44
import gitIgnores from "eslint-config-flat-gitignore";
55
import { recommended as fastImportRecommended } from "eslint-plugin-fast-import";
66
import pluginVitest from "eslint-plugin-vitest";
7-
import { globalIgnores } from "eslint/config";
7+
import { defineConfig, globalIgnores } from "eslint/config";
88
import tseslint from "typescript-eslint";
99

1010
import * as configs from "@local/configs/eslint";
@@ -36,7 +36,7 @@ const packagesTsConfigs = [
3636
"packages/*/*/tsconfig.json",
3737
];
3838

39-
export default tseslint.config(
39+
export default defineConfig([
4040
gitIgnores(),
4141
globalIgnores(GLOB_IGNORES),
4242
{
@@ -57,7 +57,7 @@ export default tseslint.config(
5757
},
5858
{
5959
extends: [
60-
...tseslint.configs.strictTypeChecked,
60+
tseslint.configs.strictTypeChecked,
6161
configs.typescript,
6262
fastImportRecommended({ rootDir: dirname }),
6363
],
@@ -120,4 +120,4 @@ export default tseslint.config(
120120
"local/avoid-multiline-template-expression": "off",
121121
},
122122
},
123-
);
123+
] as never);

packages/plugins/eslint-plugin-react-debug/README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,30 @@ npm install --save-dev eslint-plugin-react-debug
1919
// @ts-check
2020
import js from "@eslint/js";
2121
import reactDebug from "eslint-plugin-react-debug";
22+
import { defineConfig } from "eslint/config";
2223
import tseslint from "typescript-eslint";
2324

24-
export default tseslint.config({
25-
files: ["**/*.ts", "**/*.tsx"],
26-
extends: [
27-
js.configs.recommended,
28-
tseslint.configs.recommended,
29-
reactDebug.configs.all,
30-
],
31-
languageOptions: {
32-
parser: tseslint.parser,
33-
parserOptions: {
34-
projectService: true,
35-
tsconfigRootDir: import.meta.dirname,
25+
export default defineConfig([
26+
{
27+
files: ["**/*.ts", "**/*.tsx"],
28+
extends: [
29+
js.configs.recommended,
30+
tseslint.configs.recommended,
31+
reactDebug.configs.all,
32+
],
33+
languageOptions: {
34+
parser: tseslint.parser,
35+
parserOptions: {
36+
projectService: true,
37+
tsconfigRootDir: import.meta.dirname,
38+
},
39+
},
40+
rules: {
41+
// Put rules you want to override here
42+
"react-debug/function-component": "warn",
3643
},
3744
},
38-
rules: {
39-
// Put rules you want to override here
40-
"react-debug/function-component": "warn",
41-
},
42-
});
45+
]);
4346
```
4447

4548
## Rules

packages/plugins/eslint-plugin-react-dom/README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,30 @@ npm install --save-dev eslint-plugin-react-dom
1717
// @ts-check
1818
import js from "@eslint/js";
1919
import reactDom from "eslint-plugin-react-dom";
20+
import { defineConfig } from "eslint/config";
2021
import tseslint from "typescript-eslint";
2122

22-
export default tseslint.config({
23-
files: ["**/*.ts", "**/*.tsx"],
24-
extends: [
25-
js.configs.recommended,
26-
tseslint.configs.recommended,
27-
reactDom.configs.recommended,
28-
],
29-
languageOptions: {
30-
parser: tseslint.parser,
31-
parserOptions: {
32-
projectService: true,
33-
tsconfigRootDir: import.meta.dirname,
23+
export default defineConfig([
24+
{
25+
files: ["**/*.ts", "**/*.tsx"],
26+
extends: [
27+
js.configs.recommended,
28+
tseslint.configs.recommended,
29+
reactDom.configs.recommended,
30+
],
31+
languageOptions: {
32+
parser: tseslint.parser,
33+
parserOptions: {
34+
projectService: true,
35+
tsconfigRootDir: import.meta.dirname,
36+
},
37+
},
38+
rules: {
39+
// Put rules you want to override here
40+
"react-dom/no-dangerously-set-innerhtml": "warn",
3441
},
3542
},
36-
rules: {
37-
// Put rules you want to override here
38-
"react-dom/no-dangerously-set-innerhtml": "warn",
39-
},
40-
});
43+
]);
4144
```
4245

4346
## Rules

packages/plugins/eslint-plugin-react-hooks-extra/README.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,29 @@ npm install --save-dev eslint-plugin-react-hooks-extra
1717
// @ts-check
1818
import js from "@eslint/js";
1919
import reactHooksExtra from "eslint-plugin-react-hooks-extra";
20+
import { defineConfig } from "eslint/config";
2021
import tseslint from "typescript-eslint";
2122

22-
export default tseslint.config({
23-
files: ["**/*.ts", "**/*.tsx"],
24-
extends: [
25-
js.configs.recommended,
26-
tseslint.configs.recommended,
27-
reactHooksExtra.configs.recommended,
28-
],
29-
languageOptions: {
30-
parser: tseslint.parser,
31-
parserOptions: {
32-
projectService: true,
33-
tsconfigRootDir: import.meta.dirname,
23+
export default defineConfig([
24+
{
25+
files: ["**/*.ts", "**/*.tsx"],
26+
extends: [
27+
js.configs.recommended,
28+
tseslint.configs.recommended,
29+
reactHooksExtra.configs.recommended,
30+
],
31+
languageOptions: {
32+
parser: tseslint.parser,
33+
parserOptions: {
34+
projectService: true,
35+
tsconfigRootDir: import.meta.dirname,
36+
},
37+
},
38+
rules: {
39+
// Put rules you want to override here
3440
},
3541
},
36-
rules: {
37-
// Put rules you want to override here
38-
},
39-
});
42+
]);
4043
```
4144

4245
## Rules

0 commit comments

Comments
 (0)