Skip to content

Commit

Permalink
Merge pull request #213 from haxpor/master
Browse files Browse the repository at this point in the history
Updated ESLint version & rules, then fix code across project, and fixed #212, #208, #176
  • Loading branch information
n7best committed Mar 13, 2017
2 parents ace7de6 + ec45e68 commit 01bc1c5
Show file tree
Hide file tree
Showing 64 changed files with 488 additions and 432 deletions.
48 changes: 47 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,53 @@
"strict": [2, "never"],
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2
"react/react-in-jsx-scope": 2,
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-labels": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-implied-eval": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-process-exit": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-undef-init": 2,
"no-unused-expressions": 2,
"no-use-before-define": 2,
"no-with": 2,
"comma-spacing": 2,
"consistent-return": 2,
"no-extra-parens": [2, "functions"],
"eqeqeq": 2,
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"new-cap": 2,
"new-parens": 2,
"semi": 2,
"semi-spacing": [2, {"before": false, "after": true}],
"space-infix-ops": 1,
"keyword-spacing": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"yoda": [2, "never"]
},
"plugins": [
"react"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"codemirror": "^5.20.2",
"css-loader": "^0.23.0",
"enzyme": "^2.6.0",
"eslint": "^1.10.3",
"eslint": "^3.17.1",
"eslint-plugin-react": "^3.11.3",
"extract-text-webpack-plugin": "^1.0.1",
"fastclick": "^1.0.6",
Expand Down
12 changes: 6 additions & 6 deletions src/components/actionsheet/actionsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ActionSheet extends Component {
isAndroid: ''
};

this.handleMaskClick = this.handleMaskClick.bind(this)
this.handleMaskClick = this.handleMaskClick.bind(this);
}

renderMenuItem() {
Expand Down Expand Up @@ -85,7 +85,7 @@ class ActionSheet extends Component {
}

handleMaskClick(e){
if(this.props.onRequestClose) this.props.onRequestClose(e)
if (this.props.onRequestClose) this.props.onRequestClose(e);
}

componentDidMount(){
Expand All @@ -104,13 +104,13 @@ class ActionSheet extends Component {

let styleType = type ? type : 'ios';

if(!type && autoDectect){
if(this.state.isAndroid) styleType = 'android';
if (!type && autoDectect){
if (this.state.isAndroid) styleType = 'android';
}

return (
<div
className={styleType == 'android' ? 'weui-skin_android' : ''}
className={styleType === 'android' ? 'weui-skin_android' : ''}
>
<Mask style={{display: show ? 'block' : 'none'}} onClick={this.handleMaskClick} />
<div className={cls} {...others} >
Expand All @@ -126,4 +126,4 @@ class ActionSheet extends Component {
}
};

export default ActionSheet;
export default ActionSheet;
10 changes: 5 additions & 5 deletions src/components/badge/badge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component, PropTypes } from 'react';
import classNames from 'classnames'
import classNames from 'classnames';

const presetStyles = {
'default': {},
Expand All @@ -15,7 +15,7 @@ const presetStyles = {
marginLeft: '5px',
marginRight: '5px'
}
}
};
/**
* Small status descriptors for UI elements.
*
Expand Down Expand Up @@ -44,10 +44,10 @@ class Badge extends Component {
const { children, className, dot, style, preset, ...domProps } = this.props;
let clz = classNames('weui-badge', {
'weui-badge_dot': dot
}, className)
}, className);

let stylez = Object.assign({}, presetStyles[preset], style)
return <span className={clz} style={stylez} {...domProps}>{children}</span>
let stylez = Object.assign({}, presetStyles[preset], style);
return <span className={clz} style={stylez} {...domProps}>{children}</span>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/badge/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Badge from './badge'
import Badge from './badge';

export default Badge;
4 changes: 2 additions & 2 deletions src/components/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default class Button extends React.Component {

render() {
const { component, type, size, plain, className, children, ...others } = this.props;
const Component = component ? component : this.props.href || type == 'vcode' ? 'a' : 'button';
const cls = type == 'vcode' ? classNames('weui-vcode-btn', {[className]: className}) : classNames({
const Component = component ? component : this.props.href || type === 'vcode' ? 'a' : 'button';
const cls = type === 'vcode' ? classNames('weui-vcode-btn', {[className]: className}) : classNames({
'weui-btn': true,
'weui-btn_mini': size === 'small',
'weui-btn_primary': type === 'primary' && !plain,
Expand Down
8 changes: 4 additions & 4 deletions src/components/button/button_preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const PreviewButton = (props) => {
const { className, primary, children, ...others } = props;
const cls = classNames({
'weui-form-preview__btn': true,
'weui-form-preview__btn_default' : !primary,
'weui-form-preview__btn_primary' : primary,
'weui-form-preview__btn_default': !primary,
'weui-form-preview__btn_primary': primary,
[className]: className
});

Expand All @@ -23,11 +23,11 @@ PreviewButton.propTypes = {
*
*/
primary: PropTypes.bool
}
};

PreviewButton.defaultProps = {
primary: false
}
};

export default PreviewButton;

4 changes: 2 additions & 2 deletions src/components/cell/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Cell.propTypes = {
*
*/
component: PropTypes.func
}
};

Cell.defaultProps = {
access: false,
link: false,
}
};

export default Cell;
4 changes: 2 additions & 2 deletions src/components/cell/cell_body.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ CellBody.propTypes = {
*
*/
primary: PropTypes.bool,
}
};

CellBody.defaultProps = {
primary: false,
}
};

export default CellBody;
6 changes: 3 additions & 3 deletions src/components/cell/cell_footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ CellFooter.propTypes = {
*
*/
primary: PropTypes.bool,
}
};

CellFooter.defaultProps = {
primary: false,
}
};

export default CellFooter
export default CellFooter;
6 changes: 3 additions & 3 deletions src/components/cell/cell_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ CellHeader.propTypes = {
*
*/
primary: PropTypes.bool,
}
};

CellHeader.defaultProps = {
primary: false,
}
};

export default CellHeader
export default CellHeader;
8 changes: 4 additions & 4 deletions src/components/cell/cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import deprecationWarning from '../../utils/deprecationWarning';
const Cells = (props) => {
const { children, className, access, ...others } = props;

if(access){
if (access){
deprecationWarning(
'Cells Access',
'Cell Access',
'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'
)
);
}

const cls = classNames({
Expand All @@ -29,9 +29,9 @@ const Cells = (props) => {
};

Cells.propTypes = {
}
};

Cells.defaultProps = {
}
};

export default Cells;
8 changes: 4 additions & 4 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class Dialog extends Component {
};

constructor(props){
super(props)
super(props);

this.state = {
isAndroid: ''
}
};
}

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

return (
<div style={{display: show ? 'block' : 'none'}}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/flex/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ const Flex = (props) => (
<div className="weui-flex" {...props}>
{ props.children }
</div>
)
);

export default Flex;
8 changes: 4 additions & 4 deletions src/components/flex/flex_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ const FlexItem = (props) => {
<component className="weui-flex__item" {...others}>
{ children }
</component>
)
}
);
};

FlexItem.propTypes = {
/**
* pass component to replace the component but maintaing style
*
*/
component: React.PropTypes.node
}
};

FlexItem.defaultProps = {
component: 'div'
}
};

export default FlexItem;
2 changes: 1 addition & 1 deletion src/components/footer/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ const Footer = (props) => {
);
};

export default Footer
export default Footer;
2 changes: 1 addition & 1 deletion src/components/footer/footer_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ const FooterLink = (props) => {
);
};

export default FooterLink
export default FooterLink;
2 changes: 1 addition & 1 deletion src/components/footer/footer_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ const FooterLinks = (props) => {
);
};

export default FooterLinks
export default FooterLinks;
2 changes: 1 addition & 1 deletion src/components/footer/footer_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ const FooterText = (props) => {
);
};

export default FooterText
export default FooterText;
2 changes: 1 addition & 1 deletion src/components/form/agreement.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ const Agreement = (props) => {
);
};

export default Agreement
export default Agreement;
2 changes: 1 addition & 1 deletion src/components/form/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ const Checkbox = (props) => {
);
};

export default Checkbox
export default Checkbox;
10 changes: 5 additions & 5 deletions src/components/form/form_cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ export default class FormCell extends Component {
'weui-cell_warn': warn,
'weui-cell_switch': this.props.switch,
'weui-cell_select': select,
'weui-cell_select-before': selectPos == 'before',
'weui-cell_select-after': selectPos == 'after',
'weui-cell_select-before': selectPos === 'before',
'weui-cell_select-after': selectPos === 'after',
'weui-check__label': radio || checkbox,
[className]: className
});

if(radio || checkbox) {
if (radio || checkbox) {
return (
<label className={cls} {...cellDomProps}>{children}</label>
)
}else{
);
} else {
return (
<div className={cls} {...cellDomProps}>{children}</div>
);
Expand Down
Loading

0 comments on commit 01bc1c5

Please sign in to comment.