Skip to content

Commit 9232ff4

Browse files
committed
docs(examples): update eslint configuration to use new plugin imports and include .d.ts files
1 parent 48727b3 commit 9232ff4

File tree

8 files changed

+56
-61
lines changed

8 files changed

+56
-61
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
declare module "@eslint/js";
2+
declare module "eslint-plugin-react-hooks";

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @ts-check
22

3-
import react from "@eslint-react/eslint-plugin";
4-
import js from "@eslint/js";
5-
import reactHooks from "eslint-plugin-react-hooks";
3+
import eslintJs from "@eslint/js";
4+
import eslintReact from "@eslint-react/eslint-plugin";
5+
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
66
import tseslint from "typescript-eslint";
77

88
import TSCONFIG from "./tsconfig.json" with { type: "json" };
@@ -14,7 +14,7 @@ export default tseslint.config(
1414
{
1515
files: GLOB_TS,
1616
extends: [
17-
js.configs.recommended,
17+
eslintJs.configs.recommended,
1818
tseslint.configs.recommended,
1919
],
2020
},
@@ -50,16 +50,14 @@ export default tseslint.config(
5050
// React configuration
5151
{
5252
files: TSCONFIG.include,
53-
...react.configs["recommended-type-checked"],
53+
...eslintReact.configs["recommended-type-checked"],
5454
},
5555
// React Hooks configuration
5656
{
5757
files: TSCONFIG.include,
5858
plugins: {
59-
// @ts-expect-error - Missing types
60-
"react-hooks": reactHooks,
59+
"react-hooks": eslintPluginReactHooks,
6160
},
62-
// @ts-ignore - Missing types
63-
rules: reactHooks.configs.recommended.rules,
61+
rules: eslintPluginReactHooks.configs.recommended.rules,
6462
},
6563
);

examples/next-app/eslint.config.mjs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// @ts-check
2-
3-
import react from "@eslint-react/eslint-plugin";
4-
import js from "@eslint/js";
5-
import next from "@next/eslint-plugin-next";
6-
import reactHooks from "eslint-plugin-react-hooks";
7-
import reactRefresh from "eslint-plugin-react-refresh";
1+
import eslintJs from "@eslint/js";
2+
import eslintReact from "@eslint-react/eslint-plugin";
3+
import eslintPluginNext from "@next/eslint-plugin-next";
4+
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
5+
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
86
import tseslint from "typescript-eslint";
97
import gitignore from "eslint-config-flat-gitignore";
108

@@ -19,7 +17,7 @@ export default tseslint.config(
1917
{
2018
files: GLOB_TS,
2119
extends: [
22-
js.configs.recommended,
20+
eslintJs.configs.recommended,
2321
tseslint.configs.recommended,
2422
],
2523
},
@@ -38,21 +36,19 @@ export default tseslint.config(
3836
},
3937
{
4038
files: TSCONFIG.include,
41-
...react.configs["recommended-type-checked"],
39+
...eslintReact.configs["recommended-type-checked"],
4240
},
4341
{
4442
files: TSCONFIG.include,
4543
plugins: {
46-
// @ts-expect-error - Missing types
47-
"react-hooks": reactHooks,
44+
"react-hooks": eslintPluginReactHooks,
4845
},
49-
// @ts-ignore - Missing types
50-
rules: reactHooks.configs.recommended.rules,
46+
rules: eslintPluginReactHooks.configs.recommended.rules,
5147
},
5248
{
5349
files: TSCONFIG.include,
5450
plugins: {
55-
"react-refresh": reactRefresh,
51+
"react-refresh": eslintPluginReactRefresh,
5652
},
5753
rules: {
5854
"react-refresh/only-export-components": "warn",
@@ -61,11 +57,11 @@ export default tseslint.config(
6157
{
6258
files: TSCONFIG.include,
6359
plugins: {
64-
"@next/next": next,
60+
"@next/next": eslintPluginNext,
6561
},
6662
rules: {
67-
...next.configs.recommended.rules,
68-
...next.configs["core-web-vitals"].rules,
63+
...eslintPluginNext.configs.recommended.rules,
64+
...eslintPluginNext.configs["core-web-vitals"].rules,
6965
},
7066
},
7167
{

examples/next-app/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"include": [
2828
"**/*.ts",
2929
"**/*.tsx",
30+
"*.d.ts",
3031
"next-env.d.ts",
3132
".next/types/**/*.ts"
3233
],

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// @ts-check
22

3-
import react from "@eslint-react/eslint-plugin";
4-
import js from "@eslint/js";
5-
import reactHooks from "eslint-plugin-react-hooks";
6-
import reactRefresh from "eslint-plugin-react-refresh";
3+
import eslintJs from "@eslint/js";
4+
import eslintReact from "@eslint-react/eslint-plugin";
5+
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
6+
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
77
import tseslint from "typescript-eslint";
88

99
import TSCONFIG from "./tsconfig.json" with { type: "json" };
@@ -15,7 +15,7 @@ export default tseslint.config(
1515
{
1616
files: GLOB_TS,
1717
extends: [
18-
js.configs.recommended,
18+
eslintJs.configs.recommended,
1919
tseslint.configs.recommended,
2020
],
2121
},
@@ -51,23 +51,21 @@ export default tseslint.config(
5151
// React configuration
5252
{
5353
files: TSCONFIG.include,
54-
...react.configs["recommended-type-checked"],
54+
...eslintReact.configs["recommended-type-checked"],
5555
},
5656
// React Hooks configuration
5757
{
5858
files: TSCONFIG.include,
5959
plugins: {
60-
// @ts-expect-error - Missing types
61-
"react-hooks": reactHooks,
60+
"react-hooks": eslintPluginReactHooks,
6261
},
63-
// @ts-ignore - Missing types
64-
rules: reactHooks.configs.recommended.rules,
62+
rules: eslintPluginReactHooks.configs.recommended.rules,
6563
},
6664
// React Refresh configuration
6765
{
6866
files: TSCONFIG.include,
6967
plugins: {
70-
"react-refresh": reactRefresh,
68+
"react-refresh": eslintPluginReactRefresh,
7169
},
7270
rules: {
7371
"react-refresh/only-export-components": "warn",

examples/vite-react-dom-app/tsconfig.node.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"include": [
1616
"*.ts",
1717
"*.cts",
18-
"*.mts"
18+
"*.mts",
19+
"*.d.ts"
1920
],
2021
"exclude": [
2122
"node_modules",

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import js from "@eslint/js";
2-
import react from "@eslint-react/eslint-plugin";
3-
import reactHooks from "eslint-plugin-react-hooks";
4-
import reactRefresh from "eslint-plugin-react-refresh";
1+
import eslintJs from "@eslint/js";
2+
import eslintReact from "@eslint-react/eslint-plugin";
3+
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
4+
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
55
import globals from "globals";
66

77
import JSCONFIG from "./jsconfig.json" with { type: "json" };
@@ -22,7 +22,7 @@ export default [
2222
},
2323
},
2424
rules: {
25-
...js.configs.recommended.rules,
25+
...eslintJs.configs.recommended.rules,
2626
},
2727
},
2828
// base configuration for node environment source files (*.config.js, etc.)
@@ -35,28 +35,28 @@ export default [
3535
},
3636
},
3737
rules: {
38-
...js.configs.recommended.rules,
38+
...eslintJs.configs.recommended.rules,
3939
"no-console": "off",
4040
},
4141
},
4242
// React configuration
4343
{
4444
files: JSCONFIG.include,
45-
...react.configs.recommended,
45+
...eslintReact.configs.recommended,
4646
},
4747
// React Hooks configuration
4848
{
4949
files: JSCONFIG.include,
5050
plugins: {
51-
"react-hooks": reactHooks,
51+
"react-hooks": eslintPluginReactHooks,
5252
},
53-
rules: reactHooks.configs.recommended.rules,
53+
rules: eslintPluginReactHooks.configs.recommended.rules,
5454
},
5555
// React Refresh configuration
5656
{
5757
files: JSCONFIG.include,
5858
plugins: {
59-
"react-refresh": reactRefresh,
59+
"react-refresh": eslintPluginReactRefresh,
6060
},
6161
rules: {
6262
"react-refresh/only-export-components": "warn",

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import js from "@eslint/js";
2-
import react from "@eslint-react/eslint-plugin";
3-
import reactHooks from "eslint-plugin-react-hooks";
4-
import reactRefresh from "eslint-plugin-react-refresh";
5-
import parser from "@babel/eslint-parser";
1+
import eslintJs from "@eslint/js";
2+
import eslintReact from "@eslint-react/eslint-plugin";
3+
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
4+
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
5+
import babelEslintParser from "@babel/eslint-parser";
66
import globals from "globals";
77

88
import JSCONFIG from "./jsconfig.json" with { type: "json" };
@@ -16,7 +16,7 @@ export default [
1616
globals: {
1717
...globals.browser,
1818
},
19-
parser,
19+
parser: babelEslintParser,
2020
parserOptions: {
2121
requireConfigFile: false,
2222
babelOptions: {
@@ -27,7 +27,7 @@ export default [
2727
},
2828
},
2929
rules: {
30-
...js.configs.recommended.rules,
30+
...eslintJs.configs.recommended.rules,
3131
},
3232
},
3333
// base configuration for node environment source files (*.config.js, etc.)
@@ -38,7 +38,7 @@ export default [
3838
globals: {
3939
...globals.node,
4040
},
41-
parser,
41+
parser: babelEslintParser,
4242
parserOptions: {
4343
requireConfigFile: false,
4444
babelOptions: {
@@ -49,28 +49,28 @@ export default [
4949
},
5050
},
5151
rules: {
52-
...js.configs.recommended.rules,
52+
...eslintJs.configs.recommended.rules,
5353
"no-console": "off",
5454
},
5555
},
5656
// React configuration
5757
{
5858
files: JSCONFIG.include,
59-
...react.configs.recommended,
59+
...eslintReact.configs.recommended,
6060
},
6161
// React Hooks configuration
6262
{
6363
files: JSCONFIG.include,
6464
plugins: {
65-
"react-hooks": reactHooks,
65+
"react-hooks": eslintPluginReactHooks,
6666
},
67-
rules: reactHooks.configs.recommended.rules,
67+
rules: eslintPluginReactHooks.configs.recommended.rules,
6868
},
6969
// React Refresh configuration
7070
{
7171
files: JSCONFIG.include,
7272
plugins: {
73-
"react-refresh": reactRefresh,
73+
"react-refresh": eslintPluginReactRefresh,
7474
},
7575
rules: {
7676
"react-refresh/only-export-components": "warn",

0 commit comments

Comments
 (0)