From 3508a116ff41b27b97f3bd432c62ccb69503975e Mon Sep 17 00:00:00 2001 From: Debora Crescenzo Date: Tue, 14 May 2024 10:27:56 +0100 Subject: [PATCH] MT#60094 Lint review Resolve current lint issues to improve the code reliability. Disable lint for auto-generated/auto-updated files. Note, Vue3 does not longer provide a default export therefore the line has been ignored for now, however tests still seem to work as expected. Change-Id: I668c50868b4cb9eceb0ff89767be9082585655a7 --- .eslintrc.js | 28 +++++++++-------- bin/config-create.js | 2 ++ bin/vue-i18n-extract/vue-i18n-extract.js | 2 +- bin/vue-i18n-extract/vue-i18n-extract.umd.js | 1 + public/service-worker.js | 11 ++++--- src/helpers/store-helper.js | 2 +- t/api/call-blocking.js | 32 ++++++++++---------- t/api/conversations.js | 3 +- t/api/speed-dial.js | 7 ++--- t/api/subscriber.js | 2 +- t/api/voicebox.js | 6 +--- t/components/login.js | 3 +- t/store/call-blocking.js | 16 +++++----- t/store/user.js | 2 +- t/store/voicebox.js | 3 +- test/jest/utils/index.js | 2 +- 16 files changed, 59 insertions(+), 63 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0f132510..55d1733b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,8 @@ module.exports = { }, env: { - browser: true + browser: true, + 'jest/globals': true }, // Rules order is important, please avoid shuffling them @@ -32,17 +33,17 @@ module.exports = { // https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-file // required to lint *.vue files 'vue', - + 'jest' ], globals: { - 'ga': true, // Google Analytics - 'cordova': true, - '__statics': true, - 'process': true, - 'Capacitor': true, - 'chrome': true, - 'jest': true + ga: true, // Google Analytics + cordova: true, + __statics: true, + process: true, + Capacitor: true, + chrome: true, + jest: true }, // add your custom rules here @@ -66,15 +67,16 @@ module.exports = { 'no-trailing-spaces': 'error', // allow debugger during development only 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + // eslint-disable-next-line quote-props 'indent': ['error', 4], 'vue/script-indent': ['error', 4], 'vue/html-indent': ['error', 4] }, - "overrides": [ + overrides: [ { - "files": ["*.vue"], - "rules": { - "indent": "off" + files: ['*.vue'], + rules: { + indent: 'off' } } ] diff --git a/bin/config-create.js b/bin/config-create.js index 5b8fa0a6..315c01a5 100644 --- a/bin/config-create.js +++ b/bin/config-create.js @@ -2,7 +2,9 @@ const path = require('path') const fs = require('fs') +// eslint-disable-next-line node/no-path-concat const filePathTemplate = path.resolve(__dirname + '/../src/config/app.template.root.js') +// eslint-disable-next-line node/no-path-concat const filePathConfig = path.resolve(__dirname + '/../src/config/app.js') const template = fs.readFileSync(filePathTemplate, 'utf8') const rendered = template.split('{{host}}').join(process.argv[2]) diff --git a/bin/vue-i18n-extract/vue-i18n-extract.js b/bin/vue-i18n-extract/vue-i18n-extract.js index a140563d..03b0c622 100644 --- a/bin/vue-i18n-extract/vue-i18n-extract.js +++ b/bin/vue-i18n-extract/vue-i18n-extract.js @@ -1,6 +1,6 @@ #!/usr/bin/env node // vim: set filetype=javascript: - /* eslint-disable */ +/* eslint-disable */ 'use strict'; const program = require('commander'); const { reportCommand } = require('./vue-i18n-extract.umd.js'); diff --git a/bin/vue-i18n-extract/vue-i18n-extract.umd.js b/bin/vue-i18n-extract/vue-i18n-extract.umd.js index bad0f665..f7b37aab 100644 --- a/bin/vue-i18n-extract/vue-i18n-extract.umd.js +++ b/bin/vue-i18n-extract/vue-i18n-extract.umd.js @@ -1,3 +1,4 @@ +/* eslint-disable */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('is-valid-glob'), require('glob'), require('fs'), require('dot-object'), require('js-yaml')) : typeof define === 'function' && define.amd ? define(['exports', 'path', 'is-valid-glob', 'glob', 'fs', 'dot-object', 'js-yaml'], factory) : diff --git a/public/service-worker.js b/public/service-worker.js index 0dac02de..9c8a9560 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,13 +1,14 @@ - self.addEventListener('notificationclick', function (event) { event.notification.close() - var promiseChain = clients.matchAll({ + // eslint-disable-next-line no-undef + const promiseChain = clients.matchAll({ type: 'window', includeUncontrolled: true }).then((windowClients) => { - var matchingClient = null - for (var i = 0; i < windowClients.length; i++) { - var windowClient = windowClients[i] + // eslint-disable-next-line no-unused-vars + const matchingClient = null + for (let i = 0; i < windowClients.length; i++) { + const windowClient = windowClients[i] if (windowClient.url === event.notification.data.url) { return windowClient.focus() } diff --git a/src/helpers/store-helper.js b/src/helpers/store-helper.js index f4eb661c..d3a2fdf6 100644 --- a/src/helpers/store-helper.js +++ b/src/helpers/store-helper.js @@ -1,4 +1,4 @@ - +// eslint-disable-next-line import/default import Vue from 'vue' export function reactiveSet (object, name, value) { diff --git a/t/api/call-blocking.js b/t/api/call-blocking.js index af560121..21eb554d 100644 --- a/t/api/call-blocking.js +++ b/t/api/call-blocking.js @@ -1,5 +1,5 @@ 'use strict' - +// eslint-disable-next-line import/default import Vue from 'vue' import VueResource from 'vue-resource' import { @@ -21,7 +21,7 @@ import { assert } from 'chai' Vue.use(VueResource) describe('CallBlocking', function () { - var subscriberId = 123 + const subscriberId = 123 beforeEach(function () { Vue.http.interceptors = [] @@ -63,7 +63,7 @@ describe('CallBlocking', function () { }) it('should get all data regarding incoming call blocking', function (done) { - var list = [ + const list = [ '0123456789', '0987654321' ] @@ -86,8 +86,8 @@ describe('CallBlocking', function () { }) it('should add a new number to incoming call blocking list', function (done) { - var number = '0987654321' - var list = [ + const number = '0987654321' + const list = [ '0123456789' ] Vue.http.interceptors.unshift((request, next) => { @@ -113,8 +113,8 @@ describe('CallBlocking', function () { }) it('should edit a number from incoming call blocking list', function (done) { - var number = '0987654321' - var list = [ + const number = '0987654321' + const list = [ '0123456789' ] Vue.http.interceptors.unshift((request, next) => { @@ -140,8 +140,8 @@ describe('CallBlocking', function () { }) it('should remove a number from incoming call blocking list', function (done) { - var number = '0987654321' - var list = [ + const number = '0987654321' + const list = [ '0123456789' ] Vue.http.interceptors.unshift((request, next) => { @@ -203,7 +203,7 @@ describe('CallBlocking', function () { }) it('should get all data regarding outgoing call blocking', function (done) { - var list = [ + const list = [ '0123456789', '0987654321' ] @@ -226,8 +226,8 @@ describe('CallBlocking', function () { }) it('should add a new number to outgoing call blocking list', function (done) { - var number = '0987654321' - var list = [ + const number = '0987654321' + const list = [ '0123456789' ] Vue.http.interceptors.unshift((request, next) => { @@ -253,8 +253,8 @@ describe('CallBlocking', function () { }) it('should edit a number from outgoing call blocking list', function (done) { - var number = '0987654321' - var list = [ + const number = '0987654321' + const list = [ '0123456789' ] Vue.http.interceptors.unshift((request, next) => { @@ -280,8 +280,8 @@ describe('CallBlocking', function () { }) it('should remove a number from outgoing call blocking list', function (done) { - var number = '0987654321' - var list = [ + const number = '0987654321' + const list = [ '0123456789' ] Vue.http.interceptors.unshift((request, next) => { diff --git a/t/api/conversations.js b/t/api/conversations.js index 88bf3fad..9ccdd010 100644 --- a/t/api/conversations.js +++ b/t/api/conversations.js @@ -1,9 +1,8 @@ 'use strict' - +// eslint-disable-next-line import/default import Vue from 'vue' import VueResource from 'vue-resource' -import crypto from 'crypto-browserify' import { getConversations } from '../../src/api/conversations' import { assert } from 'chai' diff --git a/t/api/speed-dial.js b/t/api/speed-dial.js index 233a8396..369e0a03 100644 --- a/t/api/speed-dial.js +++ b/t/api/speed-dial.js @@ -1,17 +1,14 @@ 'use strict' - +// eslint-disable-next-line import/default import Vue from 'vue' import VueResource from 'vue-resource' -import { - getFieldList -} from '../../src/api/common' import { getSpeedDialsById, getUnassignedSlots } from '../../src/api/speed-dial' import { assert } from 'chai' -import { i18n } from '../../src/i18n' +import { i18n } from 'src/boot/i18n' Vue.use(VueResource) diff --git a/t/api/subscriber.js b/t/api/subscriber.js index 9cee3843..a34cb0c1 100644 --- a/t/api/subscriber.js +++ b/t/api/subscriber.js @@ -1,6 +1,6 @@ 'use strict' - +// eslint-disable-next-line import/default import Vue from 'vue' import VueResource from 'vue-resource' import { getPreferences } from '../../src/api/subscriber' diff --git a/t/api/voicebox.js b/t/api/voicebox.js index 51797445..18830b54 100644 --- a/t/api/voicebox.js +++ b/t/api/voicebox.js @@ -1,12 +1,8 @@ 'use strict' - +// eslint-disable-next-line import/default import Vue from 'vue' import VueResource from 'vue-resource' -import { - get, - getList -} from '../../src/api/common' import { getVoiceboxSettings, getVoiceboxGreetingByType diff --git a/t/components/login.js b/t/components/login.js index b239e0ca..69264558 100644 --- a/t/components/login.js +++ b/t/components/login.js @@ -1,11 +1,10 @@ -import Vue from 'vue' import Login from '../../src/components/Login.vue' import { assert } from 'chai' describe('Login', function () { it('should initialize with default data', function () { - var defaultData = Login.data() + const defaultData = Login.data() assert.equal(defaultData.username, '') assert.equal(defaultData.password, '') }) diff --git a/t/store/call-blocking.js b/t/store/call-blocking.js index 3d23c73b..36df38b1 100644 --- a/t/store/call-blocking.js +++ b/t/store/call-blocking.js @@ -6,20 +6,20 @@ import { assert } from 'chai' describe('CallBlocking', function () { describe('Incoming', function () { it('should enable list', function () { - var state = {} + const state = {} CallBlockingModule.mutations.toggleSucceeded(state, true) assert.equal(state.enabled, true) }) it('should disable list', function () { - var state = {} + const state = {} CallBlockingModule.mutations.toggleSucceeded(state, false) assert.equal(state.enabled, false) }) it('should load list and flag', function () { - var state = {} - var list = [ + const state = {} + const list = [ '0123456789', '0987654321' ] @@ -34,20 +34,20 @@ describe('CallBlocking', function () { describe('Outgoing', function () { it('should enable list', function () { - var state = {} + const state = {} CallBlockingModule.mutations.toggleSucceeded(state, true) assert.equal(state.enabled, true) }) it('should disable list', function () { - var state = {} + const state = {} CallBlockingModule.mutations.toggleSucceeded(state, false) assert.equal(state.enabled, false) }) it('should load list and flag', function () { - var state = {} - var list = [ + const state = {} + const list = [ '0123456789', '0987654321' ] diff --git a/t/store/user.js b/t/store/user.js index 658c38be..90030959 100644 --- a/t/store/user.js +++ b/t/store/user.js @@ -5,7 +5,7 @@ import { assert } from 'chai' describe('UserModule', () => { it('should login', () => { - var state = {} + const state = {} UserModule.mutations.loginSucceeded(state, { jwt: 'abc123', subscriberId: 123 diff --git a/t/store/voicebox.js b/t/store/voicebox.js index 03bdc0b5..63bd1f6b 100644 --- a/t/store/voicebox.js +++ b/t/store/voicebox.js @@ -2,8 +2,7 @@ 'use strict' import VoiceboxModule from '../../src/store/voicebox' -import localeEn from 'src/i18n/en.json' -import { i18n } from '../../src/i18n' +import { i18n } from 'boot/i18n' import { assert } from 'chai' describe('Voicebox', function () { diff --git a/test/jest/utils/index.js b/test/jest/utils/index.js index 552b6554..e1391d00 100755 --- a/test/jest/utils/index.js +++ b/test/jest/utils/index.js @@ -3,7 +3,7 @@ import { createLocalVue, shallowMount } from 'test-utils' import Vuex from 'vuex' import VueRouter from 'vue-router' -import Quasar, { Cookies } from 'quasar' +import { Quasar, Cookies } from 'quasar' const mockSsrContext = () => { return {