Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pkgs/configs/eslint.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-deprecated */
import js from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import pluginDeMorgan from "eslint-plugin-de-morgan";
Expand Down
1 change: 1 addition & 0 deletions .pkgs/configs/eslint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-deprecated */
import js from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import pluginDeMorgan from "eslint-plugin-de-morgan";
Expand Down
56 changes: 29 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,40 +69,42 @@ npm install --save-dev typescript-eslint @eslint-react/eslint-plugin
```js
// eslint.config.js

// @ts-check
import eslintReact from "@eslint-react/eslint-plugin";
import eslintJs from "@eslint/js";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";

export default tseslint.config({
files: ["**/*.ts", "**/*.tsx"],

// Extend recommended rule sets from:
// 1. ESLint JS's recommended rules
// 2. TypeScript ESLint recommended rules
// 3. ESLint React's recommended-typescript rules
extends: [
eslintJs.configs.recommended,
tseslint.configs.recommended,
eslintReact.configs["recommended-typescript"],
],

// Configure language/parsing options
languageOptions: {
// Use TypeScript ESLint parser for TypeScript files
parser: tseslint.parser,
parserOptions: {
// Enable project service for better TypeScript integration
projectService: true,
tsconfigRootDir: import.meta.dirname,
export default defineConfig([
{
files: ["**/*.ts", "**/*.tsx"],

// Extend recommended rule sets from:
// 1. ESLint JS's recommended rules
// 2. TypeScript ESLint recommended rules
// 3. ESLint React's recommended-typescript rules
extends: [
eslintJs.configs.recommended,
tseslint.configs.recommended,
eslintReact.configs["recommended-typescript"],
],

// Configure language/parsing options
languageOptions: {
// Use TypeScript ESLint parser for TypeScript files
parser: tseslint.parser,
parserOptions: {
// Enable project service for better TypeScript integration
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},

// Custom rule overrides (modify rule levels or disable rules)
rules: {
"@eslint-react/no-missing-key": "warn",
// Custom rule overrides (modify rule levels or disable rules)
rules: {
"@eslint-react/no-missing-key": "warn",
},
},
});
]);
```

[Full Installation Guide ↗](https://eslint-react.xyz/docs/getting-started/typescript)
Expand Down
61 changes: 31 additions & 30 deletions apps/website/content/docs/getting-started/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,50 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
<Step>
## Configure ESLint

```js title="eslint.config.js"
// @ts-check
import eslintJs from "@eslint/js";
```ts title="eslint.config.js"
import eslintReact from "@eslint-react/eslint-plugin";
import eslintJs from "@eslint/js";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";

export default tseslint.config({
files: ["**/*.ts", "**/*.tsx"],

// Extend recommended rule sets from:
// 1. ESLint JS's recommended rules
// 2. TypeScript ESLint recommended rules
// 3. ESLint React's recommended-typescript rules
extends: [
eslintJs.configs.recommended,
tseslint.configs.recommended,
eslintReact.configs["recommended-typescript"],
],

// Configure language/parsing options
languageOptions: {
// Use TypeScript ESLint parser for TypeScript files
parser: tseslint.parser,
parserOptions: {
// Enable project service for better TypeScript integration
projectService: true,
tsconfigRootDir: import.meta.dirname,
export default defineConfig([
{
files: ["**/*.ts", "**/*.tsx"],

// Extend recommended rule sets from:
// 1. ESLint JS's recommended rules
// 2. TypeScript ESLint recommended rules
// 3. ESLint React's recommended-typescript rules
extends: [
eslintJs.configs.recommended,
tseslint.configs.recommended,
eslintReact.configs["recommended-typescript"],
],

// Configure language/parsing options
languageOptions: {
// Use TypeScript ESLint parser for TypeScript files
parser: tseslint.parser,
parserOptions: {
// Enable project service for better TypeScript integration
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},

// Custom rule overrides (modify rule levels or disable rules)
rules: {
"@eslint-react/no-missing-key": "warn",
// Custom rule overrides (modify rule levels or disable rules)
rules: {
"@eslint-react/no-missing-key": "warn",
},
},
});
]);
```
</Step>

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

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

export default [
Expand Down
5 changes: 3 additions & 2 deletions apps/website/eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { recommended as fastImportRecommended } from "eslint-plugin-fast-import"
import pluginReactHooks from "eslint-plugin-react-hooks";
import pluginReactRefresh from "eslint-plugin-react-refresh";
import { globalIgnores } from "eslint/config";
import { defineConfig } from "eslint/config";
import url from "node:url";
import tseslint from "typescript-eslint";

Expand All @@ -26,7 +27,7 @@ const GLOB_IGNORES = [

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

export default tseslint.config(
export default defineConfig([
gitignore(),
globalIgnores(GLOB_IGNORES),
{
Expand Down Expand Up @@ -107,4 +108,4 @@ export default tseslint.config(
"no-undef": "off",
},
},
);
] as never);
8 changes: 4 additions & 4 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import markdown from "@eslint/markdown";
import gitIgnores from "eslint-config-flat-gitignore";
import { recommended as fastImportRecommended } from "eslint-plugin-fast-import";
import pluginVitest from "eslint-plugin-vitest";
import { globalIgnores } from "eslint/config";
import { defineConfig, globalIgnores } from "eslint/config";
import tseslint from "typescript-eslint";

import * as configs from "@local/configs/eslint";
Expand Down Expand Up @@ -36,7 +36,7 @@ const packagesTsConfigs = [
"packages/*/*/tsconfig.json",
];

export default tseslint.config(
export default defineConfig([
gitIgnores(),
globalIgnores(GLOB_IGNORES),
{
Expand All @@ -57,7 +57,7 @@ export default tseslint.config(
},
{
extends: [
...tseslint.configs.strictTypeChecked,
tseslint.configs.strictTypeChecked,
configs.typescript,
fastImportRecommended({ rootDir: dirname }),
],
Expand Down Expand Up @@ -120,4 +120,4 @@ export default tseslint.config(
"local/avoid-multiline-template-expression": "off",
},
},
);
] as never);
37 changes: 20 additions & 17 deletions packages/plugins/eslint-plugin-react-debug/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,30 @@ npm install --save-dev eslint-plugin-react-debug
// @ts-check
import js from "@eslint/js";
import reactDebug from "eslint-plugin-react-debug";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";

export default tseslint.config({
files: ["**/*.ts", "**/*.tsx"],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactDebug.configs.all,
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
export default defineConfig([
{
files: ["**/*.ts", "**/*.tsx"],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactDebug.configs.all,
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// Put rules you want to override here
"react-debug/function-component": "warn",
},
},
rules: {
// Put rules you want to override here
"react-debug/function-component": "warn",
},
});
]);
```

## Rules
Expand Down
37 changes: 20 additions & 17 deletions packages/plugins/eslint-plugin-react-dom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,30 @@ npm install --save-dev eslint-plugin-react-dom
// @ts-check
import js from "@eslint/js";
import reactDom from "eslint-plugin-react-dom";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";

export default tseslint.config({
files: ["**/*.ts", "**/*.tsx"],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactDom.configs.recommended,
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
export default defineConfig([
{
files: ["**/*.ts", "**/*.tsx"],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactDom.configs.recommended,
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// Put rules you want to override here
"react-dom/no-dangerously-set-innerhtml": "warn",
},
},
rules: {
// Put rules you want to override here
"react-dom/no-dangerously-set-innerhtml": "warn",
},
});
]);
```

## Rules
Expand Down
35 changes: 19 additions & 16 deletions packages/plugins/eslint-plugin-react-hooks-extra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,29 @@ npm install --save-dev eslint-plugin-react-hooks-extra
// @ts-check
import js from "@eslint/js";
import reactHooksExtra from "eslint-plugin-react-hooks-extra";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";

export default tseslint.config({
files: ["**/*.ts", "**/*.tsx"],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooksExtra.configs.recommended,
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
export default defineConfig([
{
files: ["**/*.ts", "**/*.tsx"],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooksExtra.configs.recommended,
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// Put rules you want to override here
},
},
rules: {
// Put rules you want to override here
},
});
]);
```

## Rules
Expand Down
Loading