Skip to content

Commit 6ca9952

Browse files
authored
docs: update eslint configs in examples to use extends (#978)
1 parent b64e79b commit 6ca9952

File tree

11 files changed

+72
-129
lines changed

11 files changed

+72
-129
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,28 @@ npm install --save-dev eslint @eslint/js @eslint-react/eslint-plugin
1414
```js title="eslint.config.js"
1515
import eslintJs from "@eslint/js";
1616
import eslintReact from "@eslint-react/eslint-plugin";
17+
import { defineConfig } from "eslint/config";
1718

18-
export default [
19+
export default defineConfig([
1920
{
2021
files: ["**/*.js", "**/*.jsx"],
21-
...eslintJs.configs.recommended,
22+
extends: [
23+
eslintJs.configs.recommended,
24+
eslintReact.configs.recommended,
25+
],
2226
languageOptions: {
2327
parserOptions: {
2428
ecmaFeatures: {
2529
jsx: true,
2630
},
2731
},
2832
},
29-
},
30-
{
31-
files: ["**/*.js", "**/*.jsx"],
32-
...eslintReact.configs.recommended,
33-
},
34-
{
35-
files: ["**/*.js", "**/*.jsx"],
3633
rules: {
34+
// Add `globals` if you need this rule
35+
"no-undef": "off",
3736
// Put rules you want to override here
3837
"@eslint-react/prefer-shorthand-boolean": "warn",
3938
},
4039
},
41-
];
40+
]);
4241
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"title": "Getting Started",
33
"pages": [
4-
"typescript",
5-
"javascript"
4+
"javascript",
5+
"typescript"
66
],
77
"defaultOpen": true
88
}

apps/website/lib/source.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { loader } from "fumadocs-core/source";
2-
import { createMDXSource } from "fumadocs-mdx";
32

4-
import { docs, meta } from "#/.source";
3+
import { docs } from "#/.source";
54

65
export const source = loader({
76
baseUrl: "/docs",
8-
source: createMDXSource(docs, meta),
7+
source: docs.toFumadocsSource(),
98
});

apps/website/source.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { remarkDocGen, remarkInstall } from "fumadocs-docgen";
33
import { defineConfig, defineDocs } from "fumadocs-mdx/config";
44
import { transformerTwoslash } from "fumadocs-twoslash";
55

6-
export const { meta, docs } = defineDocs({
6+
export const docs = defineDocs({
77
dir: "content/docs",
88
});
99

apps/website/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"erasableSyntaxOnly": true,
1616
"paths": {
1717
"#": ["."],
18-
"#/*": ["./*"]
18+
"#/*": ["./*"],
19+
"#/.source": ["./.source/index.ts"]
1920
},
2021
"plugins": [
2122
{

examples/dual-react-dom-lib/eslint.config.mjs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,39 +38,31 @@ export default tseslint.config(
3838
{
3939
files: TSCONFIG_NODE.include,
4040
ignores: TSCONFIG_NODE.exclude,
41+
extends: [tseslint.configs.disableTypeChecked],
4142
languageOptions: {
4243
parserOptions: {
4344
project: "./tsconfig.node.json",
4445
projectService: false,
4546
},
4647
},
4748
rules: {
48-
...tseslint.configs.disableTypeChecked.rules,
4949
"no-console": "off",
5050
},
5151
},
5252
// react specific configurations
5353
{
5454
files: TSCONFIG.include,
55-
...eslintPluginReactx.configs["recommended-type-checked"],
56-
},
57-
{
58-
files: TSCONFIG.include,
59-
...eslintPluginReactDom.configs.recommended,
60-
},
61-
{
62-
files: TSCONFIG.include,
63-
...eslintPluginReactWebApi.configs.recommended,
64-
},
65-
{
66-
files: TSCONFIG.include,
67-
...eslintPluginReactHooksExtra.configs.recommended,
68-
},
69-
{
70-
files: TSCONFIG.include,
55+
extends: [
56+
eslintPluginReactx.configs["recommended-type-checked"],
57+
eslintPluginReactDom.configs.recommended,
58+
eslintPluginReactWebApi.configs.recommended,
59+
eslintPluginReactHooksExtra.configs.recommended,
60+
],
7161
plugins: {
7262
"react-hooks": eslintPluginReactHooks,
7363
},
74-
rules: eslintPluginReactHooks.configs.recommended.rules,
64+
rules: {
65+
...eslintPluginReactHooks.configs.recommended.rules,
66+
},
7567
},
7668
);

examples/next-app/eslint.config.mjs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const GLOB_APP = ["app/**/*.{js,ts,jsx,tsx}"];
1414
const GLOB_CONFIG = ["**/*.config.{js,mjs,ts,tsx}"];
1515

1616
export default tseslint.config(
17+
gitignore(),
1718
{
1819
files: GLOB_TS,
1920
extends: [
@@ -40,26 +41,16 @@ export default tseslint.config(
4041
},
4142
{
4243
files: TSCONFIG.include,
44+
extends: [
45+
eslintReact.configs["recommended-type-checked"],
46+
eslintPluginReactRefresh.configs.recommended,
47+
],
4348
plugins: {
4449
"react-hooks": eslintPluginReactHooks,
45-
},
46-
rules: eslintPluginReactHooks.configs.recommended.rules,
47-
},
48-
{
49-
files: TSCONFIG.include,
50-
plugins: {
51-
"react-refresh": eslintPluginReactRefresh,
52-
},
53-
rules: {
54-
"react-refresh/only-export-components": "warn",
55-
},
56-
},
57-
{
58-
files: TSCONFIG.include,
59-
plugins: {
6050
"@next/next": eslintPluginNext,
6151
},
6252
rules: {
53+
...eslintPluginReactHooks.configs.recommended.rules,
6354
...eslintPluginNext.configs.recommended.rules,
6455
...eslintPluginNext.configs["core-web-vitals"].rules,
6556
},
@@ -72,11 +63,10 @@ export default tseslint.config(
7263
},
7364
{
7465
files: [...GLOB_JS, ...GLOB_CONFIG],
66+
extends: [tseslint.configs.disableTypeChecked],
7567
rules: {
76-
...tseslint.configs.disableTypeChecked.rules,
7768
"no-undef": "off",
7869
"no-console": "off",
7970
},
8071
},
81-
gitignore(),
8272
);

examples/vite-react-dom-app/eslint.config.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,29 @@ export default tseslint.config(
3535
{
3636
files: TSCONFIG_NODE.include,
3737
ignores: TSCONFIG_NODE.exclude,
38+
extends: [tseslint.configs.disableTypeChecked],
3839
languageOptions: {
3940
parserOptions: {
4041
project: "./tsconfig.node.json",
4142
projectService: false,
4243
},
4344
},
4445
rules: {
45-
...tseslint.configs.disableTypeChecked.rules,
4646
"no-console": "off",
4747
},
4848
},
49-
// React configuration
50-
{
51-
files: TSCONFIG.include,
52-
...eslintReact.configs["recommended-type-checked"],
53-
},
54-
// React Hooks configuration
49+
// react specific configurations
5550
{
5651
files: TSCONFIG.include,
52+
extends: [
53+
eslintReact.configs["recommended-type-checked"],
54+
eslintPluginReactRefresh.configs.recommended,
55+
],
5756
plugins: {
5857
"react-hooks": eslintPluginReactHooks,
5958
},
60-
rules: eslintPluginReactHooks.configs.recommended.rules,
61-
},
62-
// React Refresh configuration
63-
{
64-
files: TSCONFIG.include,
65-
plugins: {
66-
"react-refresh": eslintPluginReactRefresh,
67-
},
6859
rules: {
69-
"react-refresh/only-export-components": "warn",
60+
...eslintPluginReactHooks.configs.recommended.rules,
7061
},
7162
},
7263
);

examples/vite-react-dom-js-app/eslint.config.js

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import eslintReact from "@eslint-react/eslint-plugin";
33
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
44
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
55
import globals from "globals";
6+
import { defineConfig } from "eslint/config";
67

78
import JSCONFIG from "./jsconfig.json" with { type: "json" };
89
import JSCONFIG_NODE from "./jsconfig.node.json" with { type: "json" };
910

10-
export default [
11+
export default defineConfig([
1112
// base configuration for browser environment source files
1213
{
1314
files: JSCONFIG.include,
15+
extends: [eslintJs.configs.recommended],
1416
languageOptions: {
1517
globals: {
1618
...globals.browser,
@@ -21,45 +23,33 @@ export default [
2123
},
2224
},
2325
},
24-
rules: {
25-
...eslintJs.configs.recommended.rules,
26-
},
2726
},
2827
// base configuration for node environment source files (*.config.js, etc.)
2928
{
3029
files: JSCONFIG_NODE.include,
3130
ignores: JSCONFIG_NODE.exclude,
31+
extends: [eslintJs.configs.recommended],
3232
languageOptions: {
3333
globals: {
3434
...globals.node,
3535
},
3636
},
3737
rules: {
38-
...eslintJs.configs.recommended.rules,
3938
"no-console": "off",
4039
},
4140
},
42-
// React configuration
43-
{
44-
files: JSCONFIG.include,
45-
...eslintReact.configs.recommended,
46-
},
47-
// React Hooks configuration
41+
// react specific configurations
4842
{
4943
files: JSCONFIG.include,
44+
extends: [
45+
eslintReact.configs.recommended,
46+
eslintPluginReactRefresh.configs.recommended,
47+
],
5048
plugins: {
5149
"react-hooks": eslintPluginReactHooks,
5250
},
53-
rules: eslintPluginReactHooks.configs.recommended.rules,
54-
},
55-
// React Refresh configuration
56-
{
57-
files: JSCONFIG.include,
58-
plugins: {
59-
"react-refresh": eslintPluginReactRefresh,
60-
},
6151
rules: {
62-
"react-refresh/only-export-components": "warn",
52+
...eslintPluginReactHooks.configs.recommended.rules,
6353
},
6454
},
65-
];
55+
]);

examples/vite-react-dom-js-with-babel-eslint-parser-app/eslint.config.js

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import eslintPluginReactHooks from "eslint-plugin-react-hooks";
44
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
55
import babelEslintParser from "@babel/eslint-parser";
66
import globals from "globals";
7+
import { defineConfig } from "eslint/config";
78

89
import JSCONFIG from "./jsconfig.json" with { type: "json" };
910
import JSCONFIG_NODE from "./jsconfig.node.json" with { type: "json" };
1011

11-
export default [
12+
export default defineConfig([
1213
// base configuration for browser environment source files
1314
{
1415
files: JSCONFIG.include,
16+
extends: [eslintJs.configs.recommended],
1517
languageOptions: {
1618
globals: {
1719
...globals.browser,
@@ -26,14 +28,12 @@ export default [
2628
},
2729
},
2830
},
29-
rules: {
30-
...eslintJs.configs.recommended.rules,
31-
},
3231
},
3332
// base configuration for node environment source files (*.config.js, etc.)
3433
{
3534
files: JSCONFIG_NODE.include,
3635
ignores: JSCONFIG_NODE.exclude,
36+
extends: [eslintJs.configs.recommended],
3737
languageOptions: {
3838
globals: {
3939
...globals.node,
@@ -49,31 +49,21 @@ export default [
4949
},
5050
},
5151
rules: {
52-
...eslintJs.configs.recommended.rules,
5352
"no-console": "off",
5453
},
5554
},
56-
// React configuration
57-
{
58-
files: JSCONFIG.include,
59-
...eslintReact.configs.recommended,
60-
},
61-
// React Hooks configuration
55+
// react specific configurations
6256
{
6357
files: JSCONFIG.include,
58+
extends: [
59+
eslintReact.configs.recommended,
60+
eslintPluginReactRefresh.configs.recommended,
61+
],
6462
plugins: {
6563
"react-hooks": eslintPluginReactHooks,
6664
},
67-
rules: eslintPluginReactHooks.configs.recommended.rules,
68-
},
69-
// React Refresh configuration
70-
{
71-
files: JSCONFIG.include,
72-
plugins: {
73-
"react-refresh": eslintPluginReactRefresh,
74-
},
7565
rules: {
76-
"react-refresh/only-export-components": "warn",
66+
...eslintPluginReactHooks.configs.recommended.rules,
7767
},
7868
},
79-
];
69+
]);

0 commit comments

Comments
 (0)