Skip to content

Commit e0b2061

Browse files
committed
new installations:
- eslint (standard, react-app, hooks, TS) - husky - npm scripts for lint, lint:fix and type-check - lint fix
1 parent c7b8905 commit e0b2061

File tree

8 files changed

+2933
-155
lines changed

8 files changed

+2933
-155
lines changed

.eslintrc.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"extends": [
3+
"react-app",
4+
"react-app/jest",
5+
"standard",
6+
"standard-jsx",
7+
"standard-react"
8+
],
9+
"plugins": [
10+
"jsx-a11y"
11+
],
12+
"rules": {
13+
"comma-dangle": [
14+
"error",
15+
{
16+
"arrays": "always-multiline",
17+
"objects": "always-multiline",
18+
"imports": "always-multiline",
19+
"exports": "always-multiline",
20+
"functions": "always-multiline"
21+
}
22+
],
23+
"react/react-in-jsx-scope": "off",
24+
"react/jsx-pascal-case": "off",
25+
"no-unused-vars": "off",
26+
"@typescript-eslint/no-unused-vars": ["off", {
27+
"ignoreRestSiblings": true
28+
}]
29+
}
30+
}

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint:fix && yarn type-check

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>Vite App</title>
88
</head>
99
<body>
10-
<div id="root"></div>
10+
<div data-js="root"></div>
1111
<script type="module" src="/src/main.tsx"></script>
1212
</body>
1313
</html>

package.json

+22-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,32 @@
55
"scripts": {
66
"dev": "vite",
77
"build": "tsc && vite build",
8-
"preview": "vite preview"
8+
"preview": "vite preview",
9+
"lint": "eslint src --ext ts,tsx",
10+
"lint:fix": "yarn lint --fix",
11+
"type-check": "tsc --project tsconfig.json --pretty --noEmit",
12+
"prepare": "husky install"
913
},
1014
"dependencies": {
11-
"@types/react": "17.0.33",
12-
"@types/react-dom": "17.0.10",
13-
"@vitejs/plugin-react": "1.0.7",
15+
"@types/react": "17.0.38",
16+
"@types/react-dom": "17.0.11",
17+
"@vitejs/plugin-react": "1.1.4",
18+
"babel-eslint": "10.1.0",
19+
"eslint": "8.7.0",
20+
"eslint-config-react-app": "7.0.0",
21+
"eslint-config-standard": "16.0.3",
22+
"eslint-config-standard-jsx": "10.0.0",
23+
"eslint-config-standard-react": "11.0.1",
24+
"eslint-plugin-import": "2.25.4",
25+
"eslint-plugin-node": "11.1.0",
26+
"eslint-plugin-promise": "6.0.0",
27+
"eslint-plugin-react": "7.28.0",
28+
"husky": "7.0.4",
1429
"react": "17.0.2",
1530
"react-dom": "17.0.2",
16-
"typescript": "4.4.4",
17-
"vite": "2.7.2",
31+
"typescript": "4.5.4",
32+
"vite": "2.7.12",
33+
"vite-plugin-linter": "0.2.4",
1834
"vite-tsconfig-paths": "3.3.17"
1935
}
2036
}

src/App.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import { useState } from 'react'
22
import logo from './logo.svg'
33
import './App.css'
44

5-
function App() {
5+
function App () {
66
const [count, setCount] = useState(0)
77

88
return (
9-
<div className="App">
10-
<header className="App-header">
11-
<img src={logo} className="App-logo" alt="logo" />
9+
<div className='App'>
10+
<header className='App-header'>
11+
<img src={logo} className='App-logo' alt='logo' />
1212
<p>Hello Vite + React!</p>
1313
<p>
14-
<button type="button" onClick={() => setCount((count) => count + 1)}>
14+
<button type='button' onClick={() => setCount((count) => count + 1)}>
1515
count is: {count}
1616
</button>
1717
</p>
@@ -20,19 +20,19 @@ function App() {
2020
</p>
2121
<p>
2222
<a
23-
className="App-link"
24-
href="https://reactjs.org"
25-
target="_blank"
26-
rel="noopener noreferrer"
23+
className='App-link'
24+
href='https://reactjs.org'
25+
target='_blank'
26+
rel='noopener noreferrer'
2727
>
2828
Learn React
2929
</a>
3030
{' | '}
3131
<a
32-
className="App-link"
33-
href="https://vitejs.dev/guide/features.html"
34-
target="_blank"
35-
rel="noopener noreferrer"
32+
className='App-link'
33+
href='https://vitejs.dev/guide/features.html'
34+
target='_blank'
35+
rel='noopener noreferrer'
3636
>
3737
Vite Docs
3838
</a>

src/main.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react'
1+
import { StrictMode } from 'react'
22
import ReactDOM from 'react-dom'
33
import './index.css'
44
import App from '@/App'
55

66
ReactDOM.render(
7-
<React.StrictMode>
7+
<StrictMode>
88
<App />
9-
</React.StrictMode>,
10-
document.getElementById('root')
9+
</StrictMode>,
10+
document.querySelector('[data-js="root"]'),
1111
)

vite.config.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
33
import tsConfigPaths from 'vite-tsconfig-paths'
4+
import { EsLinter, linterPlugin } from 'vite-plugin-linter'
45

56
// https://vitejs.dev/config/
6-
export default defineConfig({
7-
plugins: [react(), tsConfigPaths()],
8-
})
7+
export default defineConfig(configEnv => ({
8+
plugins: [
9+
react(),
10+
tsConfigPaths(),
11+
linterPlugin({
12+
include: ['./src/**/*.{ts,tsx}'],
13+
linters: [new EsLinter({ configEnv })],
14+
}),
15+
],
16+
}))

0 commit comments

Comments
 (0)