From 4fa3372e97d2003a8636d180fabc756257c6cdf2 Mon Sep 17 00:00:00 2001 From: Daniel Avellaneda Date: Tue, 26 Mar 2019 14:44:46 -0500 Subject: [PATCH] ESLint formidable new rules --- .eslintrc.js | 90 +++++++++++++++++++++++++++- src/components/AdminCities.vue | 4 ++ src/components/AdminUsers.vue | 5 ++ src/components/ForgotPassword.vue | 1 + src/components/Login.vue | 1 + src/components/Profile.vue | 3 + src/components/ResetPassword.vue | 1 + src/components/SignUp.vue | 1 + src/components/Verify.vue | 1 + src/plugins/axios.js | 8 +-- src/router/routes/index.js | 5 +- src/store/modules/index.js | 5 +- tests/e2e/specs/05.forgotAndReset.js | 2 +- 13 files changed, 118 insertions(+), 9 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3b474d1a..7e92a903 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,10 +3,96 @@ module.exports = { env: { node: true }, - extends: ['plugin:vue/essential', '@vue/prettier'], + extends: [ + 'formidable/rules/eslint/best-practices/on', + 'formidable/rules/eslint/es6/on', + 'formidable/rules/eslint/errors/off', + 'formidable/rules/eslint/strict/on', + 'formidable/rules/eslint/node/off', + 'formidable/rules/eslint/style/on', + 'formidable/rules/eslint/variables/on', + 'plugin:vue/essential', + '@vue/prettier' + ], rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'callback-return': [ + 'error', + ['done', 'proceed', 'next', 'onwards', 'callback', 'cb'] + ], + camelcase: [ + 'warn', + { + properties: 'always' + } + ], + 'comma-style': ['warn', 'last'], + curly: ['error'], + eqeqeq: ['error', 'always'], + 'eol-last': ['warn'], + 'no-undef': 2, + 'handle-callback-err': ['error'], + 'arrow-body-style': ['off', 2], + indent: ['off', 2], + 'linebreak-style': ['error', 'unix'], + 'no-dupe-keys': ['error'], + 'no-duplicate-case': ['error'], + 'no-extra-semi': ['warn'], + 'no-labels': ['error'], + 'no-mixed-spaces-and-tabs': [2, 'smart-tabs'], + 'no-redeclare': ['warn'], + 'no-return-assign': ['error', 'always'], + 'no-sequences': ['error'], + 'no-trailing-spaces': ['warn'], + 'no-unexpected-multiline': ['warn'], + 'no-unreachable': ['warn'], + 'no-magic-numbers': ['off'], + 'max-params': ['off'], + 'max-len': ['off'], + 'max-nested-callbacks': ['off'], + 'new-cap': ['off'], + 'consistent-this': ['error', 'that'], + 'no-unused-vars': [ + 'warn', + { + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^unused($|[A-Z].*$)' + } + ], + 'no-use-before-define': [ + 'error', + { + functions: false + } + ], + 'no-var': 2, + 'one-var': ['warn', 'never'], + 'prefer-arrow-callback': [ + 'warn', + { + allowNamedFunctions: true + } + ], + quotes: [ + 'warn', + 'single', + { + avoidEscape: false, + allowTemplateLiterals: true + } + ], + semi: ['error', 'never'], + 'semi-spacing': [ + 'warn', + { + before: false, + after: true + } + ], + 'semi-style': ['warn', 'last'], + 'space-before-function-paren': ['off', 2], + 'prettier/prettier': 'error' }, parserOptions: { parser: 'babel-eslint' diff --git a/src/components/AdminCities.vue b/src/components/AdminCities.vue index 4316021f..96f07247 100644 --- a/src/components/AdminCities.vue +++ b/src/components/AdminCities.vue @@ -219,6 +219,7 @@ export default { buildPayloadPagination(this.pagination, this.buildSearch()) ) this.dataTableLoading = false + // eslint-disable-next-line no-unused-vars } catch (error) { this.dataTableLoading = false } @@ -245,6 +246,7 @@ export default { buildPayloadPagination(this.pagination, this.buildSearch()) ) this.dataTableLoading = false + // eslint-disable-next-line no-unused-vars } catch (error) { this.dataTableLoading = false } @@ -278,6 +280,7 @@ export default { ) this.dataTableLoading = false } + // eslint-disable-next-line no-unused-vars } catch (error) { this.dataTableLoading = false } @@ -310,6 +313,7 @@ export default { } this.close() } + // eslint-disable-next-line no-unused-vars } catch (error) { this.dataTableLoading = false this.close() diff --git a/src/components/AdminUsers.vue b/src/components/AdminUsers.vue index fd5ecf83..26a573e8 100644 --- a/src/components/AdminUsers.vue +++ b/src/components/AdminUsers.vue @@ -388,6 +388,7 @@ export default { buildPayloadPagination(this.pagination, this.buildSearch()) ) this.dataTableLoading = false + // eslint-disable-next-line no-unused-vars } catch (error) { this.dataTableLoading = false } @@ -428,6 +429,7 @@ export default { buildPayloadPagination(this.pagination, this.buildSearch()) ) this.dataTableLoading = false + // eslint-disable-next-line no-unused-vars } catch (error) { this.dataTableLoading = false } @@ -461,6 +463,7 @@ export default { ) this.dataTableLoading = false } + // eslint-disable-next-line no-unused-vars } catch (error) { this.dataTableLoading = false } @@ -502,6 +505,7 @@ export default { this.close() return } + // eslint-disable-next-line no-unused-vars } catch (error) { this.dataTableLoading = false this.close() @@ -512,6 +516,7 @@ export default { async created() { try { await this.getAllCities() + // eslint-disable-next-line no-unused-vars } catch (error) { return } diff --git a/src/components/ForgotPassword.vue b/src/components/ForgotPassword.vue index 41a2941d..2dd32de5 100644 --- a/src/components/ForgotPassword.vue +++ b/src/components/ForgotPassword.vue @@ -80,6 +80,7 @@ export default { }) return } + // eslint-disable-next-line no-unused-vars } catch (error) { return } diff --git a/src/components/Login.vue b/src/components/Login.vue index 982086c2..78b9e4a1 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -94,6 +94,7 @@ export default { }) return } + // eslint-disable-next-line no-unused-vars } catch (error) { return } diff --git a/src/components/Profile.vue b/src/components/Profile.vue index 69289dc0..6fb9479d 100644 --- a/src/components/Profile.vue +++ b/src/components/Profile.vue @@ -352,6 +352,7 @@ export default { }) return } + // eslint-disable-next-line no-unused-vars } catch (error) { return } @@ -375,6 +376,7 @@ export default { this.close() return } + // eslint-disable-next-line no-unused-vars } catch (error) { this.oldPassword = '' this.newPassword = '' @@ -389,6 +391,7 @@ export default { try { await this.getProfile() await this.getAllCities() + // eslint-disable-next-line no-unused-vars } catch (error) { return } diff --git a/src/components/ResetPassword.vue b/src/components/ResetPassword.vue index 0214ebc6..413c963a 100644 --- a/src/components/ResetPassword.vue +++ b/src/components/ResetPassword.vue @@ -91,6 +91,7 @@ export default { }) return } + // eslint-disable-next-line no-unused-vars } catch (error) { return } diff --git a/src/components/SignUp.vue b/src/components/SignUp.vue index 0b14dfc8..129c9227 100644 --- a/src/components/SignUp.vue +++ b/src/components/SignUp.vue @@ -115,6 +115,7 @@ export default { }) return } + // eslint-disable-next-line no-unused-vars } catch (error) { return } diff --git a/src/components/Verify.vue b/src/components/Verify.vue index 5b2c337e..88ea2ee1 100644 --- a/src/components/Verify.vue +++ b/src/components/Verify.vue @@ -32,6 +32,7 @@ export default { async created() { try { await this.sendVerify(this.$route.params.id) + // eslint-disable-next-line no-unused-vars } catch (error) { return } diff --git a/src/plugins/axios.js b/src/plugins/axios.js index 15cde791..7ad00fc8 100644 --- a/src/plugins/axios.js +++ b/src/plugins/axios.js @@ -8,7 +8,7 @@ axios.defaults.headers.common['Accept-Language'] = JSON.parse(localStorage.getItem('locale')) || 'en' axios.interceptors.request.use( - function(config) { + config => { // Do something before request is sent // If request is different than login, then send Authorization header with token from localstorage if (config.url !== '/login') { @@ -17,7 +17,7 @@ axios.interceptors.request.use( } return config }, - function(error) { + error => { // Do something with request error return Promise.reject(error) } @@ -25,11 +25,11 @@ axios.interceptors.request.use( // Add a response interceptor axios.interceptors.response.use( - function(response) { + response => { // Do something with response data return response }, - function(error) { + error => { // Do something with response error return Promise.reject(error) } diff --git a/src/router/routes/index.js b/src/router/routes/index.js index be8bcf61..13a818c2 100644 --- a/src/router/routes/index.js +++ b/src/router/routes/index.js @@ -2,7 +2,10 @@ const requireRoute = require.context('.', false, /\.js$/) // Get js files inside let routes = [] requireRoute.keys().forEach(fileName => { - if (fileName === './index.js') return // Avoid the index.js file + // Avoid the index.js file + if (fileName === './index.js') { + return + } let route = requireRoute(fileName).default routes.push(...route) }) diff --git a/src/store/modules/index.js b/src/store/modules/index.js index e56139cf..77b63e28 100644 --- a/src/store/modules/index.js +++ b/src/store/modules/index.js @@ -3,7 +3,10 @@ const requireModule = require.context('.', false, /\.js$/) // Get js files insid const modules = {} requireModule.keys().forEach(fileName => { - if (fileName === './index.js') return // Avoid the index.js file + // Avoid the index.js file + if (fileName === './index.js') { + return + } const moduleName = camelCase(fileName.replace(/(\.\/|\.js)/g, '')) modules[moduleName] = requireModule(fileName).default }) diff --git a/tests/e2e/specs/05.forgotAndReset.js b/tests/e2e/specs/05.forgotAndReset.js index 4b12f34f..2ad96903 100644 --- a/tests/e2e/specs/05.forgotAndReset.js +++ b/tests/e2e/specs/05.forgotAndReset.js @@ -70,7 +70,7 @@ describe('Forgot Password / Reset Password', () => { cy.wait('@forgot') //Assert on XHR - cy.get('@forgot').then(function(xhr) { + cy.get('@forgot').then(xhr => { expect(xhr.status).to.eq(200) expect(xhr.responseBody).to.have.property('verification') verification = xhr.responseBody.verification