From 804969cf2cd654743b5b7b0d88ac36a35cc03592 Mon Sep 17 00:00:00 2001 From: duanledexianxianxian Date: Fri, 21 Jun 2019 11:37:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:eslint=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 7 +++++++ package.json | 8 +++++--- src/pages/account/center/index.tsx | 11 ++++------- src/pages/dashboard/analysis/index.tsx | 11 ++++------- src/pages/dashboard/workplace/index.tsx | 4 ++-- src/pages/user/register/index.tsx | 17 ++++++++--------- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a2551389..d43710d6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,6 +4,13 @@ module.exports = { ...fabric.default, rules: { ...fabric.default.rules, + 'import/no-extraneous-dependencies': [ + 2, + { + optionalDependencies: true, + devDependencies: ['**/tests/**.js', '/mock/**/**.js', '**/**.test.js', '**/**._mock.js'], + }, + ], }, globals: { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true, diff --git a/package.json b/package.json index 870182a3..d8ab4740 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ }, "husky": { "hooks": { + "pre-commit": "npm run lint-staged" } }, "lint-staged": { @@ -102,7 +103,7 @@ "@types/react-document-title": "^2.0.3", "@types/react-dom": "^16.8.4", "@types/numeral":"^0.0.25", - "@umijs/fabric": "^1.0.4", + "@umijs/fabric": "^1.0.5", "babel-eslint": "^10.0.1", "chalk": "^2.4.2", "check-prettier": "^1.0.3", @@ -120,14 +121,15 @@ "jest-puppeteer": "^4.2.0", "jsdom-global": "^3.0.2", "lint-staged": "^8.1.7", - "mockjs": "^1.0.1-beta3", "netlify-lambda": "^1.4.13", "node-fetch": "^2.6.0", "prettier": "^1.17.1", "serverless-http": "^2.0.2", "slash2": "^2.0.0", "stylelint": "^10.1.0", - "webpack-theme-color-replacer": "^1.1.5" + "webpack-theme-color-replacer": "^1.1.5", + "mockjs": "^1.0.1-beta3", + "@types/mockjs":"^1.0.2" }, "optionalDependencies": { "puppeteer": "^1.17.0" diff --git a/src/pages/account/center/index.tsx b/src/pages/account/center/index.tsx index f457223c..515dc4b5 100644 --- a/src/pages/account/center/index.tsx +++ b/src/pages/account/center/index.tsx @@ -40,12 +40,12 @@ const operationTabList = [ }, ]; -interface accountCenterProps extends RouteChildrenProps { +interface AccountCenterProps extends RouteChildrenProps { dispatch: Dispatch; currentUser: CurrentUser; currentUserLoading: boolean; } -interface accountCenterState { +interface AccountCenterState { newTags: TagType[]; tabKey: 'articles' | 'applications' | 'projects'; inputVisible: boolean; @@ -64,10 +64,7 @@ interface accountCenterState { currentUserLoading: loading.effects['accountCenter/fetchCurrent'], }), ) -class Center extends PureComponent< - accountCenterProps, - accountCenterState -> { +class Center extends PureComponent { // static getDerivedStateFromProps( // props: accountCenterProps, // state: accountCenterState, @@ -86,7 +83,7 @@ class Center extends PureComponent< // return null; // } - state: accountCenterState = { + state: AccountCenterState = { newTags: [], inputVisible: false, inputValue: '', diff --git a/src/pages/dashboard/analysis/index.tsx b/src/pages/dashboard/analysis/index.tsx index ea04cce6..61919cf1 100644 --- a/src/pages/dashboard/analysis/index.tsx +++ b/src/pages/dashboard/analysis/index.tsx @@ -17,13 +17,13 @@ const TopSearch = React.lazy(() => import('./components/TopSearch')); const ProportionSales = React.lazy(() => import('./components/ProportionSales')); const OfflineData = React.lazy(() => import('./components/OfflineData')); -interface dashboardAnalysisProps { +interface DashboardAnalysisProps { dashboardAnalysis: AnalysisData; dispatch: Dispatch; loading: boolean; } -interface dashboardAnalysisState { +interface DashboardAnalysisState { salesType: 'all' | 'online' | 'stores'; currentTabKey: string; rangePickerValue: RangePickerValue; @@ -43,11 +43,8 @@ interface dashboardAnalysisState { loading: loading.effects['dashboardAnalysis/fetch'], }), ) -class Analysis extends Component< - dashboardAnalysisProps, - dashboardAnalysisState -> { - state: dashboardAnalysisState = { +class Analysis extends Component { + state: DashboardAnalysisState = { salesType: 'all', currentTabKey: '', rangePickerValue: getTimeDistance('year'), diff --git a/src/pages/dashboard/workplace/index.tsx b/src/pages/dashboard/workplace/index.tsx index fd87398e..7e656fb9 100644 --- a/src/pages/dashboard/workplace/index.tsx +++ b/src/pages/dashboard/workplace/index.tsx @@ -39,7 +39,7 @@ const links = [ }, ]; -interface dashboardWorkplaceProps { +interface DashboardWorkplaceProps { currentUser: CurrentUser; projectNotice: NoticeType[]; activities: ActivitiesType[]; @@ -67,7 +67,7 @@ interface dashboardWorkplaceProps { activitiesLoading: loading.effects['dashboardWorkplace/fetchActivitiesList'], }), ) -class Workplace extends PureComponent { +class Workplace extends PureComponent { componentDidMount() { const { dispatch } = this.props; dispatch({ diff --git a/src/pages/user/register/index.tsx b/src/pages/user/register/index.tsx index d011ef91..b4de7c52 100644 --- a/src/pages/user/register/index.tsx +++ b/src/pages/user/register/index.tsx @@ -42,12 +42,12 @@ const passwordProgressMap: { poor: 'exception', }; -interface userRegisterProps extends FormComponentProps { +interface UserRegisterProps extends FormComponentProps { dispatch: Dispatch; userRegister: StateType; submitting: boolean; } -interface userRegisterState { +interface UserRegisterState { count: number; confirmDirty: boolean; visible: boolean; @@ -80,11 +80,8 @@ export interface UserRegisterParams { submitting: loading.effects['userRegister/submit'], }), ) -class Register extends Component< - userRegisterProps, - userRegisterState -> { - state: userRegisterState = { +class Register extends Component { + state: UserRegisterState = { count: 0, confirmDirty: false, visible: false, @@ -342,7 +339,9 @@ class Register extends Component< })( , )} @@ -380,4 +379,4 @@ class Register extends Component< } } -export default Form.create()(Register); +export default Form.create()(Register); -- GitLab