Skip to content

Commit 26546b1

Browse files
committed
Chore: update eslint config as consist
1 parent 1bb5010 commit 26546b1

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed
Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,58 @@
1-
import { defineConfig } from "eslint/config";
2-
import js from '@eslint/js'
1+
import { resolve } from "node:path";
2+
import { cwd } from "node:process";
33
import globals from 'globals'
4-
import reactHooks from 'eslint-plugin-react-hooks'
5-
import reactRefresh from 'eslint-plugin-react-refresh'
4+
import { defineConfig } from "eslint/config";
5+
import eslint from '@eslint/js'
66
import tseslint from 'typescript-eslint'
7+
import tsParser from "@typescript-eslint/parser";
8+
import reactRefreshPlugin from 'eslint-plugin-react-refresh'
9+
import reactHooksPlugin from 'eslint-plugin-react-hooks'
10+
11+
const PACKAGE_ROOT = resolve(cwd());
712

813
export default defineConfig(
9-
{ ignores: ['dist'] },
14+
eslint.configs.recommended,
15+
...tseslint.configs.recommended,
16+
reactHooksPlugin.configs.flat.recommended,
17+
{
18+
languageOptions: {
19+
parserOptions: {
20+
tsconfigRootDir: PACKAGE_ROOT,
21+
projectService: true,
22+
},
23+
},
24+
},
1025
{
11-
extends: [js.configs.recommended, ...tseslint.configs.recommended],
1226
files: ['**/*.{ts,tsx}'],
1327
languageOptions: {
14-
ecmaVersion: 2020,
15-
globals: globals.browser,
28+
parser: tsParser,
29+
parserOptions: {
30+
project: ["tsconfig.json"],
31+
tsconfigRootDir: cwd(),
32+
projectService: true,
33+
34+
ecmaVersion: "latest",
35+
sourceType: "module",
36+
globals: { ...globals.browser, ...globals.es2020 },
37+
}
1638
},
1739
plugins: {
18-
'react-hooks': reactHooks,
19-
'react-refresh': reactRefresh,
40+
'react-hooks': reactHooksPlugin,
41+
'react-refresh': reactRefreshPlugin,
2042
},
2143
rules: {
22-
...reactHooks.configs.recommended.rules,
44+
...reactHooksPlugin.configs.recommended.rules,
2345
'react-refresh/only-export-components': [
2446
'warn',
2547
{ allowConstantExport: true },
2648
],
2749
},
2850
},
51+
{
52+
files: ["*.js", "*.cjs", "*.mjs"],
53+
extends: [tseslint.configs.disableTypeChecked],
54+
},
55+
{
56+
ignores: ["dist/**"],
57+
},
2958
)

examples/react-babel/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@types/react": "^19.2.2",
4242
"@types/react-dom": "^19.2.2",
4343
"@types/scheduler": "^0.26.0",
44+
"@typescript-eslint/parser": "^8.46.2",
4445
"@vitejs/plugin-react": "^5.0.4",
4546
"eslint": "^9.38.0",
4647
"eslint-plugin-react-hooks": "^7.0.0",

examples/react-swc/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default defineConfig(
4040
"react-hooks": reactHooksPlugin,
4141
},
4242
rules: {
43+
...reactHooksPlugin.configs.recommended.rules,
4344
"react-refresh/only-export-components": [
4445
"warn",
4546
{ allowConstantExport: true },

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5816,6 +5816,7 @@ __metadata:
58165816
"@types/react": "npm:^19.2.2"
58175817
"@types/react-dom": "npm:^19.2.2"
58185818
"@types/scheduler": "npm:^0.26.0"
5819+
"@typescript-eslint/parser": "npm:^8.46.2"
58195820
"@vanilla-extract/css": "npm:^1.17.4"
58205821
"@vanilla-extract/css-utils": "npm:^0.1.6"
58215822
"@vanilla-extract/private": "npm:^1.0.9"

0 commit comments

Comments
 (0)