Skip to content

Commit 08e50f4

Browse files
committed
Update ESLint v. and its rules and fix warnings/errors across project
- already tested via `npm run test` and all tests passed. - most of code fixed across the project are about semi colon, space after if/else if/else/for statement, removed newline at the end of file, a few dangerous code statement fixed, and a few that is not needed. - ESlint is updated to version 3.17.1. The project has used version 1.x.x. This should be better. - ESLint's rules are updated to be more stricted but not too strict. See it in .eslintrc.
1 parent e9be6e4 commit 08e50f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+479
-486
lines changed

.eslintrc

+48-59
Original file line numberDiff line numberDiff line change
@@ -13,70 +13,59 @@
1313
"strict": [2, "never"],
1414
"react/jsx-uses-react": 2,
1515
"react/jsx-uses-vars": 2,
16-
"react/react-in-jsx-scope": 2
16+
"react/react-in-jsx-scope": 2,
17+
"no-alert": 2,
18+
"no-array-constructor": 2,
19+
"no-caller": 2,
20+
"no-catch-shadow": 2,
21+
"no-labels": 2,
22+
"no-eval": 2,
23+
"no-extend-native": 2,
24+
"no-extra-bind": 2,
25+
"no-implied-eval": 2,
26+
"no-iterator": 2,
27+
"no-label-var": 2,
28+
"no-lone-blocks": 2,
29+
"no-loop-func": 2,
30+
"no-multi-spaces": 2,
31+
"no-multi-str": 2,
32+
"no-native-reassign": 2,
33+
"no-new": 2,
34+
"no-new-func": 2,
35+
"no-new-object": 2,
36+
"no-new-wrappers": 2,
37+
"no-octal-escape": 2,
38+
"no-process-exit": 2,
39+
"no-proto": 2,
40+
"no-return-assign": 2,
41+
"no-sequences": 2,
42+
"no-shadow": 2,
43+
"no-shadow-restricted-names": 2,
44+
"no-spaced-func": 2,
45+
"no-trailing-spaces": 2,
46+
"no-undef-init": 2,
47+
"no-unused-expressions": 2,
48+
"no-use-before-define": 2,
49+
"no-with": 2,
50+
"comma-spacing": 2,
51+
"consistent-return": 2,
52+
"no-extra-parens": [2, "functions"],
53+
"eqeqeq": 2,
54+
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
55+
"new-cap": 2,
56+
"new-parens": 2,
57+
"semi": 2,
58+
"semi-spacing": [2, {"before": false, "after": true}],
59+
"space-infix-ops": 1,
60+
"keyword-spacing": 2,
61+
"space-unary-ops": [2, { "words": true, "nonwords": false }],
62+
"yoda": [2, "never"]
1763
},
1864
"plugins": [
1965
"react"
2066
],
2167
"globals": {
2268
"it": true,
2369
"describe": true,
24-
},
25-
"rules": {
26-
"no-alert": 2,
27-
"no-array-constructor": 2,
28-
"no-caller": 2,
29-
"no-catch-shadow": 2,
30-
"no-empty-label": 2,
31-
"no-eval": 2,
32-
"no-extend-native": 2,
33-
"no-extra-bind": 2,
34-
"no-implied-eval": 2,
35-
"no-iterator": 2,
36-
"no-label-var": 2,
37-
"no-labels": 2,
38-
"no-lone-blocks": 2,
39-
"no-loop-func": 2,
40-
"no-multi-spaces": 2,
41-
"no-multi-str": 2,
42-
"no-native-reassign": 2,
43-
"no-new": 2,
44-
"no-new-func": 2,
45-
"no-new-object": 2,
46-
"no-new-wrappers": 2,
47-
"no-octal-escape": 2,
48-
"no-process-exit": 2,
49-
"no-proto": 2,
50-
"no-return-assign": 2,
51-
"no-script-url": 2,
52-
"no-sequences": 2,
53-
"no-shadow": 2,
54-
"no-shadow-restricted-names": 2,
55-
"no-spaced-func": 2,
56-
"no-trailing-spaces": 2,
57-
"no-undef-init": 2,
58-
"no-underscore-dangle": 2,
59-
"no-unused-expressions": 2,
60-
"no-use-before-define": 2,
61-
"no-with": 2,
62-
"camelcase": 2,
63-
"comma-spacing": 2,
64-
"consistent-return": 2,
65-
"curly": [2, "all"],
66-
"dot-notation": [2, { "allowKeywords": true }],
67-
"eol-last": 2,
68-
"no-extra-parens": [2, "functions"],
69-
"eqeqeq": 2,
70-
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
71-
"new-cap": 2,
72-
"new-parens": 2,
73-
"quotes": [2, "double"],
74-
"semi": 2,
75-
"semi-spacing": [2, {"before": false, "after": true}],
76-
"space-infix-ops": 2,
77-
"space-return-throw-case": 2,
78-
"space-unary-ops": [2, { "words": true, "nonwords": false }],
79-
"strict": [2, "function"],
80-
"yoda": [2, "never"]
81-
}
70+
}
8271
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"codemirror": "^5.20.2",
6565
"css-loader": "^0.23.0",
6666
"enzyme": "^2.6.0",
67-
"eslint": "^1.10.3",
67+
"eslint": "^3.17.1",
6868
"eslint-plugin-react": "^3.11.3",
6969
"extract-text-webpack-plugin": "^1.0.1",
7070
"fastclick": "^1.0.6",

src/components/actionsheet/actionsheet.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ActionSheet extends Component {
5353
isAndroid: ''
5454
};
5555

56-
this.handleMaskClick = this.handleMaskClick.bind(this)
56+
this.handleMaskClick = this.handleMaskClick.bind(this);
5757
}
5858

5959
renderMenuItem() {
@@ -85,7 +85,7 @@ class ActionSheet extends Component {
8585
}
8686

8787
handleMaskClick(e){
88-
if(this.props.onRequestClose) this.props.onRequestClose(e)
88+
if (this.props.onRequestClose) this.props.onRequestClose(e);
8989
}
9090

9191
componentDidMount(){
@@ -104,13 +104,13 @@ class ActionSheet extends Component {
104104

105105
let styleType = type ? type : 'ios';
106106

107-
if(!type && autoDectect){
108-
if(this.state.isAndroid) styleType = 'android';
107+
if (!type && autoDectect){
108+
if (this.state.isAndroid) styleType = 'android';
109109
}
110110

111111
return (
112112
<div
113-
className={styleType == 'android' ? 'weui-skin_android' : ''}
113+
className={styleType === 'android' ? 'weui-skin_android' : ''}
114114
>
115115
<Mask style={{display: show ? 'block' : 'none'}} onClick={this.handleMaskClick} />
116116
<div className={cls} {...others} >
@@ -126,4 +126,4 @@ class ActionSheet extends Component {
126126
}
127127
};
128128

129-
export default ActionSheet;
129+
export default ActionSheet;

src/components/badge/badge.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component, PropTypes } from 'react';
2-
import classNames from 'classnames'
2+
import classNames from 'classnames';
33

44
const presetStyles = {
55
'default': {},
@@ -15,7 +15,7 @@ const presetStyles = {
1515
marginLeft: '5px',
1616
marginRight: '5px'
1717
}
18-
}
18+
};
1919
/**
2020
* Small status descriptors for UI elements.
2121
*
@@ -44,10 +44,10 @@ class Badge extends Component {
4444
const { children, className, dot, style, preset, ...domProps } = this.props;
4545
let clz = classNames('weui-badge', {
4646
'weui-badge_dot': dot
47-
}, className)
47+
}, className);
4848

49-
let stylez = Object.assign({}, presetStyles[preset], style)
50-
return <span className={clz} style={stylez} {...domProps}>{children}</span>
49+
let stylez = Object.assign({}, presetStyles[preset], style);
50+
return <span className={clz} style={stylez} {...domProps}>{children}</span>;
5151
}
5252
}
5353

src/components/badge/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import Badge from './badge'
1+
import Badge from './badge';
22

33
export default Badge;

src/components/button/button.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export default class Button extends React.Component {
2828

2929
render() {
3030
const { component, type, size, plain, className, children, ...others } = this.props;
31-
const Component = component ? component : this.props.href || type == 'vcode' ? 'a' : 'button';
32-
const cls = type == 'vcode' ? classNames('weui-vcode-btn', {[className]: className}) : classNames({
31+
const Component = component ? component : this.props.href || type === 'vcode' ? 'a' : 'button';
32+
const cls = type === 'vcode' ? classNames('weui-vcode-btn', {[className]: className}) : classNames({
3333
'weui-btn': true,
3434
'weui-btn_mini': size === 'small',
3535
'weui-btn_primary': type === 'primary' && !plain,

src/components/button/button_preview.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const PreviewButton = (props) => {
55
const { className, primary, children, ...others } = props;
66
const cls = classNames({
77
'weui-form-preview__btn': true,
8-
'weui-form-preview__btn_default' : !primary,
9-
'weui-form-preview__btn_primary' : primary,
8+
'weui-form-preview__btn_default': !primary,
9+
'weui-form-preview__btn_primary': primary,
1010
[className]: className
1111
});
1212

@@ -23,11 +23,11 @@ PreviewButton.propTypes = {
2323
*
2424
*/
2525
primary: PropTypes.bool
26-
}
26+
};
2727

2828
PreviewButton.defaultProps = {
2929
primary: false
30-
}
30+
};
3131

3232
export default PreviewButton;
3333

src/components/cell/cell.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ Cell.propTypes = {
4545
*
4646
*/
4747
component: PropTypes.func
48-
}
48+
};
4949

5050
Cell.defaultProps = {
5151
access: false,
5252
link: false,
53-
}
53+
};
5454

5555
export default Cell;

src/components/cell/cell_body.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ CellBody.propTypes = {
2424
*
2525
*/
2626
primary: PropTypes.bool,
27-
}
27+
};
2828

2929
CellBody.defaultProps = {
3030
primary: false,
31-
}
31+
};
3232

3333
export default CellBody;

src/components/cell/cell_footer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ CellFooter.propTypes = {
2424
*
2525
*/
2626
primary: PropTypes.bool,
27-
}
27+
};
2828

2929
CellFooter.defaultProps = {
3030
primary: false,
31-
}
31+
};
3232

33-
export default CellFooter
33+
export default CellFooter;

src/components/cell/cell_header.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ CellHeader.propTypes = {
2424
*
2525
*/
2626
primary: PropTypes.bool,
27-
}
27+
};
2828

2929
CellHeader.defaultProps = {
3030
primary: false,
31-
}
31+
};
3232

33-
export default CellHeader
33+
export default CellHeader;

src/components/cell/cells.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import deprecationWarning from '../../utils/deprecationWarning';
1010
const Cells = (props) => {
1111
const { children, className, access, ...others } = props;
1212

13-
if(access){
13+
if (access){
1414
deprecationWarning(
1515
'Cells Access',
1616
'Cell Access',
1717
'https://github.com/weui/weui/wiki/%E5%9C%A81.0.0%E5%9C%A8%E4%BB%A3%E7%A0%81%E5%B1%82%E9%9D%A2%E4%B8%8A%E5%81%9A%E4%BA%86%E5%93%AA%E4%BA%9B%E6%94%B9%E5%8F%98#%E5%B8%A6%E7%AE%AD%E5%A4%B4%E7%9A%84%E5%88%97%E8%A1%A8%E7%94%B1%E4%B9%8B%E5%89%8D%E7%9A%84weui_cells_access%E6%94%B9%E4%B8%BA%E5%8D%95%E7%8B%AC%E6%8E%A7%E5%88%B6%E7%9A%84weui-cell_access'
18-
)
18+
);
1919
}
2020

2121
const cls = classNames({
@@ -29,9 +29,9 @@ const Cells = (props) => {
2929
};
3030

3131
Cells.propTypes = {
32-
}
32+
};
3333

3434
Cells.defaultProps = {
35-
}
35+
};
3636

3737
export default Cells;

src/components/dialog/dialog.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class Dialog extends Component {
4444
};
4545

4646
constructor(props){
47-
super(props)
47+
super(props);
4848

4949
this.state = {
5050
isAndroid: ''
51-
}
51+
};
5252
}
5353

5454
renderButtons() {
@@ -77,9 +77,9 @@ class Dialog extends Component {
7777
const {title, show, className, children, buttons, type, autoDectect, ...others} = this.props;
7878
const styleType = type ? type : 'ios';
7979
const cls = classNames('weui-dialog', {
80-
'weui-skin_android': styleType == 'android' || (!type && autoDectect && this.state.isAndroid),
80+
'weui-skin_android': styleType === 'android' || (!type && autoDectect && this.state.isAndroid),
8181
[className]: className
82-
})
82+
});
8383

8484
return (
8585
<div style={{display: show ? 'block' : 'none'}}>

src/components/flex/flex.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ const Flex = (props) => (
1010
<div className="weui-flex" {...props}>
1111
{ props.children }
1212
</div>
13-
)
13+
);
1414

1515
export default Flex;

src/components/flex/flex_item.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ const FlexItem = (props) => {
1212
<component className="weui-flex__item" {...others}>
1313
{ children }
1414
</component>
15-
)
16-
}
15+
);
16+
};
1717

1818
FlexItem.propTypes = {
1919
/**
2020
* pass component to replace the component but maintaing style
2121
*
2222
*/
2323
component: React.PropTypes.node
24-
}
24+
};
2525

2626
FlexItem.defaultProps = {
2727
component: 'div'
28-
}
28+
};
2929

3030
export default FlexItem;

src/components/footer/footer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ const Footer = (props) => {
1919
);
2020
};
2121

22-
export default Footer
22+
export default Footer;

0 commit comments

Comments
 (0)