From 475e4ff23d8cccf03f4aeec3deaca53e1b66a89b Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 9 Oct 2017 13:23:20 +0800 Subject: [PATCH] upgrade eslint-config-airbnb --- .eslintrc.js | 7 ++ components/affix/__tests__/Affix.test.js | 38 ++++---- components/alert/demo/closable.md | 30 +++--- components/alert/demo/description.md | 46 +++++----- components/alert/demo/icon.md | 62 +++++++------ components/alert/demo/style.md | 14 +-- components/calendar/demo/notice-calendar.md | 10 +- components/carousel/__tests__/index.test.js | 2 +- components/cascader/demo/lazy.md | 4 - components/collapse/demo/accordion.md | 8 +- components/collapse/demo/mix.md | 8 +- components/dropdown/demo/trigger.md | 4 +- components/layout/demo/responsive.md | 74 +++++++-------- .../locale-provider/__tests__/index.test.js | 6 +- components/menu/__tests__/index.test.js | 2 +- components/modal/__tests__/confirm.test.js | 2 +- .../notification/__tests__/placement.test.js | 2 +- components/popconfirm/demo/dynamic-trigger.md | 6 +- components/popconfirm/demo/placement.md | 92 ++++++++++--------- components/radio/demo/radiobutton.md | 50 +++++----- components/radio/demo/size.md | 50 +++++----- components/rate/demo/text.md | 1 - components/select/demo/label-in-value.md | 2 +- components/switch/demo/text.md | 16 ++-- .../table/__tests__/Table.filter.test.js | 30 +++--- components/table/__tests__/empty.test.js | 8 +- components/table/demo/nested-table.md | 2 +- .../table/demo/row-selection-and-operation.md | 2 +- components/table/demo/row-selection-custom.md | 4 +- components/table/demo/row-selection.md | 2 +- components/transfer/__tests__/search.test.js | 2 +- components/transfer/demo/custom-item.md | 4 +- components/upload/demo/defaultFileList.md | 4 +- components/upload/index.en-US.md | 4 +- components/upload/index.zh-CN.md | 4 +- package.json | 6 +- site/theme/index.js | 4 +- .../theme/template/Color/ColorPaletteTool.jsx | 8 +- site/theme/template/Content/Article.jsx | 6 +- site/theme/template/Content/ComponentDoc.jsx | 8 +- site/theme/template/Content/Demo.jsx | 6 +- site/theme/template/Content/MainContent.jsx | 34 +++---- site/theme/template/Content/index.jsx | 8 +- site/theme/template/Home/Page4.jsx | 4 +- site/theme/template/Layout/Footer.jsx | 2 +- site/theme/template/Layout/Header.jsx | 56 +++++------ site/theme/template/Layout/index.jsx | 2 +- 47 files changed, 394 insertions(+), 352 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index aa92f6346940..e2f3c0ec5deb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,6 +30,7 @@ const eslintrc = { 'import/extensions': 0, 'import/no-unresolved': 0, 'import/no-extraneous-dependencies': 0, + 'prefer-destructuring': 0, 'no-param-reassign': 0, 'no-return-assign': 0, 'max-len': 0, @@ -38,8 +39,13 @@ const eslintrc = { 'react/require-extension': 0, 'jsx-a11y/no-static-element-interactions': 0, 'jsx-a11y/anchor-has-content': 0, + 'jsx-a11y/click-events-have-key-events': 0, + 'jsx-a11y/anchor-is-valid': 0, 'react/no-danger': 0, 'comma-dangle': ['error', 'always-multiline'], + 'function-paren-newline': 0, + 'object-curly-newline': 0, + 'no-restricted-globals': 0, }, }; @@ -51,6 +57,7 @@ if (process.env.RUN_ENV === 'DEMO') { }; Object.assign(eslintrc.rules, { + indent: 0, 'no-console': 0, 'no-plusplus': 0, 'eol-last': 0, diff --git a/components/affix/__tests__/Affix.test.js b/components/affix/__tests__/Affix.test.js index 9e3ce25e1502..ce449fffbf73 100644 --- a/components/affix/__tests__/Affix.test.js +++ b/components/affix/__tests__/Affix.test.js @@ -18,30 +18,32 @@ class AffixMounter extends React.Component { return this.container; } render() { - return (
{ this.container = node; }} - > + return (
{ this.container = node; }} > - this.container} - ref={ele => this.affix = ele} +
- - + this.container} + ref={ele => this.affix = ele} + > + + +
-
); + ); } } diff --git a/components/alert/demo/closable.md b/components/alert/demo/closable.md index d1f35acb71c7..fffd5390f47f 100644 --- a/components/alert/demo/closable.md +++ b/components/alert/demo/closable.md @@ -20,17 +20,21 @@ const onClose = function (e) { console.log(e, 'I was closed.'); }; -ReactDOM.render(
- - -
, mountNode); +ReactDOM.render( +
+ + +
+, mountNode); ```` diff --git a/components/alert/demo/description.md b/components/alert/demo/description.md index 9d8c5fd18933..b7362992a2e0 100644 --- a/components/alert/demo/description.md +++ b/components/alert/demo/description.md @@ -16,26 +16,28 @@ Additional description for alert message. ````jsx import { Alert } from 'antd'; -ReactDOM.render(
- - - - -
, mountNode); +ReactDOM.render( +
+ + + + +
+, mountNode); ```` diff --git a/components/alert/demo/icon.md b/components/alert/demo/icon.md index 8b94e9b3b3dd..821adba8f38a 100644 --- a/components/alert/demo/icon.md +++ b/components/alert/demo/icon.md @@ -16,34 +16,36 @@ Decent icon make information more clear and more friendly. ````jsx import { Alert } from 'antd'; -ReactDOM.render(
- - - - - - - - -
, mountNode); +ReactDOM.render( +
+ + + + + + + + +
+, mountNode); ```` diff --git a/components/alert/demo/style.md b/components/alert/demo/style.md index 7fae3b28b690..37f906abea7b 100644 --- a/components/alert/demo/style.md +++ b/components/alert/demo/style.md @@ -16,10 +16,12 @@ There are 4 types of Alert: `success`, `info`, `warning`, `error`. ````jsx import { Alert } from 'antd'; -ReactDOM.render(
- - - - -
, mountNode); +ReactDOM.render( +
+ + + + +
+, mountNode); ```` diff --git a/components/calendar/demo/notice-calendar.md b/components/calendar/demo/notice-calendar.md index 2d464329cd45..56afb9ca62ef 100644 --- a/components/calendar/demo/notice-calendar.md +++ b/components/calendar/demo/notice-calendar.md @@ -68,10 +68,12 @@ function getMonthData(value) { function monthCellRender(value) { const num = getMonthData(value); - return num ?
-
{num}
- Backlog number -
: null; + return num ? ( +
+
{num}
+ Backlog number +
+ ) : null; } ReactDOM.render( diff --git a/components/carousel/__tests__/index.test.js b/components/carousel/__tests__/index.test.js index 356c4412b21f..6226dd2017f0 100644 --- a/components/carousel/__tests__/index.test.js +++ b/components/carousel/__tests__/index.test.js @@ -5,7 +5,7 @@ import Carousel from '..'; describe('Carousel', () => { it('should has innerSlider', () => { const wrapper = mount(
); - const innerSlider = wrapper.node.innerSlider; + const { innerSlider } = wrapper.node; const innerSliderFromRefs = wrapper.node.refs.slick.innerSlider; expect(innerSlider).toBe(innerSliderFromRefs); expect(typeof innerSlider.slickNext).toBe('function'); diff --git a/components/cascader/demo/lazy.md b/components/cascader/demo/lazy.md index 2852cd0c5d8a..bf97cf747f75 100644 --- a/components/cascader/demo/lazy.md +++ b/components/cascader/demo/lazy.md @@ -32,14 +32,10 @@ const options = [{ class LazyOptions extends React.Component { state = { - inputValue: '', options, }; onChange = (value, selectedOptions) => { console.log(value, selectedOptions); - this.setState({ - inputValue: selectedOptions.map(o => o.label).join(', '), - }); } loadData = (selectedOptions) => { const targetOption = selectedOptions[selectedOptions.length - 1]; diff --git a/components/collapse/demo/accordion.md b/components/collapse/demo/accordion.md index 33a4143c4b67..b2ec93873b06 100644 --- a/components/collapse/demo/accordion.md +++ b/components/collapse/demo/accordion.md @@ -1,6 +1,6 @@ --- order: 1 -title: +title: zh-CN: 手风琴 en-US: Accordion --- @@ -25,13 +25,13 @@ const text = ` ReactDOM.render( - +

{text}

- +

{text}

- +

{text}

diff --git a/components/collapse/demo/mix.md b/components/collapse/demo/mix.md index b6124e715bd8..ebbd73454dd0 100644 --- a/components/collapse/demo/mix.md +++ b/components/collapse/demo/mix.md @@ -29,17 +29,17 @@ const text = ` ReactDOM.render( - + - +

{text}

- +

{text}

- +

{text}

diff --git a/components/dropdown/demo/trigger.md b/components/dropdown/demo/trigger.md index d000480e2676..993737d51e82 100644 --- a/components/dropdown/demo/trigger.md +++ b/components/dropdown/demo/trigger.md @@ -29,11 +29,11 @@ const menu = ( ); -ReactDOM.render(
+ReactDOM.render( Click me -
, mountNode); +, mountNode); ```` diff --git a/components/layout/demo/responsive.md b/components/layout/demo/responsive.md index b91979aed976..d75d8c9fef18 100644 --- a/components/layout/demo/responsive.md +++ b/components/layout/demo/responsive.md @@ -21,44 +21,46 @@ Layout.Sider supports responsive layout. import { Layout, Menu, Icon } from 'antd'; const { Header, Content, Footer, Sider } = Layout; -ReactDOM.render( - { console.log(collapsed, type); }} - > -
- - - - nav 1 - - - - nav 2 - - - - nav 3 - - - - nav 4 - - - +ReactDOM.render( -
- -
- content -
-
-
- Ant Design ©2016 Created by Ant UED -
+ { console.log(collapsed, type); }} + > +
+ + + + nav 1 + + + + nav 2 + + + + nav 3 + + + + nav 4 + + + + +
+ +
+ content +
+
+
+ Ant Design ©2016 Created by Ant UED +
+ -, mountNode); +, mountNode); ```` ````css diff --git a/components/locale-provider/__tests__/index.test.js b/components/locale-provider/__tests__/index.test.js index 69795dd44e1d..76bd48d90239 100644 --- a/components/locale-provider/__tests__/index.test.js +++ b/components/locale-provider/__tests__/index.test.js @@ -2,7 +2,7 @@ import React from 'react'; import { mount } from 'enzyme'; import moment from 'moment'; import { LocaleProvider, Pagination, DatePicker, TimePicker, Calendar, - Popconfirm, Table, Modal, Select, Transfer } from '../../'; + Popconfirm, Table, Modal, Select, Transfer } from '../../'; import enGB from '../en_GB'; import frFR from '../fr_FR'; import nlBE from '../nl_BE'; @@ -36,8 +36,8 @@ import srRS from '../sr_RS'; const locales = [enUS, ptPT, ptBR, ruRU, esES, svSE, frBE, deDE, nlNL, caES, csCZ, koKR, etEE, skSK, jaJP, trTR, zhTW, fiFI, plPL, bgBG, enGB, frFR, nlBE, itIT, viVN, thTH, faIR, elGR, nbNO, srRS]; -const Option = Select.Option; -const RangePicker = DatePicker.RangePicker; +const { Option } = Select; +const { RangePicker } = DatePicker; const columns = [{ title: 'Name', diff --git a/components/menu/__tests__/index.test.js b/components/menu/__tests__/index.test.js index 313fb91c083a..f4b42848f529 100644 --- a/components/menu/__tests__/index.test.js +++ b/components/menu/__tests__/index.test.js @@ -3,7 +3,7 @@ import { mount } from 'enzyme'; import Menu from '..'; import Icon from '../../icon'; -const SubMenu = Menu.SubMenu; +const { SubMenu } = Menu; const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); describe('Menu', () => { diff --git a/components/modal/__tests__/confirm.test.js b/components/modal/__tests__/confirm.test.js index e394348314aa..c1a0b975e9ed 100644 --- a/components/modal/__tests__/confirm.test.js +++ b/components/modal/__tests__/confirm.test.js @@ -1,6 +1,6 @@ import Modal from '..'; -const confirm = Modal.confirm; +const { confirm } = Modal; describe('Modal.confirm triggers callbacks correctly', () => { const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); diff --git a/components/notification/__tests__/placement.test.js b/components/notification/__tests__/placement.test.js index f533610ee252..f120af007acd 100644 --- a/components/notification/__tests__/placement.test.js +++ b/components/notification/__tests__/placement.test.js @@ -8,7 +8,7 @@ describe('Notification.placement', () => { } function getStyle(el, prop, getComputedStyle, style) { - getComputedStyle = window.getComputedStyle; + getComputedStyle = getComputedStyle || window.getComputedStyle; style = getComputedStyle ? getComputedStyle(el) : el.currentStyle; // If a css property's value is `auto`, it will return an empty string. diff --git a/components/popconfirm/demo/dynamic-trigger.md b/components/popconfirm/demo/dynamic-trigger.md index c68f8bc5215a..25930cd3727d 100755 --- a/components/popconfirm/demo/dynamic-trigger.md +++ b/components/popconfirm/demo/dynamic-trigger.md @@ -19,7 +19,7 @@ import { Popconfirm, Switch, message } from 'antd'; class App extends React.Component { state = { visible: false, - condition: true, // Whether meet the condition, if not show popconfirm. + condition: true, // Whether meet the condition, if not show popconfirm. } changeCondition = (value) => { this.setState({ condition: value }); @@ -40,9 +40,9 @@ class App extends React.Component { // Determining condition before show the popconfirm. console.log(this.state.condition); if (this.state.condition) { - this.confirm(); // next step + this.confirm(); // next step } else { - this.setState({ visible }); // show the popconfirm + this.setState({ visible }); // show the popconfirm } } render() { diff --git a/components/popconfirm/demo/placement.md b/components/popconfirm/demo/placement.md index 1f796fde08d4..9487fa26a1d4 100755 --- a/components/popconfirm/demo/placement.md +++ b/components/popconfirm/demo/placement.md @@ -22,52 +22,54 @@ function confirm() { message.info('Click on Yes.'); } -ReactDOM.render(
-
- - - - - - - - - +ReactDOM.render( +
+
+ + + + + + + + + +
+
+ + + + + + + + + +
+
+ + + + + + + + + +
+
+ + + + + + + + + +
-
- - - - - - - - - -
-
- - - - - - - - - -
-
- - - - - - - - - -
-
, mountNode); +, mountNode); ````