From bfb652864c2dbe43a3545701a8a8084b01b8dd7c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 7 May 2021 11:59:43 +0200 Subject: [PATCH] eslint standard rules implemented --- frontend/.eslintrc.js | 27 ++++++-------- frontend/jest.config.js | 2 +- frontend/run/server.js | 1 + frontend/src/App.vue | 5 --- frontend/src/apis/communityAPI.js | 20 +++++------ frontend/src/apis/loginAPI.js | 16 ++++----- frontend/src/components/BaseAlert.vue | 2 +- frontend/src/components/BaseSlider.vue | 2 +- frontend/src/components/Charts/config.js | 24 ++++++------- .../src/components/Charts/optionHelpers.js | 2 +- .../Charts/roundedCornersExtension.js | 36 +++++++++---------- frontend/src/components/CloseButton.spec.js | 2 +- .../src/components/Collapse/CollapseItem.vue | 2 +- frontend/src/components/Inputs/BaseInput.vue | 2 +- frontend/src/components/Modal-OLD.vue | 4 +-- frontend/src/components/Modal.vue | 2 +- frontend/src/components/Navbar/BaseNav.vue | 4 +-- .../NotificationPlugin/Notification.vue | 14 ++++---- .../components/NotificationPlugin/index.js | 2 +- frontend/src/components/SearchUser.vue | 2 +- .../components/SidebarPlugin/SidebarItem.vue | 4 +-- .../src/components/SidebarPlugin/index.js | 2 +- frontend/src/components/Tabs/Tabs.vue | 4 +-- frontend/src/directives/click-ouside.js | 2 +- frontend/src/main.js | 1 - frontend/src/plugins/dashboard-plugin.js | 5 ++- frontend/src/routes/routes.js | 8 ++--- frontend/src/store/store.js | 12 +++---- frontend/src/store/store.test.js | 26 +++++++------- .../src/views/Layout/ContentFooter.spec.js | 2 +- .../views/Layout/DashboardLayout_gdd.spec.js | 32 ++++++++--------- .../src/views/Layout/DashboardLayout_gdd.vue | 17 ++++----- .../src/views/Pages/AccountOverview.spec.js | 2 +- .../Pages/AccountOverview/GddAddWork2.vue | 10 +++--- .../Pages/AccountOverview/GddSend.spec.js | 6 ++-- .../views/Pages/AccountOverview/GddSend.vue | 2 +- .../Pages/AccountOverview/GddStatus.spec.js | 4 +-- .../views/Pages/AccountOverview/GddTable.vue | 2 +- .../Pages/AccountOverview/GddWorkTable.vue | 1 + frontend/src/views/Pages/Login.spec.js | 8 ++--- frontend/src/views/Pages/Login.vue | 4 +-- frontend/src/views/Pages/Register.spec.js | 8 ++--- frontend/src/views/Pages/Register.vue | 4 +-- .../src/views/Pages/ResetPassword.spec.js | 16 ++++----- frontend/src/views/Pages/ResetPassword.vue | 4 +-- .../Pages/UserProfile/ImageUploaderAvatar.vue | 10 +++--- frontend/test/testSetup.js | 4 +-- frontend/vue.config.js | 1 + 48 files changed, 181 insertions(+), 191 deletions(-) diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 925aceb9a..8c410feba 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -3,29 +3,24 @@ module.exports = { env: { browser: true, node: true, - jest: true + jest: true, }, parserOptions: { - parser: 'babel-eslint' + parser: 'babel-eslint', }, - extends: [ - 'standard', - 'plugin:vue/essential', - 'plugin:prettier/recommended' - ], + extends: ['standard', 'plugin:vue/essential', 'plugin:prettier/recommended'], // required to lint *.vue files - plugins: [ - 'vue', - 'prettier', - 'jest' - ], + plugins: ['vue', 'prettier', 'jest'], // add your custom rules here rules: { 'no-console': ['error'], 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'vue/component-name-in-template-casing': ['error', 'kebab-case'], - 'prettier/prettier': ['error', { - htmlWhitespaceSensitivity: 'ignore' - }], - } + 'prettier/prettier': [ + 'error', + { + htmlWhitespaceSensitivity: 'ignore', + }, + ], + }, } diff --git a/frontend/jest.config.js b/frontend/jest.config.js index f1082faad..dc44ca43e 100644 --- a/frontend/jest.config.js +++ b/frontend/jest.config.js @@ -3,7 +3,7 @@ module.exports = { collectCoverageFrom: ['src/**/*.{js,vue}', '!**/node_modules/**', '!**/?(*.)+(spec|test).js?(x)'], moduleFileExtensions: [ 'js', - //'jsx', + // 'jsx', 'json', 'vue', ], diff --git a/frontend/run/server.js b/frontend/run/server.js index 470acdc4e..8a3f54557 100644 --- a/frontend/run/server.js +++ b/frontend/run/server.js @@ -7,6 +7,7 @@ const port = process.env.PORT || 3000 // Express Server const app = express() +// eslint-disable-next-line node/no-path-concat app.use(serveStatic(__dirname + '/../dist')) app.listen(port) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index f0b7e513c..b47b9caf0 100755 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -36,11 +36,6 @@ export default { DashboardLayout, AuthLayoutGDD, }, - data() { - return { - language: 'en', - } - }, data() { return { config: { diff --git a/frontend/src/apis/communityAPI.js b/frontend/src/apis/communityAPI.js index d2e71439c..5d56f4a1b 100644 --- a/frontend/src/apis/communityAPI.js +++ b/frontend/src/apis/communityAPI.js @@ -32,17 +32,17 @@ const apiPost = async (url, payload) => { } const communityAPI = { - balance: async (session_id) => { - return apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + session_id) + balance: async (sessionId) => { + return apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + sessionId) }, - transactions: async (session_id, firstPage = 1, items = 25, order = 'DESC') => { + transactions: async (sessionId, firstPage = 1, items = 25, order = 'DESC') => { return apiGet( - `${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${session_id}`, + `${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${sessionId}`, ) }, - /*create: async (session_id, email, amount, memo, target_date = new Date() ) => { + /* create: async (sessionId, email, amount, memo, target_date = new Date() ) => { const payload = { - session_id, + sessionId, email, amount, target_date, @@ -50,14 +50,14 @@ const communityAPI = { auto_sign: true, } return apiPost(CONFIG.COMMUNITY_API__URL + 'createCoins/', payload) - },*/ - send: async (session_id, email, amount, memo, target_date) => { + }, */ + send: async (sessionId, email, amount, memo, targetDate) => { const payload = { - session_id, + session_id: sessionId, email, amount, memo, - target_date, + target_date: targetDate, auto_sign: true, } return apiPost(CONFIG.COMMUNITY_API_URL + 'sendCoins/', payload) diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index a31a4062e..f5b0c57f5 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -29,7 +29,7 @@ const apiPost = async (url, payload) => { throw new Error('HTTP Status Error ' + result.status) } if (result.data.state === 'warning') { - return { success: true, result: error } + return { success: true, result: result.error } } if (result.data.state !== 'success') { throw new Error(result.data.msg) @@ -48,15 +48,15 @@ const loginAPI = { } return apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', payload) }, - logout: async (session_id) => { - const payload = { session_id } + logout: async (sessionId) => { + const payload = { session_id: sessionId } return apiPost(CONFIG.LOGIN_API_URL + 'logout', payload) }, - create: async (email, first_name, last_name, password) => { + create: async (email, firstName, lastName, password) => { const payload = { email, - first_name, - last_name, + first_name: firstName, + last_name: lastName, password, emailType: EMAIL_TYPE.DEFAULT, login_after_register: true, @@ -76,9 +76,9 @@ const loginAPI = { CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin, ) }, - changePassword: async (session_id, email, password) => { + changePassword: async (sessionId, email, password) => { const payload = { - session_id, + session_id: sessionId, email, update: { 'User.password': password, diff --git a/frontend/src/components/BaseAlert.vue b/frontend/src/components/BaseAlert.vue index 3349bde50..fe17428a2 100644 --- a/frontend/src/components/BaseAlert.vue +++ b/frontend/src/components/BaseAlert.vue @@ -42,7 +42,7 @@ export default { FadeTransition, }, created() { - //console.log('base-alert gesetzt in =>', this.$route.path) + // console.log('base-alert gesetzt in =>', this.$route.path) }, props: { type: { diff --git a/frontend/src/components/BaseSlider.vue b/frontend/src/components/BaseSlider.vue index 754bea355..14180674a 100644 --- a/frontend/src/components/BaseSlider.vue +++ b/frontend/src/components/BaseSlider.vue @@ -62,7 +62,7 @@ export default { }) const slider = this.$el.noUiSlider slider.on('slide', () => { - let value = slider.get() + const value = slider.get() if (value !== this.value) { this.$emit('input', value) } diff --git a/frontend/src/components/Charts/config.js b/frontend/src/components/Charts/config.js index 5da4578f0..694a036b5 100644 --- a/frontend/src/components/Charts/config.js +++ b/frontend/src/components/Charts/config.js @@ -2,7 +2,7 @@ import { parseOptions } from '@/components/Charts/optionHelpers' import Chart from 'chart.js' export const Charts = { - mode: 'light', //(themeMode) ? themeMode : 'light'; + mode: 'light', // (themeMode) ? themeMode : 'light'; fonts: { base: 'Open Sans', }, @@ -34,9 +34,9 @@ export const Charts = { } function chartOptions() { - let { colors, mode, fonts } = Charts + const { colors, mode, fonts } = Charts // Options - let options = { + const options = { defaults: { global: { responsive: true, @@ -59,21 +59,21 @@ function chartOptions() { elements: { point: { radius: 0, - backgroundColor: colors.theme['primary'], + backgroundColor: colors.theme.primary, }, line: { tension: 0.4, borderWidth: 4, - borderColor: colors.theme['primary'], + borderColor: colors.theme.primary, backgroundColor: colors.transparent, borderCapStyle: 'rounded', }, rectangle: { - backgroundColor: colors.theme['warning'], + backgroundColor: colors.theme.warning, }, arc: { - backgroundColor: colors.theme['primary'], - borderColor: mode == 'dark' ? colors.gray[800] : colors.white, + backgroundColor: colors.theme.primary, + borderColor: mode === 'dark' ? colors.gray[800] : colors.white, borderWidth: 4, }, }, @@ -94,11 +94,11 @@ function chartOptions() { }, cutoutPercentage: 83, legendCallback: function (chart) { - let data = chart.data + const data = chart.data let content = '' data.labels.forEach(function (label, index) { - let bgColor = data.datasets[0].backgroundColor[index] + const bgColor = data.datasets[0].backgroundColor[index] content += '' content += @@ -172,7 +172,7 @@ export const basicOptions = { }, responsive: true, } -export let blueChartOptions = { +export const blueChartOptions = { scales: { yAxes: [ { @@ -185,7 +185,7 @@ export let blueChartOptions = { }, } -export let lineChartOptionsBlue = { +export const lineChartOptionsBlue = { ...basicOptions, tooltips: { backgroundColor: '#f5f5f5', diff --git a/frontend/src/components/Charts/optionHelpers.js b/frontend/src/components/Charts/optionHelpers.js index 4caa22367..5b4630b73 100644 --- a/frontend/src/components/Charts/optionHelpers.js +++ b/frontend/src/components/Charts/optionHelpers.js @@ -1,6 +1,6 @@ // Parse global options export function parseOptions(parent, options) { - for (let item in options) { + for (const item in options) { if (typeof options[item] !== 'object') { parent[item] = options[item] } else { diff --git a/frontend/src/components/Charts/roundedCornersExtension.js b/frontend/src/components/Charts/roundedCornersExtension.js index ae7f84ce8..2ef8fd1d2 100644 --- a/frontend/src/components/Charts/roundedCornersExtension.js +++ b/frontend/src/components/Charts/roundedCornersExtension.js @@ -4,13 +4,13 @@ // import Chart from 'chart.js' Chart.elements.Rectangle.prototype.draw = function () { - let ctx = this._chart.ctx - let vm = this._view - let left, right, top, bottom, signX, signY, borderSkipped, radius + const ctx = this._chart.ctx + const vm = this._view + let left, right, top, bottom, signX, signY, borderSkipped let borderWidth = vm.borderWidth // Set Radius Here // If radius is large enough to cause drawing errors a max radius is imposed - let cornerRadius = 6 + const cornerRadius = 6 if (!vm.horizontal) { // bar @@ -36,14 +36,14 @@ Chart.elements.Rectangle.prototype.draw = function () { // adjust the sizes to fit if we're setting a stroke on the line if (borderWidth) { // borderWidth shold be less than bar width and bar height. - let barSize = Math.min(Math.abs(left - right), Math.abs(top - bottom)) + const barSize = Math.min(Math.abs(left - right), Math.abs(top - bottom)) borderWidth = borderWidth > barSize ? barSize : borderWidth - let halfStroke = borderWidth / 2 + const halfStroke = borderWidth / 2 // Adjust borderWidth when bar top position is near vm.base(zero). - let borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0) - let borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0) - let borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0) - let borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0) + const borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0) + const borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0) + const borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0) + const borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0) // not become a vertical line? if (borderLeft !== borderRight) { top = borderTop @@ -64,7 +64,7 @@ Chart.elements.Rectangle.prototype.draw = function () { // Corner points, from bottom-left to bottom-right clockwise // | 1 2 | // | 0 3 | - let corners = [ + const corners = [ [left, bottom], [left, top], [right, top], @@ -72,7 +72,7 @@ Chart.elements.Rectangle.prototype.draw = function () { ] // Find first (starting) corner with fallback to 'bottom' - let borders = ['bottom', 'left', 'top', 'right'] + const borders = ['bottom', 'left', 'top', 'right'] let startCorner = borders.indexOf(borderSkipped, 0) if (startCorner === -1) { startCorner = 0 @@ -89,16 +89,14 @@ Chart.elements.Rectangle.prototype.draw = function () { for (let i = 1; i < 4; i++) { corner = cornerAt(i) let nextCornerId = i + 1 - if (nextCornerId == 4) { + if (nextCornerId === 4) { nextCornerId = 0 } - let nextCorner = cornerAt(nextCornerId) - - let width = corners[2][0] - corners[1][0] - let height = corners[0][1] - corners[1][1] - let x = corners[1][0] - let y = corners[1][1] + const width = corners[2][0] - corners[1][0] + const height = corners[0][1] - corners[1][1] + const x = corners[1][0] + const y = corners[1][1] let radius = cornerRadius diff --git a/frontend/src/components/CloseButton.spec.js b/frontend/src/components/CloseButton.spec.js index 7bf4d52de..b92422df8 100644 --- a/frontend/src/components/CloseButton.spec.js +++ b/frontend/src/components/CloseButton.spec.js @@ -6,7 +6,7 @@ const localVue = global.localVue describe('CloseButton', () => { let wrapper - let propsData = { + const propsData = { target: 'Target', expanded: false, } diff --git a/frontend/src/components/Collapse/CollapseItem.vue b/frontend/src/components/Collapse/CollapseItem.vue index 80a0cbe49..7d6b8ded1 100644 --- a/frontend/src/components/Collapse/CollapseItem.vue +++ b/frontend/src/components/Collapse/CollapseItem.vue @@ -70,7 +70,7 @@ export default { }, methods: { activate() { - let wasActive = this.active + const wasActive = this.active if (!this.multipleActive) { this.deactivateAll() } diff --git a/frontend/src/components/Inputs/BaseInput.vue b/frontend/src/components/Inputs/BaseInput.vue index c4e323696..c43e0a265 100644 --- a/frontend/src/components/Inputs/BaseInput.vue +++ b/frontend/src/components/Inputs/BaseInput.vue @@ -170,7 +170,7 @@ export default { }, methods: { updateValue(evt) { - let value = evt.target.value + const value = evt.target.value this.$emit('input', value) }, onFocus(evt) { diff --git a/frontend/src/components/Modal-OLD.vue b/frontend/src/components/Modal-OLD.vue index 4e2ea3cae..515b510a0 100644 --- a/frontend/src/components/Modal-OLD.vue +++ b/frontend/src/components/Modal-OLD.vue @@ -60,7 +60,7 @@ export default { type: String, default: '', validator(value) { - let acceptedValues = ['', 'notice', 'mini'] + const acceptedValues = ['', 'notice', 'mini'] return acceptedValues.indexOf(value) !== -1 }, description: 'Modal type (notice|mini|"") ', @@ -73,7 +73,7 @@ export default { type: String, description: 'Modal size', validator(value) { - let acceptedValues = ['', 'sm', 'lg'] + const acceptedValues = ['', 'sm', 'lg'] return acceptedValues.indexOf(value) !== -1 }, }, diff --git a/frontend/src/components/Modal.vue b/frontend/src/components/Modal.vue index 88bcd1e6f..c43bf6c67 100644 --- a/frontend/src/components/Modal.vue +++ b/frontend/src/components/Modal.vue @@ -39,7 +39,7 @@ export default { submittedNames: [], } }, - /*Modal*/ + /* Modal */ checkFormValidity() { const valid = this.$refs.form.checkValidity() this.nameState = valid diff --git a/frontend/src/components/Navbar/BaseNav.vue b/frontend/src/components/Navbar/BaseNav.vue index a656648e5..778f550fc 100644 --- a/frontend/src/components/Navbar/BaseNav.vue +++ b/frontend/src/components/Navbar/BaseNav.vue @@ -90,8 +90,8 @@ export default { }, computed: { classes() { - let color = `bg-${this.type}` - let classes = [ + const color = `bg-${this.type}` + const classes = [ { 'navbar-transparent': this.transparent }, { [`navbar-expand-${this.expand}`]: this.expand }, ] diff --git a/frontend/src/components/NotificationPlugin/Notification.vue b/frontend/src/components/NotificationPlugin/Notification.vue index 20251d9fa..e36985036 100644 --- a/frontend/src/components/NotificationPlugin/Notification.vue +++ b/frontend/src/components/NotificationPlugin/Notification.vue @@ -59,7 +59,7 @@ export default { type: String, default: 'top', validator: (value) => { - let acceptedValues = ['top', 'bottom'] + const acceptedValues = ['top', 'bottom'] return acceptedValues.indexOf(value) !== -1 }, description: 'Vertical alignment of notification (top|bottom)', @@ -68,7 +68,7 @@ export default { type: String, default: 'right', validator: (value) => { - let acceptedValues = ['left', 'center', 'right'] + const acceptedValues = ['left', 'center', 'right'] return acceptedValues.indexOf(value) !== -1 }, description: 'Horizontal alignment of notification (left|center|right)', @@ -77,7 +77,7 @@ export default { type: String, default: 'info', validator: (value) => { - let acceptedValues = ['default', 'info', 'primary', 'danger', 'warning', 'success'] + const acceptedValues = ['default', 'info', 'primary', 'danger', 'warning', 'success'] return acceptedValues.indexOf(value) !== -1 }, description: @@ -129,8 +129,8 @@ export default { return `alert-${this.type}` }, customPosition() { - let initialMargin = 20 - let alertHeight = this.elmHeight + 10 + const initialMargin = 20 + const alertHeight = this.elmHeight + 10 let sameAlertsCount = this.$notifications.state.filter((alert) => { return ( alert.horizontalAlign === this.horizontalAlign && @@ -141,8 +141,8 @@ export default { if (this.$notifications.settings.overlap) { sameAlertsCount = 1 } - let pixels = (sameAlertsCount - 1) * alertHeight + initialMargin - let styles = {} + const pixels = (sameAlertsCount - 1) * alertHeight + initialMargin + const styles = {} if (this.verticalAlign === 'top') { styles.top = `${pixels}px` } else { diff --git a/frontend/src/components/NotificationPlugin/index.js b/frontend/src/components/NotificationPlugin/index.js index fbf48d214..5b6bbe67b 100644 --- a/frontend/src/components/NotificationPlugin/index.js +++ b/frontend/src/components/NotificationPlugin/index.js @@ -44,7 +44,7 @@ const NotificationStore = { const NotificationsPlugin = { install(Vue, options) { - let app = new Vue({ + const app = new Vue({ data: { notificationStore: NotificationStore, }, diff --git a/frontend/src/components/SearchUser.vue b/frontend/src/components/SearchUser.vue index ae06c6dd8..dd3fe34a6 100644 --- a/frontend/src/components/SearchUser.vue +++ b/frontend/src/components/SearchUser.vue @@ -5,7 +5,7 @@ import VueBootstrapTypeahead from 'vue-bootstrap-typeahead' // Global registration -//Vue.component('vue-bootstrap-typeahead', VueBootstrapTypeahead) +// Vue.component('vue-bootstrap-typeahead', VueBootstrapTypeahead) // OR diff --git a/frontend/src/components/SidebarPlugin/SidebarItem.vue b/frontend/src/components/SidebarPlugin/SidebarItem.vue index 84a722aa3..309af33b0 100755 --- a/frontend/src/components/SidebarPlugin/SidebarItem.vue +++ b/frontend/src/components/SidebarPlugin/SidebarItem.vue @@ -110,7 +110,7 @@ export default { }, linkPrefix() { if (this.link.name) { - let words = this.link.name.split(' ') + const words = this.link.name.split(' ') return words.map((word) => word.substring(0, 1)).join('') } return '' @@ -120,7 +120,7 @@ export default { }, isActive() { if (this.$route && this.$route.path) { - let matchingRoute = this.children.find((c) => this.$route.path.startsWith(c.link.path)) + const matchingRoute = this.children.find((c) => this.$route.path.startsWith(c.link.path)) if (matchingRoute !== undefined) { return true } diff --git a/frontend/src/components/SidebarPlugin/index.js b/frontend/src/components/SidebarPlugin/index.js index cbe421862..ab59a9595 100755 --- a/frontend/src/components/SidebarPlugin/index.js +++ b/frontend/src/components/SidebarPlugin/index.js @@ -29,7 +29,7 @@ const SidebarPlugin = { if (options && options.sidebarLinks) { SidebarStore.sidebarLinks = options.sidebarLinks } - let app = new Vue({ + const app = new Vue({ data: { sidebarStore: SidebarStore, }, diff --git a/frontend/src/components/Tabs/Tabs.vue b/frontend/src/components/Tabs/Tabs.vue index 7ba788329..211c8d0cd 100644 --- a/frontend/src/components/Tabs/Tabs.vue +++ b/frontend/src/components/Tabs/Tabs.vue @@ -67,7 +67,7 @@ export default { type: String, default: 'primary', validator: (value) => { - let acceptedValues = ['primary', 'info', 'success', 'warning', 'danger'] + const acceptedValues = ['primary', 'info', 'success', 'warning', 'danger'] return acceptedValues.indexOf(value) !== -1 }, }, @@ -102,7 +102,7 @@ export default { }, methods: { findAndActivateTab(title) { - let tabToActivate = this.tabs.find((t) => t.title === title) + const tabToActivate = this.tabs.find((t) => t.title === title) if (tabToActivate) { this.activateTab(tabToActivate) } diff --git a/frontend/src/directives/click-ouside.js b/frontend/src/directives/click-ouside.js index 9661a4e16..be4afb4ce 100644 --- a/frontend/src/directives/click-ouside.js +++ b/frontend/src/directives/click-ouside.js @@ -2,7 +2,7 @@ export default { bind: function (el, binding, vnode) { el.clickOutsideEvent = function (event) { // here I check that click was outside the el and his childrens - if (!(el == event.target || el.contains(event.target))) { + if (!(el === event.target || el.contains(event.target))) { // and if it did, call method provided in attribute value vnode.context[binding.expression](event) } diff --git a/frontend/src/main.js b/frontend/src/main.js index f1b7ee0c2..dea19c3fe 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -2,7 +2,6 @@ import Vue from 'vue' import DashboardPlugin from './plugins/dashboard-plugin' import App from './App.vue' import i18n from './i18n.js' -import VeeValidate from './vee-validate.js' // store import { store } from './store/store' diff --git a/frontend/src/plugins/dashboard-plugin.js b/frontend/src/plugins/dashboard-plugin.js index 881fecf7d..6bafb569e 100755 --- a/frontend/src/plugins/dashboard-plugin.js +++ b/frontend/src/plugins/dashboard-plugin.js @@ -3,7 +3,7 @@ import '@/polyfills' // Notifications plugin. Used on Notifications page import Notifications from '@/components/NotificationPlugin' // Validation plugin used to validate forms -import { configure } from 'vee-validate' +import { configure, extend } from 'vee-validate' // A plugin file where you could register global components used across the app import GlobalComponents from './globalComponents' // A plugin file where you could register global directives @@ -14,7 +14,6 @@ import SideBar from '@/components/SidebarPlugin' // element ui language configuration import lang from 'element-ui/lib/locale/lang/en' import locale from 'element-ui/lib/locale' -locale.use(lang) // vue-bootstrap import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' @@ -22,7 +21,6 @@ import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' // asset imports import '@/assets/scss/argon.scss' import '@/assets/vendor/nucleo/css/nucleo.css' -import { extend } from 'vee-validate' import * as rules from 'vee-validate/dist/rules' import { messages } from 'vee-validate/dist/locale/en.json' @@ -40,6 +38,7 @@ import VueMoment from 'vue-moment' import Loading from 'vue-loading-overlay' // import the styles import 'vue-loading-overlay/dist/vue-loading.css' +locale.use(lang) Object.keys(rules).forEach((rule) => { extend(rule, { diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index 236cc15af..e9bcf38c8 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -21,20 +21,20 @@ const routes = [ requiresAuth: true, }, }, - //{ + // { // path: '/profileedit', // component: () => import('../views/Pages/UserProfileEdit.vue'), // meta: { // requiresAuth: true, // }, - //}, - //{ + // }, + // { // path: '/activity', // component: () => import('../views/Pages/UserProfileActivity.vue'), // meta: { // requiresAuth: true, // }, - //}, + // }, { path: '/transactions', component: () => import('../views/Pages/UserProfileTransactionList.vue'), diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 5c9e1bc1e..070074bfd 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -1,7 +1,7 @@ import Vue from 'vue' import Vuex from 'vuex' -Vue.use(Vuex) import createPersistedState from 'vuex-persistedstate' +Vue.use(Vuex) export const mutations = { language: (state, language) => { @@ -10,18 +10,18 @@ export const mutations = { email: (state, email) => { state.email = email }, - session_id: (state, session_id) => { - state.session_id = session_id + sessionId: (state, sessionId) => { + state.sessionId = sessionId }, } export const actions = { login: ({ dispatch, commit }, data) => { - commit('session_id', data.session_id) + commit('sessionId', data.session_id) commit('email', data.email) }, logout: ({ commit, state }) => { - commit('session_id', null) + commit('sessionId', null) commit('email', null) sessionStorage.clear() }, @@ -34,7 +34,7 @@ export const store = new Vuex.Store({ }), ], state: { - session_id: null, + sessionId: null, email: '', language: 'en', modals: false, diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index ccf59dfbf..655cca7a0 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -1,6 +1,6 @@ import { mutations, actions } from './store' -const { language, email, session_id } = mutations +const { language, email, sessionId } = mutations const { login, logout } = actions describe('Vuex store', () => { @@ -21,11 +21,11 @@ describe('Vuex store', () => { }) }) - describe('session_id', () => { - it('sets the state of session_id', () => { - const state = { session_id: null } - session_id(state, '1234') - expect(state.session_id).toEqual('1234') + describe('sessionId', () => { + it('sets the state of sessionId', () => { + const state = { sessionId: null } + sessionId(state, '1234') + expect(state.sessionId).toEqual('1234') }) }) }) @@ -36,17 +36,17 @@ describe('Vuex store', () => { const state = {} it('calls two commits', () => { - login({ commit, state }, { session_id: 1234, email: 'someone@there.is' }) + login({ commit, state }, { sessionId: 1234, email: 'someone@there.is' }) expect(commit).toHaveBeenCalledTimes(2) }) - it('commits session_id', () => { - login({ commit, state }, { session_id: 1234, email: 'someone@there.is' }) - expect(commit).toHaveBeenNthCalledWith(1, 'session_id', 1234) + it('commits sessionId', () => { + login({ commit, state }, { sessionId: 1234, email: 'someone@there.is' }) + expect(commit).toHaveBeenNthCalledWith(1, 'sessionId', 1234) }) it('commits email', () => { - login({ commit, state }, { session_id: 1234, email: 'someone@there.is' }) + login({ commit, state }, { sessionId: 1234, email: 'someone@there.is' }) expect(commit).toHaveBeenNthCalledWith(2, 'email', 'someone@there.is') }) }) @@ -60,9 +60,9 @@ describe('Vuex store', () => { expect(commit).toHaveBeenCalledTimes(2) }) - it('commits session_id', () => { + it('commits sessionId', () => { logout({ commit, state }) - expect(commit).toHaveBeenNthCalledWith(1, 'session_id', null) + expect(commit).toHaveBeenNthCalledWith(1, 'sessionId', null) }) it('commits email', () => { diff --git a/frontend/src/views/Layout/ContentFooter.spec.js b/frontend/src/views/Layout/ContentFooter.spec.js index ec4d3ff74..a5e321466 100644 --- a/frontend/src/views/Layout/ContentFooter.spec.js +++ b/frontend/src/views/Layout/ContentFooter.spec.js @@ -7,7 +7,7 @@ const localVue = global.localVue describe('ContentFooter', () => { let wrapper - let mocks = { + const mocks = { $i18n: { locale: 'en', }, diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js index acf971a93..ee9bab18b 100644 --- a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js +++ b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js @@ -20,7 +20,7 @@ const transitionStub = () => ({ describe('DashboardLayoutGdd', () => { let wrapper - let mocks = { + const mocks = { $i18n: { locale: 'en', }, @@ -28,7 +28,7 @@ describe('DashboardLayoutGdd', () => { $n: jest.fn(), } - let state = { + const state = { user: { name: 'Peter Lustig', balance: 2546, @@ -37,12 +37,12 @@ describe('DashboardLayoutGdd', () => { email: 'peter.lustig@example.org', } - let stubs = { + const stubs = { RouterLink: RouterLinkStub, FadeTransition: transitionStub(), } - let store = new Vuex.Store({ + const store = new Vuex.Store({ state, }) @@ -104,41 +104,41 @@ describe('DashboardLayoutGdd', () => { expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/transactions') }) - //it('has third item "My profile" in navbar', () => { + // it('has third item "My profile" in navbar', () => { // expect(navbar.findAll('ul > li').at(2).text()).toEqual('site.navbar.my-profil') - //}) + // }) // - //it.skip('has third item "My profile" linked to profile in navbar', async () => { + // it.skip('has third item "My profile" linked to profile in navbar', async () => { // navbar.findAll('ul > li > a').at(2).trigger('click') // await flushPromises() // await jest.runAllTimers() // await flushPromises() // expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/profile') - //}) + // }) - //it('has fourth item "Settigs" in navbar', () => { + // it('has fourth item "Settigs" in navbar', () => { // expect(navbar.findAll('ul > li').at(3).text()).toEqual('site.navbar.settings') - //}) + // }) // - //it.skip('has fourth item "Settings" linked to profileedit in navbar', async () => { + // it.skip('has fourth item "Settings" linked to profileedit in navbar', async () => { // navbar.findAll('ul > li > a').at(3).trigger('click') // await flushPromises() // await jest.runAllTimers() // await flushPromises() // expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/profileedit') - //}) + // }) - //it('has fifth item "Activity" in navbar', () => { + // it('has fifth item "Activity" in navbar', () => { // expect(navbar.findAll('ul > li').at(4).text()).toEqual('site.navbar.activity') - //}) + // }) // - //it.skip('has fourth item "Activity" linked to activity in navbar', async () => { + // it.skip('has fourth item "Activity" linked to activity in navbar', async () => { // navbar.findAll('ul > li > a').at(4).trigger('click') // await flushPromises() // await jest.runAllTimers() // await flushPromises() // expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/activity') - //}) + // }) }) }) }) diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index aac4f3743..bc7ad6dad 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -46,12 +46,19 @@ import PerfectScrollbar from 'perfect-scrollbar' import 'perfect-scrollbar/css/perfect-scrollbar.css' import loginAPI from '../../apis/loginAPI' +import DashboardNavbar from './DashboardNavbar.vue' +import ContentFooter from './ContentFooter.vue' +// import DashboardContent from './Content.vue'; +import { FadeTransition } from 'vue2-transitions' +import communityAPI from '../../apis/communityAPI' + function hasElement(className) { return document.getElementsByClassName(className).length > 0 } function initScrollbar(className) { if (hasElement(className)) { + // eslint-disable-next-line no-new new PerfectScrollbar(`.${className}`) } else { // try to init it later in case this component is loaded async @@ -61,12 +68,6 @@ function initScrollbar(className) { } } -import DashboardNavbar from './DashboardNavbar.vue' -import ContentFooter from './ContentFooter.vue' -// import DashboardContent from './Content.vue'; -import { FadeTransition } from 'vue2-transitions' -import communityAPI from '../../apis/communityAPI' - export default { components: { DashboardNavbar, @@ -84,13 +85,13 @@ export default { }, methods: { initScrollbar() { - let isWindows = navigator.platform.startsWith('Win') + const isWindows = navigator.platform.startsWith('Win') if (isWindows) { initScrollbar('sidenav') } }, async logout() { - const result = await loginAPI.logout(this.$store.state.session_id) + await loginAPI.logout(this.$store.state.session_id) // do we have to check success? this.$store.dispatch('logout') this.$router.push('/login') diff --git a/frontend/src/views/Pages/AccountOverview.spec.js b/frontend/src/views/Pages/AccountOverview.spec.js index 668521cf6..1454ada5c 100644 --- a/frontend/src/views/Pages/AccountOverview.spec.js +++ b/frontend/src/views/Pages/AccountOverview.spec.js @@ -6,7 +6,7 @@ const localVue = global.localVue describe('AccountOverview', () => { let wrapper - let mocks = { + const mocks = { $t: jest.fn((t) => t), } diff --git a/frontend/src/views/Pages/AccountOverview/GddAddWork2.vue b/frontend/src/views/Pages/AccountOverview/GddAddWork2.vue index 0c3dad131..419742874 100644 --- a/frontend/src/views/Pages/AccountOverview/GddAddWork2.vue +++ b/frontend/src/views/Pages/AccountOverview/GddAddWork2.vue @@ -102,7 +102,7 @@ export default { created() {}, watch: { $form: function () { - stunden(this.form) + this.stunden(this.form) }, }, mounted() {}, @@ -133,16 +133,16 @@ export default { }, deleteNewMessage: function (event) { this.form.splice(event, null) - this.messages.splice(index, 1) + this.messages.splice(this.index, 1) this.index-- }, submitForm: function (e) { - //console.log('submitForm') + // console.log('submitForm') this.messages = [{ DaysNumber: '', TextDecoded: '' }] this.submitted = true }, textFocus() { - //console.log('textFocus TODO') + // console.log('textFocus TODO') }, newWorkForm() { this.formular = ` @@ -174,7 +174,7 @@ export default { > - ` + ` // console.log('newWorkForm TODO') const myElement = this.$refs.mydiv diff --git a/frontend/src/views/Pages/AccountOverview/GddSend.spec.js b/frontend/src/views/Pages/AccountOverview/GddSend.spec.js index b206eb803..ffc8fd211 100644 --- a/frontend/src/views/Pages/AccountOverview/GddSend.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GddSend.spec.js @@ -7,18 +7,18 @@ const localVue = global.localVue describe('GddSend', () => { let wrapper - let state = { + const state = { user: { balance: 1234, balance_gdt: 9876, }, } - let store = new Vuex.Store({ + const store = new Vuex.Store({ state, }) - let mocks = { + const mocks = { // $n: jest.fn((n) => n), $t: jest.fn((t) => t), $moment: jest.fn((m) => ({ diff --git a/frontend/src/views/Pages/AccountOverview/GddSend.vue b/frontend/src/views/Pages/AccountOverview/GddSend.vue index a353d0485..b54340de5 100644 --- a/frontend/src/views/Pages/AccountOverview/GddSend.vue +++ b/frontend/src/views/Pages/AccountOverview/GddSend.vue @@ -240,7 +240,7 @@ export default { this.scan = false }, async onSubmit() { - //event.preventDefault() + // event.preventDefault() this.ajaxCreateData.email = this.form.email this.ajaxCreateData.amount = this.form.amount const now = new Date(Date.now()).toISOString() diff --git a/frontend/src/views/Pages/AccountOverview/GddStatus.spec.js b/frontend/src/views/Pages/AccountOverview/GddStatus.spec.js index 83b306ace..9adc3b4ca 100644 --- a/frontend/src/views/Pages/AccountOverview/GddStatus.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GddStatus.spec.js @@ -6,11 +6,11 @@ const localVue = global.localVue describe('GddStatus', () => { let wrapper - let mocks = { + const mocks = { $n: jest.fn((n) => n), } - let propsData = { + const propsData = { balance: 1234, GdtBalance: 9876, } diff --git a/frontend/src/views/Pages/AccountOverview/GddTable.vue b/frontend/src/views/Pages/AccountOverview/GddTable.vue index 84a049537..bb93a04f2 100644 --- a/frontend/src/views/Pages/AccountOverview/GddTable.vue +++ b/frontend/src/views/Pages/AccountOverview/GddTable.vue @@ -127,7 +127,7 @@ export default { }, methods: { ojectToArray(obj) { - let result = new Array(Object.keys(obj).length) + const result = new Array(Object.keys(obj).length) Object.entries(obj).forEach((entry) => { const [key, value] = entry result[key] = value diff --git a/frontend/src/views/Pages/AccountOverview/GddWorkTable.vue b/frontend/src/views/Pages/AccountOverview/GddWorkTable.vue index c17e3dc2d..247175a63 100644 --- a/frontend/src/views/Pages/AccountOverview/GddWorkTable.vue +++ b/frontend/src/views/Pages/AccountOverview/GddWorkTable.vue @@ -68,6 +68,7 @@ export default { if (item.status === 'earned') return 'table-primary' }, toogle(item) { + // eslint-disable-next-line no-unused-vars const temp = 'xxx porta' }, diff --git a/frontend/src/views/Pages/Login.spec.js b/frontend/src/views/Pages/Login.spec.js index f0bb1b3b8..c95aa5a4c 100644 --- a/frontend/src/views/Pages/Login.spec.js +++ b/frontend/src/views/Pages/Login.spec.js @@ -9,22 +9,22 @@ const localVue = global.localVue describe('Login', () => { let wrapper - let mocks = { + const mocks = { $i18n: { locale: 'en', }, $t: jest.fn((t) => t), } - let state = { + const state = { loginfail: false, } - let store = new Vuex.Store({ + const store = new Vuex.Store({ state, }) - let stubs = { + const stubs = { RouterLink: RouterLinkStub, } diff --git a/frontend/src/views/Pages/Login.vue b/frontend/src/views/Pages/Login.vue index ee71bad87..ae0bdeaf5 100755 --- a/frontend/src/views/Pages/Login.vue +++ b/frontend/src/views/Pages/Login.vue @@ -112,7 +112,7 @@ export default { }, methods: { async onSubmit() { - let loader = this.$loading.show({ + const loader = this.$loading.show({ container: this.$refs.submitButton, }) const result = await loginAPI.login(this.model.email, this.model.password) @@ -129,7 +129,7 @@ export default { } }, closeAlert() { - loader.hide() + this.$loading.hide() this.loginfail = false }, }, diff --git a/frontend/src/views/Pages/Register.spec.js b/frontend/src/views/Pages/Register.spec.js index e9d09a242..dcb97cf42 100644 --- a/frontend/src/views/Pages/Register.spec.js +++ b/frontend/src/views/Pages/Register.spec.js @@ -9,22 +9,22 @@ const localVue = global.localVue describe('Register', () => { let wrapper - let mocks = { + const mocks = { $i18n: { locale: 'en', }, $t: jest.fn((t) => t), } - let state = { + const state = { // loginfail: false, } - let store = new Vuex.Store({ + const store = new Vuex.Store({ state, }) - let stubs = { + const stubs = { RouterLink: RouterLinkStub, } diff --git a/frontend/src/views/Pages/Register.vue b/frontend/src/views/Pages/Register.vue index 80a93c5d5..75bf46bd3 100755 --- a/frontend/src/views/Pages/Register.vue +++ b/frontend/src/views/Pages/Register.vue @@ -232,8 +232,8 @@ export default { return this.model.email !== '' }, passwordValidation() { - let errors = [] - for (let condition of this.rules) { + const errors = [] + for (const condition of this.rules) { if (!condition.regex.test(this.password)) { errors.push(condition.message) } diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index 7e87bb90f..6ad405e71 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -11,9 +11,9 @@ const router = new VueRouter({ routes }) describe('ResetPassword', () => { let wrapper - let emailVerification = jest.fn() + const emailVerification = jest.fn() - let mocks = { + const mocks = { $i18n: { locale: 'en', }, @@ -49,13 +49,13 @@ describe('ResetPassword', () => { expect(wrapper.find('div.resetpwd-form').exists()).toBeTruthy() }) - //describe('Register header', () => { + // describe('Register header', () => { // it('has a welcome message', () => { // expect(wrapper.find('div.header').text()).toBe('site.signup.title site.signup.subtitle') // }) - //}) + // }) - //describe('links', () => { + // describe('links', () => { // it('has a link "Back"', () => { // expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual('back') // }) @@ -63,9 +63,9 @@ describe('ResetPassword', () => { // it('links to /login when clicking "Back"', () => { // expect(wrapper.findAllComponents(RouterLinkStub).at(0).props().to).toBe('/login') // }) - //}) + // }) - //describe('Register form', () => { + // describe('Register form', () => { // it('has a register form', () => { // expect(wrapper.find('form').exists()).toBeTruthy() // }) @@ -108,7 +108,7 @@ describe('ResetPassword', () => { // }) // //TODO test different invalid password combinations - //}) + // }) // TODO test submit button }) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 4935b47db..243a8519a 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -141,8 +141,8 @@ export default { return this.password !== '' && this.checkPassword !== '' }, passwordValidation() { - let errors = [] - for (let condition of this.rules) { + const errors = [] + for (const condition of this.rules) { if (!condition.regex.test(this.password)) { errors.push(condition.message) } diff --git a/frontend/src/views/Pages/UserProfile/ImageUploaderAvatar.vue b/frontend/src/views/Pages/UserProfile/ImageUploaderAvatar.vue index c355699eb..8c35b918a 100644 --- a/frontend/src/views/Pages/UserProfile/ImageUploaderAvatar.vue +++ b/frontend/src/views/Pages/UserProfile/ImageUploaderAvatar.vue @@ -43,11 +43,11 @@ export default { }, onFileChange(fieldName, file) { const { maxSize } = this - let imageFile = file[0] + const imageFile = file[0] - //check if user actually selected a file + // check if user actually selected a file if (file.length > 0) { - let size = imageFile.size / maxSize / maxSize + const size = imageFile.size / maxSize / maxSize if (!imageFile.type.match('image.*')) { // check whether the upload is an image this.errorDialog = true @@ -58,8 +58,8 @@ export default { this.errorText = 'Your file is too big! Please select an image under 1MB' } else { // Append file into FormData & turn file into image URL - let formData = new FormData() - let imageURL = URL.createObjectURL(imageFile) + const formData = new FormData() + const imageURL = URL.createObjectURL(imageFile) formData.append(fieldName, imageFile) // Emit FormData & image URL to the parent component this.$emit('input', { formData, imageURL }) diff --git a/frontend/test/testSetup.js b/frontend/test/testSetup.js index 497f04e3e..457c13f45 100644 --- a/frontend/test/testSetup.js +++ b/frontend/test/testSetup.js @@ -2,9 +2,9 @@ import { createLocalVue } from '@vue/test-utils' import ElementUI from 'element-ui' import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' import Vuex from 'vuex' -import { ValidationProvider, ValidationObserver } from 'vee-validate' +import { ValidationProvider, ValidationObserver, extend } from 'vee-validate' import * as rules from 'vee-validate/dist/rules' -import { extend } from 'vee-validate' + import { messages } from 'vee-validate/dist/locale/en.json' import BaseInput from '@/components/Inputs/BaseInput.vue' import BaseButton from '@/components/BaseButton.vue' diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 0ff92c052..9fffda28c 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -23,6 +23,7 @@ module.exports = { assets: path.join(__dirname, 'src/assets'), }, }, + // eslint-disable-next-line new-cap plugins: [new dotenv()], }, css: {