chore: fix some eslint problems (#24836)

* 💄 fix lint

* 💄 fix lint
This commit is contained in:
偏右 2020-06-08 18:01:50 +08:00 committed by GitHub
parent 1eb702b166
commit 637aa09bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 170 additions and 150 deletions

View File

@ -50,19 +50,29 @@ module.exports = {
'react/no-multi-comp': 0,
'jsx-a11y/href-no-hash': 0,
'import/no-extraneous-dependencies': 0,
'import/no-unresolved': 0,
'jsx-a11y/control-has-associated-label': 0,
},
},
],
rules: {
camelcase: 0,
'react/jsx-one-expression-per-line': 0,
'react/prop-types': 0,
'react/forbid-prop-types': 0,
'react/jsx-indent': 0,
'react/jsx-wrap-multilines': ['error', { declaration: false, assignment: false }],
'react/jsx-filename-extension': 0,
'react/state-in-constructor': 0,
'react/jsx-props-no-spreading': 0,
'react/destructuring-assignment': 0, // TODO: remove later
'react/require-default-props': 0,
'react/sort-comp': 0,
'react/display-name': 0,
'react/static-property-placement': 0,
'react/no-find-dom-node': 0,
'react-hooks/rules-of-hooks': 2, // Checks rules of Hooks
'import/extensions': 0,
'import/no-cycle': 0,
'import/no-extraneous-dependencies': [
'error',
{
@ -82,38 +92,26 @@ module.exports = {
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/anchor-is-valid': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0,
'comma-dangle': ['error', 'always-multiline'],
'react/jsx-filename-extension': 0,
'react/state-in-constructor': 0,
'react/jsx-props-no-spreading': 0,
'prefer-destructuring': 0, // TODO: remove later
'consistent-return': 0, // TODO: remove later
'no-return-assign': 0, // TODO: remove later
'no-param-reassign': 0, // TODO: remove later
'react/destructuring-assignment': 0, // TODO: remove later
'react/no-did-update-set-state': 0, // TODO: remove later
'react/require-default-props': 0,
'react/default-props-match-prop-types': 0,
'import/no-cycle': 0,
'react/no-find-dom-node': 0,
'no-underscore-dangle': 0,
'react/sort-comp': 0,
// label-has-for has been deprecated
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
'jsx-a11y/label-has-for': 0,
'comma-dangle': ['error', 'always-multiline'],
'consistent-return': 0, // TODO: remove later
'no-param-reassign': 0, // TODO: remove later
'no-underscore-dangle': 0,
// for (let i = 0; i < len; i++)
'no-plusplus': 0,
// https://eslint.org/docs/rules/no-continue
// labeledLoop is conflicted with `eslint . --fix`
'no-continue': 0,
'react/display-name': 0,
// ban this for Number.isNaN needs polyfill
'no-restricted-globals': 0,
'max-classes-per-file': 0,
'react/static-property-placement': 0,
'jest/no-test-callback': 0,
'jest/expect-expect': 0,
'react-hooks/rules-of-hooks': 2, // Checks rules of Hooks
'unicorn/better-regex': 2,
'unicorn/prefer-trim-start-end': 2,
'unicorn/expiring-todo-comments': 2,

View File

@ -5,5 +5,6 @@ export function easeInOutCubic(t: number, b: number, c: number, d: number) {
if (t < 1) {
return (cc / 2) * t * t * t + b;
}
// eslint-disable-next-line no-return-assign
return (cc / 2) * ((t -= 2) * t * t + 2) + b;
}

View File

@ -1,6 +1,6 @@
import * as React from 'react';
export const isValidElement = React.isValidElement;
export const { isValidElement } = React;
export function replaceElement(
element: React.ReactNode,

View File

@ -107,6 +107,7 @@ class Affix extends React.Component<AffixProps, AffixState> {
this.updatePosition();
}
// eslint-disable-next-line react/no-did-update-set-state
this.setState({ prevTarget: newTarget });
}

View File

@ -307,7 +307,8 @@ describe('Anchor Render', () => {
let start = 0;
const handler = () => {
return (start += 1000);
start += 1000;
return start;
};
return jest.spyOn(Date, 'now').mockImplementation(handler);
@ -384,7 +385,8 @@ describe('Anchor Render', () => {
let start = 0;
const handler = () => {
return (start += 1000);
start += 1000;
return start;
};
return jest.spyOn(Date, 'now').mockImplementation(handler);
@ -432,7 +434,8 @@ describe('Anchor Render', () => {
let start = 0;
const handler = () => {
return (start += 1000);
start += 1000;
return start;
};
return jest.spyOn(Date, 'now').mockImplementation(handler);

View File

@ -53,7 +53,7 @@ const AutoComplete: React.RefForwardingComponent<Select, AutoCompleteProps> = (p
isValidElement(childNodes[0]) &&
!isSelectOptionOrSelectOptGroup(childNodes[0])
) {
customizeInput = childNodes[0];
[customizeInput] = childNodes;
}
const getInputElement = (): React.ReactElement => customizeInput;

View File

@ -63,6 +63,7 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
componentDidUpdate(prevProps: AvatarProps) {
if (prevProps.src !== this.props.src) {
// eslint-disable-next-line react/no-did-update-set-state
this.setState({ isImgExist: true, scale: 1 });
}
if (prevProps.children !== this.props.children || prevProps.gap !== this.props.gap) {
@ -179,7 +180,9 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
children = (
<span
className={`${prefixCls}-string`}
ref={(node: HTMLElement) => (this.avatarChildren = node)}
ref={(node: HTMLElement) => {
this.avatarChildren = node;
}}
style={{ ...sizeChildrenStyle, ...childrenStyle }}
>
{children}
@ -195,7 +198,9 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
<span
className={`${prefixCls}-string`}
style={{ opacity: 0 }}
ref={(node: HTMLElement) => (this.avatarChildren = node)}
ref={(node: HTMLElement) => {
this.avatarChildren = node;
}}
>
{children}
</span>
@ -213,7 +218,9 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
{...others}
style={{ ...sizeStyle, ...others.style }}
className={classString}
ref={(node: HTMLElement) => (this.avatarNode = node)}
ref={(node: HTMLElement) => {
this.avatarNode = node;
}}
>
{children}
</span>

View File

@ -1,3 +1,3 @@
import ar_EG from '../../date-picker/locale/ar_EG';
import arEG from '../../date-picker/locale/ar_EG';
export default ar_EG;
export default arEG;

View File

@ -1,3 +1,3 @@
import az_AZ from '../../date-picker/locale/az_AZ';
import azAZ from '../../date-picker/locale/az_AZ';
export default az_AZ;
export default azAZ;

View File

@ -1,3 +1,3 @@
import bg_BG from '../../date-picker/locale/bg_BG';
import bgBG from '../../date-picker/locale/bg_BG';
export default bg_BG;
export default bgBG;

View File

@ -1,3 +1,3 @@
import ca_ES from '../../date-picker/locale/ca_ES';
import caES from '../../date-picker/locale/ca_ES';
export default ca_ES;
export default caES;

View File

@ -1,3 +1,3 @@
import cs_CZ from '../../date-picker/locale/cs_CZ';
import csCZ from '../../date-picker/locale/cs_CZ';
export default cs_CZ;
export default csCZ;

View File

@ -1,3 +1,3 @@
import da_DK from '../../date-picker/locale/da_DK';
import daDK from '../../date-picker/locale/da_DK';
export default da_DK;
export default daDK;

View File

@ -1,3 +1,3 @@
import de_DE from '../../date-picker/locale/de_DE';
import deDE from '../../date-picker/locale/de_DE';
export default de_DE;
export default deDE;

View File

@ -1,3 +1,3 @@
import el_GR from '../../date-picker/locale/el_GR';
import elGR from '../../date-picker/locale/el_GR';
export default el_GR;
export default elGR;

View File

@ -1,3 +1,3 @@
import en_GB from '../../date-picker/locale/en_GB';
import enGB from '../../date-picker/locale/en_GB';
export default en_GB;
export default enGB;

View File

@ -1,3 +1,3 @@
import en_US from '../../date-picker/locale/en_US';
import enUS from '../../date-picker/locale/en_US';
export default en_US;
export default enUS;

View File

@ -1,3 +1,3 @@
import es_ES from '../../date-picker/locale/es_ES';
import esES from '../../date-picker/locale/es_ES';
export default es_ES;
export default esES;

View File

@ -1,3 +1,3 @@
import et_EE from '../../date-picker/locale/et_EE';
import etEE from '../../date-picker/locale/et_EE';
export default et_EE;
export default etEE;

View File

@ -1,3 +1,3 @@
import fa_IR from '../../date-picker/locale/fa_IR';
import faIR from '../../date-picker/locale/fa_IR';
export default fa_IR;
export default faIR;

View File

@ -1,3 +1,3 @@
import fi_FI from '../../date-picker/locale/fi_FI';
import fiFI from '../../date-picker/locale/fi_FI';
export default fi_FI;
export default fiFI;

View File

@ -1,3 +1,3 @@
import fr_BE from '../../date-picker/locale/fr_BE';
import frBE from '../../date-picker/locale/fr_BE';
export default fr_BE;
export default frBE;

View File

@ -1,3 +1,3 @@
import fr_FR from '../../date-picker/locale/fr_FR';
import frFR from '../../date-picker/locale/fr_FR';
export default fr_FR;
export default frFR;

View File

@ -1,3 +1,3 @@
import ga_IE from '../../date-picker/locale/ga_IE';
import gaIE from '../../date-picker/locale/ga_IE';
export default ga_IE;
export default gaIE;

View File

@ -1,3 +1,3 @@
import he_IL from '../../date-picker/locale/he_IL';
import heIL from '../../date-picker/locale/he_IL';
export default he_IL;
export default heIL;

View File

@ -1,3 +1,3 @@
import hi_IN from '../../date-picker/locale/hi_IN';
import hiIN from '../../date-picker/locale/hi_IN';
export default hi_IN;
export default hiIN;

View File

@ -1,3 +1,3 @@
import hr_HR from '../../date-picker/locale/hr_HR';
import hrHR from '../../date-picker/locale/hr_HR';
export default hr_HR;
export default hrHR;

View File

@ -1,3 +1,3 @@
import hu_HU from '../../date-picker/locale/hu_HU';
import huHU from '../../date-picker/locale/hu_HU';
export default hu_HU;
export default huHU;

View File

@ -1,3 +1,3 @@
import id_ID from '../../date-picker/locale/id_ID';
import idID from '../../date-picker/locale/id_ID';
export default id_ID;
export default idID;

View File

@ -1,3 +1,3 @@
import is_IS from '../../date-picker/locale/is_IS';
import isIS from '../../date-picker/locale/is_IS';
export default is_IS;
export default isIS;

View File

@ -1,3 +1,3 @@
import it_IT from '../../date-picker/locale/it_IT';
import itIT from '../../date-picker/locale/it_IT';
export default it_IT;
export default itIT;

View File

@ -1,3 +1,3 @@
import ja_JP from '../../date-picker/locale/ja_JP';
import jaJP from '../../date-picker/locale/ja_JP';
export default ja_JP;
export default jaJP;

View File

@ -1,3 +1,3 @@
import kn_IN from '../../date-picker/locale/kn_IN';
import knIN from '../../date-picker/locale/kn_IN';
export default kn_IN;
export default knIN;

View File

@ -1,3 +1,3 @@
import ko_KR from '../../date-picker/locale/ko_KR';
import koKR from '../../date-picker/locale/ko_KR';
export default ko_KR;
export default koKR;

View File

@ -1,3 +1,3 @@
import ku_IQ from '../../date-picker/locale/ku_IQ';
import kuIQ from '../../date-picker/locale/ku_IQ';
export default ku_IQ;
export default kuIQ;

View File

@ -1,3 +1,3 @@
import lv_LV from '../../date-picker/locale/lv_LV';
import lvLV from '../../date-picker/locale/lv_LV';
export default lv_LV;
export default lvLV;

View File

@ -1,3 +1,3 @@
import mk_MK from '../../date-picker/locale/mk_MK';
import mkMK from '../../date-picker/locale/mk_MK';
export default mk_MK;
export default mkMK;

View File

@ -1,3 +1,3 @@
import mn_MN from '../../date-picker/locale/mn_MN';
import mnMN from '../../date-picker/locale/mn_MN';
export default mn_MN;
export default mnMN;

View File

@ -1,3 +1,3 @@
import ms_MY from '../../date-picker/locale/ms_MY';
import msMY from '../../date-picker/locale/ms_MY';
export default ms_MY;
export default msMY;

View File

@ -1,3 +1,3 @@
import nb_NO from '../../date-picker/locale/nb_NO';
import nbNO from '../../date-picker/locale/nb_NO';
export default nb_NO;
export default nbNO;

View File

@ -1,3 +1,3 @@
import nl_BE from '../../date-picker/locale/nl_BE';
import nlBE from '../../date-picker/locale/nl_BE';
export default nl_BE;
export default nlBE;

View File

@ -1,3 +1,3 @@
import nl_NL from '../../date-picker/locale/nl_NL';
import nlNL from '../../date-picker/locale/nl_NL';
export default nl_NL;
export default nlNL;

View File

@ -1,3 +1,3 @@
import pl_PL from '../../date-picker/locale/pl_PL';
import plPL from '../../date-picker/locale/pl_PL';
export default pl_PL;
export default plPL;

View File

@ -1,3 +1,3 @@
import pt_BR from '../../date-picker/locale/pt_BR';
import ptBR from '../../date-picker/locale/pt_BR';
export default pt_BR;
export default ptBR;

View File

@ -1,3 +1,3 @@
import pt_PT from '../../date-picker/locale/pt_PT';
import ptPT from '../../date-picker/locale/pt_PT';
export default pt_PT;
export default ptPT;

View File

@ -1,3 +1,3 @@
import ro_RO from '../../date-picker/locale/ro_RO';
import roRO from '../../date-picker/locale/ro_RO';
export default ro_RO;
export default roRO;

View File

@ -1,3 +1,3 @@
import ru_RU from '../../date-picker/locale/ru_RU';
import ruRU from '../../date-picker/locale/ru_RU';
export default ru_RU;
export default ruRU;

View File

@ -1,3 +1,3 @@
import sk_SK from '../../date-picker/locale/sk_SK';
import skSK from '../../date-picker/locale/sk_SK';
export default sk_SK;
export default skSK;

View File

@ -1,3 +1,3 @@
import sl_SI from '../../date-picker/locale/sl_SI';
import slSI from '../../date-picker/locale/sl_SI';
export default sl_SI;
export default slSI;

View File

@ -1,3 +1,3 @@
import sr_RS from '../../date-picker/locale/sr_RS';
import srRS from '../../date-picker/locale/sr_RS';
export default sr_RS;
export default srRS;

View File

@ -1,3 +1,3 @@
import sv_SE from '../../date-picker/locale/sv_SE';
import svSE from '../../date-picker/locale/sv_SE';
export default sv_SE;
export default svSE;

View File

@ -1,3 +1,3 @@
import ta_IN from '../../date-picker/locale/ta_IN';
import taIN from '../../date-picker/locale/ta_IN';
export default ta_IN;
export default taIN;

View File

@ -1,3 +1,3 @@
import th_TH from '../../date-picker/locale/th_TH';
import thTH from '../../date-picker/locale/th_TH';
export default th_TH;
export default thTH;

View File

@ -1,3 +1,3 @@
import tr_TR from '../../date-picker/locale/tr_TR';
import trTR from '../../date-picker/locale/tr_TR';
export default tr_TR;
export default trTR;

View File

@ -1,3 +1,3 @@
import uk_UA from '../../date-picker/locale/uk_UA';
import ukUA from '../../date-picker/locale/uk_UA';
export default uk_UA;
export default ukUA;

View File

@ -1,3 +1,3 @@
import vi_VN from '../../date-picker/locale/vi_VN';
import viVN from '../../date-picker/locale/vi_VN';
export default vi_VN;
export default viVN;

View File

@ -1,3 +1,3 @@
import zh_CN from '../../date-picker/locale/zh_CN';
import zhCN from '../../date-picker/locale/zh_CN';
export default zh_CN;
export default zhCN;

View File

@ -1,3 +1,3 @@
import zh_TW from '../../date-picker/locale/zh_TW';
import zhTW from '../../date-picker/locale/zh_TW';
export default zh_TW;
export default zhTW;

View File

@ -23,9 +23,7 @@ import {
} from 'antd';
const { Text } = Typography;
const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
const Option = Select.Option;
const { Option } = Select;
const { MonthPicker, RangePicker } = DatePicker;
const narrowStyle = {
@ -91,10 +89,10 @@ ReactDOM.render(
<Cascader defaultValue={['zhejiang', 'hangzhou', 'xihu']} options={options} />
<RangePicker />
<MonthPicker />
<RadioGroup defaultValue="a">
<RadioButton value="a">Hangzhou</RadioButton>
<RadioButton value="b">Shanghai</RadioButton>
</RadioGroup>
<Radio.Group defaultValue="a">
<Radio.Button value="a">Hangzhou</Radio.Button>
<Radio.Button value="b">Shanghai</Radio.Button>
</Radio.Group>
<AutoComplete style={{ width: 100 }} placeholder="input here" />
<br />
<Input prefix="$" addonBefore="Http://" addonAfter=".com" defaultValue="mysite" />

View File

@ -23,7 +23,9 @@ const getClickPosition = (e: MouseEvent) => {
// 100ms 内发生过点击事件,则从点击位置动画展示
// 否则直接 zoom 展示
// 这样可以兼容非点击方式展开
setTimeout(() => (mousePosition = null), 100);
setTimeout(() => {
mousePosition = null;
}, 100);
};
// 只有点击事件支持从鼠标位置动画展开

View File

@ -116,8 +116,11 @@ Result.defaultProps = {
status: 'info',
};
// eslint-disable-next-line prefer-destructuring
Result.PRESENTED_IMAGE_403 = ExceptionMap[403];
// eslint-disable-next-line prefer-destructuring
Result.PRESENTED_IMAGE_404 = ExceptionMap[404];
// eslint-disable-next-line prefer-destructuring
Result.PRESENTED_IMAGE_500 = ExceptionMap[500];
export default Result;

View File

@ -53,7 +53,9 @@ class EditableTagGroup extends React.Component {
});
};
saveInputRef = input => (this.input = input);
saveInputRef = input => {
this.input = input;
};
forMap = tag => {
const tagElem = (

View File

@ -71,9 +71,13 @@ class EditableTagGroup extends React.Component {
});
};
saveInputRef = input => (this.input = input);
saveInputRef = input => {
this.input = input;
};
saveEditInputRef = input => (this.editInput = input);
saveEditInputRef = input => {
this.editInput = input;
};
render() {
const { tags, inputVisible, inputValue, editInputIndex, editInputValue } = this.state;

View File

@ -222,7 +222,7 @@ class Transfer extends React.Component<TransferProps, TransferState> {
handleFilter = (direction: TransferDirection, e: React.ChangeEvent<HTMLInputElement>) => {
const { onSearch } = this.props;
const value = e.target.value;
const { value } = e.target;
if (onSearch) {
onSearch(direction, value);
}

View File

@ -195,7 +195,7 @@
"eslint-config-airbnb": "^18.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "~2.20.0",
"eslint-plugin-import": "^2.21.1",
"eslint-plugin-jest": "^23.0.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-markdown": "^1.0.0",

View File

@ -4,7 +4,7 @@ const REPO = process.env.ACCESS_REPO;
const TOKEN = process.env.ACCESS_TOKEN;
const PR = process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER;
const argv = process.argv;
const { argv } = process;
const comment = argv[argv.length - 1];
const isUiTest = argv.includes('-ui');

View File

@ -79,7 +79,7 @@ async function printLog() {
let prList = [];
for (let i = 0; i < logs.all.length; i += 1) {
const { message, body, hash, author_name } = logs.all[i];
const { message, body, hash, author_name: author } = logs.all[i];
const text = `${message} ${body}`;
@ -147,7 +147,7 @@ async function printLog() {
prList.push({
hash,
title: message,
author: author_name,
author,
english: message,
chinese: message,
});

View File

@ -238,7 +238,7 @@ class Demo extends React.Component {
const importReactReg = /import(\D*)from 'react';/;
const matchImportReact = parsedSourceCode.match(importReactReg);
if (matchImportReact) {
importReactContent = matchImportReact[0];
[importReactContent] = matchImportReact;
parsedSourceCode = parsedSourceCode.replace(importReactReg, '').trim();
}

View File

@ -35,7 +35,7 @@ export default () => {
const onSyncAffix = React.useMemo(() => {
function doSync() {
const scrollY = window.scrollY;
const { scrollY } = window;
const containerHeight = containerRef.current!.offsetHeight;
for (let i = idsRef.current.length - 1; i >= 0; i -= 1) {

View File

@ -62,6 +62,7 @@ function toList([, ...items]: ContentUnit[]): ContentUnit[] {
const titleMatch = titleStr.match(/(.*)(#[\dA-Fa-f]{6})/);
if (titleMatch) {
titleStr = titleMatch[1].trim();
// eslint-disable-next-line prefer-destructuring
coverColor = titleMatch[2];
}

View File

@ -2,7 +2,7 @@
// This config is for building dist files
const getWebpackConfig = require('@ant-design/tools/lib/getWebpackConfig');
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const BundleAnalyzerPluginCom = require('@bundle-analyzer/webpack-plugin');
const EsbuildPlugin = require('esbuild-webpack-plugin').default;
const darkVars = require('./scripts/dark-vars');