From 6d0a622fcd0d4121dcfd7d4a0a09339374f68641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=84=9A=E9=81=93?= Date: Wed, 29 Aug 2018 16:37:56 +0800 Subject: [PATCH] fix reveiw issue add consistent-return rule --- .eslintrc.js | 1 - mock/api.js | 19 +++---------------- mock/rule.js | 12 ++---------- src/pages/Dashboard/Analysis.js | 3 ++- src/utils/utils.js | 1 + 5 files changed, 8 insertions(+), 28 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 57231e2c..292b7e06 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,7 +22,6 @@ module.exports = { 'jsx-a11y/click-events-have-key-events': 0, 'jsx-a11y/no-static-element-interactions': 0, 'jsx-a11y/anchor-is-valid': 0, - 'consistent-return': 0, }, settings: { polyfills: ['fetch', 'promises'], diff --git a/mock/api.js b/mock/api.js index 2bcdd8bb..a1ffa76e 100644 --- a/mock/api.js +++ b/mock/api.js @@ -118,12 +118,7 @@ function getFakeList(req, res) { const result = fakeList(count); sourceData = result; - - if (res && res.json) { - res.json(result); - } else { - return result; - } + res.json(result); } function postFakeList(req, res) { @@ -155,11 +150,7 @@ function postFakeList(req, res) { break; } - if (res && res.json) { - res.json(result); - } else { - return result; - } + res.json(result); } const getNotice = [ @@ -327,11 +318,7 @@ const getActivities = [ ]; function getFakeCaptcha(req, res) { - if (res && res.json) { - res.json('captcha-xxx'); - } else { - return 'captcha-xxx'; - } + res.json('captcha-xxx'); } export default { diff --git a/mock/rule.js b/mock/rule.js index ea1b0fac..eaa2bede 100644 --- a/mock/rule.js +++ b/mock/rule.js @@ -72,11 +72,7 @@ function getRule(req, res, u) { }, }; - if (res && res.json) { - res.json(result); - } else { - return result; - } + res.json(result); } function postRule(req, res, u, b) { @@ -133,11 +129,7 @@ function postRule(req, res, u, b) { }, }; - if (res && res.json) { - res.json(result); - } else { - return result; - } + res.json(result); } export default { diff --git a/src/pages/Dashboard/Analysis.js b/src/pages/Dashboard/Analysis.js index b7f7e6ba..4ba2f017 100644 --- a/src/pages/Dashboard/Analysis.js +++ b/src/pages/Dashboard/Analysis.js @@ -132,7 +132,7 @@ class Analysis extends Component { const { rangePickerValue } = this.state; const value = getTimeDistance(type); if (!rangePickerValue[0] || !rangePickerValue[1]) { - return; + return undefined; } if ( rangePickerValue[0].isSame(value[0], 'day') && @@ -140,6 +140,7 @@ class Analysis extends Component { ) { return styles.currentDate; } + return undefined; } render() { diff --git a/src/utils/utils.js b/src/utils/utils.js index e9c51514..a506dd03 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -52,6 +52,7 @@ export function getTimeDistance(type) { return [moment(`${year}-01-01 00:00:00`), moment(`${year}-12-31 23:59:59`)]; } + return undefined; } export function getPlainNode(nodeList, parentPath = '') { -- GitLab