diff --git a/apps/website/content/docs/getting-started/javascript.mdx b/apps/website/content/docs/getting-started/javascript.mdx index 6b30506eab..ceec4b0b85 100644 --- a/apps/website/content/docs/getting-started/javascript.mdx +++ b/apps/website/content/docs/getting-started/javascript.mdx @@ -14,11 +14,15 @@ npm install --save-dev eslint @eslint/js @eslint-react/eslint-plugin ```js title="eslint.config.js" import eslintJs from "@eslint/js"; import eslintReact from "@eslint-react/eslint-plugin"; +import { defineConfig } from "eslint/config"; -export default [ +export default defineConfig([ { files: ["**/*.js", "**/*.jsx"], - ...eslintJs.configs.recommended, + extends: [ + eslintJs.configs.recommended, + eslintReact.configs.recommended, + ], languageOptions: { parserOptions: { ecmaFeatures: { @@ -26,17 +30,12 @@ export default [ }, }, }, - }, - { - files: ["**/*.js", "**/*.jsx"], - ...eslintReact.configs.recommended, - }, - { - files: ["**/*.js", "**/*.jsx"], rules: { + // Add `globals` if you need this rule + "no-undef": "off", // Put rules you want to override here "@eslint-react/prefer-shorthand-boolean": "warn", }, }, -]; +]); ``` diff --git a/apps/website/content/docs/getting-started/meta.json b/apps/website/content/docs/getting-started/meta.json index c227c05ad6..198368d743 100644 --- a/apps/website/content/docs/getting-started/meta.json +++ b/apps/website/content/docs/getting-started/meta.json @@ -1,8 +1,8 @@ { "title": "Getting Started", "pages": [ - "typescript", - "javascript" + "javascript", + "typescript" ], "defaultOpen": true } diff --git a/apps/website/lib/source.ts b/apps/website/lib/source.ts index 2242779886..7857627920 100644 --- a/apps/website/lib/source.ts +++ b/apps/website/lib/source.ts @@ -1,9 +1,8 @@ import { loader } from "fumadocs-core/source"; -import { createMDXSource } from "fumadocs-mdx"; -import { docs, meta } from "#/.source"; +import { docs } from "#/.source"; export const source = loader({ baseUrl: "/docs", - source: createMDXSource(docs, meta), + source: docs.toFumadocsSource(), }); diff --git a/apps/website/source.config.ts b/apps/website/source.config.ts index f95ecb6cf9..6770f64d7d 100644 --- a/apps/website/source.config.ts +++ b/apps/website/source.config.ts @@ -3,7 +3,7 @@ import { remarkDocGen, remarkInstall } from "fumadocs-docgen"; import { defineConfig, defineDocs } from "fumadocs-mdx/config"; import { transformerTwoslash } from "fumadocs-twoslash"; -export const { meta, docs } = defineDocs({ +export const docs = defineDocs({ dir: "content/docs", }); diff --git a/apps/website/tsconfig.json b/apps/website/tsconfig.json index 80b8d66263..56b1486c6a 100644 --- a/apps/website/tsconfig.json +++ b/apps/website/tsconfig.json @@ -15,7 +15,8 @@ "erasableSyntaxOnly": true, "paths": { "#": ["."], - "#/*": ["./*"] + "#/*": ["./*"], + "#/.source": ["./.source/index.ts"] }, "plugins": [ { diff --git a/examples/dual-react-dom-lib/eslint.config.mjs b/examples/dual-react-dom-lib/eslint.config.mjs index 913c4cb5e6..10c67b3507 100644 --- a/examples/dual-react-dom-lib/eslint.config.mjs +++ b/examples/dual-react-dom-lib/eslint.config.mjs @@ -38,6 +38,7 @@ export default tseslint.config( { files: TSCONFIG_NODE.include, ignores: TSCONFIG_NODE.exclude, + extends: [tseslint.configs.disableTypeChecked], languageOptions: { parserOptions: { project: "./tsconfig.node.json", @@ -45,32 +46,23 @@ export default tseslint.config( }, }, rules: { - ...tseslint.configs.disableTypeChecked.rules, "no-console": "off", }, }, // react specific configurations { files: TSCONFIG.include, - ...eslintPluginReactx.configs["recommended-type-checked"], - }, - { - files: TSCONFIG.include, - ...eslintPluginReactDom.configs.recommended, - }, - { - files: TSCONFIG.include, - ...eslintPluginReactWebApi.configs.recommended, - }, - { - files: TSCONFIG.include, - ...eslintPluginReactHooksExtra.configs.recommended, - }, - { - files: TSCONFIG.include, + extends: [ + eslintPluginReactx.configs["recommended-type-checked"], + eslintPluginReactDom.configs.recommended, + eslintPluginReactWebApi.configs.recommended, + eslintPluginReactHooksExtra.configs.recommended, + ], plugins: { "react-hooks": eslintPluginReactHooks, }, - rules: eslintPluginReactHooks.configs.recommended.rules, + rules: { + ...eslintPluginReactHooks.configs.recommended.rules, + }, }, ); diff --git a/examples/next-app/eslint.config.mjs b/examples/next-app/eslint.config.mjs index 16dab1e0a6..31388f0881 100644 --- a/examples/next-app/eslint.config.mjs +++ b/examples/next-app/eslint.config.mjs @@ -14,6 +14,7 @@ const GLOB_APP = ["app/**/*.{js,ts,jsx,tsx}"]; const GLOB_CONFIG = ["**/*.config.{js,mjs,ts,tsx}"]; export default tseslint.config( + gitignore(), { files: GLOB_TS, extends: [ @@ -40,26 +41,16 @@ export default tseslint.config( }, { files: TSCONFIG.include, + extends: [ + eslintReact.configs["recommended-type-checked"], + eslintPluginReactRefresh.configs.recommended, + ], plugins: { "react-hooks": eslintPluginReactHooks, - }, - rules: eslintPluginReactHooks.configs.recommended.rules, - }, - { - files: TSCONFIG.include, - plugins: { - "react-refresh": eslintPluginReactRefresh, - }, - rules: { - "react-refresh/only-export-components": "warn", - }, - }, - { - files: TSCONFIG.include, - plugins: { "@next/next": eslintPluginNext, }, rules: { + ...eslintPluginReactHooks.configs.recommended.rules, ...eslintPluginNext.configs.recommended.rules, ...eslintPluginNext.configs["core-web-vitals"].rules, }, @@ -72,11 +63,10 @@ export default tseslint.config( }, { files: [...GLOB_JS, ...GLOB_CONFIG], + extends: [tseslint.configs.disableTypeChecked], rules: { - ...tseslint.configs.disableTypeChecked.rules, "no-undef": "off", "no-console": "off", }, }, - gitignore(), ); diff --git a/examples/vite-react-dom-app/eslint.config.js b/examples/vite-react-dom-app/eslint.config.js index 68d7c677f7..ccdbcdc280 100644 --- a/examples/vite-react-dom-app/eslint.config.js +++ b/examples/vite-react-dom-app/eslint.config.js @@ -35,6 +35,7 @@ export default tseslint.config( { files: TSCONFIG_NODE.include, ignores: TSCONFIG_NODE.exclude, + extends: [tseslint.configs.disableTypeChecked], languageOptions: { parserOptions: { project: "./tsconfig.node.json", @@ -42,31 +43,21 @@ export default tseslint.config( }, }, rules: { - ...tseslint.configs.disableTypeChecked.rules, "no-console": "off", }, }, - // React configuration - { - files: TSCONFIG.include, - ...eslintReact.configs["recommended-type-checked"], - }, - // React Hooks configuration + // react specific configurations { files: TSCONFIG.include, + extends: [ + eslintReact.configs["recommended-type-checked"], + eslintPluginReactRefresh.configs.recommended, + ], plugins: { "react-hooks": eslintPluginReactHooks, }, - rules: eslintPluginReactHooks.configs.recommended.rules, - }, - // React Refresh configuration - { - files: TSCONFIG.include, - plugins: { - "react-refresh": eslintPluginReactRefresh, - }, rules: { - "react-refresh/only-export-components": "warn", + ...eslintPluginReactHooks.configs.recommended.rules, }, }, ); diff --git a/examples/vite-react-dom-js-app/eslint.config.js b/examples/vite-react-dom-js-app/eslint.config.js index 56aedd5e00..bde45b0af3 100644 --- a/examples/vite-react-dom-js-app/eslint.config.js +++ b/examples/vite-react-dom-js-app/eslint.config.js @@ -3,14 +3,16 @@ import eslintReact from "@eslint-react/eslint-plugin"; import eslintPluginReactHooks from "eslint-plugin-react-hooks"; import eslintPluginReactRefresh from "eslint-plugin-react-refresh"; import globals from "globals"; +import { defineConfig } from "eslint/config"; import JSCONFIG from "./jsconfig.json" with { type: "json" }; import JSCONFIG_NODE from "./jsconfig.node.json" with { type: "json" }; -export default [ +export default defineConfig([ // base configuration for browser environment source files { files: JSCONFIG.include, + extends: [eslintJs.configs.recommended], languageOptions: { globals: { ...globals.browser, @@ -21,45 +23,33 @@ export default [ }, }, }, - rules: { - ...eslintJs.configs.recommended.rules, - }, }, // base configuration for node environment source files (*.config.js, etc.) { files: JSCONFIG_NODE.include, ignores: JSCONFIG_NODE.exclude, + extends: [eslintJs.configs.recommended], languageOptions: { globals: { ...globals.node, }, }, rules: { - ...eslintJs.configs.recommended.rules, "no-console": "off", }, }, - // React configuration - { - files: JSCONFIG.include, - ...eslintReact.configs.recommended, - }, - // React Hooks configuration + // react specific configurations { files: JSCONFIG.include, + extends: [ + eslintReact.configs.recommended, + eslintPluginReactRefresh.configs.recommended, + ], plugins: { "react-hooks": eslintPluginReactHooks, }, - rules: eslintPluginReactHooks.configs.recommended.rules, - }, - // React Refresh configuration - { - files: JSCONFIG.include, - plugins: { - "react-refresh": eslintPluginReactRefresh, - }, rules: { - "react-refresh/only-export-components": "warn", + ...eslintPluginReactHooks.configs.recommended.rules, }, }, -]; +]); diff --git a/examples/vite-react-dom-js-with-babel-eslint-parser-app/eslint.config.js b/examples/vite-react-dom-js-with-babel-eslint-parser-app/eslint.config.js index b5dea78e5e..1d9ab96724 100644 --- a/examples/vite-react-dom-js-with-babel-eslint-parser-app/eslint.config.js +++ b/examples/vite-react-dom-js-with-babel-eslint-parser-app/eslint.config.js @@ -4,14 +4,16 @@ import eslintPluginReactHooks from "eslint-plugin-react-hooks"; import eslintPluginReactRefresh from "eslint-plugin-react-refresh"; import babelEslintParser from "@babel/eslint-parser"; import globals from "globals"; +import { defineConfig } from "eslint/config"; import JSCONFIG from "./jsconfig.json" with { type: "json" }; import JSCONFIG_NODE from "./jsconfig.node.json" with { type: "json" }; -export default [ +export default defineConfig([ // base configuration for browser environment source files { files: JSCONFIG.include, + extends: [eslintJs.configs.recommended], languageOptions: { globals: { ...globals.browser, @@ -26,14 +28,12 @@ export default [ }, }, }, - rules: { - ...eslintJs.configs.recommended.rules, - }, }, // base configuration for node environment source files (*.config.js, etc.) { files: JSCONFIG_NODE.include, ignores: JSCONFIG_NODE.exclude, + extends: [eslintJs.configs.recommended], languageOptions: { globals: { ...globals.node, @@ -49,31 +49,21 @@ export default [ }, }, rules: { - ...eslintJs.configs.recommended.rules, "no-console": "off", }, }, - // React configuration - { - files: JSCONFIG.include, - ...eslintReact.configs.recommended, - }, - // React Hooks configuration + // react specific configurations { files: JSCONFIG.include, + extends: [ + eslintReact.configs.recommended, + eslintPluginReactRefresh.configs.recommended, + ], plugins: { "react-hooks": eslintPluginReactHooks, }, - rules: eslintPluginReactHooks.configs.recommended.rules, - }, - // React Refresh configuration - { - files: JSCONFIG.include, - plugins: { - "react-refresh": eslintPluginReactRefresh, - }, rules: { - "react-refresh/only-export-components": "warn", + ...eslintPluginReactHooks.configs.recommended.rules, }, }, -]; +]); diff --git a/examples/vite-react-dom-with-ts-blank-eslint-parser-app/eslint.config.js b/examples/vite-react-dom-with-ts-blank-eslint-parser-app/eslint.config.js index 5a43a8fc49..54f1c17579 100644 --- a/examples/vite-react-dom-with-ts-blank-eslint-parser-app/eslint.config.js +++ b/examples/vite-react-dom-with-ts-blank-eslint-parser-app/eslint.config.js @@ -10,10 +10,11 @@ import globals from "globals"; import TSCONFIG from "./tsconfig.json" with { type: "json" }; import TSCONFIG_NODE from "./tsconfig.node.json" with { type: "json" }; -export default [ +export default tseslint.config( // base configuration for browser environment source files { files: TSCONFIG.include, + extends: [eslintJs.configs.recommended], languageOptions: { globals: { ...globals.browser, @@ -21,7 +22,6 @@ export default [ parser: tsBlankEslintParser, }, rules: { - ...eslintJs.configs.recommended.rules, "no-unused-vars": "off", }, }, @@ -29,6 +29,7 @@ export default [ { files: TSCONFIG_NODE.include, ignores: TSCONFIG_NODE.exclude, + extends: [eslintJs.configs.recommended], languageOptions: { globals: { ...globals.node, @@ -36,31 +37,21 @@ export default [ parser: tsBlankEslintParser, }, rules: { - ...eslintJs.configs.recommended.rules, "no-console": "off", }, }, - // React configuration - { - files: TSCONFIG.include, - ...eslintReact.configs["recommended-typescript"], - }, - // React Hooks configuration + // react specific configurations { files: TSCONFIG.include, + extends: [ + eslintReact.configs["recommended-typescript"], + eslintPluginReactRefresh.configs.recommended, + ], plugins: { "react-hooks": eslintPluginReactHooks, }, - rules: eslintPluginReactHooks.configs.recommended.rules, - }, - // React Refresh configuration - { - files: TSCONFIG.include, - plugins: { - "react-refresh": eslintPluginReactRefresh, - }, rules: { - "react-refresh/only-export-components": "warn", + ...eslintPluginReactHooks.configs.recommended.rules, }, }, -]; +);