From b37c7cbd8d4abd0873db53b40ab46b5af5e690e3 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 5 Jun 2017 13:27:41 +0430 Subject: [PATCH] chore: eslint --- lib/module.js | 24 ++++++++++++------------ lib/render.js | 16 +++++++++------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/module.js b/lib/module.js index c62b65e813..630db411e2 100755 --- a/lib/module.js +++ b/lib/module.js @@ -2,21 +2,21 @@ import path from 'path' import fs from 'fs' -import {uniq} from 'lodash' +import { uniq } from 'lodash' import hash from 'hash-sum' -import {chainFn, sequence} from './utils' +import { chainFn, sequence } from './utils' const debug = require('debug')('nuxt:module') class Module { - constructor(nuxt) { + constructor (nuxt) { this.nuxt = nuxt this.options = nuxt.options this.requiredModules = [] this.initing = this.ready() } - async ready() { + async ready () { if (this.initing) { await this.initing return this @@ -26,7 +26,7 @@ class Module { return this } - addVendor(vendor) { + addVendor (vendor) { /* istanbul ignore if */ if (!vendor) { return @@ -34,7 +34,7 @@ class Module { this.options.build.vendor = uniq(this.options.build.vendor.concat(vendor)) } - addTemplate(template) { + addTemplate (template) { /* istanbul ignore if */ if (!template) { return @@ -60,7 +60,7 @@ class Module { return templateObj } - addPlugin(template) { + addPlugin (template) { const {dst} = this.addTemplate(template) // Add to nuxt plugins this.options.plugins.push({ @@ -69,24 +69,24 @@ class Module { }) } - 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) } - addModule(moduleOpts, requireOnce) { + addModule (moduleOpts, requireOnce) { /* istanbul ignore if */ if (!moduleOpts) { return diff --git a/lib/render.js b/lib/render.js index fda235b2c1..238c31a528 100644 --- a/lib/render.js +++ b/lib/render.js @@ -5,6 +5,7 @@ import serialize from 'serialize-javascript' import generateETag from 'etag' import fresh from 'fresh' import { getContext, setAnsiColors, encodeHtml } from './utils' + const debug = require('debug')('nuxt:render') // force blue color debug.color = 4 @@ -57,7 +58,7 @@ export async function render (req, res) { res.statusCode = 404 return res.end() } - const { html, error, redirected, resourceHints } = await this.renderRoute(req.url, context) + const {html, error, redirected, resourceHints} = await this.renderRoute(req.url, context) if (redirected) { return html } @@ -67,7 +68,7 @@ export async function render (req, res) { // ETag header if (!error && this.options.render.etag) { const etag = generateETag(html, this.options.render.etag) - if (fresh(req.headers, { etag })) { + if (fresh(req.headers, {etag})) { res.statusCode = 304 res.end() return @@ -75,7 +76,7 @@ export async function render (req, res) { res.setHeader('ETag', etag) } // HTTP2 push headers - if(!error && this.options.render.http2.push) { + if (!error && this.options.render.http2.push) { // Parse resourceHints to extract HTTP.2 prefetch/push headers // https://w3c.github.io/preload/#server-push-http-2 const regex = /link rel="([^"]*)" href="([^"]*)" as="([^"]*)"/g @@ -101,7 +102,7 @@ export async function render (req, res) { return err } const html = this.errorTemplate({ - /* istanbul ignore if */ + /* istanbul ignore if */ error: err, stack: ansiHTML(encodeHtml(err.stack)) }) @@ -133,7 +134,7 @@ export async function renderRoute (url, context = {}) { } const resourceHints = context.renderResourceHints() HEAD += resourceHints + context.renderStyles() - APP += `` + APP += `` APP += context.renderScripts() const html = this.appTemplate({ HTML_ATTRS: 'data-n-head-ssr ' + m.htmlAttrs.text(), @@ -168,14 +169,15 @@ export async function renderAndGetWindow (url, opts = {}) { runScripts: 'dangerously', beforeParse (window) { // Mock window.scrollTo - window.scrollTo = () => {} + window.scrollTo = () => { + } } } if (opts.virtualConsole !== false) { options.virtualConsole = new jsdom.VirtualConsole().sendTo(console) } url = url || 'http://localhost:3000' - const { window } = await jsdom.JSDOM.fromURL(url, options) + const {window} = await jsdom.JSDOM.fromURL(url, options) // If Nuxt could not be loaded (error from the server-side) const nuxtExists = window.document.body.innerHTML.includes('window.__NUXT__') if (!nuxtExists) {