From 3fa79eb4adf3237040a70c174c0f681b698daeab Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 15 Dec 2020 16:08:31 +0800 Subject: [PATCH 1/4] style: replace eslint-plugin-vue-libs with standard config --- .eslintrc.js | 20 +++++++++---------- packages/@vue/babel-preset-app/index.js | 4 ++-- .../__tests__/usePluginPreset.spec.js | 1 - packages/@vue/cli-plugin-babel/index.js | 2 ++ .../nightwatch.config.js | 12 ++++++----- .../__tests__/wdioGenerator.spec.js | 4 ++-- .../@vue/cli-plugin-eslint/generator/index.js | 2 +- .../__tests__/pwaPlugin.spec.js | 2 +- packages/@vue/cli-plugin-pwa/index.js | 6 +++--- packages/@vue/cli-plugin-pwa/ui.js | 4 ++-- .../__tests__/tsGenerator.spec.js | 4 ++-- .../codemods/migrateComponentType.js | 2 ++ .../__tests__/jestGenerator.spec.js | 4 ++-- .../__tests__/mochaGenerator.spec.js | 4 ++-- packages/@vue/cli-plugin-unit-mocha/index.js | 14 +++++++------ .../cli-service/__tests__/Service.spec.js | 2 +- .../@vue/cli-service/__tests__/css.spec.js | 3 +-- .../@vue/cli-service/__tests__/serve.spec.js | 1 - packages/@vue/cli-service/lib/PluginAPI.js | 2 +- packages/@vue/cli-service/lib/Service.js | 2 +- .../cli-service/lib/commands/build/index.js | 2 +- .../lib/commands/build/setPublicPath.js | 1 + packages/@vue/cli-service/lib/config/css.js | 4 ++-- .../cli-service/lib/util/isAbsoluteUrl.js | 2 +- .../@vue/cli-service/lib/util/prepareProxy.js | 6 +++--- .../lib/webpack/ModernModePlugin.js | 2 +- packages/@vue/cli-shared-utils/lib/module.js | 1 + .../@vue/cli-shared-utils/lib/openBrowser.js | 3 +-- packages/@vue/cli/__tests__/Generator.spec.js | 2 ++ packages/@vue/cli/__tests__/invoke.spec.js | 4 ++-- packages/@vue/cli/lib/GeneratorAPI.js | 2 +- .../cli/lib/util/ProjectPackageManager.js | 6 +++--- packages/@vue/cli/lib/util/executeCommand.js | 2 +- .../@vue/cli/lib/util/loadPresetFromDir.js | 2 +- packages/@vue/cli/lib/util/sortObject.js | 2 +- 35 files changed, 72 insertions(+), 64 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index e763a94c89..d2ef595f38 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,23 +1,20 @@ module.exports = { extends: [ - 'plugin:vue-libs/recommended' + '@vue/standard' ], - plugins: [ - 'node' - ], - env: { - 'jest': true - }, globals: { name: 'off' }, rules: { - 'indent': ['error', 2, { - 'MemberExpression': 'off' + indent: ['error', 2, { + MemberExpression: 'off' }], + 'object-curly-newline': 'off', + quotes: [2, 'single', { avoidEscape: true, allowTemplateLiterals: true }], + 'quote-props': 'off', 'no-shadow': ['error'], 'node/no-extraneous-require': ['error', { - 'allowModules': [ + allowModules: [ '@vue/cli-service', '@vue/cli-test-utils' ] @@ -26,6 +23,9 @@ module.exports = { overrides: [ { files: ['**/__tests__/**/*.js', '**/cli-test-utils/**/*.js'], + env: { + jest: true + }, rules: { 'node/no-extraneous-require': 'off' } diff --git a/packages/@vue/babel-preset-app/index.js b/packages/@vue/babel-preset-app/index.js index a87ebfbbef..f2f712cc87 100644 --- a/packages/@vue/babel-preset-app/index.js +++ b/packages/@vue/babel-preset-app/index.js @@ -259,13 +259,13 @@ module.exports = (context, options = {}) => { return { sourceType: 'unambiguous', overrides: [{ - exclude: [/@babel[\/|\\\\]runtime/, /core-js/], + exclude: [/@babel[/|\\\\]runtime/, /core-js/], presets, plugins }, { // there are some untranspiled code in @babel/runtime // https://github.com/babel/babel/issues/9903 - include: [/@babel[\/|\\\\]runtime/], + include: [/@babel[/|\\\\]runtime/], presets: [ [require('@babel/preset-env'), envOptions] ] diff --git a/packages/@vue/cli-plugin-babel/codemods/__tests__/usePluginPreset.spec.js b/packages/@vue/cli-plugin-babel/codemods/__tests__/usePluginPreset.spec.js index d07395c8c4..2758b7a7b4 100644 --- a/packages/@vue/cli-plugin-babel/codemods/__tests__/usePluginPreset.spec.js +++ b/packages/@vue/cli-plugin-babel/codemods/__tests__/usePluginPreset.spec.js @@ -6,4 +6,3 @@ defineTest(__dirname, 'usePluginPreset', null, 'default') defineTest(__dirname, 'usePluginPreset', null, 'customConfig') defineTest(__dirname, 'usePluginPreset', null, 'require') defineTest(__dirname, 'usePluginPreset', null, 'templateLiteral') - diff --git a/packages/@vue/cli-plugin-babel/index.js b/packages/@vue/cli-plugin-babel/index.js index 30b561717a..f758e31f96 100644 --- a/packages/@vue/cli-plugin-babel/index.js +++ b/packages/@vue/cli-plugin-babel/index.js @@ -12,6 +12,8 @@ function genTranspileDepRegex (transpileDependencies) { } else if (dep instanceof RegExp) { return dep.source } + + throw new Error('transpileDependencies only accepts an array of string or regular expressions') }) return deps.length ? new RegExp(deps.join('|')) : null } diff --git a/packages/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js b/packages/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js index a5406d8829..4071a3aa19 100644 --- a/packages/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js +++ b/packages/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js @@ -33,7 +33,7 @@ const defaultSettings = { test_settings: { default: { detailed_output: !concurrentMode, - launch_url: '${VUE_DEV_SERVER_URL}' + launch_url: '${VUE_DEV_SERVER_URL}' // eslint-disable-line no-template-curly-in-string }, chrome: { @@ -56,10 +56,12 @@ const defaultSettings = { } } }, - webdriver: useSelenium ? {} : { - server_path: geckodriver.path, - port: 4444 - } + webdriver: useSelenium + ? {} + : { + server_path: geckodriver.path, + port: 4444 + } } } } diff --git a/packages/@vue/cli-plugin-e2e-webdriverio/__tests__/wdioGenerator.spec.js b/packages/@vue/cli-plugin-e2e-webdriverio/__tests__/wdioGenerator.spec.js index fbc6cdbb56..30f7661d5f 100644 --- a/packages/@vue/cli-plugin-e2e-webdriverio/__tests__/wdioGenerator.spec.js +++ b/packages/@vue/cli-plugin-e2e-webdriverio/__tests__/wdioGenerator.spec.js @@ -11,13 +11,13 @@ test('should add types to existing tsconfig.json', async () => { } } }) - await write('tsconfig.json', JSON.stringify({ compilerOptions: { types: ['some-type'] }})) + await write('tsconfig.json', JSON.stringify({ compilerOptions: { types: ['some-type'] } })) const invoke = require('@vue/cli/lib/invoke') await invoke('e2e-webdriverio', { webdrivers: ['chrome'] }, dir) const tsconfig = await read('tsconfig.json') expect(tsconfig).toMatch(/\r?\n$/) - expect(JSON.parse(tsconfig)['compilerOptions']['types']) + expect(JSON.parse(tsconfig).compilerOptions.types) .toEqual(['some-type', 'mocha', '@wdio/mocha-framework', '@wdio/sync']) }) diff --git a/packages/@vue/cli-plugin-eslint/generator/index.js b/packages/@vue/cli-plugin-eslint/generator/index.js index 9ac49df89c..a3975e6047 100644 --- a/packages/@vue/cli-plugin-eslint/generator/index.js +++ b/packages/@vue/cli-plugin-eslint/generator/index.js @@ -44,7 +44,7 @@ module.exports = (api, { config, lintOn = [] }, rootOptions, invoking) => { 'pre-commit': 'lint-staged' } const extensions = require('../eslintOptions').extensions(api) - .map(ext => ext.replace(/^\./, '')) // remove the leading `.` + .map(ext => ext.replace(/^\./, '')) // remove the leading `.` pkg['lint-staged'] = { [`*.{${extensions.join(',')}}`]: 'vue-cli-service lint' } diff --git a/packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js b/packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js index 814174395c..56054308cc 100644 --- a/packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js +++ b/packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js @@ -59,7 +59,7 @@ test('pwa', async () => { browser = launched.browser // workbox plugin fetches scripts from CDN so it takes a while... - await new Promise(r => setTimeout(r, process.env.CI ? 5000 : 2000)) + await new Promise(resolve => setTimeout(resolve, process.env.CI ? 5000 : 2000)) const logs = launched.logs expect(logs.some(msg => msg.match(/Content has been cached for offline use/))).toBe(true) expect(logs.some(msg => msg.match(/App is being served from cache by a service worker/))).toBe(true) diff --git a/packages/@vue/cli-plugin-pwa/index.js b/packages/@vue/cli-plugin-pwa/index.js index f8feae2256..89ac894134 100644 --- a/packages/@vue/cli-plugin-pwa/index.js +++ b/packages/@vue/cli-plugin-pwa/index.js @@ -54,9 +54,9 @@ module.exports = (api, options) => { ] } - const defaultGenerateSWOptions = workboxPluginMode === 'GenerateSW' ? { - cacheId: name - } : {} + const defaultGenerateSWOptions = workboxPluginMode === 'GenerateSW' + ? { cacheId: name } + : {} const workBoxConfig = Object.assign(defaultOptions, defaultGenerateSWOptions, userOptions.workboxOptions) diff --git a/packages/@vue/cli-plugin-pwa/ui.js b/packages/@vue/cli-plugin-pwa/ui.js index f3c7a9a056..b4d9730eb0 100644 --- a/packages/@vue/cli-plugin-pwa/ui.js +++ b/packages/@vue/cli-plugin-pwa/ui.js @@ -129,7 +129,7 @@ module.exports = api => { // Update app manifest (only when there's a manifest.json file, // otherwise it will be inferred from options in vue.config.js) if (data.manifest) { - const name = result['name'] + const name = result.name if (name) { onWriteApi.setData('manifest', { name, @@ -137,7 +137,7 @@ module.exports = api => { }) } - const themeColor = result['themeColor'] + const themeColor = result.themeColor if (themeColor) { onWriteApi.setData('manifest', { theme_color: themeColor diff --git a/packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js b/packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js index 1603917fd0..a745786439 100644 --- a/packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js +++ b/packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js @@ -18,7 +18,7 @@ test('generate files', async () => { expect(files['src/main.js']).toBeFalsy() expect(files['src/App.vue']).toMatch('`) // Test crossorigin="use-credentials" - await project.write('vue.config.js', `module.exports = { crossorigin: 'use-credentials' }`) + await project.write('vue.config.js', 'module.exports = { crossorigin: \'use-credentials\' }') const { stdout: stdout2 } = await project.run('vue-cli-service build --modern') expect(stdout2).toMatch('Build complete.') const index2 = await project.read('dist/index.html') diff --git a/packages/@vue/cli-service/__tests__/multiPage.spec.js b/packages/@vue/cli-service/__tests__/multiPage.spec.js index 441fe07537..7b4c23861b 100644 --- a/packages/@vue/cli-service/__tests__/multiPage.spec.js +++ b/packages/@vue/cli-service/__tests__/multiPage.spec.js @@ -55,8 +55,8 @@ async function makeProjectMultiPage (project) { `) const app = await project.read('src/App.vue') await project.write('src/App.vue', app.replace( - `import HelloWorld from './components/HelloWorld.vue'`, - `const HelloWorld = () => import('./components/HelloWorld.vue')` + 'import HelloWorld from \'./components/HelloWorld.vue\'', + 'const HelloWorld = () => import(\'./components/HelloWorld.vue\')' )) } @@ -68,22 +68,22 @@ test('serve w/ multi page', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, url, helpers }) => { - expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) + expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') await page.goto(`${url}/foo.html`) - expect(await helpers.getText('h1')).toMatch(`Foo`) + expect(await helpers.getText('h1')).toMatch('Foo') await page.goto(`${url}/bar.html`) - expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) + expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') await page.goto(`${url}foo`) - expect(await helpers.getText('h1')).toMatch(`Foo`) + expect(await helpers.getText('h1')).toMatch('Foo') await page.goto(`${url}bar`) - expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) + expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') await page.goto(`${url}foobar`) - expect(await helpers.getText('h1')).toMatch(`FooBar`) + expect(await helpers.getText('h1')).toMatch('FooBar') } ) }) diff --git a/packages/@vue/cli-service/__tests__/proxy.spec.js b/packages/@vue/cli-service/__tests__/proxy.spec.js index cbaff7f9df..7b99120ffb 100644 --- a/packages/@vue/cli-service/__tests__/proxy.spec.js +++ b/packages/@vue/cli-service/__tests__/proxy.spec.js @@ -11,13 +11,13 @@ let mockServer2 beforeAll(done => { mockServer1 = createJSONServer({ - 'posts': [ - { 'id': 1, 'title': 'server-one', 'author': 'typicode' } + posts: [ + { id: 1, title: 'server-one', author: 'typicode' } ] }).listen(3000, () => { mockServer2 = createJSONServer({ - 'posts': [ - { 'id': 1, 'title': 'server-two', 'author': 'typicode' } + posts: [ + { id: 1, title: 'server-two', author: 'typicode' } ] }).listen(3001, done) }) diff --git a/packages/@vue/cli-service/__tests__/serve.spec.js b/packages/@vue/cli-service/__tests__/serve.spec.js index 6eaa11926d..2003c7e894 100644 --- a/packages/@vue/cli-service/__tests__/serve.spec.js +++ b/packages/@vue/cli-service/__tests__/serve.spec.js @@ -13,12 +13,12 @@ test('serve', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, nextUpdate, helpers }) => { - const msg = `Welcome to Your Vue.js App` + const msg = 'Welcome to Your Vue.js App' expect(await helpers.getText('h1')).toMatch(msg) // test hot reload - const file = await project.read(`src/App.vue`) - project.write(`src/App.vue`, file.replace(msg, `Updated`)) + const file = await project.read('src/App.vue') + project.write('src/App.vue', file.replace(msg, 'Updated')) await nextUpdate() // wait for child stdout update signal try { await page.waitForFunction(selector => { @@ -47,14 +47,14 @@ test('serve with router', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, helpers }) => { - expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) + expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') expect(await helpers.hasElement('#nav')).toBe(true) expect(await helpers.hasClass('a[href="#/"]', 'router-link-exact-active')).toBe(true) expect(await helpers.hasClass('a[href="#/about"]', 'router-link-exact-active')).toBe(false) await page.click('a[href="#/about"]') await sleep(1000) - expect(await helpers.getText('h1')).toMatch(`This is an about page`) + expect(await helpers.getText('h1')).toMatch('This is an about page') expect(await helpers.hasElement('#nav')).toBe(true) expect(await helpers.hasClass('a[href="#/"]', 'router-link-exact-active')).toBe(false) expect(await helpers.hasClass('a[href="#/about"]', 'router-link-exact-active')).toBe(true) @@ -71,14 +71,14 @@ test('serve with legacy router option', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, helpers }) => { - expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) + expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') expect(await helpers.hasElement('#nav')).toBe(true) expect(await helpers.hasClass('a[href="/"]', 'router-link-exact-active')).toBe(true) expect(await helpers.hasClass('a[href="/about"]', 'router-link-exact-active')).toBe(false) await page.click('a[href="/about"]') await sleep(1000) - expect(await helpers.getText('h1')).toMatch(`This is an about page`) + expect(await helpers.getText('h1')).toMatch('This is an about page') expect(await helpers.hasElement('#nav')).toBe(true) expect(await helpers.hasClass('a[href="/"]', 'router-link-exact-active')).toBe(false) expect(await helpers.hasClass('a[href="/about"]', 'router-link-exact-active')).toBe(true) @@ -94,7 +94,7 @@ test('serve with legacy vuex option', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, helpers }) => { - expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) + expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') } ) }) @@ -110,12 +110,12 @@ test('serve with inline entry', async () => { await serve( () => project.run('vue-cli-service serve src/index.js'), async ({ page, nextUpdate, helpers }) => { - const msg = `Welcome to Your Vue.js App` + const msg = 'Welcome to Your Vue.js App' expect(await helpers.getText('h1')).toMatch(msg) // test hot reload - const file = await project.read(`src/App.vue`) - project.write(`src/App.vue`, file.replace(msg, `Updated`)) + const file = await project.read('src/App.vue') + project.write('src/App.vue', file.replace(msg, 'Updated')) await nextUpdate() // wait for child stdout update signal try { await page.waitForFunction(selector => { @@ -143,12 +143,12 @@ test('serve with no public dir', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, nextUpdate, helpers }) => { - const msg = `Welcome to Your Vue.js App` + const msg = 'Welcome to Your Vue.js App' expect(await helpers.getText('h1')).toMatch(msg) // test hot reload - const file = await project.read(`src/App.vue`) - project.write(`src/App.vue`, file.replace(msg, `Updated`)) + const file = await project.read('src/App.vue') + project.write('src/App.vue', file.replace(msg, 'Updated')) await nextUpdate() // wait for child stdout update signal try { await page.waitForFunction(selector => { @@ -185,7 +185,7 @@ test('use a single websocket connection for HMR', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ helpers, requestUrls }) => { - const msg = `Welcome to Your Vue.js App` + const msg = 'Welcome to Your Vue.js App' expect(await helpers.getText('h1')).toMatch(msg) expect(requestUrls.filter(url => url.includes('sockjs-node')).length).toBe(1) diff --git a/packages/@vue/cli-service/__tests__/serveVue3.spec.js b/packages/@vue/cli-service/__tests__/serveVue3.spec.js index 1021497c22..92a90360b2 100644 --- a/packages/@vue/cli-service/__tests__/serveVue3.spec.js +++ b/packages/@vue/cli-service/__tests__/serveVue3.spec.js @@ -11,13 +11,13 @@ test('serve with Vue 3', async () => { await serve( () => project.run('yarn serve'), async ({ page, nextUpdate, helpers }) => { - const msg = `Welcome to Your Vue.js App` + const msg = 'Welcome to Your Vue.js App' expect(await helpers.getText('h1')).toMatch(msg) expect(await page.evaluate(() => window.__VUE__)).toBeDefined() // test hot reload - const file = await project.read(`src/App.vue`) - project.write(`src/App.vue`, file.replace(msg, `Updated`)) + const file = await project.read('src/App.vue') + project.write('src/App.vue', file.replace(msg, 'Updated')) await nextUpdate() // wait for child stdout update signal try { await page.waitForFunction(selector => { diff --git a/packages/@vue/cli-service/generator/index.js b/packages/@vue/cli-service/generator/index.js index ef6705182f..09a91efcb0 100644 --- a/packages/@vue/cli-service/generator/index.js +++ b/packages/@vue/cli-service/generator/index.js @@ -6,7 +6,7 @@ module.exports = (api, options) => { if (options.vueVersion === '3') { api.extendPackage({ dependencies: { - 'vue': '^3.0.4' + vue: '^3.0.4' }, devDependencies: { '@vue/compiler-sfc': '^3.0.4' @@ -15,7 +15,7 @@ module.exports = (api, options) => { } else { api.extendPackage({ dependencies: { - 'vue': '^2.6.11' + vue: '^2.6.11' }, devDependencies: { 'vue-template-compiler': '^2.6.11' @@ -25,8 +25,8 @@ module.exports = (api, options) => { api.extendPackage({ scripts: { - 'serve': 'vue-cli-service serve', - 'build': 'vue-cli-service build' + serve: 'vue-cli-service serve', + build: 'vue-cli-service build' }, browserslist: [ '> 1%', @@ -46,11 +46,11 @@ module.exports = (api, options) => { 'sass-loader': '^8.0.2' }, less: { - 'less': '^3.0.4', + less: '^3.0.4', 'less-loader': '^5.0.0' }, stylus: { - 'stylus': '^0.54.8', + stylus: '^0.54.8', 'stylus-loader': '^4.3.1' } } diff --git a/packages/@vue/cli-service/lib/Service.js b/packages/@vue/cli-service/lib/Service.js index 4fb59cd8a5..9d69613ff2 100644 --- a/packages/@vue/cli-service/lib/Service.js +++ b/packages/@vue/cli-service/lib/Service.js @@ -92,7 +92,7 @@ module.exports = class Service { loadEnv (mode) { const logger = debug('vue:env') - const basePath = path.resolve(this.context, `.env${mode ? `.${mode}` : ``}`) + const basePath = path.resolve(this.context, `.env${mode ? `.${mode}` : ''}`) const localPath = `${basePath}.local` const load = envPath => { @@ -278,8 +278,8 @@ module.exports = class Service { config.output.publicPath !== this.projectOptions.publicPath ) { throw new Error( - `Do not modify webpack output.publicPath directly. ` + - `Use the "publicPath" option in vue.config.js instead.` + 'Do not modify webpack output.publicPath directly. ' + + 'Use the "publicPath" option in vue.config.js instead.' ) } @@ -354,8 +354,8 @@ module.exports = class Service { pkgConfig = this.pkg.vue if (pkgConfig && typeof pkgConfig !== 'object') { error( - `Error loading vue-cli config in ${chalk.bold(`package.json`)}: ` + - `the "vue" field should be an object.` + `Error loading vue-cli config in ${chalk.bold('package.json')}: ` + + 'the "vue" field should be an object.' ) pkgConfig = null } @@ -363,12 +363,12 @@ module.exports = class Service { if (fileConfig) { if (pkgConfig) { warn( - `"vue" field in package.json ignored ` + + '"vue" field in package.json ignored ' + `due to presence of ${chalk.bold('vue.config.js')}.` ) warn( `You should migrate it into ${chalk.bold('vue.config.js')} ` + - `and remove it from package.json.` + 'and remove it from package.json.' ) } resolved = fileConfig @@ -385,12 +385,12 @@ module.exports = class Service { if (typeof resolved.css.requireModuleExtension !== 'undefined') { warn( `You have set both "css.modules" and "css.requireModuleExtension" in ${chalk.bold('vue.config.js')}, ` + - `"css.modules" will be ignored in favor of "css.requireModuleExtension".` + '"css.modules" will be ignored in favor of "css.requireModuleExtension".' ) } else { warn( `"css.modules" option in ${chalk.bold('vue.config.js')} ` + - `is deprecated now, please use "css.requireModuleExtension" instead.` + 'is deprecated now, please use "css.requireModuleExtension" instead.' ) resolved.css.requireModuleExtension = !resolved.css.modules } diff --git a/packages/@vue/cli-service/lib/commands/build/formatStats.js b/packages/@vue/cli-service/lib/commands/build/formatStats.js index a6dec9554f..be83e5e82b 100644 --- a/packages/@vue/cli-service/lib/commands/build/formatStats.js +++ b/packages/@vue/cli-service/lib/commands/build/formatStats.js @@ -55,18 +55,18 @@ module.exports = function formatStats (stats, dir, api) { ui.div( makeRow( - chalk.cyan.bold(`File`), - chalk.cyan.bold(`Size`), - chalk.cyan.bold(`Gzipped`) - ) + `\n\n` + + chalk.cyan.bold('File'), + chalk.cyan.bold('Size'), + chalk.cyan.bold('Gzipped') + ) + '\n\n' + assets.map(asset => makeRow( /js$/.test(asset.name) ? chalk.green(path.join(dir, asset.name)) : chalk.blue(path.join(dir, asset.name)), formatSize(asset.size), getGzippedSize(asset) - )).join(`\n`) + )).join('\n') ) - return `${ui.toString()}\n\n ${chalk.gray(`Images and other types of assets omitted.`)}\n` + return `${ui.toString()}\n\n ${chalk.gray('Images and other types of assets omitted.')}\n` } diff --git a/packages/@vue/cli-service/lib/commands/build/index.js b/packages/@vue/cli-service/lib/commands/build/index.js index 7354731ec5..9a37a71043 100644 --- a/packages/@vue/cli-service/lib/commands/build/index.js +++ b/packages/@vue/cli-service/lib/commands/build/index.js @@ -24,21 +24,21 @@ module.exports = (api, options) => { description: 'build for production', usage: 'vue-cli-service build [options] [entry|pattern]', options: { - '--mode': `specify env mode (default: production)`, + '--mode': 'specify env mode (default: production)', '--dest': `specify output directory (default: ${options.outputDir})`, - '--modern': `build app targeting modern browsers with auto fallback`, - '--no-unsafe-inline': `build app without introducing inline scripts`, + '--modern': 'build app targeting modern browsers with auto fallback', + '--no-unsafe-inline': 'build app without introducing inline scripts', '--target': `app | lib | wc | wc-async (default: ${defaults.target})`, '--inline-vue': 'include the Vue module in the final bundle of library or web component target', '--formats': `list of output formats for library builds (default: ${defaults.formats})`, - '--name': `name for lib or web-component mode (default: "name" in package.json or entry filename)`, - '--filename': `file name for output, only usable for 'lib' target (default: value of --name)`, - '--no-clean': `do not remove the dist directory before building the project`, - '--report': `generate report.html to help analyze bundle content`, + '--name': 'name for lib or web-component mode (default: "name" in package.json or entry filename)', + '--filename': 'file name for output, only usable for \'lib\' target (default: value of --name)', + '--no-clean': 'do not remove the dist directory before building the project', + '--report': 'generate report.html to help analyze bundle content', '--report-json': 'generate report.json to help analyze bundle content', - '--skip-plugins': `comma-separated list of plugin names to skip for this run`, - '--watch': `watch for changes`, - '--stdin': `close when stdin ends` + '--skip-plugins': 'comma-separated list of plugin names to skip for this run', + '--watch': 'watch for changes', + '--stdin': 'close when stdin ends' } }, async (args, rawArgs) => { for (const key in defaults) { @@ -81,9 +81,9 @@ module.exports = (api, options) => { if (args.modern) { const { warn } = require('@vue/cli-shared-utils') warn( - `Modern mode only works with default target (app). ` + - `For libraries or web components, use the browserslist ` + - `config to specify target browsers.` + 'Modern mode only works with default target (app). ' + + 'For libraries or web components, use the browserslist ' + + 'config to specify target browsers.' ) } await build(args, api, options) @@ -112,14 +112,14 @@ async function build (args, api, options) { if (args.target === 'app') { const bundleTag = args.modern ? args.modernBuild - ? `modern bundle ` - : `legacy bundle ` - : `` + ? 'modern bundle ' + : 'legacy bundle ' + : '' logWithSpinner(`Building ${bundleTag}for ${mode}...`) } else { const buildMode = buildModes[args.target] if (buildMode) { - const additionalParams = buildMode === 'library' ? ` (${args.formats})` : `` + const additionalParams = buildMode === 'library' ? ` (${args.formats})` : '' logWithSpinner(`Building for ${mode} as ${buildMode}${additionalParams}...`) } else { throw new Error(`Unknown build target: ${args.target}`) @@ -216,9 +216,9 @@ async function build (args, api, options) { if (args.target === 'app' && !isLegacyBuild) { if (!args.watch) { done(`Build complete. The ${chalk.cyan(targetDirShort)} directory is ready to be deployed.`) - info(`Check out deployment instructions at ${chalk.cyan(`https://cli.vuejs.org/guide/deployment.html`)}\n`) + info(`Check out deployment instructions at ${chalk.cyan('https://cli.vuejs.org/guide/deployment.html')}\n`) } else { - done(`Build complete. Watching for changes...`) + done('Build complete. Watching for changes...') } } } diff --git a/packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js b/packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js index cea6a23f0b..552f7f3c2b 100644 --- a/packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js +++ b/packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js @@ -13,8 +13,8 @@ module.exports = (api, { entry, name, formats, filename, 'inline-vue': inlineVue if (!fs.existsSync(fullEntryPath)) { abort( - `Failed to resolve lib entry: ${entry}${entry === `src/App.vue` ? ' (default)' : ''}. ` + - `Make sure to specify the correct entry file.` + `Failed to resolve lib entry: ${entry}${entry === 'src/App.vue' ? ' (default)' : ''}. ` + + 'Make sure to specify the correct entry file.' ) } @@ -119,7 +119,7 @@ module.exports = (api, { entry, name, formats, filename, 'inline-vue': inlineVue // libraryTarget: 'esm' or target: 'universal' // https://github.com/webpack/webpack/issues/6522 // https://github.com/webpack/webpack/issues/6525 - globalObject: `(typeof self !== 'undefined' ? self : this)` + globalObject: '(typeof self !== \'undefined\' ? self : this)' }, rawConfig.output, { filename: `${entryName}.js`, chunkFilename: `${entryName}.[name].js`, diff --git a/packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js b/packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js index 037e88c717..ef2daacbce 100644 --- a/packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js +++ b/packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js @@ -17,7 +17,7 @@ module.exports = (api, { target, entry, name, 'inline-vue': inlineVue }) => { const webpackMajor = semver.major(webpack.version) const vueMajor = require('../../util/getVueMajor')(cwd) if (vueMajor === 3) { - abort(`Vue 3 support of the web component target is still under development.`) + abort('Vue 3 support of the web component target is still under development.') } const isAsync = /async/.test(target) @@ -35,13 +35,13 @@ module.exports = (api, { target, entry, name, 'inline-vue': inlineVue }) => { libName = name || fileToComponentName('', resolvedFiles[0]).kebabName prefix = '' if (libName.indexOf('-') < 0) { - abort(`--name must contain a hyphen when building a single web component.`) + abort('--name must contain a hyphen when building a single web component.') } } else { // multi mode libName = prefix = (name || api.service.pkg.name) if (!libName) { - abort(`--name is required when building multiple web components.`) + abort('--name is required when building multiple web components.') } } @@ -86,7 +86,7 @@ module.exports = (api, { target, entry, name, 'inline-vue': inlineVue }) => { config .plugin('demo-html') .use(require('html-webpack-plugin'), [{ - template: path.resolve(__dirname, `./demo-wc.html`), + template: path.resolve(__dirname, './demo-wc.html'), inject: false, filename: 'demo.html', libName, @@ -115,14 +115,14 @@ module.exports = (api, { target, entry, name, 'inline-vue': inlineVue }) => { { ...(inlineVue || { vue: 'Vue' }) } ].filter(Boolean) - const entryName = `${libName}${minify ? `.min` : ``}` + const entryName = `${libName}${minify ? '.min' : ''}` rawConfig.entry = { [entryName]: dynamicEntry.filePath } Object.assign(rawConfig.output, { filename: `${entryName}.js`, - chunkFilename: `${libName}.[name]${minify ? `.min` : ``}.js`, + chunkFilename: `${libName}.[name]${minify ? '.min' : ''}.js`, // use dynamic publicPath so this can be deployed anywhere // the actual path will be determined at runtime by checking // document.currentScript.src. diff --git a/packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js b/packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js index 21c640488e..04b30ba29f 100644 --- a/packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js +++ b/packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js @@ -29,7 +29,7 @@ const createElement = (prefix, component, file, isAsync) => { exports.fileToComponentName = (prefix, file) => { const basename = path.basename(file).replace(/\.(jsx?|vue)$/, '') const camelName = camelize(basename) - const kebabName = `${prefix ? `${prefix}-` : ``}${hyphenate(basename)}` + const kebabName = `${prefix ? `${prefix}-` : ''}${hyphenate(basename)}` return { basename, camelName, diff --git a/packages/@vue/cli-service/lib/commands/help.js b/packages/@vue/cli-service/lib/commands/help.js index f649885d7c..7c1b22942a 100644 --- a/packages/@vue/cli-service/lib/commands/help.js +++ b/packages/@vue/cli-service/lib/commands/help.js @@ -13,8 +13,8 @@ module.exports = (api, options) => { function logMainHelp () { console.log( - `\n Usage: vue-cli-service [options]\n` + - `\n Commands:\n` + '\n Usage: vue-cli-service [options]\n' + + '\n Commands:\n' ) const commands = api.service.commands const padLength = getPadLength(commands) @@ -29,7 +29,7 @@ module.exports = (api, options) => { } } console.log(`\n run ${ - chalk.green(`vue-cli-service help [command]`) + chalk.green('vue-cli-service help [command]') } for usage of a specific command.\n`) } @@ -42,7 +42,7 @@ module.exports = (api, options) => { console.log(`\n Usage: ${opts.usage}`) } if (opts.options) { - console.log(`\n Options:\n`) + console.log('\n Options:\n') const padLength = getPadLength(opts.options) for (const [flags, description] of Object.entries(opts.options)) { console.log(` ${ diff --git a/packages/@vue/cli-service/lib/commands/serve.js b/packages/@vue/cli-service/lib/commands/serve.js index 6d0903ce31..514b00abe0 100644 --- a/packages/@vue/cli-service/lib/commands/serve.js +++ b/packages/@vue/cli-service/lib/commands/serve.js @@ -18,15 +18,15 @@ module.exports = (api, options) => { description: 'start development server', usage: 'vue-cli-service serve [options] [entry]', options: { - '--open': `open browser on server start`, - '--copy': `copy url to clipboard on server start`, - '--stdin': `close when stdin ends`, - '--mode': `specify env mode (default: development)`, + '--open': 'open browser on server start', + '--copy': 'copy url to clipboard on server start', + '--stdin': 'close when stdin ends', + '--mode': 'specify env mode (default: development)', '--host': `specify host (default: ${defaults.host})`, '--port': `specify port (default: ${defaults.port})`, '--https': `use https (default: ${defaults.https})`, - '--public': `specify the public network URL for the HMR client`, - '--skip-plugins': `comma-separated list of plugin names to skip for this run` + '--public': 'specify the public network URL for the HMR client', + '--skip-plugins': 'comma-separated list of plugin names to skip for this run' } }, async function serve (args) { info('Starting development server...') @@ -61,7 +61,7 @@ module.exports = (api, options) => { // https://github.com/vuejs/vue-cli/issues/3539 webpackConfig .output - .globalObject(`(typeof self !== 'undefined' ? self : this)`) + .globalObject('(typeof self !== \'undefined\' ? self : this)') if (!process.env.VUE_CLI_TEST && options.devServer.progress !== false) { webpackConfig @@ -136,16 +136,16 @@ module.exports = (api, options) => { : isInContainer // can't infer public network url if inside a container... // use client-side inference (note this would break with non-root publicPath) - ? `` + ? '' // otherwise infer the url - : `?` + url.format({ + : '?' + url.format({ protocol, port, hostname: urls.lanUrlForConfig || 'localhost' }) + `&sockPath=${sockPath}` const devClients = [ // dev server client - require.resolve(`webpack-dev-server/client`) + sockjsUrl, + require.resolve('webpack-dev-server/client') + sockjsUrl, // hmr client require.resolve(projectDevServerOptions.hotOnly ? 'webpack/hot/only-dev-server' @@ -154,7 +154,7 @@ module.exports = (api, options) => { // `@vue/cli-overlay/dist/client` ] if (process.env.APPVEYOR) { - devClients.push(`webpack/hot/poll?500`) + devClients.push('webpack/hot/poll?500') } // inject dev/hot client addDevClientToEntry(webpackConfig, devClients) @@ -195,8 +195,8 @@ module.exports = (api, options) => { // launch editor support. // this works with vue-devtools & @vue/cli-overlay app.use('/__open-in-editor', launchEditorMiddleware(() => console.log( - `To specify an editor, specify the EDITOR env variable or ` + - `add "editor" field to your Vue project config.\n` + 'To specify an editor, specify the EDITOR env variable or ' + + 'add "editor" field to your Vue project config.\n' ))) // allow other plugins to register middlewares, e.g. PWA api.service.devServerConfigFns.forEach(fn => fn(app, server)) @@ -261,18 +261,18 @@ module.exports = (api, options) => { : urls.lanUrlForTerminal console.log() - console.log(` App running at:`) + console.log(' App running at:') console.log(` - Local: ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`) if (!isInContainer) { console.log(` - Network: ${chalk.cyan(networkUrl)}`) } else { console.log() - console.log(chalk.yellow(` It seems you are running Vue CLI inside a container.`)) + console.log(chalk.yellow(' It seems you are running Vue CLI inside a container.')) if (!publicUrl && options.publicPath && options.publicPath !== '/') { console.log() - console.log(chalk.yellow(` Since you are using a non-root publicPath, the hot-reload socket`)) - console.log(chalk.yellow(` will not be able to infer the correct URL to connect. You should`)) - console.log(chalk.yellow(` explicitly specify the URL via ${chalk.blue(`devServer.public`)}.`)) + console.log(chalk.yellow(' Since you are using a non-root publicPath, the hot-reload socket')) + console.log(chalk.yellow(' will not be able to infer the correct URL to connect. You should')) + console.log(chalk.yellow(` explicitly specify the URL via ${chalk.blue('devServer.public')}.`)) console.log() } console.log(chalk.yellow(` Access the dev server via ${chalk.cyan( @@ -285,12 +285,12 @@ module.exports = (api, options) => { isFirstCompile = false if (!isProduction) { - const buildCommand = hasProjectYarn(api.getCwd()) ? `yarn build` : hasProjectPnpm(api.getCwd()) ? `pnpm run build` : `npm run build` - console.log(` Note that the development build is not optimized.`) + const buildCommand = hasProjectYarn(api.getCwd()) ? 'yarn build' : hasProjectPnpm(api.getCwd()) ? 'pnpm run build' : 'npm run build' + console.log(' Note that the development build is not optimized.') console.log(` To create a production build, run ${chalk.cyan(buildCommand)}.`) } else { - console.log(` App is served in production mode.`) - console.log(` Note this is for preview or E2E testing only.`) + console.log(' App is served in production mode.') + console.log(' Note this is for preview or E2E testing only.') } console.log() @@ -351,8 +351,8 @@ function checkInContainer () { return true } const fs = require('fs') - if (fs.existsSync(`/proc/1/cgroup`)) { - const content = fs.readFileSync(`/proc/1/cgroup`, 'utf-8') + if (fs.existsSync('/proc/1/cgroup')) { + const content = fs.readFileSync('/proc/1/cgroup', 'utf-8') return /:\/(lxc|docker|kubepods(\.slice)?)\//.test(content) } } diff --git a/packages/@vue/cli-service/lib/config/app.js b/packages/@vue/cli-service/lib/config/app.js index ad5d9aa758..4104ec048e 100644 --- a/packages/@vue/cli-service/lib/config/app.js +++ b/packages/@vue/cli-service/lib/config/app.js @@ -30,7 +30,7 @@ module.exports = (api, options) => { const getAssetPath = require('../util/getAssetPath') const outputFilename = getAssetPath( options, - `js/[name]${isLegacyBundle ? `-legacy` : ``}${isProd && options.filenameHashing ? '.[contenthash:8]' : ''}.js` + `js/[name]${isLegacyBundle ? '-legacy' : ''}${isProd && options.filenameHashing ? '.[contenthash:8]' : ''}.js` ) webpackConfig .output @@ -43,13 +43,13 @@ module.exports = (api, options) => { webpackConfig.optimization.splitChunks({ cacheGroups: { vendors: { - name: `chunk-vendors`, + name: 'chunk-vendors', test: /[\\/]node_modules[\\/]/, priority: -10, chunks: 'initial' }, common: { - name: `chunk-common`, + name: 'chunk-common', minChunks: 2, priority: -20, chunks: 'initial', @@ -61,13 +61,13 @@ module.exports = (api, options) => { webpackConfig.optimization.splitChunks({ cacheGroups: { defaultVendors: { - name: `chunk-vendors`, + name: 'chunk-vendors', test: /[\\/]node_modules[\\/]/, priority: -10, chunks: 'initial' }, common: { - name: `chunk-common`, + name: 'chunk-common', minChunks: 2, priority: -20, chunks: 'initial', @@ -129,7 +129,7 @@ module.exports = (api, options) => { const joinedHash = hash( Array.from(chunk.modulesIterable, m => m.id).join('_') ) - return `chunk-` + joinedHash + return 'chunk-' + joinedHash }]) } diff --git a/packages/@vue/cli-service/lib/util/checkWebpack.js b/packages/@vue/cli-service/lib/util/checkWebpack.js index aab5d83c11..a754bf2cd1 100644 --- a/packages/@vue/cli-service/lib/util/checkWebpack.js +++ b/packages/@vue/cli-service/lib/util/checkWebpack.js @@ -52,7 +52,7 @@ module.exports = function checkWebpack (cwd) { // Because many uses runtime sniffing to run conditional code for different webpack versions. if (customWebpackVersion !== requiredWebpackVersion) { // TODO: recommend users to use yarn force resolutions or pnpm hooks instead - warn(`Using "module-alias" to load custom webpack version.`) + warn('Using "module-alias" to load custom webpack version.') const webpack4Path = path.dirname(resolveModule('webpack/package.json', cwd)) moduleAlias.addAlias('webpack', (fromPath, request) => { diff --git a/packages/@vue/cli-service/lib/util/resolveLoaderError.js b/packages/@vue/cli-service/lib/util/resolveLoaderError.js index ba037a067e..b19bb41271 100644 --- a/packages/@vue/cli-service/lib/util/resolveLoaderError.js +++ b/packages/@vue/cli-service/lib/util/resolveLoaderError.js @@ -6,7 +6,7 @@ const rules = [ re: /Can't resolve '(.*loader)'/, msg: (e, match) => ( `Failed to resolve loader: ${chalk.yellow(match[1])}\n` + - `You may need to install it.` + 'You may need to install it.' ) } ] diff --git a/packages/@vue/cli-service/lib/util/validateWebpackConfig.js b/packages/@vue/cli-service/lib/util/validateWebpackConfig.js index dc61dce76b..f94a84e0a0 100644 --- a/packages/@vue/cli-service/lib/util/validateWebpackConfig.js +++ b/packages/@vue/cli-service/lib/util/validateWebpackConfig.js @@ -15,24 +15,24 @@ module.exports = function validateWebpackConfig ( // this is not supported because there's no way for us to give copy // plugin the correct value this way. throw new Error( - `\n\nConfiguration Error: ` + - `Avoid modifying webpack output.path directly. ` + - `Use the "outputDir" option instead.\n` + '\n\nConfiguration Error: ' + + 'Avoid modifying webpack output.path directly. ' + + 'Use the "outputDir" option instead.\n' ) } if (actualTargetDir === api.service.context) { throw new Error( - `\n\nConfiguration Error: ` + - `Do not set output directory to project root.\n` + '\n\nConfiguration Error: ' + + 'Do not set output directory to project root.\n' ) } if (target === 'app' && singleConfig.output.publicPath !== options.publicPath) { throw new Error( - `\n\nConfiguration Error: ` + - `Avoid modifying webpack output.publicPath directly. ` + - `Use the "publicPath" option instead.\n` + '\n\nConfiguration Error: ' + + 'Avoid modifying webpack output.publicPath directly. ' + + 'Use the "publicPath" option instead.\n' ) } } diff --git a/packages/@vue/cli-service/lib/webpack/CorsPlugin.js b/packages/@vue/cli-service/lib/webpack/CorsPlugin.js index 9cd317678b..e199a4cf33 100644 --- a/packages/@vue/cli-service/lib/webpack/CorsPlugin.js +++ b/packages/@vue/cli-service/lib/webpack/CorsPlugin.js @@ -8,7 +8,7 @@ module.exports = class CorsPlugin { } apply (compiler) { - const ID = `vue-cli-cors-plugin` + const ID = 'vue-cli-cors-plugin' compiler.hooks.compilation.tap(ID, compilation => { const ssri = require('ssri') diff --git a/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js b/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js index 874b361338..b3cb55c12e 100644 --- a/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js +++ b/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js @@ -3,7 +3,7 @@ const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') // https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc -const safariFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();` +const safariFix = '!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();' class ModernModePlugin { constructor ({ targetDir, isModernBuild, unsafeInline, jsDirectory }) { @@ -22,7 +22,7 @@ class ModernModePlugin { } applyLegacy (compiler) { - const ID = `vue-cli-legacy-bundle` + const ID = 'vue-cli-legacy-bundle' compiler.hooks.compilation.tap(ID, compilation => { HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tapAsync(ID, async (data, cb) => { // get stats, write to disk @@ -39,7 +39,7 @@ class ModernModePlugin { } applyModern (compiler) { - const ID = `vue-cli-modern-bundle` + const ID = 'vue-cli-modern-bundle' compiler.hooks.compilation.tap(ID, compilation => { HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tapAsync(ID, async (data, cb) => { // use `) // Test crossorigin="use-credentials" - await project.write('vue.config.js', 'module.exports = { crossorigin: \'use-credentials\' }') + await project.write('vue.config.js', `module.exports = { crossorigin: 'use-credentials' }`) const { stdout: stdout2 } = await project.run('vue-cli-service build --modern') expect(stdout2).toMatch('Build complete.') const index2 = await project.read('dist/index.html') diff --git a/packages/@vue/cli-service/__tests__/multiPage.spec.js b/packages/@vue/cli-service/__tests__/multiPage.spec.js index 7b4c23861b..441fe07537 100644 --- a/packages/@vue/cli-service/__tests__/multiPage.spec.js +++ b/packages/@vue/cli-service/__tests__/multiPage.spec.js @@ -55,8 +55,8 @@ async function makeProjectMultiPage (project) { `) const app = await project.read('src/App.vue') await project.write('src/App.vue', app.replace( - 'import HelloWorld from \'./components/HelloWorld.vue\'', - 'const HelloWorld = () => import(\'./components/HelloWorld.vue\')' + `import HelloWorld from './components/HelloWorld.vue'`, + `const HelloWorld = () => import('./components/HelloWorld.vue')` )) } @@ -68,22 +68,22 @@ test('serve w/ multi page', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, url, helpers }) => { - expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') + expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) await page.goto(`${url}/foo.html`) - expect(await helpers.getText('h1')).toMatch('Foo') + expect(await helpers.getText('h1')).toMatch(`Foo`) await page.goto(`${url}/bar.html`) - expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') + expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) await page.goto(`${url}foo`) - expect(await helpers.getText('h1')).toMatch('Foo') + expect(await helpers.getText('h1')).toMatch(`Foo`) await page.goto(`${url}bar`) - expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') + expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) await page.goto(`${url}foobar`) - expect(await helpers.getText('h1')).toMatch('FooBar') + expect(await helpers.getText('h1')).toMatch(`FooBar`) } ) }) diff --git a/packages/@vue/cli-service/__tests__/proxy.spec.js b/packages/@vue/cli-service/__tests__/proxy.spec.js index 7b99120ffb..cbaff7f9df 100644 --- a/packages/@vue/cli-service/__tests__/proxy.spec.js +++ b/packages/@vue/cli-service/__tests__/proxy.spec.js @@ -11,13 +11,13 @@ let mockServer2 beforeAll(done => { mockServer1 = createJSONServer({ - posts: [ - { id: 1, title: 'server-one', author: 'typicode' } + 'posts': [ + { 'id': 1, 'title': 'server-one', 'author': 'typicode' } ] }).listen(3000, () => { mockServer2 = createJSONServer({ - posts: [ - { id: 1, title: 'server-two', author: 'typicode' } + 'posts': [ + { 'id': 1, 'title': 'server-two', 'author': 'typicode' } ] }).listen(3001, done) }) diff --git a/packages/@vue/cli-service/__tests__/serve.spec.js b/packages/@vue/cli-service/__tests__/serve.spec.js index 2003c7e894..6eaa11926d 100644 --- a/packages/@vue/cli-service/__tests__/serve.spec.js +++ b/packages/@vue/cli-service/__tests__/serve.spec.js @@ -13,12 +13,12 @@ test('serve', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, nextUpdate, helpers }) => { - const msg = 'Welcome to Your Vue.js App' + const msg = `Welcome to Your Vue.js App` expect(await helpers.getText('h1')).toMatch(msg) // test hot reload - const file = await project.read('src/App.vue') - project.write('src/App.vue', file.replace(msg, 'Updated')) + const file = await project.read(`src/App.vue`) + project.write(`src/App.vue`, file.replace(msg, `Updated`)) await nextUpdate() // wait for child stdout update signal try { await page.waitForFunction(selector => { @@ -47,14 +47,14 @@ test('serve with router', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, helpers }) => { - expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') + expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) expect(await helpers.hasElement('#nav')).toBe(true) expect(await helpers.hasClass('a[href="#/"]', 'router-link-exact-active')).toBe(true) expect(await helpers.hasClass('a[href="#/about"]', 'router-link-exact-active')).toBe(false) await page.click('a[href="#/about"]') await sleep(1000) - expect(await helpers.getText('h1')).toMatch('This is an about page') + expect(await helpers.getText('h1')).toMatch(`This is an about page`) expect(await helpers.hasElement('#nav')).toBe(true) expect(await helpers.hasClass('a[href="#/"]', 'router-link-exact-active')).toBe(false) expect(await helpers.hasClass('a[href="#/about"]', 'router-link-exact-active')).toBe(true) @@ -71,14 +71,14 @@ test('serve with legacy router option', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, helpers }) => { - expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') + expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) expect(await helpers.hasElement('#nav')).toBe(true) expect(await helpers.hasClass('a[href="/"]', 'router-link-exact-active')).toBe(true) expect(await helpers.hasClass('a[href="/about"]', 'router-link-exact-active')).toBe(false) await page.click('a[href="/about"]') await sleep(1000) - expect(await helpers.getText('h1')).toMatch('This is an about page') + expect(await helpers.getText('h1')).toMatch(`This is an about page`) expect(await helpers.hasElement('#nav')).toBe(true) expect(await helpers.hasClass('a[href="/"]', 'router-link-exact-active')).toBe(false) expect(await helpers.hasClass('a[href="/about"]', 'router-link-exact-active')).toBe(true) @@ -94,7 +94,7 @@ test('serve with legacy vuex option', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, helpers }) => { - expect(await helpers.getText('h1')).toMatch('Welcome to Your Vue.js App') + expect(await helpers.getText('h1')).toMatch(`Welcome to Your Vue.js App`) } ) }) @@ -110,12 +110,12 @@ test('serve with inline entry', async () => { await serve( () => project.run('vue-cli-service serve src/index.js'), async ({ page, nextUpdate, helpers }) => { - const msg = 'Welcome to Your Vue.js App' + const msg = `Welcome to Your Vue.js App` expect(await helpers.getText('h1')).toMatch(msg) // test hot reload - const file = await project.read('src/App.vue') - project.write('src/App.vue', file.replace(msg, 'Updated')) + const file = await project.read(`src/App.vue`) + project.write(`src/App.vue`, file.replace(msg, `Updated`)) await nextUpdate() // wait for child stdout update signal try { await page.waitForFunction(selector => { @@ -143,12 +143,12 @@ test('serve with no public dir', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ page, nextUpdate, helpers }) => { - const msg = 'Welcome to Your Vue.js App' + const msg = `Welcome to Your Vue.js App` expect(await helpers.getText('h1')).toMatch(msg) // test hot reload - const file = await project.read('src/App.vue') - project.write('src/App.vue', file.replace(msg, 'Updated')) + const file = await project.read(`src/App.vue`) + project.write(`src/App.vue`, file.replace(msg, `Updated`)) await nextUpdate() // wait for child stdout update signal try { await page.waitForFunction(selector => { @@ -185,7 +185,7 @@ test('use a single websocket connection for HMR', async () => { await serve( () => project.run('vue-cli-service serve'), async ({ helpers, requestUrls }) => { - const msg = 'Welcome to Your Vue.js App' + const msg = `Welcome to Your Vue.js App` expect(await helpers.getText('h1')).toMatch(msg) expect(requestUrls.filter(url => url.includes('sockjs-node')).length).toBe(1) diff --git a/packages/@vue/cli-service/__tests__/serveVue3.spec.js b/packages/@vue/cli-service/__tests__/serveVue3.spec.js index 92a90360b2..1021497c22 100644 --- a/packages/@vue/cli-service/__tests__/serveVue3.spec.js +++ b/packages/@vue/cli-service/__tests__/serveVue3.spec.js @@ -11,13 +11,13 @@ test('serve with Vue 3', async () => { await serve( () => project.run('yarn serve'), async ({ page, nextUpdate, helpers }) => { - const msg = 'Welcome to Your Vue.js App' + const msg = `Welcome to Your Vue.js App` expect(await helpers.getText('h1')).toMatch(msg) expect(await page.evaluate(() => window.__VUE__)).toBeDefined() // test hot reload - const file = await project.read('src/App.vue') - project.write('src/App.vue', file.replace(msg, 'Updated')) + const file = await project.read(`src/App.vue`) + project.write(`src/App.vue`, file.replace(msg, `Updated`)) await nextUpdate() // wait for child stdout update signal try { await page.waitForFunction(selector => { diff --git a/packages/@vue/cli-service/generator/index.js b/packages/@vue/cli-service/generator/index.js index 09a91efcb0..ef6705182f 100644 --- a/packages/@vue/cli-service/generator/index.js +++ b/packages/@vue/cli-service/generator/index.js @@ -6,7 +6,7 @@ module.exports = (api, options) => { if (options.vueVersion === '3') { api.extendPackage({ dependencies: { - vue: '^3.0.4' + 'vue': '^3.0.4' }, devDependencies: { '@vue/compiler-sfc': '^3.0.4' @@ -15,7 +15,7 @@ module.exports = (api, options) => { } else { api.extendPackage({ dependencies: { - vue: '^2.6.11' + 'vue': '^2.6.11' }, devDependencies: { 'vue-template-compiler': '^2.6.11' @@ -25,8 +25,8 @@ module.exports = (api, options) => { api.extendPackage({ scripts: { - serve: 'vue-cli-service serve', - build: 'vue-cli-service build' + 'serve': 'vue-cli-service serve', + 'build': 'vue-cli-service build' }, browserslist: [ '> 1%', @@ -46,11 +46,11 @@ module.exports = (api, options) => { 'sass-loader': '^8.0.2' }, less: { - less: '^3.0.4', + 'less': '^3.0.4', 'less-loader': '^5.0.0' }, stylus: { - stylus: '^0.54.8', + 'stylus': '^0.54.8', 'stylus-loader': '^4.3.1' } } diff --git a/packages/@vue/cli-service/lib/Service.js b/packages/@vue/cli-service/lib/Service.js index 9d69613ff2..4fb59cd8a5 100644 --- a/packages/@vue/cli-service/lib/Service.js +++ b/packages/@vue/cli-service/lib/Service.js @@ -92,7 +92,7 @@ module.exports = class Service { loadEnv (mode) { const logger = debug('vue:env') - const basePath = path.resolve(this.context, `.env${mode ? `.${mode}` : ''}`) + const basePath = path.resolve(this.context, `.env${mode ? `.${mode}` : ``}`) const localPath = `${basePath}.local` const load = envPath => { @@ -278,8 +278,8 @@ module.exports = class Service { config.output.publicPath !== this.projectOptions.publicPath ) { throw new Error( - 'Do not modify webpack output.publicPath directly. ' + - 'Use the "publicPath" option in vue.config.js instead.' + `Do not modify webpack output.publicPath directly. ` + + `Use the "publicPath" option in vue.config.js instead.` ) } @@ -354,8 +354,8 @@ module.exports = class Service { pkgConfig = this.pkg.vue if (pkgConfig && typeof pkgConfig !== 'object') { error( - `Error loading vue-cli config in ${chalk.bold('package.json')}: ` + - 'the "vue" field should be an object.' + `Error loading vue-cli config in ${chalk.bold(`package.json`)}: ` + + `the "vue" field should be an object.` ) pkgConfig = null } @@ -363,12 +363,12 @@ module.exports = class Service { if (fileConfig) { if (pkgConfig) { warn( - '"vue" field in package.json ignored ' + + `"vue" field in package.json ignored ` + `due to presence of ${chalk.bold('vue.config.js')}.` ) warn( `You should migrate it into ${chalk.bold('vue.config.js')} ` + - 'and remove it from package.json.' + `and remove it from package.json.` ) } resolved = fileConfig @@ -385,12 +385,12 @@ module.exports = class Service { if (typeof resolved.css.requireModuleExtension !== 'undefined') { warn( `You have set both "css.modules" and "css.requireModuleExtension" in ${chalk.bold('vue.config.js')}, ` + - '"css.modules" will be ignored in favor of "css.requireModuleExtension".' + `"css.modules" will be ignored in favor of "css.requireModuleExtension".` ) } else { warn( `"css.modules" option in ${chalk.bold('vue.config.js')} ` + - 'is deprecated now, please use "css.requireModuleExtension" instead.' + `is deprecated now, please use "css.requireModuleExtension" instead.` ) resolved.css.requireModuleExtension = !resolved.css.modules } diff --git a/packages/@vue/cli-service/lib/commands/build/formatStats.js b/packages/@vue/cli-service/lib/commands/build/formatStats.js index be83e5e82b..a6dec9554f 100644 --- a/packages/@vue/cli-service/lib/commands/build/formatStats.js +++ b/packages/@vue/cli-service/lib/commands/build/formatStats.js @@ -55,18 +55,18 @@ module.exports = function formatStats (stats, dir, api) { ui.div( makeRow( - chalk.cyan.bold('File'), - chalk.cyan.bold('Size'), - chalk.cyan.bold('Gzipped') - ) + '\n\n' + + chalk.cyan.bold(`File`), + chalk.cyan.bold(`Size`), + chalk.cyan.bold(`Gzipped`) + ) + `\n\n` + assets.map(asset => makeRow( /js$/.test(asset.name) ? chalk.green(path.join(dir, asset.name)) : chalk.blue(path.join(dir, asset.name)), formatSize(asset.size), getGzippedSize(asset) - )).join('\n') + )).join(`\n`) ) - return `${ui.toString()}\n\n ${chalk.gray('Images and other types of assets omitted.')}\n` + return `${ui.toString()}\n\n ${chalk.gray(`Images and other types of assets omitted.`)}\n` } diff --git a/packages/@vue/cli-service/lib/commands/build/index.js b/packages/@vue/cli-service/lib/commands/build/index.js index 9a37a71043..7354731ec5 100644 --- a/packages/@vue/cli-service/lib/commands/build/index.js +++ b/packages/@vue/cli-service/lib/commands/build/index.js @@ -24,21 +24,21 @@ module.exports = (api, options) => { description: 'build for production', usage: 'vue-cli-service build [options] [entry|pattern]', options: { - '--mode': 'specify env mode (default: production)', + '--mode': `specify env mode (default: production)`, '--dest': `specify output directory (default: ${options.outputDir})`, - '--modern': 'build app targeting modern browsers with auto fallback', - '--no-unsafe-inline': 'build app without introducing inline scripts', + '--modern': `build app targeting modern browsers with auto fallback`, + '--no-unsafe-inline': `build app without introducing inline scripts`, '--target': `app | lib | wc | wc-async (default: ${defaults.target})`, '--inline-vue': 'include the Vue module in the final bundle of library or web component target', '--formats': `list of output formats for library builds (default: ${defaults.formats})`, - '--name': 'name for lib or web-component mode (default: "name" in package.json or entry filename)', - '--filename': 'file name for output, only usable for \'lib\' target (default: value of --name)', - '--no-clean': 'do not remove the dist directory before building the project', - '--report': 'generate report.html to help analyze bundle content', + '--name': `name for lib or web-component mode (default: "name" in package.json or entry filename)`, + '--filename': `file name for output, only usable for 'lib' target (default: value of --name)`, + '--no-clean': `do not remove the dist directory before building the project`, + '--report': `generate report.html to help analyze bundle content`, '--report-json': 'generate report.json to help analyze bundle content', - '--skip-plugins': 'comma-separated list of plugin names to skip for this run', - '--watch': 'watch for changes', - '--stdin': 'close when stdin ends' + '--skip-plugins': `comma-separated list of plugin names to skip for this run`, + '--watch': `watch for changes`, + '--stdin': `close when stdin ends` } }, async (args, rawArgs) => { for (const key in defaults) { @@ -81,9 +81,9 @@ module.exports = (api, options) => { if (args.modern) { const { warn } = require('@vue/cli-shared-utils') warn( - 'Modern mode only works with default target (app). ' + - 'For libraries or web components, use the browserslist ' + - 'config to specify target browsers.' + `Modern mode only works with default target (app). ` + + `For libraries or web components, use the browserslist ` + + `config to specify target browsers.` ) } await build(args, api, options) @@ -112,14 +112,14 @@ async function build (args, api, options) { if (args.target === 'app') { const bundleTag = args.modern ? args.modernBuild - ? 'modern bundle ' - : 'legacy bundle ' - : '' + ? `modern bundle ` + : `legacy bundle ` + : `` logWithSpinner(`Building ${bundleTag}for ${mode}...`) } else { const buildMode = buildModes[args.target] if (buildMode) { - const additionalParams = buildMode === 'library' ? ` (${args.formats})` : '' + const additionalParams = buildMode === 'library' ? ` (${args.formats})` : `` logWithSpinner(`Building for ${mode} as ${buildMode}${additionalParams}...`) } else { throw new Error(`Unknown build target: ${args.target}`) @@ -216,9 +216,9 @@ async function build (args, api, options) { if (args.target === 'app' && !isLegacyBuild) { if (!args.watch) { done(`Build complete. The ${chalk.cyan(targetDirShort)} directory is ready to be deployed.`) - info(`Check out deployment instructions at ${chalk.cyan('https://cli.vuejs.org/guide/deployment.html')}\n`) + info(`Check out deployment instructions at ${chalk.cyan(`https://cli.vuejs.org/guide/deployment.html`)}\n`) } else { - done('Build complete. Watching for changes...') + done(`Build complete. Watching for changes...`) } } } diff --git a/packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js b/packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js index 552f7f3c2b..cea6a23f0b 100644 --- a/packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js +++ b/packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js @@ -13,8 +13,8 @@ module.exports = (api, { entry, name, formats, filename, 'inline-vue': inlineVue if (!fs.existsSync(fullEntryPath)) { abort( - `Failed to resolve lib entry: ${entry}${entry === 'src/App.vue' ? ' (default)' : ''}. ` + - 'Make sure to specify the correct entry file.' + `Failed to resolve lib entry: ${entry}${entry === `src/App.vue` ? ' (default)' : ''}. ` + + `Make sure to specify the correct entry file.` ) } @@ -119,7 +119,7 @@ module.exports = (api, { entry, name, formats, filename, 'inline-vue': inlineVue // libraryTarget: 'esm' or target: 'universal' // https://github.com/webpack/webpack/issues/6522 // https://github.com/webpack/webpack/issues/6525 - globalObject: '(typeof self !== \'undefined\' ? self : this)' + globalObject: `(typeof self !== 'undefined' ? self : this)` }, rawConfig.output, { filename: `${entryName}.js`, chunkFilename: `${entryName}.[name].js`, diff --git a/packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js b/packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js index ef2daacbce..037e88c717 100644 --- a/packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js +++ b/packages/@vue/cli-service/lib/commands/build/resolveWcConfig.js @@ -17,7 +17,7 @@ module.exports = (api, { target, entry, name, 'inline-vue': inlineVue }) => { const webpackMajor = semver.major(webpack.version) const vueMajor = require('../../util/getVueMajor')(cwd) if (vueMajor === 3) { - abort('Vue 3 support of the web component target is still under development.') + abort(`Vue 3 support of the web component target is still under development.`) } const isAsync = /async/.test(target) @@ -35,13 +35,13 @@ module.exports = (api, { target, entry, name, 'inline-vue': inlineVue }) => { libName = name || fileToComponentName('', resolvedFiles[0]).kebabName prefix = '' if (libName.indexOf('-') < 0) { - abort('--name must contain a hyphen when building a single web component.') + abort(`--name must contain a hyphen when building a single web component.`) } } else { // multi mode libName = prefix = (name || api.service.pkg.name) if (!libName) { - abort('--name is required when building multiple web components.') + abort(`--name is required when building multiple web components.`) } } @@ -86,7 +86,7 @@ module.exports = (api, { target, entry, name, 'inline-vue': inlineVue }) => { config .plugin('demo-html') .use(require('html-webpack-plugin'), [{ - template: path.resolve(__dirname, './demo-wc.html'), + template: path.resolve(__dirname, `./demo-wc.html`), inject: false, filename: 'demo.html', libName, @@ -115,14 +115,14 @@ module.exports = (api, { target, entry, name, 'inline-vue': inlineVue }) => { { ...(inlineVue || { vue: 'Vue' }) } ].filter(Boolean) - const entryName = `${libName}${minify ? '.min' : ''}` + const entryName = `${libName}${minify ? `.min` : ``}` rawConfig.entry = { [entryName]: dynamicEntry.filePath } Object.assign(rawConfig.output, { filename: `${entryName}.js`, - chunkFilename: `${libName}.[name]${minify ? '.min' : ''}.js`, + chunkFilename: `${libName}.[name]${minify ? `.min` : ``}.js`, // use dynamic publicPath so this can be deployed anywhere // the actual path will be determined at runtime by checking // document.currentScript.src. diff --git a/packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js b/packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js index 04b30ba29f..21c640488e 100644 --- a/packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js +++ b/packages/@vue/cli-service/lib/commands/build/resolveWcEntry.js @@ -29,7 +29,7 @@ const createElement = (prefix, component, file, isAsync) => { exports.fileToComponentName = (prefix, file) => { const basename = path.basename(file).replace(/\.(jsx?|vue)$/, '') const camelName = camelize(basename) - const kebabName = `${prefix ? `${prefix}-` : ''}${hyphenate(basename)}` + const kebabName = `${prefix ? `${prefix}-` : ``}${hyphenate(basename)}` return { basename, camelName, diff --git a/packages/@vue/cli-service/lib/commands/help.js b/packages/@vue/cli-service/lib/commands/help.js index 7c1b22942a..f649885d7c 100644 --- a/packages/@vue/cli-service/lib/commands/help.js +++ b/packages/@vue/cli-service/lib/commands/help.js @@ -13,8 +13,8 @@ module.exports = (api, options) => { function logMainHelp () { console.log( - '\n Usage: vue-cli-service [options]\n' + - '\n Commands:\n' + `\n Usage: vue-cli-service [options]\n` + + `\n Commands:\n` ) const commands = api.service.commands const padLength = getPadLength(commands) @@ -29,7 +29,7 @@ module.exports = (api, options) => { } } console.log(`\n run ${ - chalk.green('vue-cli-service help [command]') + chalk.green(`vue-cli-service help [command]`) } for usage of a specific command.\n`) } @@ -42,7 +42,7 @@ module.exports = (api, options) => { console.log(`\n Usage: ${opts.usage}`) } if (opts.options) { - console.log('\n Options:\n') + console.log(`\n Options:\n`) const padLength = getPadLength(opts.options) for (const [flags, description] of Object.entries(opts.options)) { console.log(` ${ diff --git a/packages/@vue/cli-service/lib/commands/serve.js b/packages/@vue/cli-service/lib/commands/serve.js index 514b00abe0..6d0903ce31 100644 --- a/packages/@vue/cli-service/lib/commands/serve.js +++ b/packages/@vue/cli-service/lib/commands/serve.js @@ -18,15 +18,15 @@ module.exports = (api, options) => { description: 'start development server', usage: 'vue-cli-service serve [options] [entry]', options: { - '--open': 'open browser on server start', - '--copy': 'copy url to clipboard on server start', - '--stdin': 'close when stdin ends', - '--mode': 'specify env mode (default: development)', + '--open': `open browser on server start`, + '--copy': `copy url to clipboard on server start`, + '--stdin': `close when stdin ends`, + '--mode': `specify env mode (default: development)`, '--host': `specify host (default: ${defaults.host})`, '--port': `specify port (default: ${defaults.port})`, '--https': `use https (default: ${defaults.https})`, - '--public': 'specify the public network URL for the HMR client', - '--skip-plugins': 'comma-separated list of plugin names to skip for this run' + '--public': `specify the public network URL for the HMR client`, + '--skip-plugins': `comma-separated list of plugin names to skip for this run` } }, async function serve (args) { info('Starting development server...') @@ -61,7 +61,7 @@ module.exports = (api, options) => { // https://github.com/vuejs/vue-cli/issues/3539 webpackConfig .output - .globalObject('(typeof self !== \'undefined\' ? self : this)') + .globalObject(`(typeof self !== 'undefined' ? self : this)`) if (!process.env.VUE_CLI_TEST && options.devServer.progress !== false) { webpackConfig @@ -136,16 +136,16 @@ module.exports = (api, options) => { : isInContainer // can't infer public network url if inside a container... // use client-side inference (note this would break with non-root publicPath) - ? '' + ? `` // otherwise infer the url - : '?' + url.format({ + : `?` + url.format({ protocol, port, hostname: urls.lanUrlForConfig || 'localhost' }) + `&sockPath=${sockPath}` const devClients = [ // dev server client - require.resolve('webpack-dev-server/client') + sockjsUrl, + require.resolve(`webpack-dev-server/client`) + sockjsUrl, // hmr client require.resolve(projectDevServerOptions.hotOnly ? 'webpack/hot/only-dev-server' @@ -154,7 +154,7 @@ module.exports = (api, options) => { // `@vue/cli-overlay/dist/client` ] if (process.env.APPVEYOR) { - devClients.push('webpack/hot/poll?500') + devClients.push(`webpack/hot/poll?500`) } // inject dev/hot client addDevClientToEntry(webpackConfig, devClients) @@ -195,8 +195,8 @@ module.exports = (api, options) => { // launch editor support. // this works with vue-devtools & @vue/cli-overlay app.use('/__open-in-editor', launchEditorMiddleware(() => console.log( - 'To specify an editor, specify the EDITOR env variable or ' + - 'add "editor" field to your Vue project config.\n' + `To specify an editor, specify the EDITOR env variable or ` + + `add "editor" field to your Vue project config.\n` ))) // allow other plugins to register middlewares, e.g. PWA api.service.devServerConfigFns.forEach(fn => fn(app, server)) @@ -261,18 +261,18 @@ module.exports = (api, options) => { : urls.lanUrlForTerminal console.log() - console.log(' App running at:') + console.log(` App running at:`) console.log(` - Local: ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`) if (!isInContainer) { console.log(` - Network: ${chalk.cyan(networkUrl)}`) } else { console.log() - console.log(chalk.yellow(' It seems you are running Vue CLI inside a container.')) + console.log(chalk.yellow(` It seems you are running Vue CLI inside a container.`)) if (!publicUrl && options.publicPath && options.publicPath !== '/') { console.log() - console.log(chalk.yellow(' Since you are using a non-root publicPath, the hot-reload socket')) - console.log(chalk.yellow(' will not be able to infer the correct URL to connect. You should')) - console.log(chalk.yellow(` explicitly specify the URL via ${chalk.blue('devServer.public')}.`)) + console.log(chalk.yellow(` Since you are using a non-root publicPath, the hot-reload socket`)) + console.log(chalk.yellow(` will not be able to infer the correct URL to connect. You should`)) + console.log(chalk.yellow(` explicitly specify the URL via ${chalk.blue(`devServer.public`)}.`)) console.log() } console.log(chalk.yellow(` Access the dev server via ${chalk.cyan( @@ -285,12 +285,12 @@ module.exports = (api, options) => { isFirstCompile = false if (!isProduction) { - const buildCommand = hasProjectYarn(api.getCwd()) ? 'yarn build' : hasProjectPnpm(api.getCwd()) ? 'pnpm run build' : 'npm run build' - console.log(' Note that the development build is not optimized.') + const buildCommand = hasProjectYarn(api.getCwd()) ? `yarn build` : hasProjectPnpm(api.getCwd()) ? `pnpm run build` : `npm run build` + console.log(` Note that the development build is not optimized.`) console.log(` To create a production build, run ${chalk.cyan(buildCommand)}.`) } else { - console.log(' App is served in production mode.') - console.log(' Note this is for preview or E2E testing only.') + console.log(` App is served in production mode.`) + console.log(` Note this is for preview or E2E testing only.`) } console.log() @@ -351,8 +351,8 @@ function checkInContainer () { return true } const fs = require('fs') - if (fs.existsSync('/proc/1/cgroup')) { - const content = fs.readFileSync('/proc/1/cgroup', 'utf-8') + if (fs.existsSync(`/proc/1/cgroup`)) { + const content = fs.readFileSync(`/proc/1/cgroup`, 'utf-8') return /:\/(lxc|docker|kubepods(\.slice)?)\//.test(content) } } diff --git a/packages/@vue/cli-service/lib/config/app.js b/packages/@vue/cli-service/lib/config/app.js index 4104ec048e..ad5d9aa758 100644 --- a/packages/@vue/cli-service/lib/config/app.js +++ b/packages/@vue/cli-service/lib/config/app.js @@ -30,7 +30,7 @@ module.exports = (api, options) => { const getAssetPath = require('../util/getAssetPath') const outputFilename = getAssetPath( options, - `js/[name]${isLegacyBundle ? '-legacy' : ''}${isProd && options.filenameHashing ? '.[contenthash:8]' : ''}.js` + `js/[name]${isLegacyBundle ? `-legacy` : ``}${isProd && options.filenameHashing ? '.[contenthash:8]' : ''}.js` ) webpackConfig .output @@ -43,13 +43,13 @@ module.exports = (api, options) => { webpackConfig.optimization.splitChunks({ cacheGroups: { vendors: { - name: 'chunk-vendors', + name: `chunk-vendors`, test: /[\\/]node_modules[\\/]/, priority: -10, chunks: 'initial' }, common: { - name: 'chunk-common', + name: `chunk-common`, minChunks: 2, priority: -20, chunks: 'initial', @@ -61,13 +61,13 @@ module.exports = (api, options) => { webpackConfig.optimization.splitChunks({ cacheGroups: { defaultVendors: { - name: 'chunk-vendors', + name: `chunk-vendors`, test: /[\\/]node_modules[\\/]/, priority: -10, chunks: 'initial' }, common: { - name: 'chunk-common', + name: `chunk-common`, minChunks: 2, priority: -20, chunks: 'initial', @@ -129,7 +129,7 @@ module.exports = (api, options) => { const joinedHash = hash( Array.from(chunk.modulesIterable, m => m.id).join('_') ) - return 'chunk-' + joinedHash + return `chunk-` + joinedHash }]) } diff --git a/packages/@vue/cli-service/lib/util/checkWebpack.js b/packages/@vue/cli-service/lib/util/checkWebpack.js index a754bf2cd1..aab5d83c11 100644 --- a/packages/@vue/cli-service/lib/util/checkWebpack.js +++ b/packages/@vue/cli-service/lib/util/checkWebpack.js @@ -52,7 +52,7 @@ module.exports = function checkWebpack (cwd) { // Because many uses runtime sniffing to run conditional code for different webpack versions. if (customWebpackVersion !== requiredWebpackVersion) { // TODO: recommend users to use yarn force resolutions or pnpm hooks instead - warn('Using "module-alias" to load custom webpack version.') + warn(`Using "module-alias" to load custom webpack version.`) const webpack4Path = path.dirname(resolveModule('webpack/package.json', cwd)) moduleAlias.addAlias('webpack', (fromPath, request) => { diff --git a/packages/@vue/cli-service/lib/util/resolveLoaderError.js b/packages/@vue/cli-service/lib/util/resolveLoaderError.js index b19bb41271..ba037a067e 100644 --- a/packages/@vue/cli-service/lib/util/resolveLoaderError.js +++ b/packages/@vue/cli-service/lib/util/resolveLoaderError.js @@ -6,7 +6,7 @@ const rules = [ re: /Can't resolve '(.*loader)'/, msg: (e, match) => ( `Failed to resolve loader: ${chalk.yellow(match[1])}\n` + - 'You may need to install it.' + `You may need to install it.` ) } ] diff --git a/packages/@vue/cli-service/lib/util/validateWebpackConfig.js b/packages/@vue/cli-service/lib/util/validateWebpackConfig.js index f94a84e0a0..dc61dce76b 100644 --- a/packages/@vue/cli-service/lib/util/validateWebpackConfig.js +++ b/packages/@vue/cli-service/lib/util/validateWebpackConfig.js @@ -15,24 +15,24 @@ module.exports = function validateWebpackConfig ( // this is not supported because there's no way for us to give copy // plugin the correct value this way. throw new Error( - '\n\nConfiguration Error: ' + - 'Avoid modifying webpack output.path directly. ' + - 'Use the "outputDir" option instead.\n' + `\n\nConfiguration Error: ` + + `Avoid modifying webpack output.path directly. ` + + `Use the "outputDir" option instead.\n` ) } if (actualTargetDir === api.service.context) { throw new Error( - '\n\nConfiguration Error: ' + - 'Do not set output directory to project root.\n' + `\n\nConfiguration Error: ` + + `Do not set output directory to project root.\n` ) } if (target === 'app' && singleConfig.output.publicPath !== options.publicPath) { throw new Error( - '\n\nConfiguration Error: ' + - 'Avoid modifying webpack output.publicPath directly. ' + - 'Use the "publicPath" option instead.\n' + `\n\nConfiguration Error: ` + + `Avoid modifying webpack output.publicPath directly. ` + + `Use the "publicPath" option instead.\n` ) } } diff --git a/packages/@vue/cli-service/lib/webpack/CorsPlugin.js b/packages/@vue/cli-service/lib/webpack/CorsPlugin.js index e199a4cf33..9cd317678b 100644 --- a/packages/@vue/cli-service/lib/webpack/CorsPlugin.js +++ b/packages/@vue/cli-service/lib/webpack/CorsPlugin.js @@ -8,7 +8,7 @@ module.exports = class CorsPlugin { } apply (compiler) { - const ID = 'vue-cli-cors-plugin' + const ID = `vue-cli-cors-plugin` compiler.hooks.compilation.tap(ID, compilation => { const ssri = require('ssri') diff --git a/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js b/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js index b3cb55c12e..874b361338 100644 --- a/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js +++ b/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js @@ -3,7 +3,7 @@ const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') // https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc -const safariFix = '!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();' +const safariFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();` class ModernModePlugin { constructor ({ targetDir, isModernBuild, unsafeInline, jsDirectory }) { @@ -22,7 +22,7 @@ class ModernModePlugin { } applyLegacy (compiler) { - const ID = 'vue-cli-legacy-bundle' + const ID = `vue-cli-legacy-bundle` compiler.hooks.compilation.tap(ID, compilation => { HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tapAsync(ID, async (data, cb) => { // get stats, write to disk @@ -39,7 +39,7 @@ class ModernModePlugin { } applyModern (compiler) { - const ID = 'vue-cli-modern-bundle' + const ID = `vue-cli-modern-bundle` compiler.hooks.compilation.tap(ID, compilation => { HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tapAsync(ID, async (data, cb) => { // use