Skip to content

Commit

Permalink
💄 eslint for all
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Aug 14, 2019
1 parent 40f64cb commit 760853e
Show file tree
Hide file tree
Showing 66 changed files with 91 additions and 30 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ components/*/__tests__/type.tsx
# Docs templates
site/theme/template/IconDisplay/*.js
site/theme/template/IconDisplay/*.jsx
typings
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
});
}
Expand Down
1 change: 1 addition & 0 deletions components/_util/colors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { tuple } from './type';

// eslint-disable-next-line import/prefer-default-export
export const PresetColorTypes = tuple(
'pink',
'red',
Expand Down
2 changes: 1 addition & 1 deletion components/_util/raf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
1 change: 1 addition & 0 deletions components/_util/reactNode.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
5 changes: 3 additions & 2 deletions components/_util/responsiveObserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if (typeof window !== 'undefined') {
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
// eslint-disable-next-line global-require
enquire = require('enquire.js');
}

Expand Down Expand Up @@ -57,8 +58,8 @@ const responsiveObserve = {
}
const token = (++subUid).toString();
subscribers.push({
token: token,
func: func,
token,
func,
});
func(screens);
return token;
Expand Down
2 changes: 1 addition & 1 deletion components/affix/utils.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions components/calendar/locale/ar_EG.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import ar_EG from '../../date-picker/locale/ar_EG';

export default ar_EG;
1 change: 1 addition & 0 deletions components/calendar/locale/bg_BG.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import bg_BG from '../../date-picker/locale/bg_BG';

export default bg_BG;
1 change: 1 addition & 0 deletions components/calendar/locale/ca_ES.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import ca_ES from '../../date-picker/locale/ca_ES';

export default ca_ES;
1 change: 1 addition & 0 deletions components/calendar/locale/cs_CZ.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import cs_CZ from '../../date-picker/locale/cs_CZ';

export default cs_CZ;
1 change: 1 addition & 0 deletions components/calendar/locale/da_DK.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import da_DK from '../../date-picker/locale/da_DK';

export default da_DK;
1 change: 1 addition & 0 deletions components/calendar/locale/de_DE.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import de_DE from '../../date-picker/locale/de_DE';

export default de_DE;
1 change: 1 addition & 0 deletions components/calendar/locale/el_GR.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import el_GR from '../../date-picker/locale/el_GR';

export default el_GR;
1 change: 1 addition & 0 deletions components/calendar/locale/en_GB.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import en_GB from '../../date-picker/locale/en_GB';

export default en_GB;
1 change: 1 addition & 0 deletions components/calendar/locale/en_US.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import en_US from '../../date-picker/locale/en_US';

export default en_US;
1 change: 1 addition & 0 deletions components/calendar/locale/es_ES.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import es_ES from '../../date-picker/locale/es_ES';

export default es_ES;
1 change: 1 addition & 0 deletions components/calendar/locale/et_EE.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import et_EE from '../../date-picker/locale/et_EE';

export default et_EE;
1 change: 1 addition & 0 deletions components/calendar/locale/fa_IR.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import fa_IR from '../../date-picker/locale/fa_IR';

export default fa_IR;
1 change: 1 addition & 0 deletions components/calendar/locale/fi_FI.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import fi_FI from '../../date-picker/locale/fi_FI';

export default fi_FI;
1 change: 1 addition & 0 deletions components/calendar/locale/fr_BE.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import fr_BE from '../../date-picker/locale/fr_BE';

export default fr_BE;
1 change: 1 addition & 0 deletions components/calendar/locale/fr_FR.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import fr_FR from '../../date-picker/locale/fr_FR';

export default fr_FR;
1 change: 1 addition & 0 deletions components/calendar/locale/he_IL.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import he_IL from '../../date-picker/locale/he_IL';

export default he_IL;
1 change: 1 addition & 0 deletions components/calendar/locale/hi_IN.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import hi_IN from '../../date-picker/locale/hi_IN';

export default hi_IN;
1 change: 1 addition & 0 deletions components/calendar/locale/hr_HR.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import hr_HR from '../../date-picker/locale/hr_HR';

export default hr_HR;
1 change: 1 addition & 0 deletions components/calendar/locale/hu_HU.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import hu_HU from '../../date-picker/locale/hu_HU';

export default hu_HU;
1 change: 1 addition & 0 deletions components/calendar/locale/id_ID.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import id_ID from '../../date-picker/locale/id_ID';

export default id_ID;
1 change: 1 addition & 0 deletions components/calendar/locale/is_IS.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import is_IS from '../../date-picker/locale/is_IS';

export default is_IS;
1 change: 1 addition & 0 deletions components/calendar/locale/it_IT.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import it_IT from '../../date-picker/locale/it_IT';

export default it_IT;
1 change: 1 addition & 0 deletions components/calendar/locale/ja_JP.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import ja_JP from '../../date-picker/locale/ja_JP';

export default ja_JP;
1 change: 1 addition & 0 deletions components/calendar/locale/kn_IN.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import kn_IN from '../../date-picker/locale/kn_IN';

export default kn_IN;
1 change: 1 addition & 0 deletions components/calendar/locale/ko_KR.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import ko_KR from '../../date-picker/locale/ko_KR';

export default ko_KR;
1 change: 1 addition & 0 deletions components/calendar/locale/ku_IQ.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import ku_IQ from '../../date-picker/locale/ku_IQ';

export default ku_IQ;
1 change: 1 addition & 0 deletions components/calendar/locale/lv_LV.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import lv_LV from '../../date-picker/locale/lv_LV';

export default lv_LV;
1 change: 1 addition & 0 deletions components/calendar/locale/mn_MN.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import mn_MN from '../../date-picker/locale/mn_MN';

export default mn_MN;
1 change: 1 addition & 0 deletions components/calendar/locale/ms_MY.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import ms_MY from '../../date-picker/locale/ms_MY';

export default ms_MY;
1 change: 1 addition & 0 deletions components/calendar/locale/nb_NO.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import nb_NO from '../../date-picker/locale/nb_NO';

export default nb_NO;
1 change: 1 addition & 0 deletions components/calendar/locale/nl_BE.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import nl_BE from '../../date-picker/locale/nl_BE';

export default nl_BE;
1 change: 1 addition & 0 deletions components/calendar/locale/nl_NL.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import nl_NL from '../../date-picker/locale/nl_NL';

export default nl_NL;
1 change: 1 addition & 0 deletions components/calendar/locale/pl_PL.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import pl_PL from '../../date-picker/locale/pl_PL';

export default pl_PL;
1 change: 1 addition & 0 deletions components/calendar/locale/pt_BR.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import pt_BR from '../../date-picker/locale/pt_BR';

export default pt_BR;
1 change: 1 addition & 0 deletions components/calendar/locale/pt_PT.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import pt_PT from '../../date-picker/locale/pt_PT';

export default pt_PT;
1 change: 1 addition & 0 deletions components/calendar/locale/ru_RU.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import ru_RU from '../../date-picker/locale/ru_RU';

export default ru_RU;
1 change: 1 addition & 0 deletions components/calendar/locale/sk_SK.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import sk_SK from '../../date-picker/locale/sk_SK';

export default sk_SK;
1 change: 1 addition & 0 deletions components/calendar/locale/sl_SI.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import sl_SI from '../../date-picker/locale/sl_SI';

export default sl_SI;
1 change: 1 addition & 0 deletions components/calendar/locale/sr_RS.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import sr_RS from '../../date-picker/locale/sr_RS';

export default sr_RS;
1 change: 1 addition & 0 deletions components/calendar/locale/sv_SE.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import sv_SE from '../../date-picker/locale/sv_SE';

export default sv_SE;
1 change: 1 addition & 0 deletions components/calendar/locale/ta_IN.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import ta_IN from '../../date-picker/locale/ta_IN';

export default ta_IN;
1 change: 1 addition & 0 deletions components/calendar/locale/th_TH.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import th_TH from '../../date-picker/locale/th_TH';

export default th_TH;
1 change: 1 addition & 0 deletions components/calendar/locale/tr_TR.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import tr_TR from '../../date-picker/locale/tr_TR';

export default tr_TR;
1 change: 1 addition & 0 deletions components/calendar/locale/uk_UA.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import uk_UA from '../../date-picker/locale/uk_UA';

export default uk_UA;
1 change: 1 addition & 0 deletions components/calendar/locale/vi_VN.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import vi_VN from '../../date-picker/locale/vi_VN';

export default vi_VN;
1 change: 1 addition & 0 deletions components/calendar/locale/zh_CN.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import zh_CN from '../../date-picker/locale/zh_CN';

export default zh_CN;
1 change: 1 addition & 0 deletions components/calendar/locale/zh_TW.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import zh_TW from '../../date-picker/locale/zh_TW';

export default zh_TW;
4 changes: 3 additions & 1 deletion components/config-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions components/date-picker/utils.ts
Original file line number Diff line number Diff line change
@@ -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[],
Expand Down
2 changes: 1 addition & 1 deletion components/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion components/form/FormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', '');

Expand Down
4 changes: 3 additions & 1 deletion components/form/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 1 deletion components/icon/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const svgBaseProps = {
width: '1em',
height: '1em',
fill: 'currentColor',
['aria-hidden']: true,
'aria-hidden': true,
focusable: 'false',
};

Expand Down
3 changes: 2 additions & 1 deletion components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
4 changes: 3 additions & 1 deletion components/progress/utils.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 760853e

Please sign in to comment.