File tree 9 files changed +806
-42
lines changed
9 files changed +806
-42
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "extends": [
3
+ "airbnb",
4
+ "plugin:jsx-a11y/recommended",
5
+ "prettier",
6
+ "prettier/react"
7
+ ],
8
+ "plugins": [
9
+ "jsx-a11y",
10
+ "prettier",
11
+ // "react-hooks"
12
+ ],
13
+ "rules": {
14
+ // "react-hooks/rules-of-hooks": 2, // Checks rules of Hooks
15
+ // "react-hooks/exhaustive-deps": 1, // Checks effect dependencies
16
+ "semi": 0,
17
+ "react/jsx-filename-extension": [
18
+ 1,
19
+ {
20
+ "extensions": [
21
+ ".js",
22
+ ".jsx"
23
+ ]
24
+ }
25
+ ],
26
+ "prettier/prettier": [
27
+ "error",
28
+ {
29
+ "semi": false
30
+ }
31
+ ]
32
+ }
33
+ }
Original file line number Diff line number Diff line change 1
1
# .npmrc
2
- registry = https ://registry.npmjs .org/
2
+ registry = http ://r.cnpmjs .org/
Original file line number Diff line number Diff line change 1
1
# .yarnrc
2
2
3
- registry "https ://registry.npmjs .org/"
3
+ registry "http ://r.cnpmjs .org/"
Original file line number Diff line number Diff line change 10
10
"react-scripts" : " 2.1.8"
11
11
},
12
12
"devDependencies" : {
13
+ "eslint" : " ^7.5.0" ,
14
+ "eslint-config-airbnb" : " ^18.2.0" ,
15
+ "eslint-config-prettier" : " ^6.11.0" ,
16
+ "eslint-plugin-import" : " ^2.22.0" ,
17
+ "eslint-plugin-jsx-a11y" : " ^6.3.1" ,
18
+ "eslint-plugin-prettier" : " ^3.1.4" ,
19
+ "eslint-plugin-react" : " ^7.20.4" ,
20
+ "eslint-plugin-react-hooks" : " ^4.0.8" ,
21
+ "prettier" : " ^2.0.5" ,
13
22
"typescript" : " 3.3.3"
14
23
},
15
24
"scripts" : {
16
25
"start" : " react-scripts start" ,
17
26
"build" : " react-scripts build" ,
18
27
"test" : " react-scripts test --env=jsdom" ,
19
- "eject" : " react-scripts eject"
28
+ "eject" : " react-scripts eject" ,
29
+ "lint" : " eslint ."
20
30
},
21
31
"browserslist" : [
22
32
" >0.2%" ,
23
33
" not dead" ,
24
34
" not ie <= 11" ,
25
35
" not op_mini all"
26
36
]
27
- }
37
+ }
Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-unused-vars */
1
2
import React from "react"
2
3
import ReactDOM from "react-dom"
3
- import { HookApp , ClassApp } from './tasks/task1'
4
- import { Demo } from './tasks/task2'
5
- import { RuleCase } from "./tasks/task3" ;
6
- import useInterval from './useInterval'
4
+ // eslint-disable-next-line import/named
5
+ import { HookApp , ClassApp } from "./tasks/task1"
6
+ import Demo from "./tasks/task2"
7
+ import RuleCase from "./tasks/task3_if_rule"
8
+ import useInterval from "./useInterval"
7
9
import "./styles.css"
8
10
9
11
function View ( ) {
@@ -16,8 +18,9 @@ function View() {
16
18
{ /* <Demo /> */ }
17
19
< RuleCase />
18
20
</ >
19
- ) ;
21
+ )
20
22
}
21
23
22
- const rootElement = document . getElementById ( "root" ) ;
23
- ReactDOM . render ( < View /> , rootElement ) ;
24
+ // eslint-disable-next-line no-undef
25
+ const rootElement = document . getElementById ( "root" )
26
+ ReactDOM . render ( < View /> , rootElement )
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import React from "react"
3
3
const { useState, useEffect } = React
4
4
5
5
function Demo ( ) {
6
- const [ count , setCount ] = React . useState ( 0 )
6
+ const [ count , setCount ] = useState ( 0 )
7
7
8
8
useEffect ( ( ) => {
9
9
const id = setInterval ( ( ) => {
@@ -18,4 +18,4 @@ function Demo() {
18
18
return < div > Count: { count } </ div >
19
19
}
20
20
21
- export { Demo }
21
+ export default Demo
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-unused-vars */
2
+ import React from "react"
3
+
4
+ const { useState, useEffect, useReducer } = React
5
+
6
+ // common case
7
+ function RuleCase ( ) {
8
+ const [ value , forceUpdate ] = useReducer ( ( n ) => n + 1 , 0 )
9
+ const [ a , setA ] = useState ( 1 )
10
+ if ( Math . floor ( Math . random ( ) * 100 ) > 50 ) {
11
+ useEffect ( ( ) => {
12
+ forceUpdate ( )
13
+ } , [ ] )
14
+ return < div > render one</ div >
15
+ }
16
+
17
+ return < div > render two</ div >
18
+ }
19
+
20
+ export default RuleCase
You can’t perform that action at this time.
0 commit comments