Skip to content

Commit 0f2040d

Browse files
author
Guillaume Chau
committed
fix: lint errors
1 parent 9817316 commit 0f2040d

File tree

8 files changed

+32
-31
lines changed

8 files changed

+32
-31
lines changed

generator/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const chalk = require('chalk')
77

88
module.exports = (api, options, rootOptions) => {
99
if (!api.hasPlugin('router')) {
10-
throw new Error(`Please install router plugin with 'vue add router'.`)
10+
throw new Error('Please install router plugin with \'vue add router\'.')
1111
}
1212

1313
api.extendPackage({
@@ -43,16 +43,16 @@ module.exports = (api, options, rootOptions) => {
4343
const file = getFile(api, './src/main.js')
4444
if (file) {
4545
let contents = fs.readFileSync(file, { encoding: 'utf8' })
46-
contents = contents.replace(/import router from ('|")\.\/router(\.\w+)?('|")/, `import { createRouter } from $1./router$3`)
47-
contents = contents.replace(/import store from ('|")\.\/store(\.\w+)?('|")/, `import { createStore } from $1./store$3`)
48-
contents = contents.replace(/import ('|")\.\/registerServiceWorker('|")\n/, ``)
49-
contents = contents.replace(/const apolloProvider = createProvider\(({(.|\s)*?})?\)\n/, ``)
46+
contents = contents.replace(/import router from ('|")\.\/router(\.\w+)?('|")/, 'import { createRouter } from $1./router$3')
47+
contents = contents.replace(/import store from ('|")\.\/store(\.\w+)?('|")/, 'import { createStore } from $1./store$3')
48+
contents = contents.replace(/import ('|")\.\/registerServiceWorker('|")\n/, '')
49+
contents = contents.replace(/const apolloProvider = createProvider\(({(.|\s)*?})?\)\n/, '')
5050
contents = contents.replace(/new Vue\({((.|\s)*)}\)\.\$mount\(.*?\)/, `export async function createApp ({
5151
beforeApp = () => {},
5252
afterApp = () => {}
5353
} = {}) {
5454
const router = createRouter()
55-
${templateOptions.vuex ? `const store = createStore()` : ''}
55+
${templateOptions.vuex ? 'const store = createStore()' : ''}
5656
${templateOptions.apollo ? `const apolloProvider = createProvider({
5757
ssr: process.server,
5858
})` : ''}
@@ -88,7 +88,7 @@ module.exports = (api, options, rootOptions) => {
8888
let contents = fs.readFileSync(file, { encoding: 'utf8' })
8989
contents = contents.replace(/export default new Router\({((.|\s)+)}\)/, `export function createRouter () {
9090
return new Router({
91-
${contents.includes('mode:') ? '' : `mode: 'history',`}$1})
91+
${contents.includes('mode:') ? '' : 'mode: \'history\','}$1})
9292
}`)
9393
contents = contents.replace(/mode:\s*("|')(hash|abstract)("|'),/, '')
9494
fs.writeFileSync(file, contents, { encoding: 'utf8' })
@@ -127,7 +127,7 @@ module.exports = (api, options, rootOptions) => {
127127
contents = contents.replace(/export default app => {((.|\s)*)}/, `export default app => {$1
128128
ssrMiddleware(app, { prodOnly: true })
129129
}`)
130-
contents = `import ssrMiddleware from '@akryum/vue-cli-plugin-ssr/lib/app'\n` + contents
130+
contents = 'import ssrMiddleware from \'@akryum/vue-cli-plugin-ssr/lib/app\'\n' + contents
131131
fs.writeFileSync(file, contents, { encoding: 'utf8' })
132132
}
133133

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = (api, options) => {
8888
config.port = port
8989
config.host = host
9090

91-
return await createServer({
91+
return createServer({
9292
port,
9393
host,
9494
})

lib/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = (app, options) => {
1919
if (options.prodOnly && !isProd) return
2020

2121
const templatePath = config.templatePath
22+
const { publicPath } = config.service.projectOptions
2223

2324
try {
2425
// Vue bundle renderer
@@ -81,7 +82,7 @@ module.exports = (app, options) => {
8182
})
8283
}
8384

84-
if(config.applyDefaultServer){
85+
if (config.applyDefaultServer) {
8586
// Serve static files
8687
const serve = (filePath, cache) => express.static(filePath, {
8788
maxAge: cache && isProd ? config.staticCacheTtl : 0,
@@ -95,7 +96,6 @@ module.exports = (app, options) => {
9596
app.use('/service-worker.js', serve(config.serviceWorkerPath))
9697
}
9798
const serveStaticFiles = serve(config.distPath, true)
98-
const { publicPath } = config.service.projectOptions
9999
app.use(publicPath, (req, res, next) => {
100100
if (/index\.html/g.test(req.path)) {
101101
next()
@@ -153,7 +153,7 @@ module.exports = (app, options) => {
153153
res.status(context.httpCode)
154154
}
155155

156-
if(config.onRender){
156+
if (config.onRender) {
157157
config.onRender(res, context)
158158
}
159159

lib/dev-server.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Prom
7272
if (stats.hasErrors()) return
7373

7474
// Fix dev server render error when a custom path is used for the server-renderer bundles
75-
const ssrPlugin = (clientConfig.plugins.find((p) => (p.__pluginName || p.constructor.name) === 'ssr') || {}).options || {}
75+
const ssrPlugin = (clientConfig.plugins.find((p) => (p.__pluginName || p.constructor.name) === 'ssr') || {}).options || {}
7676

7777
clientManifest = JSON.parse(readFile(
7878
devMiddleware.fileSystem,
@@ -116,7 +116,7 @@ module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Prom
116116

117117
// Try to find ssr plugin config options
118118
// to fix dev server render error when a custom path is used for the server-renderer bundles
119-
const ssrPlugin = (serverConfig.plugins.find((p) => (p.__pluginName || p.constructor.name) === 'ssr') || {}).options || {}
119+
const ssrPlugin = (serverConfig.plugins.find((p) => (p.__pluginName || p.constructor.name) === 'ssr') || {}).options || {}
120120

121121
// read bundle generated by vue-ssr-webpack-plugin
122122
serverBundle = JSON.parse(readFile(
@@ -131,15 +131,15 @@ module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Prom
131131
function onCompilationCompleted () {
132132
if (firstRun) {
133133
firstRun = false
134-
if(config.copyUrlOnStart) {
134+
if (config.copyUrlOnStart) {
135135
require('clipboardy').write(url)
136136
copied = chalk.dim('(copied to clipboard)')
137137
}
138138
}
139139

140140
setTimeout(() => {
141141
console.log()
142-
console.log(` App running at:`)
142+
console.log(' App running at:')
143143
console.log(` - Local: ${chalk.cyan(url)} ${copied}`)
144144
})
145145
}

lib/loaders/css-context.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ module.exports.pitch = function (remainingRequest) {
2727

2828
if (isServer && isProduction) {
2929
const shared = [
30-
`// load the styles`,
30+
'// load the styles',
3131
`var content = require(${request});`,
3232
// content list format is [id, css, media, sourceMap]
33-
`if(typeof content === 'string') content = [[module.id, content, '']];`,
34-
`module.exports = content;`,
35-
`if(content.locals) module.exports = content.locals;`,
33+
'if(typeof content === \'string\') content = [[module.id, content, \'\']];',
34+
'module.exports = content;',
35+
'if(content.locals) module.exports = content.locals;',
3636
]
3737
// on the server: attach to Vue SSR context
3838
if (isVue) {
3939
// inside *.vue file: expose a function so it can be called in
4040
// component's lifecycle hooks
4141
return shared.concat([
42-
`// add CSS to SSR context`,
42+
'// add CSS to SSR context',
4343
`var add = require(${addStylesServerPath}).default`,
44-
`module.exports.__inject__ = function (context) {`,
44+
'module.exports.__inject__ = function (context) {',
4545
` add(${id}, content, ${isProduction}, context)`,
46-
`};`,
46+
'};',
4747
]).join('\n')
4848
} else {
4949
// normal import

lib/server.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ exports.createServer = ({
77
port,
88
host,
99
}) => {
10+
// eslint-disable-next-line no-async-promise-executor
1011
return new Promise(async (resolve, reject) => {
1112
const clustered = process.env.NODE_ENV === 'production' && config.clustered
1213

1314
// If the clustering mode is enabled and we are in the master process, create one worker per CPU core
1415
if (cluster.isMaster && clustered) {
15-
let cpus = require('os').cpus().length
16+
const cpus = require('os').cpus().length
1617
console.log(`[${new Date().toTimeString().split(' ')[0]}] Setting up clusters for ${cpus} cores`)
1718
for (let i = 0; i < cpus; i += 1) {
1819
cluster.fork()

lib/webpack.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ exports.chainWebpack = (webpackConfig) => {
5353
webpackConfig.entry('app').clear().add(config.entry(target))
5454

5555
webpackConfig.plugin('define').tap(args => {
56-
return [Object.assign(args[0], {'process.client': target === 'client', 'process.server': target === 'server'})]
56+
return [Object.assign(args[0], { 'process.client': target === 'client', 'process.server': target === 'server' })]
5757
})
5858

5959
webpackConfig.stats(isProd ? 'normal' : 'none')
6060
webpackConfig.devServer.stats('errors-only').quiet(true).noInfo(true)
6161

6262
if (isClient) {
6363
webpackConfig.plugin('ssr').use(VueSSRClientPlugin)
64-
webpackConfig.plugin('loader').use(WebpackBar, [{name: 'Client', color: 'green'}])
64+
webpackConfig.plugin('loader').use(WebpackBar, [{ name: 'Client', color: 'green' }])
6565

6666
webpackConfig.devtool(!isProd ? '#cheap-module-source-map' : undefined)
6767

@@ -71,10 +71,10 @@ exports.chainWebpack = (webpackConfig) => {
7171
})
7272
} else {
7373
webpackConfig.plugin('ssr').use(VueSSRServerPlugin)
74-
webpackConfig.plugin('loader').use(WebpackBar, [{name: 'Server', color: 'orange'}])
74+
webpackConfig.plugin('loader').use(WebpackBar, [{ name: 'Server', color: 'orange' }])
7575

7676
webpackConfig.devtool('source-map')
77-
webpackConfig.externals(nodeExternals({whitelist: config.nodeExternalsWhitelist}))
77+
webpackConfig.externals(nodeExternals({ whitelist: config.nodeExternalsWhitelist }))
7878
webpackConfig.output.libraryTarget('commonjs2'); webpackConfig.target('node')
7979
webpackConfig.optimization.splitChunks(false).minimize(false)
8080

ui.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ module.exports = api => {
1515

1616
api.describeTask({
1717
match: /vue-cli-service ssr:serve --mode production/,
18-
description: `Starts the included HTTP server for SSR in production`,
18+
description: 'Starts the included HTTP server for SSR in production',
1919
link: 'https://github.com/Akryum/vue-cli-plugin-ssr#usage',
2020
...taskCommon,
2121
})
2222

2323
api.describeTask({
2424
match: /vue-cli-service ssr:serve/,
25-
description: `Compiles and hot-reloads for development with SSR`,
25+
description: 'Compiles and hot-reloads for development with SSR',
2626
link: 'https://github.com/Akryum/vue-cli-plugin-ssr#usage',
2727
...taskCommon,
2828
})
2929

3030
api.describeTask({
3131
match: /vue-cli-service ssr:build/,
32-
description: `Compiles and minifies for production with SSR`,
32+
description: 'Compiles and minifies for production with SSR',
3333
link: 'https://github.com/Akryum/vue-cli-plugin-ssr#usage',
3434
})
3535
}

0 commit comments

Comments
 (0)