mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
upgrade eslint-config-airbnb
This commit is contained in:
parent
e3f0b2c6f5
commit
1e001d2d82
22
.eslintrc
22
.eslintrc
@ -17,29 +17,15 @@
|
||||
"babel"
|
||||
],
|
||||
"rules": {
|
||||
"constructor-super": 2,
|
||||
"comma-dangle": 0,
|
||||
"func-names": 0,
|
||||
"guard-for-in": 0,
|
||||
"one-var": [2, { "initialized": "never" }],
|
||||
"prefer-const": 0,
|
||||
"key-spacing": 0,
|
||||
"no-eq-null": 0,
|
||||
"no-else-return": 0,
|
||||
"no-param-reassign": 0,
|
||||
"no-this-before-super": 2,
|
||||
"no-undef": 2,
|
||||
"babel/object-shorthand": 0,
|
||||
"react/jsx-no-duplicate-props": 2,
|
||||
"react/sort-comp": 0,
|
||||
"react/wrap-multilines": 0,
|
||||
"react/no-multi-comp": 0,
|
||||
"react/prop-types": 0,
|
||||
"space-after-keywords": 0,
|
||||
"space-before-blocks": 0,
|
||||
"space-before-function-paren": 0,
|
||||
"spaced-comment": 0,
|
||||
"vars-on-top": 0,
|
||||
"id-length": 0
|
||||
"react/prefer-es6-class": 0,
|
||||
"react/jsx-closing-bracket-location": 0,
|
||||
"react/jsx-no-bind": 0,
|
||||
"space-before-function-paren": 0
|
||||
}
|
||||
}
|
||||
|
@ -44,20 +44,20 @@ export default React.createClass({
|
||||
|
||||
let iconType = '';
|
||||
switch (type) {
|
||||
case 'success':
|
||||
iconType = 'check-circle';
|
||||
break;
|
||||
case 'info':
|
||||
iconType = 'info-circle';
|
||||
break;
|
||||
case 'error':
|
||||
iconType = 'exclamation-circle';
|
||||
break;
|
||||
case 'warn':
|
||||
iconType = 'exclamation-circle';
|
||||
break;
|
||||
default:
|
||||
iconType = 'default';
|
||||
case 'success':
|
||||
iconType = 'check-circle';
|
||||
break;
|
||||
case 'info':
|
||||
iconType = 'info-circle';
|
||||
break;
|
||||
case 'error':
|
||||
iconType = 'exclamation-circle';
|
||||
break;
|
||||
case 'warn':
|
||||
iconType = 'exclamation-circle';
|
||||
break;
|
||||
default:
|
||||
iconType = 'default';
|
||||
}
|
||||
|
||||
// use outline icon in alert with description
|
||||
@ -80,9 +80,9 @@ export default React.createClass({
|
||||
|
||||
return this.state.closed ? null : (
|
||||
<Animate component=""
|
||||
showProp="data-show"
|
||||
transitionName="slide-up"
|
||||
onEnd={this.animationEnd}>
|
||||
showProp="data-show"
|
||||
transitionName="slide-up"
|
||||
onEnd={this.animationEnd}>
|
||||
<div data-show={this.state.closing} className={alertCls}>
|
||||
{showIcon ? <Icon className="ant-alert-icon" type={iconType} /> : null}
|
||||
<span className={prefixCls + '-message'}>{message}</span>
|
||||
|
@ -80,7 +80,7 @@ class AntScrollNumber extends React.Component {
|
||||
style: {
|
||||
transition: removeTransition && 'none',
|
||||
transform: 'translate3d(0, ' + (-position * height) + 'px, 0)',
|
||||
height: height,
|
||||
height,
|
||||
},
|
||||
key: i,
|
||||
}, this.renderNumberList());
|
||||
@ -120,7 +120,7 @@ AntScrollNumber.defaultProps = {
|
||||
prefixCls: 'ant-scroll-number',
|
||||
count: null,
|
||||
component: 'sup',
|
||||
onAnimated: function() {},
|
||||
onAnimated() {},
|
||||
height: 18,
|
||||
};
|
||||
|
||||
|
@ -5,13 +5,13 @@ const prefix = 'ant-btn-group-';
|
||||
|
||||
export default class ButtonGroup extends React.Component {
|
||||
render() {
|
||||
const {size, className, ...others} = this.props;
|
||||
const { size, className, ...others } = this.props;
|
||||
|
||||
// large => lg
|
||||
// small => sm
|
||||
const sizeCls = ({
|
||||
'large': 'lg',
|
||||
'small': 'sm'
|
||||
large: 'lg',
|
||||
small: 'sm',
|
||||
})[size] || '';
|
||||
|
||||
const classes = classNames({
|
||||
|
@ -32,13 +32,13 @@ export default class Button extends React.Component {
|
||||
}
|
||||
render() {
|
||||
const props = this.props;
|
||||
const {type, shape, size, onClick, className, htmlType, children, ...others} = props;
|
||||
const { type, shape, size, onClick, className, htmlType, children, ...others } = props;
|
||||
|
||||
// large => lg
|
||||
// small => sm
|
||||
const sizeCls = ({
|
||||
'large': 'lg',
|
||||
'small': 'sm'
|
||||
large: 'lg',
|
||||
small: 'sm',
|
||||
})[size] || '';
|
||||
|
||||
const classes = classNames({
|
||||
|
@ -1,20 +1,20 @@
|
||||
import React, {PropTypes, Component} from 'react';
|
||||
import {PREFIX_CLS} from './Constants';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
import { PREFIX_CLS } from './Constants';
|
||||
import Select from '../select';
|
||||
import {Group, Button} from '../radio';
|
||||
import { Group, Button } from '../radio';
|
||||
|
||||
function noop() {}
|
||||
|
||||
class Header extends Component {
|
||||
getYearSelectElement(year) {
|
||||
const {yearSelectOffset, yearSelectTotal, locale, prefixCls, fullscreen} = this.props;
|
||||
const { yearSelectOffset, yearSelectTotal, locale, prefixCls, fullscreen } = this.props;
|
||||
const start = year - yearSelectOffset;
|
||||
const end = start + yearSelectTotal;
|
||||
const suffix = locale.year === '年' ? '年' : '';
|
||||
|
||||
const options = [];
|
||||
for (let index = start; index < end; index++) {
|
||||
options.push(<Option key={`${index}`}>{index + suffix}</Option> );
|
||||
options.push(<Option key={`${index}`}>{index + suffix}</Option>);
|
||||
}
|
||||
return (
|
||||
<Select
|
||||
@ -32,7 +32,7 @@ class Header extends Component {
|
||||
getMonthSelectElement(month) {
|
||||
const props = this.props;
|
||||
const months = props.locale.format.months;
|
||||
const {prefixCls, fullscreen} = props;
|
||||
const { prefixCls, fullscreen } = props;
|
||||
const options = [];
|
||||
|
||||
for (let index = 0; index < 12; index++) {
|
||||
@ -67,12 +67,9 @@ class Header extends Component {
|
||||
this.props.onTypeChange(e.target.value);
|
||||
}
|
||||
render() {
|
||||
const {type, value, prefixCls, locale} = this.props;
|
||||
|
||||
const { type, value, prefixCls, locale } = this.props;
|
||||
const yearSelect = this.getYearSelectElement(value.getYear());
|
||||
|
||||
const monthSelect = type === 'date' ? this.getMonthSelectElement(value.getMonth()) : null;
|
||||
|
||||
const typeSwitch = (
|
||||
<Group onChange={this.onTypeChange.bind(this)} value={type}>
|
||||
<Button value="date">{locale.month}</Button>
|
||||
|
@ -1,8 +1,8 @@
|
||||
import React, {PropTypes, Component} from 'react';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
import GregorianCalendar from 'gregorian-calendar';
|
||||
import zhCN from './locale/zh_CN';
|
||||
import FullCalendar from 'rc-calendar/lib/FullCalendar';
|
||||
import {PREFIX_CLS} from './Constants';
|
||||
import { PREFIX_CLS } from './Constants';
|
||||
import Header from './Header';
|
||||
|
||||
function noop () { return null; }
|
||||
@ -70,8 +70,8 @@ class Calendar extends Component {
|
||||
}
|
||||
render() {
|
||||
const props = this.props;
|
||||
const {value, mode} = this.state;
|
||||
const {locale, prefixCls, style, className, fullscreen} = props;
|
||||
const { value, mode } = this.state;
|
||||
const { locale, prefixCls, style, className, fullscreen } = props;
|
||||
const type = (mode === 'year') ? 'month' : 'date';
|
||||
|
||||
let cls = className || '';
|
||||
|
@ -4,10 +4,10 @@ if (typeof window !== 'undefined') {
|
||||
const matchMediaPolyfill = function matchMediaPolyfill() {
|
||||
return {
|
||||
matches: false,
|
||||
addListener: function () {
|
||||
addListener() {
|
||||
},
|
||||
removeListener() {
|
||||
},
|
||||
removeListener: function () {
|
||||
}
|
||||
};
|
||||
};
|
||||
window.matchMedia = window.matchMedia || matchMediaPolyfill;
|
||||
@ -21,7 +21,7 @@ const AntCarousel = React.createClass({
|
||||
getDefaultProps() {
|
||||
return {
|
||||
dots: true,
|
||||
arrows: false
|
||||
arrows: false,
|
||||
};
|
||||
},
|
||||
render() {
|
||||
|
@ -80,7 +80,7 @@ class AntCascader extends React.Component {
|
||||
className={pickerCls}>
|
||||
<Input placeholder={placeholder}
|
||||
className={`${prefixCls}-input ant-input ${sizeCls}`}
|
||||
style={{width: '100%'}}
|
||||
style={{ width: '100%' }}
|
||||
value={this.getLabel()}
|
||||
disabled={disabled}
|
||||
readOnly />
|
||||
|
@ -47,8 +47,8 @@ export default React.createClass({
|
||||
options.map(option =>
|
||||
<label className="ant-checkbox-group-item" key={option}>
|
||||
<Checkbox disabled={this.props.disabled}
|
||||
checked={this.state.value.indexOf(option) !== -1}
|
||||
onChange={this.toggleOption.bind(this, option)} />
|
||||
checked={this.state.value.indexOf(option) !== -1}
|
||||
onChange={this.toggleOption.bind(this, option)} />
|
||||
{option}
|
||||
</label>
|
||||
)
|
||||
|
@ -1,6 +1,5 @@
|
||||
import Collapse from 'rc-collapse';
|
||||
import React from 'react';
|
||||
const prefixCls = 'ant-collapse';
|
||||
|
||||
class AntCollapse extends React.Component {
|
||||
render() {
|
||||
@ -9,7 +8,7 @@ class AntCollapse extends React.Component {
|
||||
}
|
||||
|
||||
AntCollapse.defaultProps = {
|
||||
prefixCls: prefixCls
|
||||
prefixCls: 'ant-collapse',
|
||||
};
|
||||
|
||||
AntCollapse.Panel = Collapse.Panel;
|
||||
|
@ -17,7 +17,7 @@ function animate(node, show, transitionName, done) {
|
||||
node.style.display = show ? 'block' : 'none';
|
||||
velocity(node, transitionName, {
|
||||
duration: 240,
|
||||
complete: complete,
|
||||
complete,
|
||||
easing: 'easeInOutQuad'
|
||||
});
|
||||
return {
|
||||
|
@ -24,7 +24,7 @@ export default {
|
||||
parseDateFromValue(value) {
|
||||
if (value) {
|
||||
if (typeof value === 'string') {
|
||||
return this.getFormatter().parse(value, {locale: this.getLocale()});
|
||||
return this.getFormatter().parse(value, { locale: this.getLocale() });
|
||||
} else if (value instanceof Date) {
|
||||
let date = new GregorianCalendar(this.getLocale());
|
||||
date.setTime(+value);
|
||||
|
@ -25,7 +25,7 @@ export default React.createClass({
|
||||
};
|
||||
},
|
||||
getInitialState() {
|
||||
const {value, defaultValue} = this.props;
|
||||
const { value, defaultValue } = this.props;
|
||||
const start = (value && value[0]) || defaultValue[0];
|
||||
const end = (value && value[1]) || defaultValue[1];
|
||||
return {
|
||||
@ -35,7 +35,7 @@ export default React.createClass({
|
||||
]
|
||||
};
|
||||
},
|
||||
mixins: [ PickerMixin ],
|
||||
mixins: [PickerMixin],
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if ('value' in nextProps) {
|
||||
const value = nextProps.value || [];
|
||||
@ -62,14 +62,14 @@ export default React.createClass({
|
||||
let defaultCalendarValue = new GregorianCalendar(locale);
|
||||
defaultCalendarValue.setTime(Date.now());
|
||||
|
||||
const {disabledDate, showTime, size, startPlaceholder, endPlaceholder,
|
||||
transitionName, disabled, popupStyle, align, style} = this.props;
|
||||
const { disabledDate, showTime, size, startPlaceholder, endPlaceholder,
|
||||
transitionName, disabled, popupStyle, align, style } = this.props;
|
||||
const state = this.state;
|
||||
|
||||
const timePicker = showTime
|
||||
? <TimePicker prefixCls="ant-time-picker"
|
||||
placeholder={locale.lang.timePlaceholder}
|
||||
transitionName="slide-up" />
|
||||
placeholder={locale.lang.timePlaceholder}
|
||||
transitionName="slide-up" />
|
||||
: null;
|
||||
|
||||
const calendarClassName = classNames({
|
||||
@ -77,13 +77,13 @@ export default React.createClass({
|
||||
});
|
||||
|
||||
const calendar = <RangeCalendar prefixCls="ant-calendar"
|
||||
className={calendarClassName}
|
||||
timePicker={timePicker}
|
||||
disabledDate={disabledDate}
|
||||
dateInputPlaceholder={[startPlaceholder, endPlaceholder]}
|
||||
locale={locale.lang}
|
||||
defaultValue={defaultCalendarValue}
|
||||
showClear />;
|
||||
className={calendarClassName}
|
||||
timePicker={timePicker}
|
||||
disabledDate={disabledDate}
|
||||
dateInputPlaceholder={[startPlaceholder, endPlaceholder]}
|
||||
locale={locale.lang}
|
||||
defaultValue={defaultCalendarValue}
|
||||
showClear />;
|
||||
|
||||
const pickerClass = classNames({
|
||||
'ant-calendar-picker': true,
|
||||
@ -110,7 +110,7 @@ export default React.createClass({
|
||||
onClose={this.toggleOpen}
|
||||
onChange={this.handleChange}>
|
||||
{
|
||||
({value}) => {
|
||||
({ value }) => {
|
||||
const start = value[0];
|
||||
const end = value[1];
|
||||
return (
|
||||
|
@ -30,7 +30,7 @@ function createPicker(TheCalendar, defaultFormat) {
|
||||
value: this.parseDateFromValue(this.props.value || this.props.defaultValue)
|
||||
};
|
||||
},
|
||||
mixins: [ PickerMixin ],
|
||||
mixins: [PickerMixin],
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if ('value' in nextProps) {
|
||||
this.setState({
|
||||
@ -58,8 +58,8 @@ function createPicker(TheCalendar, defaultFormat) {
|
||||
|
||||
const timePicker = this.props.showTime
|
||||
? <TimePicker prefixCls="ant-time-picker"
|
||||
placeholder={locale.lang.timePlaceholder}
|
||||
transitionName="slide-up" />
|
||||
placeholder={locale.lang.timePlaceholder}
|
||||
transitionName="slide-up" />
|
||||
: null;
|
||||
|
||||
const calendarClassName = classNames({
|
||||
@ -104,15 +104,15 @@ function createPicker(TheCalendar, defaultFormat) {
|
||||
onClose={this.toggleOpen}
|
||||
onChange={this.handleChange}>
|
||||
{
|
||||
({value}) => {
|
||||
({ value }) => {
|
||||
return (
|
||||
<span>
|
||||
<input disabled={this.props.disabled}
|
||||
onChange={this.handleInputChange}
|
||||
value={value && this.getFormatter().format(value)}
|
||||
placeholder={placeholder}
|
||||
style={this.props.style}
|
||||
className={'ant-calendar-picker-input ant-input' + sizeClass}/>
|
||||
onChange={this.handleInputChange}
|
||||
value={value && this.getFormatter().format(value)}
|
||||
placeholder={placeholder}
|
||||
style={this.props.style}
|
||||
className={'ant-calendar-picker-input ant-input' + sizeClass}/>
|
||||
<span className="ant-calendar-picker-icon"/>
|
||||
</span>
|
||||
);
|
||||
|
@ -17,7 +17,7 @@ const align = {
|
||||
export default React.createClass({
|
||||
getDefaultProps() {
|
||||
return {
|
||||
align: align,
|
||||
align,
|
||||
type: 'default',
|
||||
};
|
||||
},
|
||||
|
@ -2,13 +2,13 @@ import React from 'react';
|
||||
import Dropdown from 'rc-dropdown';
|
||||
|
||||
export default React.createClass({
|
||||
getDefaultProps: function () {
|
||||
getDefaultProps() {
|
||||
return {
|
||||
transitionName: 'slide-up',
|
||||
prefixCls: 'ant-dropdown',
|
||||
};
|
||||
},
|
||||
render: function () {
|
||||
render() {
|
||||
const { overlay, ...otherProps } = this.props;
|
||||
const menu = React.cloneElement(overlay, {
|
||||
openTransitionName: 'zoom-big',
|
||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
function prefixClsFn(prefixCls, ...args) {
|
||||
return args.map((s)=> {
|
||||
return args.map((s) => {
|
||||
return prefixCls + '-' + s;
|
||||
}).join(' ');
|
||||
}
|
||||
@ -12,7 +12,7 @@ class FormItem extends React.Component {
|
||||
if (!colDef) {
|
||||
return '';
|
||||
}
|
||||
const {span, offset} = colDef;
|
||||
const { span, offset } = colDef;
|
||||
const col = span ? 'col-' + span : '';
|
||||
const offsetCol = offset ? ' col-offset-' + offset : '';
|
||||
return col + offsetCol;
|
||||
@ -61,7 +61,8 @@ class FormItem extends React.Component {
|
||||
const required = this.props.required ? 'required' : '';
|
||||
|
||||
return this.props.label ? (
|
||||
<label htmlFor={this.props.id} className={this._getLayoutClass(labelCol)} required={required} key="label">
|
||||
<label htmlFor={this.props.id} className={this._getLayoutClass(labelCol)}
|
||||
required={required} key="label">
|
||||
{this.props.label}
|
||||
</label>
|
||||
) : null;
|
||||
@ -92,7 +93,8 @@ class FormItem extends React.Component {
|
||||
let prefixCls = child.props && child.props.prefixCls;
|
||||
prefixCls = prefixCls ? prefixCls.substring(prefixCls.indexOf('-') + 1) : '';
|
||||
|
||||
if ((type && compactControls.indexOf(type) > -1) || (prefixCls && compactControls.indexOf(prefixCls) > -1)) {
|
||||
if ((type && compactControls.indexOf(type) > -1) ||
|
||||
(prefixCls && compactControls.indexOf(prefixCls) > -1)) {
|
||||
isCompact = true;
|
||||
} else if (child.props && typeof child.props.children === 'object') {
|
||||
isCompact = this._isCompact(child.props.children);
|
||||
|
@ -1,8 +1,8 @@
|
||||
function merge() {
|
||||
const ret = {};
|
||||
const args = [].slice.call(arguments, 0);
|
||||
args.forEach((a)=> {
|
||||
Object.keys(a).forEach((k)=> {
|
||||
args.forEach((a) => {
|
||||
Object.keys(a).forEach((k) => {
|
||||
ret[k] = a[k];
|
||||
});
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ export default React.createClass({
|
||||
};
|
||||
},
|
||||
render() {
|
||||
const {className, size, ...other} = this.props;
|
||||
const { className, size, ...other } = this.props;
|
||||
const inputNumberClass = classNames({
|
||||
'ant-input-number-lg': size === 'large',
|
||||
'ant-input-number-sm': size === 'small',
|
||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import assign from 'object-assign';
|
||||
|
||||
function prefixClsFn(prefixCls, ...args) {
|
||||
return args.map((s)=> {
|
||||
return args.map((s) => {
|
||||
return prefixCls + '-' + s;
|
||||
}).join(' ');
|
||||
}
|
||||
@ -26,8 +26,7 @@ class Group extends React.Component {
|
||||
render() {
|
||||
const className = 'ant-input-group ' + (this.props.className || '');
|
||||
return (
|
||||
<span className={className}
|
||||
style={this.props.style}>
|
||||
<span className={className} style={this.props.style}>
|
||||
{this.props.children}
|
||||
</span>
|
||||
);
|
||||
@ -73,9 +72,9 @@ class Input extends React.Component {
|
||||
}
|
||||
|
||||
switch (props.size) {
|
||||
case 'small': inputClassName = prefixClsFn(prefixCls, 'input', 'input-sm'); break;
|
||||
case 'large': inputClassName = prefixClsFn(prefixCls, 'input', 'input-lg'); break;
|
||||
default:
|
||||
case 'small': inputClassName = prefixClsFn(prefixCls, 'input', 'input-sm'); break;
|
||||
case 'large': inputClassName = prefixClsFn(prefixCls, 'input', 'input-lg'); break;
|
||||
default:
|
||||
}
|
||||
let placeholder = props.placeholder;
|
||||
if(placeholder && ieGT9()){
|
||||
|
@ -87,7 +87,7 @@
|
||||
"css-loader": "^0.23.0",
|
||||
"es3ify-loader": "^0.1.0",
|
||||
"eslint": "^1.1.0",
|
||||
"eslint-config-airbnb": "^1.0.0",
|
||||
"eslint-config-airbnb": "^3.0.0",
|
||||
"eslint-plugin-babel": "^3.0.0",
|
||||
"eslint-plugin-markdown-antd": "0.0.0",
|
||||
"eslint-plugin-react": "^3.3.1",
|
||||
|
Loading…
Reference in New Issue
Block a user