diff --git a/.eslintignore b/.eslintignore index 31997c3c01..80726d5839 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,4 @@ components/*/__tests__/type.tsx # Docs templates site/theme/template/IconDisplay/*.js site/theme/template/IconDisplay/*.jsx +typings diff --git a/.eslintrc.js b/.eslintrc.js index 97e9d90b42..289ab1f3fe 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -24,13 +24,14 @@ const eslintrc = { // https://github.com/typescript-eslint/typescript-eslint/issues/46#issuecomment-470486034 overrides: [ { - files: ['*.tsx'], + files: ['*.ts', '*.tsx'], rules: { '@typescript-eslint/no-unused-vars': [2, { args: 'none' }], }, }, ], rules: { + camelcase: 0, 'react/jsx-one-expression-per-line': 0, 'react/prop-types': 0, 'react/forbid-prop-types': 0, @@ -104,6 +105,7 @@ if (process.env.RUN_ENV === 'DEMO') { '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, }); } diff --git a/components/_util/colors.ts b/components/_util/colors.ts index d096bca3ea..b18900359b 100644 --- a/components/_util/colors.ts +++ b/components/_util/colors.ts @@ -1,5 +1,6 @@ import { tuple } from './type'; +// eslint-disable-next-line import/prefer-default-export export const PresetColorTypes = tuple( 'pink', 'red', diff --git a/components/_util/raf.ts b/components/_util/raf.ts index 652716d972..5cc7e6f0b9 100644 --- a/components/_util/raf.ts +++ b/components/_util/raf.ts @@ -28,7 +28,7 @@ export default function wrapperRaf(callback: () => void, delayFrames: number = 1 return myId; } -wrapperRaf.cancel = function(pid?: number) { +wrapperRaf.cancel = function cancel(pid?: number) { if (pid === undefined) return; raf.cancel(ids[pid]); diff --git a/components/_util/reactNode.ts b/components/_util/reactNode.ts index 5caccdd4d4..136d0f5d2f 100644 --- a/components/_util/reactNode.ts +++ b/components/_util/reactNode.ts @@ -1,5 +1,6 @@ import * as React from 'react'; +// eslint-disable-next-line import/prefer-default-export export function cloneElement(element: React.ReactNode, ...restArgs: any[]) { if (!React.isValidElement(element)) return element; diff --git a/components/_util/responsiveObserve.ts b/components/_util/responsiveObserve.ts index 6ee73cddd2..3135b0304f 100644 --- a/components/_util/responsiveObserve.ts +++ b/components/_util/responsiveObserve.ts @@ -12,6 +12,7 @@ if (typeof window !== 'undefined') { }; }; window.matchMedia = window.matchMedia || matchMediaPolyfill; + // eslint-disable-next-line global-require enquire = require('enquire.js'); } @@ -57,8 +58,8 @@ const responsiveObserve = { } const token = (++subUid).toString(); subscribers.push({ - token: token, - func: func, + token, + func, }); func(screens); return token; diff --git a/components/affix/utils.ts b/components/affix/utils.ts index aee6c16122..43f064d0f1 100644 --- a/components/affix/utils.ts +++ b/components/affix/utils.ts @@ -1,5 +1,5 @@ import addEventListener from 'rc-util/lib/Dom/addEventListener'; -import Affix from './'; +import Affix from '.'; export type BindElement = HTMLElement | Window | null | undefined; export type Rect = ClientRect | DOMRect; diff --git a/components/calendar/locale/ar_EG.tsx b/components/calendar/locale/ar_EG.tsx index f51f426ff9..4d413b4202 100644 --- a/components/calendar/locale/ar_EG.tsx +++ b/components/calendar/locale/ar_EG.tsx @@ -1,2 +1,3 @@ import ar_EG from '../../date-picker/locale/ar_EG'; + export default ar_EG; diff --git a/components/calendar/locale/bg_BG.tsx b/components/calendar/locale/bg_BG.tsx index c9dd46118d..79ded5e479 100644 --- a/components/calendar/locale/bg_BG.tsx +++ b/components/calendar/locale/bg_BG.tsx @@ -1,2 +1,3 @@ import bg_BG from '../../date-picker/locale/bg_BG'; + export default bg_BG; diff --git a/components/calendar/locale/ca_ES.tsx b/components/calendar/locale/ca_ES.tsx index 25b2888ef9..a0e79a5229 100644 --- a/components/calendar/locale/ca_ES.tsx +++ b/components/calendar/locale/ca_ES.tsx @@ -1,2 +1,3 @@ import ca_ES from '../../date-picker/locale/ca_ES'; + export default ca_ES; diff --git a/components/calendar/locale/cs_CZ.tsx b/components/calendar/locale/cs_CZ.tsx index bfba281a99..6bb7c3fdd9 100644 --- a/components/calendar/locale/cs_CZ.tsx +++ b/components/calendar/locale/cs_CZ.tsx @@ -1,2 +1,3 @@ import cs_CZ from '../../date-picker/locale/cs_CZ'; + export default cs_CZ; diff --git a/components/calendar/locale/da_DK.tsx b/components/calendar/locale/da_DK.tsx index 4b20c46034..03a86944c5 100644 --- a/components/calendar/locale/da_DK.tsx +++ b/components/calendar/locale/da_DK.tsx @@ -1,2 +1,3 @@ import da_DK from '../../date-picker/locale/da_DK'; + export default da_DK; diff --git a/components/calendar/locale/de_DE.tsx b/components/calendar/locale/de_DE.tsx index 652a9be31e..5fb008ea6a 100644 --- a/components/calendar/locale/de_DE.tsx +++ b/components/calendar/locale/de_DE.tsx @@ -1,2 +1,3 @@ import de_DE from '../../date-picker/locale/de_DE'; + export default de_DE; diff --git a/components/calendar/locale/el_GR.tsx b/components/calendar/locale/el_GR.tsx index 4d665092a5..fc3f00c59d 100644 --- a/components/calendar/locale/el_GR.tsx +++ b/components/calendar/locale/el_GR.tsx @@ -1,2 +1,3 @@ import el_GR from '../../date-picker/locale/el_GR'; + export default el_GR; diff --git a/components/calendar/locale/en_GB.tsx b/components/calendar/locale/en_GB.tsx index 0d081144e5..fef0c3e98b 100644 --- a/components/calendar/locale/en_GB.tsx +++ b/components/calendar/locale/en_GB.tsx @@ -1,2 +1,3 @@ import en_GB from '../../date-picker/locale/en_GB'; + export default en_GB; diff --git a/components/calendar/locale/en_US.tsx b/components/calendar/locale/en_US.tsx index 6847cc35d8..e0c8c2ea67 100644 --- a/components/calendar/locale/en_US.tsx +++ b/components/calendar/locale/en_US.tsx @@ -1,2 +1,3 @@ import en_US from '../../date-picker/locale/en_US'; + export default en_US; diff --git a/components/calendar/locale/es_ES.tsx b/components/calendar/locale/es_ES.tsx index 6270b85ad4..4ca5af1b92 100644 --- a/components/calendar/locale/es_ES.tsx +++ b/components/calendar/locale/es_ES.tsx @@ -1,2 +1,3 @@ import es_ES from '../../date-picker/locale/es_ES'; + export default es_ES; diff --git a/components/calendar/locale/et_EE.tsx b/components/calendar/locale/et_EE.tsx index 47ad3e77f8..d707338553 100644 --- a/components/calendar/locale/et_EE.tsx +++ b/components/calendar/locale/et_EE.tsx @@ -1,2 +1,3 @@ import et_EE from '../../date-picker/locale/et_EE'; + export default et_EE; diff --git a/components/calendar/locale/fa_IR.tsx b/components/calendar/locale/fa_IR.tsx index 9aa9d1a347..c69249c3ce 100644 --- a/components/calendar/locale/fa_IR.tsx +++ b/components/calendar/locale/fa_IR.tsx @@ -1,2 +1,3 @@ import fa_IR from '../../date-picker/locale/fa_IR'; + export default fa_IR; diff --git a/components/calendar/locale/fi_FI.tsx b/components/calendar/locale/fi_FI.tsx index b81ea86283..5f729816e4 100644 --- a/components/calendar/locale/fi_FI.tsx +++ b/components/calendar/locale/fi_FI.tsx @@ -1,2 +1,3 @@ import fi_FI from '../../date-picker/locale/fi_FI'; + export default fi_FI; diff --git a/components/calendar/locale/fr_BE.tsx b/components/calendar/locale/fr_BE.tsx index 89560fc1f1..02d279ae36 100644 --- a/components/calendar/locale/fr_BE.tsx +++ b/components/calendar/locale/fr_BE.tsx @@ -1,2 +1,3 @@ import fr_BE from '../../date-picker/locale/fr_BE'; + export default fr_BE; diff --git a/components/calendar/locale/fr_FR.tsx b/components/calendar/locale/fr_FR.tsx index 98c62aa754..a85c0892e1 100644 --- a/components/calendar/locale/fr_FR.tsx +++ b/components/calendar/locale/fr_FR.tsx @@ -1,2 +1,3 @@ import fr_FR from '../../date-picker/locale/fr_FR'; + export default fr_FR; diff --git a/components/calendar/locale/he_IL.tsx b/components/calendar/locale/he_IL.tsx index 740b2b40b5..bb3a66b453 100644 --- a/components/calendar/locale/he_IL.tsx +++ b/components/calendar/locale/he_IL.tsx @@ -1,2 +1,3 @@ import he_IL from '../../date-picker/locale/he_IL'; + export default he_IL; diff --git a/components/calendar/locale/hi_IN.tsx b/components/calendar/locale/hi_IN.tsx index fea69a5662..6a47da6338 100644 --- a/components/calendar/locale/hi_IN.tsx +++ b/components/calendar/locale/hi_IN.tsx @@ -1,2 +1,3 @@ import hi_IN from '../../date-picker/locale/hi_IN'; + export default hi_IN; diff --git a/components/calendar/locale/hr_HR.tsx b/components/calendar/locale/hr_HR.tsx index 6f1f6da149..74f31c7471 100644 --- a/components/calendar/locale/hr_HR.tsx +++ b/components/calendar/locale/hr_HR.tsx @@ -1,2 +1,3 @@ import hr_HR from '../../date-picker/locale/hr_HR'; + export default hr_HR; diff --git a/components/calendar/locale/hu_HU.tsx b/components/calendar/locale/hu_HU.tsx index 0c5853800b..0c94ec6a4c 100644 --- a/components/calendar/locale/hu_HU.tsx +++ b/components/calendar/locale/hu_HU.tsx @@ -1,2 +1,3 @@ import hu_HU from '../../date-picker/locale/hu_HU'; + export default hu_HU; diff --git a/components/calendar/locale/id_ID.tsx b/components/calendar/locale/id_ID.tsx index 494bcf4a51..86c254dc6a 100644 --- a/components/calendar/locale/id_ID.tsx +++ b/components/calendar/locale/id_ID.tsx @@ -1,2 +1,3 @@ import id_ID from '../../date-picker/locale/id_ID'; + export default id_ID; diff --git a/components/calendar/locale/is_IS.tsx b/components/calendar/locale/is_IS.tsx index a9524638e0..e1c2fb1689 100644 --- a/components/calendar/locale/is_IS.tsx +++ b/components/calendar/locale/is_IS.tsx @@ -1,2 +1,3 @@ import is_IS from '../../date-picker/locale/is_IS'; + export default is_IS; diff --git a/components/calendar/locale/it_IT.tsx b/components/calendar/locale/it_IT.tsx index 907792ffbe..26d8ac9601 100644 --- a/components/calendar/locale/it_IT.tsx +++ b/components/calendar/locale/it_IT.tsx @@ -1,2 +1,3 @@ import it_IT from '../../date-picker/locale/it_IT'; + export default it_IT; diff --git a/components/calendar/locale/ja_JP.tsx b/components/calendar/locale/ja_JP.tsx index 05ebc14403..9136243b90 100644 --- a/components/calendar/locale/ja_JP.tsx +++ b/components/calendar/locale/ja_JP.tsx @@ -1,2 +1,3 @@ import ja_JP from '../../date-picker/locale/ja_JP'; + export default ja_JP; diff --git a/components/calendar/locale/kn_IN.tsx b/components/calendar/locale/kn_IN.tsx index 958c45a7b1..4baefb1512 100644 --- a/components/calendar/locale/kn_IN.tsx +++ b/components/calendar/locale/kn_IN.tsx @@ -1,2 +1,3 @@ import kn_IN from '../../date-picker/locale/kn_IN'; + export default kn_IN; diff --git a/components/calendar/locale/ko_KR.tsx b/components/calendar/locale/ko_KR.tsx index dc0e5ebdbf..4cbab03f4f 100644 --- a/components/calendar/locale/ko_KR.tsx +++ b/components/calendar/locale/ko_KR.tsx @@ -1,2 +1,3 @@ import ko_KR from '../../date-picker/locale/ko_KR'; + export default ko_KR; diff --git a/components/calendar/locale/ku_IQ.tsx b/components/calendar/locale/ku_IQ.tsx index f491af31e7..9d6325791b 100755 --- a/components/calendar/locale/ku_IQ.tsx +++ b/components/calendar/locale/ku_IQ.tsx @@ -1,2 +1,3 @@ import ku_IQ from '../../date-picker/locale/ku_IQ'; + export default ku_IQ; diff --git a/components/calendar/locale/lv_LV.tsx b/components/calendar/locale/lv_LV.tsx index e947c8c42e..dcec393623 100644 --- a/components/calendar/locale/lv_LV.tsx +++ b/components/calendar/locale/lv_LV.tsx @@ -1,2 +1,3 @@ import lv_LV from '../../date-picker/locale/lv_LV'; + export default lv_LV; diff --git a/components/calendar/locale/mn_MN.tsx b/components/calendar/locale/mn_MN.tsx index 1eba89e09b..b03b0bbc2e 100644 --- a/components/calendar/locale/mn_MN.tsx +++ b/components/calendar/locale/mn_MN.tsx @@ -1,2 +1,3 @@ import mn_MN from '../../date-picker/locale/mn_MN'; + export default mn_MN; diff --git a/components/calendar/locale/ms_MY.tsx b/components/calendar/locale/ms_MY.tsx index 0c1ecedadf..f8f2487925 100644 --- a/components/calendar/locale/ms_MY.tsx +++ b/components/calendar/locale/ms_MY.tsx @@ -1,2 +1,3 @@ import ms_MY from '../../date-picker/locale/ms_MY'; + export default ms_MY; diff --git a/components/calendar/locale/nb_NO.tsx b/components/calendar/locale/nb_NO.tsx index f7417e06d5..b964d89f0a 100644 --- a/components/calendar/locale/nb_NO.tsx +++ b/components/calendar/locale/nb_NO.tsx @@ -1,2 +1,3 @@ import nb_NO from '../../date-picker/locale/nb_NO'; + export default nb_NO; diff --git a/components/calendar/locale/nl_BE.tsx b/components/calendar/locale/nl_BE.tsx index 7f36785fe3..38317b5baa 100644 --- a/components/calendar/locale/nl_BE.tsx +++ b/components/calendar/locale/nl_BE.tsx @@ -1,2 +1,3 @@ import nl_BE from '../../date-picker/locale/nl_BE'; + export default nl_BE; diff --git a/components/calendar/locale/nl_NL.tsx b/components/calendar/locale/nl_NL.tsx index cdf131aa37..5361ea600b 100644 --- a/components/calendar/locale/nl_NL.tsx +++ b/components/calendar/locale/nl_NL.tsx @@ -1,2 +1,3 @@ import nl_NL from '../../date-picker/locale/nl_NL'; + export default nl_NL; diff --git a/components/calendar/locale/pl_PL.tsx b/components/calendar/locale/pl_PL.tsx index c309a788b2..65fa692894 100644 --- a/components/calendar/locale/pl_PL.tsx +++ b/components/calendar/locale/pl_PL.tsx @@ -1,2 +1,3 @@ import pl_PL from '../../date-picker/locale/pl_PL'; + export default pl_PL; diff --git a/components/calendar/locale/pt_BR.tsx b/components/calendar/locale/pt_BR.tsx index 2908a36dc3..cdef750fdc 100644 --- a/components/calendar/locale/pt_BR.tsx +++ b/components/calendar/locale/pt_BR.tsx @@ -1,2 +1,3 @@ import pt_BR from '../../date-picker/locale/pt_BR'; + export default pt_BR; diff --git a/components/calendar/locale/pt_PT.tsx b/components/calendar/locale/pt_PT.tsx index c3aebf364f..875c71306f 100644 --- a/components/calendar/locale/pt_PT.tsx +++ b/components/calendar/locale/pt_PT.tsx @@ -1,2 +1,3 @@ import pt_PT from '../../date-picker/locale/pt_PT'; + export default pt_PT; diff --git a/components/calendar/locale/ru_RU.tsx b/components/calendar/locale/ru_RU.tsx index c1feaedaea..89c86111e7 100644 --- a/components/calendar/locale/ru_RU.tsx +++ b/components/calendar/locale/ru_RU.tsx @@ -1,2 +1,3 @@ import ru_RU from '../../date-picker/locale/ru_RU'; + export default ru_RU; diff --git a/components/calendar/locale/sk_SK.tsx b/components/calendar/locale/sk_SK.tsx index 3e9a32d8cb..57aa24d1ce 100644 --- a/components/calendar/locale/sk_SK.tsx +++ b/components/calendar/locale/sk_SK.tsx @@ -1,2 +1,3 @@ import sk_SK from '../../date-picker/locale/sk_SK'; + export default sk_SK; diff --git a/components/calendar/locale/sl_SI.tsx b/components/calendar/locale/sl_SI.tsx index a97c3f9a8e..9cc5921145 100644 --- a/components/calendar/locale/sl_SI.tsx +++ b/components/calendar/locale/sl_SI.tsx @@ -1,2 +1,3 @@ import sl_SI from '../../date-picker/locale/sl_SI'; + export default sl_SI; diff --git a/components/calendar/locale/sr_RS.tsx b/components/calendar/locale/sr_RS.tsx index ae46beb97f..fb5620b48b 100644 --- a/components/calendar/locale/sr_RS.tsx +++ b/components/calendar/locale/sr_RS.tsx @@ -1,2 +1,3 @@ import sr_RS from '../../date-picker/locale/sr_RS'; + export default sr_RS; diff --git a/components/calendar/locale/sv_SE.tsx b/components/calendar/locale/sv_SE.tsx index b9e4c3e5d3..9499d4188a 100644 --- a/components/calendar/locale/sv_SE.tsx +++ b/components/calendar/locale/sv_SE.tsx @@ -1,2 +1,3 @@ import sv_SE from '../../date-picker/locale/sv_SE'; + export default sv_SE; diff --git a/components/calendar/locale/ta_IN.tsx b/components/calendar/locale/ta_IN.tsx index e557a2bcf5..560961645c 100644 --- a/components/calendar/locale/ta_IN.tsx +++ b/components/calendar/locale/ta_IN.tsx @@ -1,2 +1,3 @@ import ta_IN from '../../date-picker/locale/ta_IN'; + export default ta_IN; diff --git a/components/calendar/locale/th_TH.tsx b/components/calendar/locale/th_TH.tsx index 62bbf47761..c7e36c9505 100644 --- a/components/calendar/locale/th_TH.tsx +++ b/components/calendar/locale/th_TH.tsx @@ -1,2 +1,3 @@ import th_TH from '../../date-picker/locale/th_TH'; + export default th_TH; diff --git a/components/calendar/locale/tr_TR.tsx b/components/calendar/locale/tr_TR.tsx index d5ba572d46..67a546c128 100644 --- a/components/calendar/locale/tr_TR.tsx +++ b/components/calendar/locale/tr_TR.tsx @@ -1,2 +1,3 @@ import tr_TR from '../../date-picker/locale/tr_TR'; + export default tr_TR; diff --git a/components/calendar/locale/uk_UA.tsx b/components/calendar/locale/uk_UA.tsx index b27523dd7f..8173406ed1 100644 --- a/components/calendar/locale/uk_UA.tsx +++ b/components/calendar/locale/uk_UA.tsx @@ -1,2 +1,3 @@ import uk_UA from '../../date-picker/locale/uk_UA'; + export default uk_UA; diff --git a/components/calendar/locale/vi_VN.tsx b/components/calendar/locale/vi_VN.tsx index 0579ee2e62..163ef5bd39 100644 --- a/components/calendar/locale/vi_VN.tsx +++ b/components/calendar/locale/vi_VN.tsx @@ -1,2 +1,3 @@ import vi_VN from '../../date-picker/locale/vi_VN'; + export default vi_VN; diff --git a/components/calendar/locale/zh_CN.tsx b/components/calendar/locale/zh_CN.tsx index 9c83ec8453..238c420e18 100644 --- a/components/calendar/locale/zh_CN.tsx +++ b/components/calendar/locale/zh_CN.tsx @@ -1,2 +1,3 @@ import zh_CN from '../../date-picker/locale/zh_CN'; + export default zh_CN; diff --git a/components/calendar/locale/zh_TW.tsx b/components/calendar/locale/zh_TW.tsx index 2fa73ae627..639f60a0c9 100644 --- a/components/calendar/locale/zh_TW.tsx +++ b/components/calendar/locale/zh_TW.tsx @@ -1,2 +1,3 @@ import zh_TW from '../../date-picker/locale/zh_TW'; + export default zh_TW; diff --git a/components/config-provider/index.tsx b/components/config-provider/index.tsx index d08aa9eb18..721f68a49c 100644 --- a/components/config-provider/index.tsx +++ b/components/config-provider/index.tsx @@ -132,7 +132,9 @@ interface ConstructorProps { } export function withConfigConsumer(config: ConsumerConfig) { - return function(Component: IReactComponent): React.SFC & ComponentDef { + return function withConfigConsumerFunc( + Component: IReactComponent, + ): React.SFC & ComponentDef { // Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods const SFC = ((props: ExportProps) => ( diff --git a/components/date-picker/utils.ts b/components/date-picker/utils.ts index ae309bface..12432fe74f 100644 --- a/components/date-picker/utils.ts +++ b/components/date-picker/utils.ts @@ -1,5 +1,6 @@ import * as moment from 'moment'; +// eslint-disable-next-line import/prefer-default-export export function formatDate( value: moment.Moment | undefined | null, format: string | string[], diff --git a/components/form/Form.tsx b/components/form/Form.tsx index 1b5c9645f9..ab20c54fce 100755 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -10,7 +10,7 @@ import { tuple } from '../_util/type'; import warning from '../_util/warning'; import FormItem, { FormLabelAlign } from './FormItem'; import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants'; -import { FormContext } from './context'; +import FormContext from './context'; import { FormWrappedProps } from './interface'; type FormCreateOptionMessagesCallback = (...args: any[]) => string; diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index da1a9dac02..d056b36b72 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -10,7 +10,7 @@ import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import warning from '../_util/warning'; import { tuple } from '../_util/type'; import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants'; -import { FormContext, FormContextProps } from './context'; +import FormContext, { FormContextProps } from './context'; const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', ''); diff --git a/components/form/context.ts b/components/form/context.ts index 1a9508000b..0c74422c0f 100644 --- a/components/form/context.ts +++ b/components/form/context.ts @@ -10,7 +10,9 @@ export interface FormContextProps { wrapperCol?: ColProps; } -export const FormContext = createReactContext({ +const FormContext = createReactContext({ labelAlign: 'right', vertical: false, }); + +export default FormContext; diff --git a/components/icon/utils.ts b/components/icon/utils.ts index 275e75185f..0afcba9fe8 100644 --- a/components/icon/utils.ts +++ b/components/icon/utils.ts @@ -7,7 +7,7 @@ export const svgBaseProps = { width: '1em', height: '1em', fill: 'currentColor', - ['aria-hidden']: true, + 'aria-hidden': true, focusable: 'false', }; diff --git a/components/index.tsx b/components/index.tsx index 8946a1f977..b03a0e6955 100644 --- a/components/index.tsx +++ b/components/index.tsx @@ -5,9 +5,10 @@ if ( ENV !== 'production' && ENV !== 'test' && typeof console !== 'undefined' && - console.warn && + console.warn && // eslint-disable-line no-console typeof window !== 'undefined' ) { + // eslint-disable-next-line no-console console.warn( 'You are using a whole package of antd, ' + 'please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.', diff --git a/components/progress/utils.ts b/components/progress/utils.ts index fd0e161933..e234e50a09 100644 --- a/components/progress/utils.ts +++ b/components/progress/utils.ts @@ -1,7 +1,9 @@ +// eslint-disable-next-line import/prefer-default-export export function validProgress(progress: number | undefined) { if (!progress || progress < 0) { return 0; - } else if (progress > 100) { + } + if (progress > 100) { return 100; } return progress; diff --git a/package.json b/package.json index 2ec6123a97..4113a3b71d 100644 --- a/package.json +++ b/package.json @@ -192,19 +192,17 @@ "test-node": "jest --config .jest.node.js --no-cache", "test-all": "./scripts/test-all.sh", "check-commit": "node ./scripts/check-commit.js", - "lint": "npm run lint:ts && npm run lint:ts:with-eslint && npm run lint:es && npm run lint:demo && npm run lint:style && npm run lint:deps", + "lint": "npm run lint:tsc && npm run lint:script && npm run lint:demo && npm run lint:style && npm run lint:deps", "lint:deps": "antd-tools run deps-lint", - "lint:ts": "npm run tsc && antd-tools run ts-lint", - "lint:es": "eslint tests site scripts components ./.*.js ./webpack.config.js --ext '.js,.jsx'", + "lint:tsc": "npm run tsc && antd-tools run ts-lint", + "lint:script": "eslint . --ext '.js,.jsx,.ts,.tsx'", "lint:md": "remark components/", - "lint:demo": "cross-env RUN_ENV=DEMO eslint components/*/demo/*.md --ext '.md' --rule 'import/no-unresolved: 0'", + "lint:demo": "cross-env RUN_ENV=DEMO eslint components/*/demo/*.md --ext '.md'", "lint:style": "stylelint '{site,components}/**/*.less' --syntax less", - "lint-fix:ts": "npm run tsc && antd-tools run ts-lint-fix", - "lint-fix": "npm run lint-fix:code && npm run lint-fix:demo && npm run lint-fix:style", - "lint-fix:code": "eslint --fix tests site scripts components ./.*.js ./webpack.config.js --ext '.js,.jsx'", + "lint-fix": "npm run lint-fix:script && npm run lint-fix:demo && npm run lint-fix:style", + "lint-fix:script": "npm run lint:script -- --fix", "lint-fix:demo": "eslint-tinker ./components/*/demo/*.md", - "lint-fix:style": "stylelint --fix '{site,components}/**/*.less' --syntax less", - "lint:ts:with-eslint": "eslint components/**/*.tsx", + "lint-fix:style": "npm run lint:style -- --fix", "sort-api": "antd-tools run sort-api-table", "api-collection": "antd-tools run api-collection", "dist": "antd-tools run dist", diff --git a/site/theme/template/IconDisplay/Category.tsx b/site/theme/template/IconDisplay/Category.tsx index e1378030b3..85737f8220 100644 --- a/site/theme/template/IconDisplay/Category.tsx +++ b/site/theme/template/IconDisplay/Category.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import { message } from 'antd'; +import { injectIntl } from 'react-intl'; import { ThemeType } from '../../../../components/icon'; import CopyableIcon from './CopyableIcon'; -import { injectIntl } from 'react-intl'; import { CategoriesKeys } from './fields'; interface CategoryProps { @@ -24,6 +24,10 @@ class Category extends React.Component { justCopied: null, }; + componentWillUnmount() { + window.clearTimeout(this.copyId); + } + onCopied = (type: string, text: string) => { message.success( @@ -37,10 +41,6 @@ class Category extends React.Component { }); }; - componentWillUnmount() { - window.clearTimeout(this.copyId); - } - render() { const { icons, @@ -64,7 +64,7 @@ class Category extends React.Component { return (

{messages[`app.docs.components.icon.category.${title}`]}

-
    {items}
+
    {items}
); } diff --git a/site/theme/template/IconDisplay/fields.ts b/site/theme/template/IconDisplay/fields.ts index 06024ac24f..d7b0e2f2ad 100644 --- a/site/theme/template/IconDisplay/fields.ts +++ b/site/theme/template/IconDisplay/fields.ts @@ -10,7 +10,7 @@ allIcons = allIcons.filter( (name: string) => !['interation', 'canlendar', 'colum-height'].includes(name), ); -export const categories = { +const categories = { all: [...new Set(allIcons)], direction: [ 'step-backward', @@ -207,6 +207,8 @@ export const categories = { ], }; +export default categories; + export interface Categories { all: string[]; direction: string[]; diff --git a/site/theme/template/IconDisplay/index.tsx b/site/theme/template/IconDisplay/index.tsx index 240383ff0b..44f84b78c3 100644 --- a/site/theme/template/IconDisplay/index.tsx +++ b/site/theme/template/IconDisplay/index.tsx @@ -5,10 +5,10 @@ import { Radio, Icon, Input } from 'antd'; import { RadioChangeEvent } from 'antd/es/radio/interface'; import { injectIntl } from 'react-intl'; import debounce from 'lodash/debounce'; +import { ThemeType } from 'antd/es/icon'; import Category from './Category'; import { FilledIcon, OutlinedIcon, TwoToneIcon } from './themeIcons'; -import { categories, Categories, CategoriesKeys } from './fields'; -import { ThemeType } from 'antd/es/icon'; +import categories, { Categories, CategoriesKeys } from './fields'; interface IconDisplayProps { intl: any;