fix eslint problems, eslint-config-airbnb@4.x

This commit is contained in:
afc163 2016-01-23 15:22:16 +08:00
parent 5d9978e6bb
commit 66b7ee81ad
21 changed files with 32 additions and 77 deletions

View File

@ -20,6 +20,8 @@
"comma-dangle": 0,
"func-names": 0,
"prefer-const": 0,
"prefer-template": 0,
"arrow-body-style": 0,
"react/sort-comp": 0,
"react/no-multi-comp": 0,
"react/prop-types": 0,

View File

@ -53,11 +53,11 @@ const Breadcrumb = React.createClass({
const ReactRouter = router;
if (routes && routes.length > 0 && ReactRouter) {
let Link = ReactRouter.Link;
crumbs = routes.map(function (route, i) {
crumbs = routes.map((route, i) => {
if (!route.breadcrumbName) {
return null;
}
const name = route.breadcrumbName.replace(/\:(.*)/g, function (replacement, key) {
const name = route.breadcrumbName.replace(/\:(.*)/g, (replacement, key) => {
return params[key] || replacement;
});
let link;

View File

@ -9,7 +9,7 @@
---
````jsx
import {Form, Input, Button, Checkbox, Radio, Row, Col, message} from 'antd';
import { Form, Input, Button, Checkbox, Radio, Row, Col } from 'antd';
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
@ -30,12 +30,7 @@ const Demo = React.createClass({
handleSubmit(e) {
e.preventDefault();
message.success('收到表单值~~~ ' + JSON.stringify(this.state.formData, function(k, v) {
if (typeof v === 'undefined') {
return '';
}
return v;
}));
console.log('收到表单值:', this.state.formData);
},
render() {

View File

@ -7,7 +7,7 @@
---
````jsx
import {Form, Input, Button, Checkbox, message} from 'antd';
import { Form, Input, Button, Checkbox } from 'antd';
const FormItem = Form.Item;
const Demo = React.createClass({
@ -25,12 +25,7 @@ const Demo = React.createClass({
handleSubmit(e) {
e.preventDefault();
message.success('收到表单值~~~ ' + JSON.stringify(this.state.formData, function(k, v) {
if (typeof v === 'undefined') {
return '';
}
return v;
}));
console.log('收到表单值:', this.state.formData);
},
render() {

View File

@ -44,12 +44,7 @@ const Demo = React.createClass({
handleSubmit(e) {
e.preventDefault();
message.success('收到表单值~~~ ' + JSON.stringify(this.state.formData, function(k, v) {
if (typeof v === 'undefined') {
return '';
}
return v;
}));
console.log('收到表单值:', this.state.formData);
},
render() {

View File

@ -51,7 +51,7 @@ function notice(content, duration = defaultDuration, type, onClose) {
return function () {
instance.removeNotice(target);
};
})();
}());
}
export default {

View File

@ -37,7 +37,7 @@ let AntModal = React.createClass({
return;
}
//
Dom.addEventListener(document.documentElement, 'click', function onDocumentMousemove(e) {
Dom.addEventListener(document.documentElement, 'click', (e) => {
mousePosition = {
x: e.pageX,
y: e.pageY

View File

@ -14,12 +14,12 @@ function showConfirm() {
confirm({
title: '您是否确认要删除这项内容',
content: '点确认 1 秒后关闭',
onOk: function() {
return new Promise(function(resolve) {
onOk() {
return new Promise((resolve) => {
setTimeout(resolve, 1000);
});
},
onCancel: function() {}
onCancel() {}
});
}

View File

@ -2,7 +2,7 @@ import React from 'react';
function getCheckedValue(children) {
let checkedValue = null;
React.Children.forEach(children, function (radio) {
React.Children.forEach(children, (radio) => {
if (radio.props && radio.props.checked) {
checkedValue = radio.props.value;
}

View File

@ -22,14 +22,12 @@ const Test = React.createClass({
if (!value || value.indexOf('@') >= 0) {
options = [];
} else {
options = ['gmail.com', '163.com', 'qq.com'].map(function(domain) {
options = ['gmail.com', '163.com', 'qq.com'].map((domain) => {
const email = value + '@' + domain;
return <Option key={email}>{email}</Option>;
});
}
this.setState({
options: options
});
this.setState({ options });
},
render() {
// filterOption 需要设置为 false数据是动态设置的
@ -47,4 +45,3 @@ const Test = React.createClass({
ReactDOM.render(<Test />, mountNode);
````

View File

@ -38,12 +38,8 @@ const App = React.createClass({
});
},
render() {
const provinceOptions = provinceData.map(function(province) {
return <Option key={province}>{province}</Option>;
});
const cityOptions = this.state.cities.map(function(city) {
return <Option key={city}>{city}</Option>;
});
const provinceOptions = provinceData.map(province => <Option key={province}>{province}</Option>);
const cityOptions = this.state.cities.map(city => <Option key={city}>{city}</Option>);
return (
<div>
<Select defaultValue={provinceData[0]} style={{width: 90}} onChange={this.handleProvinceChange}>
@ -58,4 +54,3 @@ const App = React.createClass({
});
ReactDOM.render(<App />, mountNode);
````

View File

@ -22,11 +22,7 @@ const steps = [{
}, {
title: '待运行',
description: '这里是多信息的描述啊'
}].map(function(s, i) {
return (
<Step key={i} title={s.title} description={s.description} />
);
});
}].map((s, i) => <Step key={i} title={s.title} description={s.description} />);
ReactDOM.render(<Steps current={1}>{steps}</Steps>, mountNode);
````

View File

@ -22,11 +22,7 @@ const steps = [{
}, {
status: 'wait',
title: '待运行'
}].map(function(s, i) {
return (
<Step key={i} title={s.title} description={s.description} />
);
});
}].map((s, i) => <Step key={i} title={s.title} description={s.description} />);
ReactDOM.render(<Steps size="small" current={1}>{steps}</Steps>, mountNode);
````

View File

@ -26,11 +26,7 @@ const steps = [{
status: 'wait',
title: '待运行',
description: '这里是多信息的描述啊'
}].map(function(s, i) {
return (
<Step key={i} title={s.title} status={s.status} description={s.description} />
);
});
}].map((s, i) => <Step key={i} title={s.title} description={s.description} />);
ReactDOM.render(<Steps>{steps}</Steps>, mountNode);
````

View File

@ -16,7 +16,7 @@
import { Steps, Button } from 'antd';
const Step = Steps.Step;
const array = Array.apply(null, Array(Math.floor(Math.random() * 3) + 3));
const steps = array.map(function(item, i) {
const steps = array.map((item, i) => {
return {
title: '步骤' + (i + 1)
};

View File

@ -19,11 +19,7 @@ const steps = [{
}, {
title: '待运行',
description: '这里是信息的描述'
}].map(function(s, i) {
return (
<Step key={i} title={s.title} description={s.description} />
);
});
}].map((s, i) => <Step key={i} title={s.title} description={s.description} />);
ReactDOM.render(<Steps size="small" direction="vertical" current={1}>{steps}</Steps>,
mountNode);

View File

@ -22,11 +22,7 @@ const steps = [{
}, {
title: '又一个待运行',
description: '这里是信息的描述'
}].map(function(s, i) {
return (
<Step key={i} title={s.title} description={s.description} />
);
});
}].map((s, i) => <Step key={i} title={s.title} description={s.description} />);
ReactDOM.render(<Steps direction="vertical" current={1}>{steps}</Steps>,
mountNode);

View File

@ -34,7 +34,7 @@ const MyUpload = React.createClass({
fileList = fileList.slice(-2);
// 2. 读取远程路径并显示链接
fileList = fileList.map(function(file) {
fileList = fileList.map((file) => {
if (file.response) {
// 组件会将 file.url 作为链接进行展示
file.url = file.response.url;
@ -43,7 +43,7 @@ const MyUpload = React.createClass({
});
// 3. 按照服务器返回信息筛选成功上传的文件
fileList = fileList.filter(function(file) {
fileList = fileList.filter((file) => {
if (file.response) {
return file.response.status === 'success';
}

View File

@ -67,7 +67,7 @@ const AntUpload = React.createClass({
let targetItem;
let nextFileList = this.state.fileList.concat();
if (file.length > 0) {
targetItem = file.map(function (f) {
targetItem = file.map(f => {
const fileObject = fileToObject(f);
fileObject.status = 'uploading';
return fileObject;

View File

@ -19,9 +19,7 @@ const FormItem = Form.Item;
function cx(classNames) {
if (typeof classNames === 'object') {
return Object.keys(classNames).filter(function(className) {
return classNames[className];
}).join(' ');
return Object.keys(classNames).filter(className => classNames[className]).join(' ');
}
return Array.prototype.join.call(arguments, ' ');
}
@ -107,7 +105,7 @@ const Demo = React.createClass({
if (!value) {
callback();
} else {
setTimeout(function () {
setTimeout(() => {
if (value === 'JasonWood') {
callback([new Error('抱歉,该用户名已被占用。')]);
} else {

View File

@ -9,7 +9,7 @@
---
````jsx
import {Validation, Select, Radio, Button, DatePicker, InputNumber, Form} from 'antd';
import { Validation, Select, Radio, Button, DatePicker, InputNumber, Form } from 'antd';
const Validator = Validation.Validator;
const Option = Select.Option;
const RadioGroup = Radio.Group;
@ -17,9 +17,7 @@ const FormItem = Form.Item;
function cx(classNames) {
if (typeof classNames === 'object') {
return Object.keys(classNames).filter(function(className) {
return classNames[className];
}).join(' ');
return Object.keys(classNames).filter(className => classNames[className]).join(' ');
}
return Array.prototype.join.call(arguments, ' ');
}