Browse Source

💄 eslint for all

pull/18268/head
afc163 5 years ago
parent
commit
760853e239
  1. 1
      .eslintignore
  2. 4
      .eslintrc.js
  3. 1
      components/_util/colors.ts
  4. 2
      components/_util/raf.ts
  5. 1
      components/_util/reactNode.ts
  6. 5
      components/_util/responsiveObserve.ts
  7. 2
      components/affix/utils.ts
  8. 1
      components/calendar/locale/ar_EG.tsx
  9. 1
      components/calendar/locale/bg_BG.tsx
  10. 1
      components/calendar/locale/ca_ES.tsx
  11. 1
      components/calendar/locale/cs_CZ.tsx
  12. 1
      components/calendar/locale/da_DK.tsx
  13. 1
      components/calendar/locale/de_DE.tsx
  14. 1
      components/calendar/locale/el_GR.tsx
  15. 1
      components/calendar/locale/en_GB.tsx
  16. 1
      components/calendar/locale/en_US.tsx
  17. 1
      components/calendar/locale/es_ES.tsx
  18. 1
      components/calendar/locale/et_EE.tsx
  19. 1
      components/calendar/locale/fa_IR.tsx
  20. 1
      components/calendar/locale/fi_FI.tsx
  21. 1
      components/calendar/locale/fr_BE.tsx
  22. 1
      components/calendar/locale/fr_FR.tsx
  23. 1
      components/calendar/locale/he_IL.tsx
  24. 1
      components/calendar/locale/hi_IN.tsx
  25. 1
      components/calendar/locale/hr_HR.tsx
  26. 1
      components/calendar/locale/hu_HU.tsx
  27. 1
      components/calendar/locale/id_ID.tsx
  28. 1
      components/calendar/locale/is_IS.tsx
  29. 1
      components/calendar/locale/it_IT.tsx
  30. 1
      components/calendar/locale/ja_JP.tsx
  31. 1
      components/calendar/locale/kn_IN.tsx
  32. 1
      components/calendar/locale/ko_KR.tsx
  33. 1
      components/calendar/locale/ku_IQ.tsx
  34. 1
      components/calendar/locale/lv_LV.tsx
  35. 1
      components/calendar/locale/mn_MN.tsx
  36. 1
      components/calendar/locale/ms_MY.tsx
  37. 1
      components/calendar/locale/nb_NO.tsx
  38. 1
      components/calendar/locale/nl_BE.tsx
  39. 1
      components/calendar/locale/nl_NL.tsx
  40. 1
      components/calendar/locale/pl_PL.tsx
  41. 1
      components/calendar/locale/pt_BR.tsx
  42. 1
      components/calendar/locale/pt_PT.tsx
  43. 1
      components/calendar/locale/ru_RU.tsx
  44. 1
      components/calendar/locale/sk_SK.tsx
  45. 1
      components/calendar/locale/sl_SI.tsx
  46. 1
      components/calendar/locale/sr_RS.tsx
  47. 1
      components/calendar/locale/sv_SE.tsx
  48. 1
      components/calendar/locale/ta_IN.tsx
  49. 1
      components/calendar/locale/th_TH.tsx
  50. 1
      components/calendar/locale/tr_TR.tsx
  51. 1
      components/calendar/locale/uk_UA.tsx
  52. 1
      components/calendar/locale/vi_VN.tsx
  53. 1
      components/calendar/locale/zh_CN.tsx
  54. 1
      components/calendar/locale/zh_TW.tsx
  55. 4
      components/config-provider/index.tsx
  56. 1
      components/date-picker/utils.ts
  57. 2
      components/form/Form.tsx
  58. 2
      components/form/FormItem.tsx
  59. 4
      components/form/context.ts
  60. 2
      components/icon/utils.ts
  61. 3
      components/index.tsx
  62. 4
      components/progress/utils.ts
  63. 16
      package.json
  64. 12
      site/theme/template/IconDisplay/Category.tsx
  65. 4
      site/theme/template/IconDisplay/fields.ts
  66. 4
      site/theme/template/IconDisplay/index.tsx

1
.eslintignore

@ -7,3 +7,4 @@ components/*/__tests__/type.tsx
# Docs templates
site/theme/template/IconDisplay/*.js
site/theme/template/IconDisplay/*.jsx
typings

4
.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,
});
}

1
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',

2
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]);

1
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;

5
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;

2
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;

1
components/calendar/locale/ar_EG.tsx

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

1
components/calendar/locale/bg_BG.tsx

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

1
components/calendar/locale/ca_ES.tsx

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

1
components/calendar/locale/cs_CZ.tsx

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

1
components/calendar/locale/da_DK.tsx

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

1
components/calendar/locale/de_DE.tsx

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

1
components/calendar/locale/el_GR.tsx

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

1
components/calendar/locale/en_GB.tsx

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

1
components/calendar/locale/en_US.tsx

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

1
components/calendar/locale/es_ES.tsx

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

1
components/calendar/locale/et_EE.tsx

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

1
components/calendar/locale/fa_IR.tsx

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

1
components/calendar/locale/fi_FI.tsx

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

1
components/calendar/locale/fr_BE.tsx

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

1
components/calendar/locale/fr_FR.tsx

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

1
components/calendar/locale/he_IL.tsx

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

1
components/calendar/locale/hi_IN.tsx

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

1
components/calendar/locale/hr_HR.tsx

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

1
components/calendar/locale/hu_HU.tsx

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

1
components/calendar/locale/id_ID.tsx

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

1
components/calendar/locale/is_IS.tsx

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

1
components/calendar/locale/it_IT.tsx

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

1
components/calendar/locale/ja_JP.tsx

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

1
components/calendar/locale/kn_IN.tsx

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

1
components/calendar/locale/ko_KR.tsx

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

1
components/calendar/locale/ku_IQ.tsx

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

1
components/calendar/locale/lv_LV.tsx

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

1
components/calendar/locale/mn_MN.tsx

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

1
components/calendar/locale/ms_MY.tsx

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

1
components/calendar/locale/nb_NO.tsx

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

1
components/calendar/locale/nl_BE.tsx

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

1
components/calendar/locale/nl_NL.tsx

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

1
components/calendar/locale/pl_PL.tsx

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

1
components/calendar/locale/pt_BR.tsx

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

1
components/calendar/locale/pt_PT.tsx

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

1
components/calendar/locale/ru_RU.tsx

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

1
components/calendar/locale/sk_SK.tsx

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

1
components/calendar/locale/sl_SI.tsx

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

1
components/calendar/locale/sr_RS.tsx

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

1
components/calendar/locale/sv_SE.tsx

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

1
components/calendar/locale/ta_IN.tsx

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

1
components/calendar/locale/th_TH.tsx

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

1
components/calendar/locale/tr_TR.tsx

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

1
components/calendar/locale/uk_UA.tsx

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

1
components/calendar/locale/vi_VN.tsx

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

1
components/calendar/locale/zh_CN.tsx

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

1
components/calendar/locale/zh_TW.tsx

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

4
components/config-provider/index.tsx

@ -132,7 +132,9 @@ interface ConstructorProps {
}
export function withConfigConsumer<ExportProps extends BasicExportProps>(config: ConsumerConfig) {
return function<ComponentDef>(Component: IReactComponent): React.SFC<ExportProps> & ComponentDef {
return function withConfigConsumerFunc<ComponentDef>(
Component: IReactComponent,
): React.SFC<ExportProps> & ComponentDef {
// Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
const SFC = ((props: ExportProps) => (
<ConfigConsumer>

1
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[],

2
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;

2
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', '');

4
components/form/context.ts

@ -10,7 +10,9 @@ export interface FormContextProps {
wrapperCol?: ColProps;
}
export const FormContext = createReactContext<FormContextProps>({
const FormContext = createReactContext<FormContextProps>({
labelAlign: 'right',
vertical: false,
});
export default FormContext;

2
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',
};

3
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.',

4
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;

16
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",

12
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<CategoryProps, CategoryState> {
justCopied: null,
};
componentWillUnmount() {
window.clearTimeout(this.copyId);
}
onCopied = (type: string, text: string) => {
message.success(
<span>
@ -37,10 +41,6 @@ class Category extends React.Component<CategoryProps, CategoryState> {
});
};
componentWillUnmount() {
window.clearTimeout(this.copyId);
}
render() {
const {
icons,
@ -64,7 +64,7 @@ class Category extends React.Component<CategoryProps, CategoryState> {
return (
<div>
<h3>{messages[`app.docs.components.icon.category.${title}`]}</h3>
<ul className={'anticons-list'}>{items}</ul>
<ul className="anticons-list">{items}</ul>
</div>
);
}

4
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[];

4
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;

Loading…
Cancel
Save