diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 2fa55682ed..e80148bf64 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -25,7 +25,7 @@ debug.color = 2 // Force green color const glob = pify(Glob) export default class Builder extends Tapable { - constructor (nuxt) { + constructor(nuxt) { super() this.nuxt = nuxt this.isStatic = false // Flag to know if the build is for a generated app @@ -59,7 +59,7 @@ export default class Builder extends Tapable { this._buildStatus = STATUS.INITIAL } - get plugins () { + get plugins() { return this.options.plugins.map((p, i) => { if (typeof p === 'string') p = { src: p } return { @@ -70,7 +70,7 @@ export default class Builder extends Tapable { }) } - vendor () { + vendor() { return [ 'vue', 'vue-router', @@ -79,7 +79,7 @@ export default class Builder extends Tapable { ].concat(this.options.build.vendor).filter(v => v) } - vendorEntries () { + vendorEntries() { // Used for dll const vendor = this.vendor() const vendorEntries = {} @@ -94,11 +94,11 @@ export default class Builder extends Tapable { return vendorEntries } - forGenerate () { + forGenerate() { this.isStatic = true } - async build () { + async build() { // Avoid calling build() method multiple times when dev:true /* istanbul ignore if */ if (this._buildStatus === STATUS.BUILD_DONE && this.options.dev) { @@ -185,7 +185,7 @@ export default class Builder extends Tapable { return this } - async generateRoutesAndFiles () { + async generateRoutesAndFiles() { debug('Generating files...') // -- Templates -- let templatesFiles = [ @@ -375,7 +375,7 @@ export default class Builder extends Tapable { await this.applyPluginsAsync('generated', this) } - async webpackBuild () { + async webpackBuild() { debug('Building files...') const compilersOptions = [] @@ -484,7 +484,7 @@ export default class Builder extends Tapable { } } - webpackDev (compiler) { + webpackDev(compiler) { debug('Adding webpack middleware...') // Create webpack dev middleware @@ -516,7 +516,7 @@ export default class Builder extends Tapable { this.watchFiles() } - watchFiles () { + watchFiles() { const patterns = [ r(this.options.srcDir, 'layouts'), r(this.options.srcDir, 'store'), diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 3afd1cb79a..2983a3fa45 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -9,7 +9,7 @@ import Debug from 'debug' const debug = Debug('nuxt:generate') export default class Generator extends Tapable { - constructor (nuxt, builder) { + constructor(nuxt, builder) { super() this.nuxt = nuxt this.options = nuxt.options @@ -22,7 +22,7 @@ export default class Generator extends Tapable { this.distNuxtPath = join(this.distPath, (isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath)) } - async generate ({ build = true, init = true } = {}) { + async generate({ build = true, init = true } = {}) { const s = Date.now() let errors = [] @@ -103,7 +103,7 @@ export default class Generator extends Tapable { return { duration, errors } } - async initDist () { + async initDist() { // Clean destination folder await remove(this.distPath) debug('Destination folder cleaned') @@ -137,7 +137,7 @@ export default class Generator extends Tapable { debug('Static & build files copied') } - decorateWithPayloads (routes, generateRoutes) { + decorateWithPayloads(routes, generateRoutes) { let routeMap = {} // Fill routeMap for known routes routes.forEach((route) => { @@ -158,7 +158,7 @@ export default class Generator extends Tapable { return _.values(routeMap) } - async generateRoute ({ route, payload = {}, errors = [] }) { + async generateRoute({ route, payload = {}, errors = [] }) { let html try { diff --git a/lib/builder/webpack/vue-loader.config.js b/lib/builder/webpack/vue-loader.config.js index c0f70a7d20..f3a2aaa4a3 100644 --- a/lib/builder/webpack/vue-loader.config.js +++ b/lib/builder/webpack/vue-loader.config.js @@ -1,4 +1,4 @@ -export default function vueLoader () { +export default function vueLoader() { // https://vue-loader.vuejs.org/en const config = { postcss: this.options.build.postcss, diff --git a/lib/core/module.js b/lib/core/module.js index 726227b8c7..6aa43866b8 100755 --- a/lib/core/module.js +++ b/lib/core/module.js @@ -9,19 +9,19 @@ import Debug from 'debug' const debug = Debug('nuxt:module') export default class ModuleContainer extends Tapable { - constructor (nuxt) { + constructor(nuxt) { super() this.nuxt = nuxt this.options = nuxt.options this.requiredModules = [] } - async _ready () { + async _ready() { await sequence(this.options.modules, this.addModule.bind(this)) await this.applyPluginsAsync('ready', this) } - addVendor (vendor) { + addVendor(vendor) { /* istanbul ignore if */ if (!vendor) { return @@ -29,7 +29,7 @@ export default class ModuleContainer extends Tapable { this.options.build.vendor = uniq(this.options.build.vendor.concat(vendor)) } - addTemplate (template) { + addTemplate(template) { /* istanbul ignore if */ if (!template) { return @@ -56,7 +56,7 @@ export default class ModuleContainer extends Tapable { return templateObj } - addPlugin (template) { + addPlugin(template) { const { dst } = this.addTemplate(template) // Add to nuxt plugins this.options.plugins.unshift({ @@ -65,24 +65,24 @@ export default class ModuleContainer extends Tapable { }) } - addServerMiddleware (middleware) { + addServerMiddleware(middleware) { this.options.serverMiddleware.push(middleware) } - extendBuild (fn) { + extendBuild(fn) { this.options.build.extend = chainFn(this.options.build.extend, fn) } - extendRoutes (fn) { + extendRoutes(fn) { this.options.router.extendRoutes = chainFn(this.options.router.extendRoutes, fn) } - requireModule (moduleOpts) { + requireModule(moduleOpts) { // Require once return this.addModule(moduleOpts, true) } - async addModule (moduleOpts, requireOnce) { + async addModule(moduleOpts, requireOnce) { /* istanbul ignore if */ if (!moduleOpts) { return diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index 8ae6a2fc60..0eb4a5142c 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -12,7 +12,7 @@ const debug = Debug('nuxt:') debug.color = 5 export default class Nuxt extends Tapable { - constructor (_options = {}) { + constructor(_options = {}) { super() this.options = Options.from(_options) @@ -35,7 +35,7 @@ export default class Nuxt extends Tapable { this._ready = this.ready().catch(this.errorHandler) } - async ready () { + async ready() { if (this._ready) { return this._ready } @@ -48,7 +48,7 @@ export default class Nuxt extends Tapable { return this } - listen (port = 3000, host = 'localhost') { + listen(port = 3000, host = 'localhost') { return new Promise((resolve, reject) => { const server = this.renderer.app.listen({ port, host, exclusive: false }, err => { /* istanbul ignore if */ @@ -81,7 +81,7 @@ export default class Nuxt extends Tapable { }) } - errorHandler /* istanbul ignore next */() { + errorHandler() { // Apply plugins // eslint-disable-next-line no-console this.applyPluginsAsync('error', ...arguments).catch(console.error) @@ -101,7 +101,7 @@ export default class Nuxt extends Tapable { console.error(...arguments) } - resolvePath (path) { + resolvePath(path) { // Try to resolve using NPM resolve path first try { let resolvedPath = Module._resolveFilename(path, { paths: this.nodeModulePaths }) @@ -118,7 +118,7 @@ export default class Nuxt extends Tapable { return resolve(this.options.srcDir, path) } - async close (callback) { + async close(callback) { await this.applyPluginsAsync('close') /* istanbul ignore if */ diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 65132bcf74..7201a4551e 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -25,7 +25,7 @@ setAnsiColors(ansiHTML) let jsdom = null export default class Renderer extends Tapable { - constructor (nuxt) { + constructor(nuxt) { super() this.nuxt = nuxt this.options = nuxt.options @@ -51,7 +51,7 @@ export default class Renderer extends Tapable { } } - async _ready () { + async _ready() { await this.nuxt.applyPluginsAsync('renderer', this) // Setup nuxt middleware @@ -66,7 +66,7 @@ export default class Renderer extends Tapable { await this.applyPluginsAsync('ready', this) } - async loadResources (_fs = fs) { + async loadResources(_fs = fs) { let distPath = resolve(this.options.buildDir, 'dist') let updated = [] @@ -115,11 +115,11 @@ export default class Renderer extends Tapable { } } - get noSSR () { + get noSSR() { return this.options.render.ssr === false } - get isReady () { + get isReady() { if (this.noSSR) { return Boolean(this.resources.spaTemplate) } @@ -127,7 +127,7 @@ export default class Renderer extends Tapable { return Boolean(this.bundleRenderer && this.resources.ssrTemplate) } - get isResourcesAvailable () { + get isResourcesAvailable() { // Required for both if (!this.resources.clientManifest) { return false @@ -142,7 +142,7 @@ export default class Renderer extends Tapable { return Boolean(this.resources.ssrTemplate && this.resources.serverBundle) } - createRenderer () { + createRenderer() { // Ensure resources are available if (!this.isResourcesAvailable) { return @@ -164,7 +164,7 @@ export default class Renderer extends Tapable { }, this.options.render.bundleRenderer)) } - useMiddleware (m) { + useMiddleware(m) { // Resolve const $m = m let src @@ -188,11 +188,11 @@ export default class Renderer extends Tapable { this.app.use(path, handler) } - get publicPath () { + get publicPath() { return isUrl(this.options.build.publicPath) ? Options.defaults.build.publicPath : this.options.build.publicPath } - async setupMiddleware () { + async setupMiddleware() { // Apply setupMiddleware from modules first await this.applyPluginsAsync('setupMiddleware', this.app) @@ -229,7 +229,7 @@ export default class Renderer extends Tapable { if (this.options.debug) { this.useMiddleware({ path: '_open', - handler (req, res) { + handler(req, res) { // Lazy load open-in-editor const openInEditor = require('open-in-editor') const editor = openInEditor.configure(_this.options.editor) @@ -280,7 +280,7 @@ export default class Renderer extends Tapable { this.useMiddleware(this.errorMiddleware.bind(this)) } - async nuxtMiddleware (req, res, next) { + async nuxtMiddleware(req, res, next) { // Get context const context = getContext(req, res) res.statusCode = 200 @@ -338,7 +338,7 @@ export default class Renderer extends Tapable { } } - errorMiddleware (err, req, res, next) { + errorMiddleware(err, req, res, next) { // ensure statusCode, message and name fields err.statusCode = err.statusCode || 500 err.message = err.message || 'Nuxt Server Error' @@ -390,7 +390,7 @@ export default class Renderer extends Tapable { } } - async readSource (frame) { + async readSource(frame) { const serverBundle = this.resources.serverBundle // Remove webpack:/// & query string from the end @@ -468,7 +468,7 @@ export default class Renderer extends Tapable { } } - async renderRoute (url, context = {}) { + async renderRoute(url, context = {}) { /* istanbul ignore if */ if (!this.isReady) { return new Promise(resolve => { @@ -546,7 +546,7 @@ export default class Renderer extends Tapable { } } - async renderAndGetWindow (url, opts = {}) { + async renderAndGetWindow(url, opts = {}) { /* istanbul ignore if */ if (!jsdom) { try { @@ -561,7 +561,7 @@ export default class Renderer extends Tapable { let options = { resources: 'usable', // load subresources (https://github.com/tmpvar/jsdom#loading-subresources) runScripts: 'dangerously', - beforeParse (window) { + beforeParse(window) { // Mock window.scrollTo window.scrollTo = () => { }