From 7981676a516f06d69edb6b83bc6efb105ee3d649 Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Sat, 31 Oct 2020 19:16:27 -0600 Subject: [PATCH] eslint: Update config and fix warnings Expand on the eslint configuration started in Ie7c2451: * Use wikimedia/vue-es6 standard for Vue frontend * Use wikimedia/mocha standard for jsonschema * Use wikimedia/server for vue.config.js * use wikimedia/client for any other js files found This change also includes lint error corrections after applying the expanded configuration. These were largely automatic changes applied by `eslint --fix .` Change-Id: I947e26ee7af7212f80aadff7c18fe7c0bbfd48f9 --- package-lock.json | 133 +++++++----- package.json | 32 +-- tests/jsonschema/repository.test.js | 2 +- vue.config.js | 183 ++++++++-------- vue/src/App.vue | 114 +++++----- vue/src/components/user/Status.vue | 32 +-- vue/src/router/index.js | 88 ++++---- vue/src/store/index.js | 1 - vue/src/views/About.vue | 24 +-- vue/src/views/AddRemoveTools.vue | 313 ++++++++++++++-------------- vue/src/views/ApiDocs.vue | 36 ++-- vue/src/views/Home.vue | 24 +-- 12 files changed, 509 insertions(+), 473 deletions(-) diff --git a/package-lock.json b/package-lock.json index b29ada13..34d8373a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3708,17 +3708,6 @@ "unique-filename": "^1.1.1" } }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "optional": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, "cliui": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", @@ -3806,31 +3795,12 @@ "path-is-absolute": "^1.0.0" } }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "optional": true - }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true }, - "loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", - "dev": true, - "optional": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^2.1.2" - } - }, "locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -3933,16 +3903,6 @@ "ansi-regex": "^5.0.0" } }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "optional": true, - "requires": { - "has-flag": "^4.0.0" - } - }, "terser-webpack-plugin": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz", @@ -3960,18 +3920,6 @@ "webpack-sources": "^1.4.3" } }, - "vue-loader-v16": { - "version": "npm:vue-loader@16.0.0-beta.9", - "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.9.tgz", - "integrity": "sha512-mu9pg6554GbXDSO8LlxkQM6qUJzUkb/A0FJc9LgRqnU9MCnhzEXwCt1Zx5NObvFpzs2mH2dH/uUCDwL8Qaz9sA==", - "dev": true, - "optional": true, - "requires": { - "chalk": "^4.1.0", - "hash-sum": "^2.0.0", - "loader-utils": "^2.0.0" - } - }, "wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", @@ -21257,6 +21205,87 @@ } } }, + "vue-loader-v16": { + "version": "npm:vue-loader@16.0.0-beta.9", + "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.9.tgz", + "integrity": "sha512-mu9pg6554GbXDSO8LlxkQM6qUJzUkb/A0FJc9LgRqnU9MCnhzEXwCt1Zx5NObvFpzs2mH2dH/uUCDwL8Qaz9sA==", + "dev": true, + "optional": true, + "requires": { + "chalk": "^4.1.0", + "hash-sum": "^2.0.0", + "loader-utils": "^2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "optional": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "optional": true + }, + "loader-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", + "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "dev": true, + "optional": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "optional": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "vue-router": { "version": "3.4.7", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.7.tgz", diff --git a/package.json b/package.json index 15eeed75..647b2bb0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private": true, "scripts": { "build:vue": "vue-cli-service build", - "lint": "eslint . & npm run lint:vue", + "lint": "npm run lint:eslint && npm run lint:vue", + "lint:eslint": "eslint .", "lint:vue": "vue-cli-service lint", "schemas:generate": "jsonschema-tools materialize-all", "serve:vue": "vue-cli-service serve", @@ -53,32 +54,37 @@ }, "eslintConfig": { "root": true, + "extends": [ "wikimedia/client" ], "overrides": [ { - "files": [ - "*.js", - "*.vue" - ], + "files": [ "vue/src/**/*.{js,vue}" ], "extends": [ - "wikimedia/client", + "wikimedia/vue-es6", "wikimedia/language/es6", "plugin:vue/recommended" ], "rules": { - "no-undef": "off" + "camelcase" : "off", + "no-undef" : "off" } + }, + { + "files": [ "tests/jsonschema/**/*.js" ], + "extends": [ + "wikimedia/server", + "wikimedia/mocha" + ] + }, + { + "files": [ "vue.config.js" ], + "extends": [ "wikimedia/server" ] } ] }, "eslintIgnore": [ - ".eslintrc.js", "docs", - "toolhub", "bin", - "jsonschema", - ".pipeline", - "tests", - "vue.config.js" + ".pipeline" ], "browserslist": [ "> 1%", diff --git a/tests/jsonschema/repository.test.js b/tests/jsonschema/repository.test.js index 87a748a2..bc46199b 100644 --- a/tests/jsonschema/repository.test.js +++ b/tests/jsonschema/repository.test.js @@ -1,2 +1,2 @@ 'use strict'; -require('@wikimedia/jsonschema-tools').tests.all({ logLevel: 'info' }); +require( '@wikimedia/jsonschema-tools' ).tests.all( { logLevel: 'info' } ); diff --git a/vue.config.js b/vue.config.js index 2e1efc73..808aac02 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,103 +1,104 @@ -const path = require("path") -const BundleTracker = require("webpack-bundle-tracker"); +'use strict'; +const path = require( 'path' ); +const BundleTracker = require( 'webpack-bundle-tracker' ); -const isProduction = process.env.NODE_ENV === "production"; +const isProduction = process.env.NODE_ENV === 'production'; const PORT = process.env.PORT || 8001; const pages = { - "main": { - "entry": "./vue/src/main.js", - "chunks": [ - "chunk-vendors" - ] - } + main: { + entry: './vue/src/main.js', + chunks: [ + 'chunk-vendors' + ] + } }; module.exports = { - pages: pages, - filenameHashing: false, - productionSourceMap: false, - publicPath: isProduction ? "" : `http://localhost:${PORT}/`, - // FIXME: what path should this be? - outputDir: path.resolve(__dirname, "vue/static"), - transpileDependencies: [ - "vuetify" - ], - configureWebpack: { - resolve: { - alias: { - "@": path.resolve(__dirname, "vue/src") - } - }, - // Prevent webpack from puting `eval`s into generated files - devtool: "inline-source-map" - }, - chainWebpack: config => { - // Separate vendored js into its own bundle - config.optimization.splitChunks( - { - cacheGroups: { - vendor: { - test: /[\\/]node_modules[\\/]/, - name: "chunk-vendors", - chunks: "all", - priority: 1, - enforce: true - }, - }, - } - ); + pages: pages, + filenameHashing: false, + productionSourceMap: false, + publicPath: isProduction ? '' : `http://localhost:${PORT}/`, + // FIXME: what path should this be? + outputDir: path.resolve( __dirname, 'vue/static' ), + transpileDependencies: [ + 'vuetify' + ], + configureWebpack: { + resolve: { + alias: { + '@': path.resolve( __dirname, 'vue/src' ) + } + }, + // Prevent webpack from puting `eval`s into generated files + devtool: 'inline-source-map' + }, + chainWebpack: ( config ) => { + // Separate vendored js into its own bundle + config.optimization.splitChunks( + { + cacheGroups: { + vendor: { + test: /[\\/]node_modules[\\/]/, + name: 'chunk-vendors', + chunks: 'all', + priority: 1, + enforce: true + } + } + } + ); - // We are not serving pages directly, so remove plugins that generate - // stubs for pages and including js/css. - Object.keys(pages).forEach(page => { - config.plugins.delete(`html-${page}`); - config.plugins.delete(`preload-${page}`); - config.plugins.delete(`prefetch-${page}`); - }); + // We are not serving pages directly, so remove plugins that generate + // stubs for pages and including js/css. + Object.keys( pages ).forEach( ( page ) => { + config.plugins.delete( `html-${page}` ); + config.plugins.delete( `preload-${page}` ); + config.plugins.delete( `prefetch-${page}` ); + } ); - // Generate an index for webpack generated files that will be consumed by - // Django's webpack_loader library. - // FIXME: make this track outputDir - config.plugin("BundleTracker").use( - BundleTracker, [{ - filename: "vue/static/vue/webpack-stats.json" - }] - ); + // Generate an index for webpack generated files that will be consumed by + // Django's webpack_loader library. + // FIXME: make this track outputDir + config.plugin( 'BundleTracker' ).use( + BundleTracker, [ { + filename: 'vue/static/vue/webpack-stats.json' + } ] + ); - // Share a static directory between Vue and Django. - // Use "~__STATIC__/..." from Vue code. - config.resolve.alias.set("__STATIC__", "static"); + // Share a static directory between Vue and Django. + // Use "~__STATIC__/..." from Vue code. + config.resolve.alias.set( '__STATIC__', 'static' ); - // Copy static assets into the shared static directory. - // https://stackoverflow.com/questions/50898675 - config.plugin("copy") - .use(require("copy-webpack-plugin")) - .tap(([pathConfigs]) => { - var conf = [{ - from: path.resolve(__dirname, "vue/public"), - to: path.resolve(__dirname, "vue/static/vue") - }] - if (!pathConfigs) { - pathConfigs = conf - } else { - pathConfigs.concat(conf) - } - return [pathConfigs] - }); + // Copy static assets into the shared static directory. + // https://stackoverflow.com/questions/50898675 + config.plugin( 'copy' ) + .use( require( 'copy-webpack-plugin' ) ) + .tap( ( [ pathConfigs ] ) => { + const conf = [ { + from: path.resolve( __dirname, 'vue/public' ), + to: path.resolve( __dirname, 'vue/static/vue' ) + } ]; + if ( !pathConfigs ) { + pathConfigs = conf; + } else { + pathConfigs.concat( conf ); + } + return [ pathConfigs ]; + } ); - // Configure the dev-mode http server for hot reloading - config.devServer - .public(`http://0.0.0.0:${PORT}`) - .host("0.0.0.0") - .port(PORT) - .hotOnly(true) - .watchOptions({poll: 1000}) - .https(false) - .headers({"Access-Control-Allow-Origin": ["*"]}); - }, - devServer: { - contentBase: path.join(__dirname, "vue/public") - }, - lintOnSave: false -} + // Configure the dev-mode http server for hot reloading + config.devServer + .public( `http://0.0.0.0:${PORT}` ) + .host( '0.0.0.0' ) + .port( PORT ) + .hotOnly( true ) + .watchOptions( { poll: 1000 } ) + .https( false ) + .headers( { 'Access-Control-Allow-Origin': [ '*' ] } ); + }, + devServer: { + contentBase: path.join( __dirname, 'vue/public' ) + }, + lintOnSave: false +}; diff --git a/vue/src/App.vue b/vue/src/App.vue index 899603c7..6f2bbe1a 100644 --- a/vue/src/App.vue +++ b/vue/src/App.vue @@ -1,67 +1,67 @@