Skip to content

Commit d84460a

Browse files
authored
feat(create-vite): add eslint to React templates (#12801)
1 parent 251d0ab commit d84460a

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = defineConfig({
1010
'plugin:@typescript-eslint/recommended',
1111
'plugin:regexp/recommended',
1212
],
13+
ignorePatterns: ['packages/create-vite/template-**'],
1314
plugins: ['import', 'regexp'],
1415
parser: '@typescript-eslint/parser',
1516
parserOptions: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
env: { browser: true, es2020: true },
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:react-hooks/recommended',
7+
],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
10+
plugins: ['react-refresh'],
11+
rules: {
12+
'react-refresh/only-export-components': 'warn',
13+
},
14+
}

packages/create-vite/template-react-ts/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc && vite build",
9+
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
910
"preview": "vite preview"
1011
},
1112
"dependencies": {
@@ -15,7 +16,12 @@
1516
"devDependencies": {
1617
"@types/react": "^18.0.28",
1718
"@types/react-dom": "^18.0.11",
19+
"@typescript-eslint/eslint-plugin": "^5.57.1",
20+
"@typescript-eslint/parser": "^5.57.1",
1821
"@vitejs/plugin-react": "^4.0.0-beta.0",
22+
"eslint": "^8.38.0",
23+
"eslint-plugin-react-hooks": "^4.6.0",
24+
"eslint-plugin-react-refresh": "^0.3.4",
1925
"typescript": "^5.0.2",
2026
"vite": "^4.3.0-beta.2"
2127
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
env: { browser: true, es2020: true },
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:react/recommended',
6+
'plugin:react/jsx-runtime',
7+
'plugin:react-hooks/recommended',
8+
],
9+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
10+
settings: { react: { version: '18.2' } },
11+
plugins: ['react-refresh'],
12+
rules: {
13+
'react-refresh/only-export-components': 'warn',
14+
},
15+
}

packages/create-vite/template-react/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "vite build",
9+
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
910
"preview": "vite preview"
1011
},
1112
"dependencies": {
@@ -16,6 +17,10 @@
1617
"@types/react": "^18.0.28",
1718
"@types/react-dom": "^18.0.11",
1819
"@vitejs/plugin-react": "^4.0.0-beta.0",
20+
"eslint": "^8.38.0",
21+
"eslint-plugin-react": "^7.32.2",
22+
"eslint-plugin-react-hooks": "^4.6.0",
23+
"eslint-plugin-react-refresh": "^0.3.4",
1924
"vite": "^4.3.0-beta.2"
2025
}
2126
}

0 commit comments

Comments
 (0)