diff --git a/.eslintrc.js b/.eslintrc.js index c5cbba917..77ea9be7c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,6 +28,9 @@ module.exports = { }], 'vue/html-self-closing': 'off', "vue/no-v-html": 'off', + 'vue/singleline-html-element-content-newline': 'warn', + 'vue/require-default-prop': 'warn', + 'vue/require-prop-types': 'warn', 'import/extensions': ['off'] }, diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..7774f34f5 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,5 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" +npm run eslint +bundle exec rubocop -a +git add diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 000000000..f0e139ad8 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +sh bin/validate_push diff --git a/app/javascript/dashboard/components/Snackbar.vue b/app/javascript/dashboard/components/Snackbar.vue index 62673e02a..d34702ab8 100644 --- a/app/javascript/dashboard/components/Snackbar.vue +++ b/app/javascript/dashboard/components/Snackbar.vue @@ -1,13 +1,14 @@ diff --git a/app/javascript/dashboard/components/ui/Switch.vue b/app/javascript/dashboard/components/ui/Switch.vue index f28c84998..e1b27df8e 100644 --- a/app/javascript/dashboard/components/ui/Switch.vue +++ b/app/javascript/dashboard/components/ui/Switch.vue @@ -1,7 +1,13 @@ - @@ -15,7 +15,7 @@ import Twilio from './Twilio'; export default { components: { PageHeader, - Twilio, + Twilio, }, }; diff --git a/app/javascript/dashboard/routes/dashboard/settings/profile/NotificationSettings.vue b/app/javascript/dashboard/routes/dashboard/settings/profile/NotificationSettings.vue index 27c10ecdc..bbf92b43d 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/profile/NotificationSettings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/profile/NotificationSettings.vue @@ -313,6 +313,7 @@ export default { this.hasEnabledPushPermissions = true; } }) + // eslint-disable-next-line no-console .catch(error => console.log(error)) ); }, diff --git a/app/javascript/dashboard/routes/login/Login.vue b/app/javascript/dashboard/routes/login/Login.vue index a56a02ad6..c31bd5479 100644 --- a/app/javascript/dashboard/routes/login/Login.vue +++ b/app/javascript/dashboard/routes/login/Login.vue @@ -149,13 +149,17 @@ export default { } if (response && response.status === 401) { - const { errors } = response.data; - const hasAuthErrorMsg = errors && errors.length && errors[0] && typeof errors[0] === 'string'; + const { errors } = response.data; + const hasAuthErrorMsg = + errors && + errors.length && + errors[0] && + typeof errors[0] === 'string'; if (hasAuthErrorMsg) { this.showAlert(errors[0]); } else { - this.showAlert(this.$t('LOGIN.API.UNAUTH')); - } + this.showAlert(this.$t('LOGIN.API.UNAUTH')); + } return; } this.showAlert(this.$t('LOGIN.API.ERROR_MESSAGE')); diff --git a/app/javascript/dashboard/store/modules/conversations/index.js b/app/javascript/dashboard/store/modules/conversations/index.js index 07475266c..c8519c253 100644 --- a/app/javascript/dashboard/store/modules/conversations/index.js +++ b/app/javascript/dashboard/store/modules/conversations/index.js @@ -68,10 +68,7 @@ export const mutations = { Vue.set(chat.meta, 'team', team); }, - [types.UPDATE_CONVERSATION_CUSTOM_ATTRIBUTES]( - _state, - custom_attributes - ) { + [types.UPDATE_CONVERSATION_CUSTOM_ATTRIBUTES](_state, custom_attributes) { const [chat] = getSelectedChatConversation(_state); Vue.set(chat, 'custom_attributes', custom_attributes); }, @@ -165,10 +162,7 @@ export const mutations = { Vue.set(chat.meta, 'assignee', payload.assignee); }, - [types.UPDATE_CONVERSATION_CONTACT]( - _state, - { conversationId, ...payload } - ) { + [types.UPDATE_CONVERSATION_CONTACT](_state, { conversationId, ...payload }) { const [chat] = _state.allConversations.filter(c => c.id === conversationId); if (chat) { Vue.set(chat.meta, 'sender', payload); @@ -179,10 +173,7 @@ export const mutations = { _state.currentInbox = inboxId ? parseInt(inboxId, 10) : null; }, - [types.SET_CONVERSATION_CAN_REPLY]( - _state, - { conversationId, canReply } - ) { + [types.SET_CONVERSATION_CAN_REPLY](_state, { conversationId, canReply }) { const [chat] = _state.allConversations.filter(c => c.id === conversationId); if (chat) { Vue.set(chat, 'can_reply', canReply); diff --git a/app/javascript/shared/components/GreetingsEditor.vue b/app/javascript/shared/components/GreetingsEditor.vue index 21054f318..86eef8a8c 100644 --- a/app/javascript/shared/components/GreetingsEditor.vue +++ b/app/javascript/shared/components/GreetingsEditor.vue @@ -56,7 +56,7 @@ export default { }; }, watch: { - value: function (newValue) { + value: function(newValue) { this.greetingsMessage = newValue; }, }, diff --git a/app/javascript/shared/components/TextArea.vue b/app/javascript/shared/components/TextArea.vue index 8d87abc7c..9ab6536bd 100644 --- a/app/javascript/shared/components/TextArea.vue +++ b/app/javascript/shared/components/TextArea.vue @@ -23,8 +23,7 @@ outline-none " :class="{ - 'border-black-200 hover:border-black-300 focus:border-black-300': - !error, + 'border-black-200 hover:border-black-300 focus:border-black-300': !error, 'border-red-200 hover:border-red-300 focus:border-red-300': error, }" :placeholder="placeholder" diff --git a/package.json b/package.json index ea76748df..5e193551d 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.22.1", "license": "MIT", "scripts": { - "eslint": "eslint app/javascript --fix", + "eslint": "eslint app/**/*.{js,vue} --fix", "pretest": "rimraf .jest-cache", "test": "jest -w 1 --no-cache", "test:watch": "jest -w 1 --watch --no-cache", @@ -13,7 +13,8 @@ "start:dev-overmind": "overmind start -f ./Procfile.dev", "storybook": "start-storybook -p 6006", "build-storybook": "build-storybook", - "ruby:prettier": "bundle exec rubocop -a" + "ruby:prettier": "bundle exec rubocop -a", + "prepare": "husky install" }, "dependencies": { "@braid/vue-formulate": "^2.5.2", @@ -100,7 +101,7 @@ "eslint-plugin-prettier": "3.4.0", "eslint-plugin-vue": "^6.2.2", "expect-more-jest": "^2.4.2", - "husky": "6.0.0", + "husky": "^7.0.0", "jest": "26.6.3", "jest-serializer-vue": "^2.0.2", "jest-transform-stub": "^2.0.0", @@ -129,7 +130,7 @@ ] }, "lint-staged": { - "*.{js,vue}": [ + "app/**/*.{js,vue}": [ "eslint --fix", "git add" ], diff --git a/yarn.lock b/yarn.lock index a0a662bac..d1bed0704 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7828,10 +7828,10 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -husky@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/husky/-/husky-6.0.0.tgz#810f11869adf51604c32ea577edbc377d7f9319e" - integrity sha512-SQS2gDTB7tBN486QSoKPKQItZw97BMOd+Kdb6ghfpBc0yXyzrddI0oDV5MkDAbuB4X2mO3/nj60TRMcYxwzZeQ== +husky@^7.0.0: + version "7.0.4" + resolved "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535" + integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ== iconv-lite@0.4.24, iconv-lite@^0.4.24: version "0.4.24"