Skip to content

Commit 02107d9

Browse files
committed
resolve linter errors, and update eslintrc.js file
1 parent f268a14 commit 02107d9

File tree

19 files changed

+157
-137
lines changed

19 files changed

+157
-137
lines changed

.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ module.exports = {
3030
peerDependencies: false
3131
}
3232
],
33+
'jsx-a11y/click-events-have-key-events': 'off',
3334
'jsx-a11y/label-has-for': 'off',
35+
'jsx-a11y/label-has-associated-control': [
36+
'error', {
37+
depth: 3,
38+
},
39+
],
3440
'jsx-a11y/no-noninteractive-element-interactions': 'off',
3541
'jsx-a11y/no-noninteractive-tabindex': 'off',
3642
'jsx-a11y/no-static-element-interactions': 'off',
3743
'no-underscore-dangle': 'off',
3844
'no-use-before-define': 'off',
45+
'react/destructuring-assignment': 'off',
3946
'react/jsx-filename-extension': 'off',
4047
'react/jsx-no-bind': 'error',
4148
'react/no-find-dom-node': 'off',

components/app_bar/AppBar.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const factory = (IconButton) => {
4646
scrollHide: false,
4747
};
4848

49-
state = { hidden: false, height: 0 };
49+
state = { hidden: false, height: 0 }; // eslint-disable-line react/no-unused-state
5050

5151
componentDidMount() {
5252
if (this.props.scrollHide) {
@@ -70,26 +70,27 @@ const factory = (IconButton) => {
7070
}
7171
}
7272

73-
initializeScroll() {
73+
handleScroll = () => {
74+
const scrollDiff = this.curScroll - window.scrollY;
75+
this.setState(state => ({
76+
hidden: scrollDiff < 0
77+
&& window.scrollY !== undefined
78+
&& window.scrollY > state.height,
79+
}));
80+
this.curScroll = window.scrollY;
81+
};
82+
83+
initializeScroll = () => {
7484
window.addEventListener('scroll', this.handleScroll);
7585
const { height } = this.rootNode.getBoundingClientRect();
7686
this.curScroll = window.scrollY;
77-
this.setState({ height });
87+
this.setState({ height }); // eslint-disable-line react/no-unused-state
7888
}
7989

8090
endScroll() {
8191
window.removeEventListener('scroll', this.handleScroll);
8292
}
8393

84-
handleScroll = () => {
85-
const scrollDiff = this.curScroll - window.scrollY;
86-
const hidden = scrollDiff < 0
87-
&& window.scrollY !== undefined
88-
&& window.scrollY > this.state.height;
89-
this.setState({ hidden });
90-
this.curScroll = window.scrollY;
91-
};
92-
9394
render() {
9495
const {
9596
children,

components/date_picker/Calendar.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ const factory = (IconButton) => {
5656
document.body.removeEventListener('keydown', this.handleKeys);
5757
}
5858

59-
scrollToActive() {
60-
const offset = (this.yearsNode.offsetHeight / 2) + (this.activeYearNode.offsetHeight / 2);
61-
this.yearsNode.scrollTop = this.activeYearNode.offsetTop - offset;
62-
}
63-
6459
handleDayClick = (day) => {
6560
this.props.onChange(time.setDay(this.state.viewDate, day), true);
6661
};
@@ -96,12 +91,17 @@ const factory = (IconButton) => {
9691

9792
changeViewMonth = (event) => {
9893
const direction = event.currentTarget.id;
99-
this.setState({
94+
this.setState(state => ({
10095
direction,
101-
viewDate: time.addMonths(this.state.viewDate, DIRECTION_STEPS[direction]),
102-
});
96+
viewDate: time.addMonths(state.viewDate, DIRECTION_STEPS[direction]),
97+
}));
10398
};
10499

100+
scrollToActive() {
101+
const offset = (this.yearsNode.offsetHeight / 2) + (this.activeYearNode.offsetHeight / 2);
102+
this.yearsNode.scrollTop = this.activeYearNode.offsetTop - offset;
103+
}
104+
105105
renderYears() {
106106
return (
107107
<ul

components/date_picker/CalendarDay.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class Day extends Component {
1818
viewDate: PropTypes.instanceOf(Date),
1919
};
2020

21+
handleClick = () => {
22+
if (!this.props.disabled && this.props.onClick) {
23+
this.props.onClick(this.props.day);
24+
}
25+
};
26+
2127
dayStyle() {
2228
if (this.props.day === 1) {
2329
const e = (this.props.sundayFirstDayOfWeek) ? 0 : 1;
@@ -36,12 +42,6 @@ class Day extends Component {
3642
return sameYear && sameMonth && sameDay;
3743
}
3844

39-
handleClick = () => {
40-
if (!this.props.disabled && this.props.onClick) {
41-
this.props.onClick(this.props.day);
42-
}
43-
};
44-
4545
render() {
4646
const className = classnames(this.props.theme.day, {
4747
[this.props.theme.active]: this.isSelected(),

components/date_picker/DatePickerDialog.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ const factory = (Dialog, Calendar) => {
5151
date: this.props.value,
5252
};
5353

54+
actions = [{
55+
label: this.props.cancelLabel,
56+
className: this.props.theme.button,
57+
onClick: this.props.onDismiss,
58+
}, {
59+
label: this.props.okLabel,
60+
className: this.props.theme.button,
61+
name: this.props.name,
62+
onClick: this.handleSelect,
63+
}];
64+
5465
componentWillMount() {
5566
this.updateStateDate(this.props.value);
5667
}
@@ -88,17 +99,6 @@ const factory = (Dialog, Calendar) => {
8899
}
89100
};
90101

91-
actions = [{
92-
label: this.props.cancelLabel,
93-
className: this.props.theme.button,
94-
onClick: this.props.onDismiss,
95-
}, {
96-
label: this.props.okLabel,
97-
className: this.props.theme.button,
98-
name: this.props.name,
99-
onClick: this.handleSelect,
100-
}];
101-
102102
render() {
103103
const { theme } = this.props;
104104
const display = `${this.state.display}Display`;

components/hoc/ActivableRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33

4-
const ActivableRendererFactory = (options = { delay: 500 }) => ActivableComponent => class ActivableRenderer extends Component {
4+
const ActivableRendererFactory = (options = { delay: 500 }) => ActivableComponent => class ActivableRenderer extends Component { // eslint-disable-line max-len
55
static propTypes = {
66
active: PropTypes.bool.isRequired,
77
children: PropTypes.node,

components/input/Input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const factory = (FontIcon) => {
113113

114114
handleAutoresize = () => {
115115
const element = this.inputNode;
116-
const rows = this.props.rows;
116+
const { rows } = this.props;
117117

118118
if (typeof rows === 'number' && !Number.isNaN(rows)) {
119119
element.style.height = null;
@@ -139,7 +139,7 @@ const factory = (FontIcon) => {
139139
// replace the selected characters, so the length of value doesn't actually
140140
// increase.
141141
const isReplacing = event.target.selectionEnd - event.target.selectionStart;
142-
const value = event.target.value;
142+
const { value } = event.target;
143143

144144
if (!isReplacing && value.length === maxLength) {
145145
event.preventDefault();

components/layout/Sidebar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const factory = (Drawer) => {
4141
clipped: PropTypes.bool,
4242
permanentAt: PropTypes.oneOf(['sm', 'smTablet', 'md', 'lg', 'lgTablet', 'xl', 'xxl', 'xxxl']),
4343
pinned: PropTypes.bool,
44+
right: PropTypes.bool,
4445
theme: PropTypes.shape({
4546
clipped: PropTypes.string,
4647
pinned: PropTypes.string,

components/list/List.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const factory = (ListItem) => {
1616
static propTypes = {
1717
children: PropTypes.node,
1818
className: PropTypes.string,
19+
ripple: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
20+
selectable: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
1921
theme: PropTypes.shape({
2022
list: PropTypes.string,
2123
}),

components/list/ListItemAction.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ const ListItemAction = ({ action, theme }) => {
88
const stopRipple = onClick && !onMouseDown;
99
const stop = e => e.stopPropagation();
1010
return (
11-
<span className={theme.itemAction} onMouseDown={stopRipple && stop} onClick={onClick && stop}>
11+
<span
12+
className={theme.itemAction}
13+
onMouseDown={stopRipple ? stop : undefined}
14+
onClick={onClick && stop}
15+
>
1216
{action}
1317
</span>
1418
);

0 commit comments

Comments
 (0)