chore: Fix pre-commit hooks (#3525)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Muhsin Keloth
2021-12-09 07:02:00 +05:30
committed by GitHub
parent 3ee6b7d6e9
commit 9306b725d8
19 changed files with 85 additions and 65 deletions

View File

@@ -28,6 +28,9 @@ module.exports = {
}], }],
'vue/html-self-closing': 'off', 'vue/html-self-closing': 'off',
"vue/no-v-html": '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'] 'import/extensions': ['off']
}, },

5
.husky/pre-commit Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run eslint
bundle exec rubocop -a
git add

4
.husky/pre-push Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
sh bin/validate_push

View File

@@ -1,13 +1,14 @@
<template> <template>
<div> <div>
<div class="ui-snackbar"> <div class="ui-snackbar">
<div class="ui-snackbar-text">{{ message }}</div> <div class="ui-snackbar-text">
{{ message }}
</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
message: String, message: String,
@@ -22,9 +23,7 @@ export default {
toggleAfterTimeout: false, toggleAfterTimeout: false,
}; };
}, },
methods: { mounted() {},
}, methods: {},
mounted() {
},
}; };
</script> </script>

View File

@@ -1,7 +1,13 @@
<template> <template>
<label class="switch" :class="classObject"> <label class="switch" :class="classObject">
<input class="switch-input" :name="name" :id="id" :disabled="disabled" v-model="value" type="checkbox"> <input
:id="id"
v-model="value"
class="switch-input"
:name="name"
:disabled="disabled"
type="checkbox"
/>
<div class="switch-paddle" :for="name"> <div class="switch-paddle" :for="name">
<span class="show-for-sr">on off</span> <span class="show-for-sr">on off</span>
</div> </div>
@@ -24,12 +30,6 @@ export default {
value: null, value: null,
}; };
}, },
beforeMount() {
this.value = this.checked;
},
mounted() {
this.$emit('input', this.value = !!this.checked);
},
computed: { computed: {
classObject() { classObject() {
const { type, size, value } = this; const { type, size, value } = this;
@@ -45,5 +45,11 @@ export default {
this.$emit('input', val); this.$emit('input', val);
}, },
}, },
beforeMount() {
this.value = this.checked;
},
mounted() {
this.$emit('input', (this.value = !!this.checked));
},
}; };
</script> </script>

View File

@@ -1,7 +1,11 @@
<template> <template>
<div class="row empty-state"> <div class="row empty-state">
<h3 class="title">{{ title }}</h3> <h3 class="title">
<p class="message">{{ message }}</p> {{ title }}
</h3>
<p class="message">
{{ message }}
</p>
<slot /> <slot />
</div> </div>
</template> </template>

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="row loading-state"> <div class="row loading-state">
<h6 class="message">{{message}}<span class="spinner"></span></h6> <h6 class="message">{{ message }}<span class="spinner"></span></h6>
</div> </div>
</template> </template>
<script> <script>

View File

@@ -42,7 +42,8 @@
</div> </div>
<div class="features-item"> <div class="features-item">
<h2 class="block-title"> <h2 class="block-title">
<span class="emoji">👥</span>{{ $t('ONBOARDING.TEAM_MEMBERS.TITLE') }} <span class="emoji">👥</span>
{{ $t('ONBOARDING.TEAM_MEMBERS.TITLE') }}
</h2> </h2>
<p class="intro-body"> <p class="intro-body">
{{ $t('ONBOARDING.TEAM_MEMBERS.DESCRIPTION') }} {{ $t('ONBOARDING.TEAM_MEMBERS.DESCRIPTION') }}
@@ -55,7 +56,7 @@
<h2 class="block-title"> <h2 class="block-title">
<span class="emoji">📥</span>{{ $t('ONBOARDING.INBOXES.TITLE') }} <span class="emoji">📥</span>{{ $t('ONBOARDING.INBOXES.TITLE') }}
</h2> </h2>
<p class="intro-body "> <p class="intro-body">
{{ $t('ONBOARDING.INBOXES.DESCRIPTION') }} {{ $t('ONBOARDING.INBOXES.DESCRIPTION') }}
</p> </p>
<router-link :to="newInboxURL" class="onboarding--link"> <router-link :to="newInboxURL" class="onboarding--link">
@@ -66,7 +67,7 @@
<h2 class="block-title"> <h2 class="block-title">
<span class="emoji">🏷</span>{{ $t('ONBOARDING.LABELS.TITLE') }} <span class="emoji">🏷</span>{{ $t('ONBOARDING.LABELS.TITLE') }}
</h2> </h2>
<p class="intro-body "> <p class="intro-body">
{{ $t('ONBOARDING.LABELS.DESCRIPTION') }} {{ $t('ONBOARDING.LABELS.DESCRIPTION') }}
</p> </p>
<router-link :to="newLabelsURL" class="onboarding--link"> <router-link :to="newLabelsURL" class="onboarding--link">

View File

@@ -10,10 +10,9 @@
variant="hollow" variant="hollow"
size="tiny" size="tiny"
@click="onAvatarDelete" @click="onAvatarDelete"
>{{
this.$t('INBOX_MGMT.DELETE.AVATAR_DELETE_BUTTON_TEXT')
}}</woot-button
> >
{{ this.$t('INBOX_MGMT.DELETE.AVATAR_DELETE_BUTTON_TEXT') }}
</woot-button>
</div> </div>
<label> <label>
<input <input
@@ -26,7 +25,6 @@
<slot></slot> <slot></slot>
</label> </label>
</div> </div>
</template> </template>
<script> <script>

View File

@@ -9,4 +9,4 @@
</woot-button> </woot-button>
</div> </div>
</template> </template>
<script> <script></script>

View File

@@ -81,7 +81,6 @@ import { required } from 'vuelidate/lib/validators';
import router from '../../../../index'; import router from '../../../../index';
import PageHeader from '../../SettingsSubPageHeader'; import PageHeader from '../../SettingsSubPageHeader';
export default { export default {
components: { components: {
PageHeader, PageHeader,
@@ -114,15 +113,18 @@ export default {
} }
try { try {
const lineChannel = await this.$store.dispatch('inboxes/createChannel', { const lineChannel = await this.$store.dispatch(
name: this.channelName, 'inboxes/createChannel',
channel: { {
type: 'line', name: this.channelName,
line_channel_id: this.lineChannelId, channel: {
line_channel_secret: this.lineChannelSecret, type: 'line',
line_channel_token: this.lineChannelToken, line_channel_id: this.lineChannelId,
}, line_channel_secret: this.lineChannelSecret,
}); line_channel_token: this.lineChannelToken,
},
}
);
router.replace({ router.replace({
name: 'settings_inboxes_add_agents', name: 'settings_inboxes_add_agents',
@@ -132,7 +134,9 @@ export default {
}, },
}); });
} catch (error) { } catch (error) {
this.showAlert(this.$t('INBOX_MGMT.ADD.LINE_CHANNEL.API.ERROR_MESSAGE')); this.showAlert(
this.$t('INBOX_MGMT.ADD.LINE_CHANNEL.API.ERROR_MESSAGE')
);
} }
}, },
}, },

View File

@@ -4,7 +4,7 @@
:header-title="$t('INBOX_MGMT.ADD.SMS.TITLE')" :header-title="$t('INBOX_MGMT.ADD.SMS.TITLE')"
:header-content="$t('INBOX_MGMT.ADD.SMS.DESC')" :header-content="$t('INBOX_MGMT.ADD.SMS.DESC')"
/> />
<twilio type="sms"></twilio> <twilio type="sms"></twilio>
</div> </div>
</template> </template>
@@ -15,7 +15,7 @@ import Twilio from './Twilio';
export default { export default {
components: { components: {
PageHeader, PageHeader,
Twilio, Twilio,
}, },
}; };
</script> </script>

View File

@@ -313,6 +313,7 @@ export default {
this.hasEnabledPushPermissions = true; this.hasEnabledPushPermissions = true;
} }
}) })
// eslint-disable-next-line no-console
.catch(error => console.log(error)) .catch(error => console.log(error))
); );
}, },

View File

@@ -149,13 +149,17 @@ export default {
} }
if (response && response.status === 401) { if (response && response.status === 401) {
const { errors } = response.data; const { errors } = response.data;
const hasAuthErrorMsg = errors && errors.length && errors[0] && typeof errors[0] === 'string'; const hasAuthErrorMsg =
errors &&
errors.length &&
errors[0] &&
typeof errors[0] === 'string';
if (hasAuthErrorMsg) { if (hasAuthErrorMsg) {
this.showAlert(errors[0]); this.showAlert(errors[0]);
} else { } else {
this.showAlert(this.$t('LOGIN.API.UNAUTH')); this.showAlert(this.$t('LOGIN.API.UNAUTH'));
} }
return; return;
} }
this.showAlert(this.$t('LOGIN.API.ERROR_MESSAGE')); this.showAlert(this.$t('LOGIN.API.ERROR_MESSAGE'));

View File

@@ -68,10 +68,7 @@ export const mutations = {
Vue.set(chat.meta, 'team', team); Vue.set(chat.meta, 'team', team);
}, },
[types.UPDATE_CONVERSATION_CUSTOM_ATTRIBUTES]( [types.UPDATE_CONVERSATION_CUSTOM_ATTRIBUTES](_state, custom_attributes) {
_state,
custom_attributes
) {
const [chat] = getSelectedChatConversation(_state); const [chat] = getSelectedChatConversation(_state);
Vue.set(chat, 'custom_attributes', custom_attributes); Vue.set(chat, 'custom_attributes', custom_attributes);
}, },
@@ -165,10 +162,7 @@ export const mutations = {
Vue.set(chat.meta, 'assignee', payload.assignee); Vue.set(chat.meta, 'assignee', payload.assignee);
}, },
[types.UPDATE_CONVERSATION_CONTACT]( [types.UPDATE_CONVERSATION_CONTACT](_state, { conversationId, ...payload }) {
_state,
{ conversationId, ...payload }
) {
const [chat] = _state.allConversations.filter(c => c.id === conversationId); const [chat] = _state.allConversations.filter(c => c.id === conversationId);
if (chat) { if (chat) {
Vue.set(chat.meta, 'sender', payload); Vue.set(chat.meta, 'sender', payload);
@@ -179,10 +173,7 @@ export const mutations = {
_state.currentInbox = inboxId ? parseInt(inboxId, 10) : null; _state.currentInbox = inboxId ? parseInt(inboxId, 10) : null;
}, },
[types.SET_CONVERSATION_CAN_REPLY]( [types.SET_CONVERSATION_CAN_REPLY](_state, { conversationId, canReply }) {
_state,
{ conversationId, canReply }
) {
const [chat] = _state.allConversations.filter(c => c.id === conversationId); const [chat] = _state.allConversations.filter(c => c.id === conversationId);
if (chat) { if (chat) {
Vue.set(chat, 'can_reply', canReply); Vue.set(chat, 'can_reply', canReply);

View File

@@ -56,7 +56,7 @@ export default {
}; };
}, },
watch: { watch: {
value: function (newValue) { value: function(newValue) {
this.greetingsMessage = newValue; this.greetingsMessage = newValue;
}, },
}, },

View File

@@ -23,8 +23,7 @@
outline-none outline-none
" "
:class="{ :class="{
'border-black-200 hover:border-black-300 focus:border-black-300': 'border-black-200 hover:border-black-300 focus:border-black-300': !error,
!error,
'border-red-200 hover:border-red-300 focus:border-red-300': error, 'border-red-200 hover:border-red-300 focus:border-red-300': error,
}" }"
:placeholder="placeholder" :placeholder="placeholder"

View File

@@ -3,7 +3,7 @@
"version": "1.22.1", "version": "1.22.1",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"eslint": "eslint app/javascript --fix", "eslint": "eslint app/**/*.{js,vue} --fix",
"pretest": "rimraf .jest-cache", "pretest": "rimraf .jest-cache",
"test": "jest -w 1 --no-cache", "test": "jest -w 1 --no-cache",
"test:watch": "jest -w 1 --watch --no-cache", "test:watch": "jest -w 1 --watch --no-cache",
@@ -13,7 +13,8 @@
"start:dev-overmind": "overmind start -f ./Procfile.dev", "start:dev-overmind": "overmind start -f ./Procfile.dev",
"storybook": "start-storybook -p 6006", "storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook", "build-storybook": "build-storybook",
"ruby:prettier": "bundle exec rubocop -a" "ruby:prettier": "bundle exec rubocop -a",
"prepare": "husky install"
}, },
"dependencies": { "dependencies": {
"@braid/vue-formulate": "^2.5.2", "@braid/vue-formulate": "^2.5.2",
@@ -100,7 +101,7 @@
"eslint-plugin-prettier": "3.4.0", "eslint-plugin-prettier": "3.4.0",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"expect-more-jest": "^2.4.2", "expect-more-jest": "^2.4.2",
"husky": "6.0.0", "husky": "^7.0.0",
"jest": "26.6.3", "jest": "26.6.3",
"jest-serializer-vue": "^2.0.2", "jest-serializer-vue": "^2.0.2",
"jest-transform-stub": "^2.0.0", "jest-transform-stub": "^2.0.0",
@@ -129,7 +130,7 @@
] ]
}, },
"lint-staged": { "lint-staged": {
"*.{js,vue}": [ "app/**/*.{js,vue}": [
"eslint --fix", "eslint --fix",
"git add" "git add"
], ],

View File

@@ -7828,10 +7828,10 @@ human-signals@^1.1.1:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==
husky@6.0.0: husky@^7.0.0:
version "6.0.0" version "7.0.4"
resolved "https://registry.yarnpkg.com/husky/-/husky-6.0.0.tgz#810f11869adf51604c32ea577edbc377d7f9319e" resolved "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535"
integrity sha512-SQS2gDTB7tBN486QSoKPKQItZw97BMOd+Kdb6ghfpBc0yXyzrddI0oDV5MkDAbuB4X2mO3/nj60TRMcYxwzZeQ== integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==
iconv-lite@0.4.24, iconv-lite@^0.4.24: iconv-lite@0.4.24, iconv-lite@^0.4.24:
version "0.4.24" version "0.4.24"