Skip to content

Commit 9e4daeb

Browse files
committed
Added airbnb eslint rules
1 parent 7c2e688 commit 9e4daeb

File tree

10 files changed

+216
-615
lines changed

10 files changed

+216
-615
lines changed

.eslintrc

Lines changed: 0 additions & 23 deletions
This file was deleted.

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
extends: [
3+
"airbnb",
4+
"airbnb/hooks"
5+
],
6+
env: {
7+
jest: true,
8+
"browser": true
9+
}
10+
}

example/src/App.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

example/src/App.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import ReactTimer from 'react-timer';
3+
4+
export default () => (
5+
<div>
6+
<ReactTimer
7+
start={30}
8+
end={(value) => value < 25}
9+
// eslint-disable-next-line no-console
10+
onEnd={(value) => console.log('ENDED WITH VALUE', value)}
11+
onTick={(value) => value - 1}
12+
>
13+
{(time) => <div>{time}</div>}
14+
</ReactTimer>
15+
</div>
16+
);

example/src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react'
2-
import ReactDOM from 'react-dom'
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
33

4-
import './index.css'
5-
import App from './App'
4+
import './index.css';
5+
import App from './App';
66

7-
ReactDOM.render(<App />, document.getElementById('root'))
7+
ReactDOM.render(<App />, document.getElementById('root'));

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"deploy": "gh-pages -d example/build",
4040
"docz:dev": "docz dev",
4141
"docz:build": "docz build",
42-
"docz:deploy": "yarn docz:build && gh-pages -d .docz/dist"
42+
"docz:deploy": "yarn docz:build && gh-pages -d .docz/dist",
43+
"lint:test": "yarn eslint ./src"
4344
},
4445
"peerDependencies": {
4546
"prop-types": "^15.5.4",
@@ -63,13 +64,11 @@
6364
"cross-env": "^5.1.4",
6465
"docz": "^2.0.0-rc.53",
6566
"eslint": "^6.2.2",
66-
"eslint-config-standard": "^14.1.0",
67-
"eslint-config-standard-react": "^9.1.0",
68-
"eslint-plugin-import": "^2.13.0",
69-
"eslint-plugin-node": "^9.1.0",
70-
"eslint-plugin-promise": "^4.0.0",
71-
"eslint-plugin-react": "^7.10.0",
72-
"eslint-plugin-standard": "^4.0.1",
67+
"eslint-config-airbnb": "^18.0.1",
68+
"eslint-plugin-import": "^2.18.2",
69+
"eslint-plugin-jsx-a11y": "^6.2.3",
70+
"eslint-plugin-react": "^7.16.0",
71+
"eslint-plugin-react-hooks": "^2.1.2",
7372
"gh-pages": "^2.1.1",
7473
"react": "^16.10.2",
7574
"react-dom": "^16.10.2",

src/.eslintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/index.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
import { useState, useEffect, useRef } from 'react'
2-
import PropTypes from 'prop-types'
1+
import { useState, useEffect, useRef } from 'react';
2+
import PropTypes from 'prop-types';
33

44
const ReactTimer = ({
55
children,
66
start = 0,
77
end = () => true,
88
interval = 1000,
99
onEnd = () => { },
10-
onTick = () => { }
10+
onTick = () => { },
1111
}) => {
12-
const [value, setValue] = useState(start)
13-
const timerRef = useRef()
12+
const [value, setValue] = useState(start);
13+
const timerRef = useRef();
1414

1515
useEffect(() => {
1616
if (!timerRef.current) {
1717
timerRef.current = window.setInterval(() => {
18-
setValue(val => onTick(val))
19-
}, interval)
18+
setValue((val) => onTick(val));
19+
}, interval);
2020
}
2121
if (end(value)) {
22-
window.clearInterval(timerRef.current)
23-
onEnd(value)
22+
window.clearInterval(timerRef.current);
23+
onEnd(value);
2424
}
25-
}, [value])
25+
}, [end, interval, onEnd, onTick, value]);
2626

27-
useEffect(() => {
28-
return () => {
29-
window.clearInterval(timerRef.current)
30-
}
31-
}, [])
27+
useEffect(() => () => {
28+
window.clearInterval(timerRef.current);
29+
}, []);
3230

33-
return children(value)
34-
}
31+
return children(value);
32+
};
3533

3634
ReactTimer.propTypes = {
3735
children: PropTypes.func.isRequired,
3836
start: PropTypes.number.isRequired,
3937
end: PropTypes.func.isRequired,
4038
interval: PropTypes.number,
4139
onTick: PropTypes.func,
42-
onEnd: PropTypes.func
43-
}
40+
onEnd: PropTypes.func,
41+
};
4442

45-
export default ReactTimer
43+
export default ReactTimer;

src/test.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)