eslint standard rules implemented

This commit is contained in:
Moriz Wahl 2021-05-07 11:59:43 +02:00
parent 7f38c80121
commit bfb652864c
48 changed files with 181 additions and 191 deletions

View File

@ -3,29 +3,24 @@ module.exports = {
env: { env: {
browser: true, browser: true,
node: true, node: true,
jest: true jest: true,
}, },
parserOptions: { parserOptions: {
parser: 'babel-eslint' parser: 'babel-eslint',
}, },
extends: [ extends: ['standard', 'plugin:vue/essential', 'plugin:prettier/recommended'],
'standard',
'plugin:vue/essential',
'plugin:prettier/recommended'
],
// required to lint *.vue files // required to lint *.vue files
plugins: [ plugins: ['vue', 'prettier', 'jest'],
'vue',
'prettier',
'jest'
],
// add your custom rules here // add your custom rules here
rules: { rules: {
'no-console': ['error'], 'no-console': ['error'],
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'vue/component-name-in-template-casing': ['error', 'kebab-case'], 'vue/component-name-in-template-casing': ['error', 'kebab-case'],
'prettier/prettier': ['error', { 'prettier/prettier': [
htmlWhitespaceSensitivity: 'ignore' 'error',
}], {
} htmlWhitespaceSensitivity: 'ignore',
},
],
},
} }

View File

@ -3,7 +3,7 @@ module.exports = {
collectCoverageFrom: ['src/**/*.{js,vue}', '!**/node_modules/**', '!**/?(*.)+(spec|test).js?(x)'], collectCoverageFrom: ['src/**/*.{js,vue}', '!**/node_modules/**', '!**/?(*.)+(spec|test).js?(x)'],
moduleFileExtensions: [ moduleFileExtensions: [
'js', 'js',
//'jsx', // 'jsx',
'json', 'json',
'vue', 'vue',
], ],

View File

@ -7,6 +7,7 @@ const port = process.env.PORT || 3000
// Express Server // Express Server
const app = express() const app = express()
// eslint-disable-next-line node/no-path-concat
app.use(serveStatic(__dirname + '/../dist')) app.use(serveStatic(__dirname + '/../dist'))
app.listen(port) app.listen(port)

View File

@ -36,11 +36,6 @@ export default {
DashboardLayout, DashboardLayout,
AuthLayoutGDD, AuthLayoutGDD,
}, },
data() {
return {
language: 'en',
}
},
data() { data() {
return { return {
config: { config: {

View File

@ -32,17 +32,17 @@ const apiPost = async (url, payload) => {
} }
const communityAPI = { const communityAPI = {
balance: async (session_id) => { balance: async (sessionId) => {
return apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + session_id) 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( 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 = { const payload = {
session_id, sessionId,
email, email,
amount, amount,
target_date, target_date,
@ -50,14 +50,14 @@ const communityAPI = {
auto_sign: true, auto_sign: true,
} }
return apiPost(CONFIG.COMMUNITY_API__URL + 'createCoins/', payload) 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 = { const payload = {
session_id, session_id: sessionId,
email, email,
amount, amount,
memo, memo,
target_date, target_date: targetDate,
auto_sign: true, auto_sign: true,
} }
return apiPost(CONFIG.COMMUNITY_API_URL + 'sendCoins/', payload) return apiPost(CONFIG.COMMUNITY_API_URL + 'sendCoins/', payload)

View File

@ -29,7 +29,7 @@ const apiPost = async (url, payload) => {
throw new Error('HTTP Status Error ' + result.status) throw new Error('HTTP Status Error ' + result.status)
} }
if (result.data.state === 'warning') { if (result.data.state === 'warning') {
return { success: true, result: error } return { success: true, result: result.error }
} }
if (result.data.state !== 'success') { if (result.data.state !== 'success') {
throw new Error(result.data.msg) throw new Error(result.data.msg)
@ -48,15 +48,15 @@ const loginAPI = {
} }
return apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', payload) return apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', payload)
}, },
logout: async (session_id) => { logout: async (sessionId) => {
const payload = { session_id } const payload = { session_id: sessionId }
return apiPost(CONFIG.LOGIN_API_URL + 'logout', payload) return apiPost(CONFIG.LOGIN_API_URL + 'logout', payload)
}, },
create: async (email, first_name, last_name, password) => { create: async (email, firstName, lastName, password) => {
const payload = { const payload = {
email, email,
first_name, first_name: firstName,
last_name, last_name: lastName,
password, password,
emailType: EMAIL_TYPE.DEFAULT, emailType: EMAIL_TYPE.DEFAULT,
login_after_register: true, login_after_register: true,
@ -76,9 +76,9 @@ const loginAPI = {
CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin, CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin,
) )
}, },
changePassword: async (session_id, email, password) => { changePassword: async (sessionId, email, password) => {
const payload = { const payload = {
session_id, session_id: sessionId,
email, email,
update: { update: {
'User.password': password, 'User.password': password,

View File

@ -42,7 +42,7 @@ export default {
FadeTransition, FadeTransition,
}, },
created() { created() {
//console.log('base-alert gesetzt in =>', this.$route.path) // console.log('base-alert gesetzt in =>', this.$route.path)
}, },
props: { props: {
type: { type: {

View File

@ -62,7 +62,7 @@ export default {
}) })
const slider = this.$el.noUiSlider const slider = this.$el.noUiSlider
slider.on('slide', () => { slider.on('slide', () => {
let value = slider.get() const value = slider.get()
if (value !== this.value) { if (value !== this.value) {
this.$emit('input', value) this.$emit('input', value)
} }

View File

@ -2,7 +2,7 @@ import { parseOptions } from '@/components/Charts/optionHelpers'
import Chart from 'chart.js' import Chart from 'chart.js'
export const Charts = { export const Charts = {
mode: 'light', //(themeMode) ? themeMode : 'light'; mode: 'light', // (themeMode) ? themeMode : 'light';
fonts: { fonts: {
base: 'Open Sans', base: 'Open Sans',
}, },
@ -34,9 +34,9 @@ export const Charts = {
} }
function chartOptions() { function chartOptions() {
let { colors, mode, fonts } = Charts const { colors, mode, fonts } = Charts
// Options // Options
let options = { const options = {
defaults: { defaults: {
global: { global: {
responsive: true, responsive: true,
@ -59,21 +59,21 @@ function chartOptions() {
elements: { elements: {
point: { point: {
radius: 0, radius: 0,
backgroundColor: colors.theme['primary'], backgroundColor: colors.theme.primary,
}, },
line: { line: {
tension: 0.4, tension: 0.4,
borderWidth: 4, borderWidth: 4,
borderColor: colors.theme['primary'], borderColor: colors.theme.primary,
backgroundColor: colors.transparent, backgroundColor: colors.transparent,
borderCapStyle: 'rounded', borderCapStyle: 'rounded',
}, },
rectangle: { rectangle: {
backgroundColor: colors.theme['warning'], backgroundColor: colors.theme.warning,
}, },
arc: { arc: {
backgroundColor: colors.theme['primary'], backgroundColor: colors.theme.primary,
borderColor: mode == 'dark' ? colors.gray[800] : colors.white, borderColor: mode === 'dark' ? colors.gray[800] : colors.white,
borderWidth: 4, borderWidth: 4,
}, },
}, },
@ -94,11 +94,11 @@ function chartOptions() {
}, },
cutoutPercentage: 83, cutoutPercentage: 83,
legendCallback: function (chart) { legendCallback: function (chart) {
let data = chart.data const data = chart.data
let content = '' let content = ''
data.labels.forEach(function (label, index) { data.labels.forEach(function (label, index) {
let bgColor = data.datasets[0].backgroundColor[index] const bgColor = data.datasets[0].backgroundColor[index]
content += '<span class="chart-legend-item">' content += '<span class="chart-legend-item">'
content += content +=
@ -172,7 +172,7 @@ export const basicOptions = {
}, },
responsive: true, responsive: true,
} }
export let blueChartOptions = { export const blueChartOptions = {
scales: { scales: {
yAxes: [ yAxes: [
{ {
@ -185,7 +185,7 @@ export let blueChartOptions = {
}, },
} }
export let lineChartOptionsBlue = { export const lineChartOptionsBlue = {
...basicOptions, ...basicOptions,
tooltips: { tooltips: {
backgroundColor: '#f5f5f5', backgroundColor: '#f5f5f5',

View File

@ -1,6 +1,6 @@
// Parse global options // Parse global options
export function parseOptions(parent, options) { export function parseOptions(parent, options) {
for (let item in options) { for (const item in options) {
if (typeof options[item] !== 'object') { if (typeof options[item] !== 'object') {
parent[item] = options[item] parent[item] = options[item]
} else { } else {

View File

@ -4,13 +4,13 @@
// //
import Chart from 'chart.js' import Chart from 'chart.js'
Chart.elements.Rectangle.prototype.draw = function () { Chart.elements.Rectangle.prototype.draw = function () {
let ctx = this._chart.ctx const ctx = this._chart.ctx
let vm = this._view const vm = this._view
let left, right, top, bottom, signX, signY, borderSkipped, radius let left, right, top, bottom, signX, signY, borderSkipped
let borderWidth = vm.borderWidth let borderWidth = vm.borderWidth
// Set Radius Here // Set Radius Here
// If radius is large enough to cause drawing errors a max radius is imposed // If radius is large enough to cause drawing errors a max radius is imposed
let cornerRadius = 6 const cornerRadius = 6
if (!vm.horizontal) { if (!vm.horizontal) {
// bar // 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 // adjust the sizes to fit if we're setting a stroke on the line
if (borderWidth) { if (borderWidth) {
// borderWidth shold be less than bar width and bar height. // 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 borderWidth = borderWidth > barSize ? barSize : borderWidth
let halfStroke = borderWidth / 2 const halfStroke = borderWidth / 2
// Adjust borderWidth when bar top position is near vm.base(zero). // Adjust borderWidth when bar top position is near vm.base(zero).
let borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0) const borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0)
let borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0) const borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0)
let borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0) const borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0)
let borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0) const borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0)
// not become a vertical line? // not become a vertical line?
if (borderLeft !== borderRight) { if (borderLeft !== borderRight) {
top = borderTop top = borderTop
@ -64,7 +64,7 @@ Chart.elements.Rectangle.prototype.draw = function () {
// Corner points, from bottom-left to bottom-right clockwise // Corner points, from bottom-left to bottom-right clockwise
// | 1 2 | // | 1 2 |
// | 0 3 | // | 0 3 |
let corners = [ const corners = [
[left, bottom], [left, bottom],
[left, top], [left, top],
[right, top], [right, top],
@ -72,7 +72,7 @@ Chart.elements.Rectangle.prototype.draw = function () {
] ]
// Find first (starting) corner with fallback to 'bottom' // 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) let startCorner = borders.indexOf(borderSkipped, 0)
if (startCorner === -1) { if (startCorner === -1) {
startCorner = 0 startCorner = 0
@ -89,16 +89,14 @@ Chart.elements.Rectangle.prototype.draw = function () {
for (let i = 1; i < 4; i++) { for (let i = 1; i < 4; i++) {
corner = cornerAt(i) corner = cornerAt(i)
let nextCornerId = i + 1 let nextCornerId = i + 1
if (nextCornerId == 4) { if (nextCornerId === 4) {
nextCornerId = 0 nextCornerId = 0
} }
let nextCorner = cornerAt(nextCornerId) const width = corners[2][0] - corners[1][0]
const height = corners[0][1] - corners[1][1]
let width = corners[2][0] - corners[1][0] const x = corners[1][0]
let height = corners[0][1] - corners[1][1] const y = corners[1][1]
let x = corners[1][0]
let y = corners[1][1]
let radius = cornerRadius let radius = cornerRadius

View File

@ -6,7 +6,7 @@ const localVue = global.localVue
describe('CloseButton', () => { describe('CloseButton', () => {
let wrapper let wrapper
let propsData = { const propsData = {
target: 'Target', target: 'Target',
expanded: false, expanded: false,
} }

View File

@ -70,7 +70,7 @@ export default {
}, },
methods: { methods: {
activate() { activate() {
let wasActive = this.active const wasActive = this.active
if (!this.multipleActive) { if (!this.multipleActive) {
this.deactivateAll() this.deactivateAll()
} }

View File

@ -170,7 +170,7 @@ export default {
}, },
methods: { methods: {
updateValue(evt) { updateValue(evt) {
let value = evt.target.value const value = evt.target.value
this.$emit('input', value) this.$emit('input', value)
}, },
onFocus(evt) { onFocus(evt) {

View File

@ -60,7 +60,7 @@ export default {
type: String, type: String,
default: '', default: '',
validator(value) { validator(value) {
let acceptedValues = ['', 'notice', 'mini'] const acceptedValues = ['', 'notice', 'mini']
return acceptedValues.indexOf(value) !== -1 return acceptedValues.indexOf(value) !== -1
}, },
description: 'Modal type (notice|mini|"") ', description: 'Modal type (notice|mini|"") ',
@ -73,7 +73,7 @@ export default {
type: String, type: String,
description: 'Modal size', description: 'Modal size',
validator(value) { validator(value) {
let acceptedValues = ['', 'sm', 'lg'] const acceptedValues = ['', 'sm', 'lg']
return acceptedValues.indexOf(value) !== -1 return acceptedValues.indexOf(value) !== -1
}, },
}, },

View File

@ -39,7 +39,7 @@ export default {
submittedNames: [], submittedNames: [],
} }
}, },
/*Modal*/ /* Modal */
checkFormValidity() { checkFormValidity() {
const valid = this.$refs.form.checkValidity() const valid = this.$refs.form.checkValidity()
this.nameState = valid this.nameState = valid

View File

@ -90,8 +90,8 @@ export default {
}, },
computed: { computed: {
classes() { classes() {
let color = `bg-${this.type}` const color = `bg-${this.type}`
let classes = [ const classes = [
{ 'navbar-transparent': this.transparent }, { 'navbar-transparent': this.transparent },
{ [`navbar-expand-${this.expand}`]: this.expand }, { [`navbar-expand-${this.expand}`]: this.expand },
] ]

View File

@ -59,7 +59,7 @@ export default {
type: String, type: String,
default: 'top', default: 'top',
validator: (value) => { validator: (value) => {
let acceptedValues = ['top', 'bottom'] const acceptedValues = ['top', 'bottom']
return acceptedValues.indexOf(value) !== -1 return acceptedValues.indexOf(value) !== -1
}, },
description: 'Vertical alignment of notification (top|bottom)', description: 'Vertical alignment of notification (top|bottom)',
@ -68,7 +68,7 @@ export default {
type: String, type: String,
default: 'right', default: 'right',
validator: (value) => { validator: (value) => {
let acceptedValues = ['left', 'center', 'right'] const acceptedValues = ['left', 'center', 'right']
return acceptedValues.indexOf(value) !== -1 return acceptedValues.indexOf(value) !== -1
}, },
description: 'Horizontal alignment of notification (left|center|right)', description: 'Horizontal alignment of notification (left|center|right)',
@ -77,7 +77,7 @@ export default {
type: String, type: String,
default: 'info', default: 'info',
validator: (value) => { validator: (value) => {
let acceptedValues = ['default', 'info', 'primary', 'danger', 'warning', 'success'] const acceptedValues = ['default', 'info', 'primary', 'danger', 'warning', 'success']
return acceptedValues.indexOf(value) !== -1 return acceptedValues.indexOf(value) !== -1
}, },
description: description:
@ -129,8 +129,8 @@ export default {
return `alert-${this.type}` return `alert-${this.type}`
}, },
customPosition() { customPosition() {
let initialMargin = 20 const initialMargin = 20
let alertHeight = this.elmHeight + 10 const alertHeight = this.elmHeight + 10
let sameAlertsCount = this.$notifications.state.filter((alert) => { let sameAlertsCount = this.$notifications.state.filter((alert) => {
return ( return (
alert.horizontalAlign === this.horizontalAlign && alert.horizontalAlign === this.horizontalAlign &&
@ -141,8 +141,8 @@ export default {
if (this.$notifications.settings.overlap) { if (this.$notifications.settings.overlap) {
sameAlertsCount = 1 sameAlertsCount = 1
} }
let pixels = (sameAlertsCount - 1) * alertHeight + initialMargin const pixels = (sameAlertsCount - 1) * alertHeight + initialMargin
let styles = {} const styles = {}
if (this.verticalAlign === 'top') { if (this.verticalAlign === 'top') {
styles.top = `${pixels}px` styles.top = `${pixels}px`
} else { } else {

View File

@ -44,7 +44,7 @@ const NotificationStore = {
const NotificationsPlugin = { const NotificationsPlugin = {
install(Vue, options) { install(Vue, options) {
let app = new Vue({ const app = new Vue({
data: { data: {
notificationStore: NotificationStore, notificationStore: NotificationStore,
}, },

View File

@ -5,7 +5,7 @@
import VueBootstrapTypeahead from 'vue-bootstrap-typeahead' import VueBootstrapTypeahead from 'vue-bootstrap-typeahead'
// Global registration // Global registration
//Vue.component('vue-bootstrap-typeahead', VueBootstrapTypeahead) // Vue.component('vue-bootstrap-typeahead', VueBootstrapTypeahead)
// OR // OR

View File

@ -110,7 +110,7 @@ export default {
}, },
linkPrefix() { linkPrefix() {
if (this.link.name) { 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 words.map((word) => word.substring(0, 1)).join('')
} }
return '' return ''
@ -120,7 +120,7 @@ export default {
}, },
isActive() { isActive() {
if (this.$route && this.$route.path) { 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) { if (matchingRoute !== undefined) {
return true return true
} }

View File

@ -29,7 +29,7 @@ const SidebarPlugin = {
if (options && options.sidebarLinks) { if (options && options.sidebarLinks) {
SidebarStore.sidebarLinks = options.sidebarLinks SidebarStore.sidebarLinks = options.sidebarLinks
} }
let app = new Vue({ const app = new Vue({
data: { data: {
sidebarStore: SidebarStore, sidebarStore: SidebarStore,
}, },

View File

@ -67,7 +67,7 @@ export default {
type: String, type: String,
default: 'primary', default: 'primary',
validator: (value) => { validator: (value) => {
let acceptedValues = ['primary', 'info', 'success', 'warning', 'danger'] const acceptedValues = ['primary', 'info', 'success', 'warning', 'danger']
return acceptedValues.indexOf(value) !== -1 return acceptedValues.indexOf(value) !== -1
}, },
}, },
@ -102,7 +102,7 @@ export default {
}, },
methods: { methods: {
findAndActivateTab(title) { findAndActivateTab(title) {
let tabToActivate = this.tabs.find((t) => t.title === title) const tabToActivate = this.tabs.find((t) => t.title === title)
if (tabToActivate) { if (tabToActivate) {
this.activateTab(tabToActivate) this.activateTab(tabToActivate)
} }

View File

@ -2,7 +2,7 @@ export default {
bind: function (el, binding, vnode) { bind: function (el, binding, vnode) {
el.clickOutsideEvent = function (event) { el.clickOutsideEvent = function (event) {
// here I check that click was outside the el and his childrens // 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 // and if it did, call method provided in attribute value
vnode.context[binding.expression](event) vnode.context[binding.expression](event)
} }

View File

@ -2,7 +2,6 @@ import Vue from 'vue'
import DashboardPlugin from './plugins/dashboard-plugin' import DashboardPlugin from './plugins/dashboard-plugin'
import App from './App.vue' import App from './App.vue'
import i18n from './i18n.js' import i18n from './i18n.js'
import VeeValidate from './vee-validate.js'
// store // store
import { store } from './store/store' import { store } from './store/store'

View File

@ -3,7 +3,7 @@ import '@/polyfills'
// Notifications plugin. Used on Notifications page // Notifications plugin. Used on Notifications page
import Notifications from '@/components/NotificationPlugin' import Notifications from '@/components/NotificationPlugin'
// Validation plugin used to validate forms // 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 // A plugin file where you could register global components used across the app
import GlobalComponents from './globalComponents' import GlobalComponents from './globalComponents'
// A plugin file where you could register global directives // A plugin file where you could register global directives
@ -14,7 +14,6 @@ import SideBar from '@/components/SidebarPlugin'
// element ui language configuration // element ui language configuration
import lang from 'element-ui/lib/locale/lang/en' import lang from 'element-ui/lib/locale/lang/en'
import locale from 'element-ui/lib/locale' import locale from 'element-ui/lib/locale'
locale.use(lang)
// vue-bootstrap // vue-bootstrap
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
@ -22,7 +21,6 @@ import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
// asset imports // asset imports
import '@/assets/scss/argon.scss' import '@/assets/scss/argon.scss'
import '@/assets/vendor/nucleo/css/nucleo.css' import '@/assets/vendor/nucleo/css/nucleo.css'
import { extend } from 'vee-validate'
import * as rules from 'vee-validate/dist/rules' import * as rules from 'vee-validate/dist/rules'
import { messages } from 'vee-validate/dist/locale/en.json' 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 Loading from 'vue-loading-overlay'
// import the styles // import the styles
import 'vue-loading-overlay/dist/vue-loading.css' import 'vue-loading-overlay/dist/vue-loading.css'
locale.use(lang)
Object.keys(rules).forEach((rule) => { Object.keys(rules).forEach((rule) => {
extend(rule, { extend(rule, {

View File

@ -21,20 +21,20 @@ const routes = [
requiresAuth: true, requiresAuth: true,
}, },
}, },
//{ // {
// path: '/profileedit', // path: '/profileedit',
// component: () => import('../views/Pages/UserProfileEdit.vue'), // component: () => import('../views/Pages/UserProfileEdit.vue'),
// meta: { // meta: {
// requiresAuth: true, // requiresAuth: true,
// }, // },
//}, // },
//{ // {
// path: '/activity', // path: '/activity',
// component: () => import('../views/Pages/UserProfileActivity.vue'), // component: () => import('../views/Pages/UserProfileActivity.vue'),
// meta: { // meta: {
// requiresAuth: true, // requiresAuth: true,
// }, // },
//}, // },
{ {
path: '/transactions', path: '/transactions',
component: () => import('../views/Pages/UserProfileTransactionList.vue'), component: () => import('../views/Pages/UserProfileTransactionList.vue'),

View File

@ -1,7 +1,7 @@
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
Vue.use(Vuex)
import createPersistedState from 'vuex-persistedstate' import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)
export const mutations = { export const mutations = {
language: (state, language) => { language: (state, language) => {
@ -10,18 +10,18 @@ export const mutations = {
email: (state, email) => { email: (state, email) => {
state.email = email state.email = email
}, },
session_id: (state, session_id) => { sessionId: (state, sessionId) => {
state.session_id = session_id state.sessionId = sessionId
}, },
} }
export const actions = { export const actions = {
login: ({ dispatch, commit }, data) => { login: ({ dispatch, commit }, data) => {
commit('session_id', data.session_id) commit('sessionId', data.session_id)
commit('email', data.email) commit('email', data.email)
}, },
logout: ({ commit, state }) => { logout: ({ commit, state }) => {
commit('session_id', null) commit('sessionId', null)
commit('email', null) commit('email', null)
sessionStorage.clear() sessionStorage.clear()
}, },
@ -34,7 +34,7 @@ export const store = new Vuex.Store({
}), }),
], ],
state: { state: {
session_id: null, sessionId: null,
email: '', email: '',
language: 'en', language: 'en',
modals: false, modals: false,

View File

@ -1,6 +1,6 @@
import { mutations, actions } from './store' import { mutations, actions } from './store'
const { language, email, session_id } = mutations const { language, email, sessionId } = mutations
const { login, logout } = actions const { login, logout } = actions
describe('Vuex store', () => { describe('Vuex store', () => {
@ -21,11 +21,11 @@ describe('Vuex store', () => {
}) })
}) })
describe('session_id', () => { describe('sessionId', () => {
it('sets the state of session_id', () => { it('sets the state of sessionId', () => {
const state = { session_id: null } const state = { sessionId: null }
session_id(state, '1234') sessionId(state, '1234')
expect(state.session_id).toEqual('1234') expect(state.sessionId).toEqual('1234')
}) })
}) })
}) })
@ -36,17 +36,17 @@ describe('Vuex store', () => {
const state = {} const state = {}
it('calls two commits', () => { 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) expect(commit).toHaveBeenCalledTimes(2)
}) })
it('commits session_id', () => { it('commits sessionId', () => {
login({ commit, state }, { session_id: 1234, email: 'someone@there.is' }) login({ commit, state }, { sessionId: 1234, email: 'someone@there.is' })
expect(commit).toHaveBeenNthCalledWith(1, 'session_id', 1234) expect(commit).toHaveBeenNthCalledWith(1, 'sessionId', 1234)
}) })
it('commits email', () => { 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') expect(commit).toHaveBeenNthCalledWith(2, 'email', 'someone@there.is')
}) })
}) })
@ -60,9 +60,9 @@ describe('Vuex store', () => {
expect(commit).toHaveBeenCalledTimes(2) expect(commit).toHaveBeenCalledTimes(2)
}) })
it('commits session_id', () => { it('commits sessionId', () => {
logout({ commit, state }) logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(1, 'session_id', null) expect(commit).toHaveBeenNthCalledWith(1, 'sessionId', null)
}) })
it('commits email', () => { it('commits email', () => {

View File

@ -7,7 +7,7 @@ const localVue = global.localVue
describe('ContentFooter', () => { describe('ContentFooter', () => {
let wrapper let wrapper
let mocks = { const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },

View File

@ -20,7 +20,7 @@ const transitionStub = () => ({
describe('DashboardLayoutGdd', () => { describe('DashboardLayoutGdd', () => {
let wrapper let wrapper
let mocks = { const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },
@ -28,7 +28,7 @@ describe('DashboardLayoutGdd', () => {
$n: jest.fn(), $n: jest.fn(),
} }
let state = { const state = {
user: { user: {
name: 'Peter Lustig', name: 'Peter Lustig',
balance: 2546, balance: 2546,
@ -37,12 +37,12 @@ describe('DashboardLayoutGdd', () => {
email: 'peter.lustig@example.org', email: 'peter.lustig@example.org',
} }
let stubs = { const stubs = {
RouterLink: RouterLinkStub, RouterLink: RouterLinkStub,
FadeTransition: transitionStub(), FadeTransition: transitionStub(),
} }
let store = new Vuex.Store({ const store = new Vuex.Store({
state, state,
}) })
@ -104,41 +104,41 @@ describe('DashboardLayoutGdd', () => {
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/transactions') 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') // 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') // navbar.findAll('ul > li > a').at(2).trigger('click')
// await flushPromises() // await flushPromises()
// await jest.runAllTimers() // await jest.runAllTimers()
// await flushPromises() // await flushPromises()
// expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/profile') // 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') // 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') // navbar.findAll('ul > li > a').at(3).trigger('click')
// await flushPromises() // await flushPromises()
// await jest.runAllTimers() // await jest.runAllTimers()
// await flushPromises() // await flushPromises()
// expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/profileedit') // 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') // 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') // navbar.findAll('ul > li > a').at(4).trigger('click')
// await flushPromises() // await flushPromises()
// await jest.runAllTimers() // await jest.runAllTimers()
// await flushPromises() // await flushPromises()
// expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/activity') // expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/activity')
//}) // })
}) })
}) })
}) })

View File

@ -46,12 +46,19 @@ import PerfectScrollbar from 'perfect-scrollbar'
import 'perfect-scrollbar/css/perfect-scrollbar.css' import 'perfect-scrollbar/css/perfect-scrollbar.css'
import loginAPI from '../../apis/loginAPI' 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) { function hasElement(className) {
return document.getElementsByClassName(className).length > 0 return document.getElementsByClassName(className).length > 0
} }
function initScrollbar(className) { function initScrollbar(className) {
if (hasElement(className)) { if (hasElement(className)) {
// eslint-disable-next-line no-new
new PerfectScrollbar(`.${className}`) new PerfectScrollbar(`.${className}`)
} else { } else {
// try to init it later in case this component is loaded async // 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 { export default {
components: { components: {
DashboardNavbar, DashboardNavbar,
@ -84,13 +85,13 @@ export default {
}, },
methods: { methods: {
initScrollbar() { initScrollbar() {
let isWindows = navigator.platform.startsWith('Win') const isWindows = navigator.platform.startsWith('Win')
if (isWindows) { if (isWindows) {
initScrollbar('sidenav') initScrollbar('sidenav')
} }
}, },
async logout() { 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? // do we have to check success?
this.$store.dispatch('logout') this.$store.dispatch('logout')
this.$router.push('/login') this.$router.push('/login')

View File

@ -6,7 +6,7 @@ const localVue = global.localVue
describe('AccountOverview', () => { describe('AccountOverview', () => {
let wrapper let wrapper
let mocks = { const mocks = {
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
} }

View File

@ -102,7 +102,7 @@ export default {
created() {}, created() {},
watch: { watch: {
$form: function () { $form: function () {
stunden(this.form) this.stunden(this.form)
}, },
}, },
mounted() {}, mounted() {},
@ -133,16 +133,16 @@ export default {
}, },
deleteNewMessage: function (event) { deleteNewMessage: function (event) {
this.form.splice(event, null) this.form.splice(event, null)
this.messages.splice(index, 1) this.messages.splice(this.index, 1)
this.index-- this.index--
}, },
submitForm: function (e) { submitForm: function (e) {
//console.log('submitForm') // console.log('submitForm')
this.messages = [{ DaysNumber: '', TextDecoded: '' }] this.messages = [{ DaysNumber: '', TextDecoded: '' }]
this.submitted = true this.submitted = true
}, },
textFocus() { textFocus() {
//console.log('textFocus TODO') // console.log('textFocus TODO')
}, },
newWorkForm() { newWorkForm() {
this.formular = ` this.formular = `
@ -174,7 +174,7 @@ export default {
></textarea> ></textarea>
</base-input> </base-input>
</b-col> </b-col>
` `
// console.log('newWorkForm TODO') // console.log('newWorkForm TODO')
const myElement = this.$refs.mydiv const myElement = this.$refs.mydiv

View File

@ -7,18 +7,18 @@ const localVue = global.localVue
describe('GddSend', () => { describe('GddSend', () => {
let wrapper let wrapper
let state = { const state = {
user: { user: {
balance: 1234, balance: 1234,
balance_gdt: 9876, balance_gdt: 9876,
}, },
} }
let store = new Vuex.Store({ const store = new Vuex.Store({
state, state,
}) })
let mocks = { const mocks = {
// $n: jest.fn((n) => n), // $n: jest.fn((n) => n),
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$moment: jest.fn((m) => ({ $moment: jest.fn((m) => ({

View File

@ -240,7 +240,7 @@ export default {
this.scan = false this.scan = false
}, },
async onSubmit() { async onSubmit() {
//event.preventDefault() // event.preventDefault()
this.ajaxCreateData.email = this.form.email this.ajaxCreateData.email = this.form.email
this.ajaxCreateData.amount = this.form.amount this.ajaxCreateData.amount = this.form.amount
const now = new Date(Date.now()).toISOString() const now = new Date(Date.now()).toISOString()

View File

@ -6,11 +6,11 @@ const localVue = global.localVue
describe('GddStatus', () => { describe('GddStatus', () => {
let wrapper let wrapper
let mocks = { const mocks = {
$n: jest.fn((n) => n), $n: jest.fn((n) => n),
} }
let propsData = { const propsData = {
balance: 1234, balance: 1234,
GdtBalance: 9876, GdtBalance: 9876,
} }

View File

@ -127,7 +127,7 @@ export default {
}, },
methods: { methods: {
ojectToArray(obj) { ojectToArray(obj) {
let result = new Array(Object.keys(obj).length) const result = new Array(Object.keys(obj).length)
Object.entries(obj).forEach((entry) => { Object.entries(obj).forEach((entry) => {
const [key, value] = entry const [key, value] = entry
result[key] = value result[key] = value

View File

@ -68,6 +68,7 @@ export default {
if (item.status === 'earned') return 'table-primary' if (item.status === 'earned') return 'table-primary'
}, },
toogle(item) { toogle(item) {
// eslint-disable-next-line no-unused-vars
const temp = const temp =
'<b-collapse visible v-bind:id="item.id">xxx <small class="text-muted">porta</small></b-collapse>' '<b-collapse visible v-bind:id="item.id">xxx <small class="text-muted">porta</small></b-collapse>'
}, },

View File

@ -9,22 +9,22 @@ const localVue = global.localVue
describe('Login', () => { describe('Login', () => {
let wrapper let wrapper
let mocks = { const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
} }
let state = { const state = {
loginfail: false, loginfail: false,
} }
let store = new Vuex.Store({ const store = new Vuex.Store({
state, state,
}) })
let stubs = { const stubs = {
RouterLink: RouterLinkStub, RouterLink: RouterLinkStub,
} }

View File

@ -112,7 +112,7 @@ export default {
}, },
methods: { methods: {
async onSubmit() { async onSubmit() {
let loader = this.$loading.show({ const loader = this.$loading.show({
container: this.$refs.submitButton, container: this.$refs.submitButton,
}) })
const result = await loginAPI.login(this.model.email, this.model.password) const result = await loginAPI.login(this.model.email, this.model.password)
@ -129,7 +129,7 @@ export default {
} }
}, },
closeAlert() { closeAlert() {
loader.hide() this.$loading.hide()
this.loginfail = false this.loginfail = false
}, },
}, },

View File

@ -9,22 +9,22 @@ const localVue = global.localVue
describe('Register', () => { describe('Register', () => {
let wrapper let wrapper
let mocks = { const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
} }
let state = { const state = {
// loginfail: false, // loginfail: false,
} }
let store = new Vuex.Store({ const store = new Vuex.Store({
state, state,
}) })
let stubs = { const stubs = {
RouterLink: RouterLinkStub, RouterLink: RouterLinkStub,
} }

View File

@ -232,8 +232,8 @@ export default {
return this.model.email !== '' return this.model.email !== ''
}, },
passwordValidation() { passwordValidation() {
let errors = [] const errors = []
for (let condition of this.rules) { for (const condition of this.rules) {
if (!condition.regex.test(this.password)) { if (!condition.regex.test(this.password)) {
errors.push(condition.message) errors.push(condition.message)
} }

View File

@ -11,9 +11,9 @@ const router = new VueRouter({ routes })
describe('ResetPassword', () => { describe('ResetPassword', () => {
let wrapper let wrapper
let emailVerification = jest.fn() const emailVerification = jest.fn()
let mocks = { const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },
@ -49,13 +49,13 @@ describe('ResetPassword', () => {
expect(wrapper.find('div.resetpwd-form').exists()).toBeTruthy() expect(wrapper.find('div.resetpwd-form').exists()).toBeTruthy()
}) })
//describe('Register header', () => { // describe('Register header', () => {
// it('has a welcome message', () => { // it('has a welcome message', () => {
// expect(wrapper.find('div.header').text()).toBe('site.signup.title site.signup.subtitle') // expect(wrapper.find('div.header').text()).toBe('site.signup.title site.signup.subtitle')
// }) // })
//}) // })
//describe('links', () => { // describe('links', () => {
// it('has a link "Back"', () => { // it('has a link "Back"', () => {
// expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual('back') // expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual('back')
// }) // })
@ -63,9 +63,9 @@ describe('ResetPassword', () => {
// it('links to /login when clicking "Back"', () => { // it('links to /login when clicking "Back"', () => {
// expect(wrapper.findAllComponents(RouterLinkStub).at(0).props().to).toBe('/login') // expect(wrapper.findAllComponents(RouterLinkStub).at(0).props().to).toBe('/login')
// }) // })
//}) // })
//describe('Register form', () => { // describe('Register form', () => {
// it('has a register form', () => { // it('has a register form', () => {
// expect(wrapper.find('form').exists()).toBeTruthy() // expect(wrapper.find('form').exists()).toBeTruthy()
// }) // })
@ -108,7 +108,7 @@ describe('ResetPassword', () => {
// }) // })
// //TODO test different invalid password combinations // //TODO test different invalid password combinations
//}) // })
// TODO test submit button // TODO test submit button
}) })

View File

@ -141,8 +141,8 @@ export default {
return this.password !== '' && this.checkPassword !== '' return this.password !== '' && this.checkPassword !== ''
}, },
passwordValidation() { passwordValidation() {
let errors = [] const errors = []
for (let condition of this.rules) { for (const condition of this.rules) {
if (!condition.regex.test(this.password)) { if (!condition.regex.test(this.password)) {
errors.push(condition.message) errors.push(condition.message)
} }

View File

@ -43,11 +43,11 @@ export default {
}, },
onFileChange(fieldName, file) { onFileChange(fieldName, file) {
const { maxSize } = this 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) { if (file.length > 0) {
let size = imageFile.size / maxSize / maxSize const size = imageFile.size / maxSize / maxSize
if (!imageFile.type.match('image.*')) { if (!imageFile.type.match('image.*')) {
// check whether the upload is an image // check whether the upload is an image
this.errorDialog = true this.errorDialog = true
@ -58,8 +58,8 @@ export default {
this.errorText = 'Your file is too big! Please select an image under 1MB' this.errorText = 'Your file is too big! Please select an image under 1MB'
} else { } else {
// Append file into FormData & turn file into image URL // Append file into FormData & turn file into image URL
let formData = new FormData() const formData = new FormData()
let imageURL = URL.createObjectURL(imageFile) const imageURL = URL.createObjectURL(imageFile)
formData.append(fieldName, imageFile) formData.append(fieldName, imageFile)
// Emit FormData & image URL to the parent component // Emit FormData & image URL to the parent component
this.$emit('input', { formData, imageURL }) this.$emit('input', { formData, imageURL })

View File

@ -2,9 +2,9 @@ import { createLocalVue } from '@vue/test-utils'
import ElementUI from 'element-ui' import ElementUI from 'element-ui'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
import Vuex from 'vuex' 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 * as rules from 'vee-validate/dist/rules'
import { extend } from 'vee-validate'
import { messages } from 'vee-validate/dist/locale/en.json' import { messages } from 'vee-validate/dist/locale/en.json'
import BaseInput from '@/components/Inputs/BaseInput.vue' import BaseInput from '@/components/Inputs/BaseInput.vue'
import BaseButton from '@/components/BaseButton.vue' import BaseButton from '@/components/BaseButton.vue'

View File

@ -23,6 +23,7 @@ module.exports = {
assets: path.join(__dirname, 'src/assets'), assets: path.join(__dirname, 'src/assets'),
}, },
}, },
// eslint-disable-next-line new-cap
plugins: [new dotenv()], plugins: [new dotenv()],
}, },
css: { css: {