File tree Expand file tree Collapse file tree 9 files changed +806
-42
lines changed
Expand file tree Collapse file tree 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 11# .npmrc
2- registry = https ://registry.npmjs .org/
2+ registry = http ://r.cnpmjs .org/
Original file line number Diff line number Diff line change 11# .yarnrc
22
3- registry "https ://registry.npmjs .org/"
3+ registry "http ://r.cnpmjs .org/"
Original file line number Diff line number Diff line change 1010 "react-scripts" : " 2.1.8"
1111 },
1212 "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" ,
1322 "typescript" : " 3.3.3"
1423 },
1524 "scripts" : {
1625 "start" : " react-scripts start" ,
1726 "build" : " react-scripts build" ,
1827 "test" : " react-scripts test --env=jsdom" ,
19- "eject" : " react-scripts eject"
28+ "eject" : " react-scripts eject" ,
29+ "lint" : " eslint ."
2030 },
2131 "browserslist" : [
2232 " >0.2%" ,
2333 " not dead" ,
2434 " not ie <= 11" ,
2535 " not op_mini all"
2636 ]
27- }
37+ }
Original file line number Diff line number Diff line change 1+ /* eslint-disable no-unused-vars */
12import React from "react"
23import 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"
79import "./styles.css"
810
911function View ( ) {
@@ -16,8 +18,9 @@ function View() {
1618 { /* <Demo /> */ }
1719 < RuleCase />
1820 </ >
19- ) ;
21+ )
2022}
2123
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"
33const { useState, useEffect } = React
44
55function Demo ( ) {
6- const [ count , setCount ] = React . useState ( 0 )
6+ const [ count , setCount ] = useState ( 0 )
77
88 useEffect ( ( ) => {
99 const id = setInterval ( ( ) => {
@@ -18,4 +18,4 @@ function Demo() {
1818 return < div > Count: { count } </ div >
1919}
2020
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