mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-22 21:10:33 +03:00
chore: fix lint
This commit is contained in:
@@ -23,9 +23,9 @@ describe(browserString, () => {
|
||||
|
||||
browser = await createBrowser(browserString, {
|
||||
BrowserStackLocal: { folder },
|
||||
extendPage(page) {
|
||||
extendPage (page) {
|
||||
return {
|
||||
async navigate(path) {
|
||||
async navigate (path) {
|
||||
// IMPORTANT: use (arrow) function with block'ed body
|
||||
// see: https://github.com/tunnckoCoreLabs/parse-function/issues/179
|
||||
await page.runAsyncScript((path) => {
|
||||
@@ -49,7 +49,7 @@ describe(browserString, () => {
|
||||
})
|
||||
}, path)
|
||||
},
|
||||
routeData() {
|
||||
routeData () {
|
||||
return page.runScript(() => ({
|
||||
path: window.$vueMeta.$route.path,
|
||||
query: window.$vueMeta.$route.query
|
||||
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@ Vue.use(Router)
|
||||
|
||||
const Post = () => import('./views/about.vue')
|
||||
|
||||
export default function createRouter() {
|
||||
export default function createRouter () {
|
||||
return new Router({
|
||||
mode: 'hash',
|
||||
base: '/',
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('client', () => {
|
||||
|
||||
const Component = Vue.extend({
|
||||
metaInfo: { title: 'Test' },
|
||||
render(h) {
|
||||
render (h) {
|
||||
return h('div', null, 'Test')
|
||||
}
|
||||
})
|
||||
@@ -157,10 +157,10 @@ describe('client', () => {
|
||||
localVue: Vue,
|
||||
mocks: {
|
||||
$router: {
|
||||
beforeEach(fn) {
|
||||
beforeEach (fn) {
|
||||
guards.before = fn
|
||||
},
|
||||
afterEach(fn) {
|
||||
afterEach (fn) {
|
||||
guards.after = fn
|
||||
}
|
||||
}
|
||||
@@ -192,10 +192,10 @@ describe('client', () => {
|
||||
localVue: Vue,
|
||||
mocks: {
|
||||
$router: {
|
||||
beforeEach(fn) {
|
||||
beforeEach (fn) {
|
||||
guards.before = fn
|
||||
},
|
||||
afterEach(fn) {
|
||||
afterEach (fn) {
|
||||
guards.after = fn
|
||||
}
|
||||
}
|
||||
@@ -225,21 +225,21 @@ describe('client', () => {
|
||||
// this component uses a computed prop to simulate a non-synchronous
|
||||
// metaInfo update like you would have with a Vuex mutation
|
||||
const Component = Vue.extend({
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
hiddenTheme: 'light'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
theme() {
|
||||
theme () {
|
||||
return this.hiddenTheme
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
beforeMount () {
|
||||
this.hiddenTheme = 'dark'
|
||||
},
|
||||
render: h => h('div'),
|
||||
metaInfo() {
|
||||
metaInfo () {
|
||||
return {
|
||||
htmlAttrs: {
|
||||
theme: this.theme
|
||||
@@ -270,21 +270,21 @@ describe('client', () => {
|
||||
document.body.appendChild(el)
|
||||
|
||||
const Component = Vue.extend({
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
hiddenTheme: 'light'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
theme() {
|
||||
theme () {
|
||||
return this.hiddenTheme
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
mounted () {
|
||||
this.hiddenTheme = 'dark'
|
||||
},
|
||||
render: h => h('div'),
|
||||
metaInfo() {
|
||||
metaInfo () {
|
||||
return {
|
||||
htmlAttrs: {
|
||||
theme: this.theme
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('getComponentOption', () => {
|
||||
test('calls a function option, injecting the component as context', () => {
|
||||
const component = new Vue({
|
||||
name: 'Foobar',
|
||||
someFunc() {
|
||||
someFunc () {
|
||||
return { opt: this.$options.name }
|
||||
}
|
||||
})
|
||||
@@ -90,13 +90,13 @@ describe('getComponentOption', () => {
|
||||
|
||||
localVue.component('meta-child', {
|
||||
foo: { bar: 'baz' },
|
||||
render(h) {
|
||||
render (h) {
|
||||
return h('div', this.$slots.default)
|
||||
}
|
||||
})
|
||||
|
||||
localVue.component('nometa-child', {
|
||||
render(h) {
|
||||
render (h) {
|
||||
return h('div', this.$slots.default)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -208,7 +208,7 @@ describe('getMetaInfo', () => {
|
||||
{ charset: 'utf-8' }
|
||||
]
|
||||
},
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
helloWorldText: 'Function World'
|
||||
}
|
||||
@@ -648,7 +648,7 @@ describe('getMetaInfo', () => {
|
||||
|
||||
test('no errors when metaInfo returns nothing', () => {
|
||||
const component = new Vue({
|
||||
metaInfo() {},
|
||||
metaInfo () {},
|
||||
el: document.createElement('div'),
|
||||
render: h => h('div', null, [])
|
||||
})
|
||||
|
||||
@@ -90,7 +90,7 @@ describe('plugin', () => {
|
||||
})
|
||||
|
||||
const Component = Vue.component('test-component', {
|
||||
metaInfo() {
|
||||
metaInfo () {
|
||||
return {
|
||||
title: this.title
|
||||
}
|
||||
@@ -161,7 +161,7 @@ describe('plugin', () => {
|
||||
})
|
||||
|
||||
const Component = Vue.component('test-component', {
|
||||
metaInfo() {
|
||||
metaInfo () {
|
||||
return {
|
||||
title: this.title
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ import puppeteer from 'puppeteer-core'
|
||||
import ChromeDetector from './chrome'
|
||||
|
||||
export default class Browser {
|
||||
constructor() {
|
||||
constructor () {
|
||||
this.detector = new ChromeDetector()
|
||||
}
|
||||
|
||||
async start(options = {}) {
|
||||
async start (options = {}) {
|
||||
// https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
|
||||
const _opts = {
|
||||
args: [
|
||||
@@ -25,13 +25,13 @@ export default class Browser {
|
||||
this.browser = await puppeteer.launch(_opts)
|
||||
}
|
||||
|
||||
async close() {
|
||||
if (!this.browser) return
|
||||
async close () {
|
||||
if (!this.browser) { return }
|
||||
await this.browser.close()
|
||||
}
|
||||
|
||||
async page(url, globalName = 'vueMeta') {
|
||||
if (!this.browser) throw new Error('Please call start() before page(url)')
|
||||
async page (url, globalName = 'vueMeta') {
|
||||
if (!this.browser) { throw new Error('Please call start() before page(url)') }
|
||||
const page = await this.browser.newPage()
|
||||
|
||||
// pass on console messages
|
||||
@@ -69,7 +69,7 @@ export default class Browser {
|
||||
page.$vueMeta = await page.evaluateHandle(page.$globalHandle)
|
||||
|
||||
page.vueMeta = {
|
||||
async navigate(path, waitEnd = true) {
|
||||
async navigate (path, waitEnd = true) {
|
||||
const hook = page.evaluate(`
|
||||
new Promise(resolve =>
|
||||
${page.$globalHandle}.$once('routeChanged', resolve)
|
||||
@@ -85,7 +85,7 @@ export default class Browser {
|
||||
}
|
||||
return { hook }
|
||||
},
|
||||
routeData() {
|
||||
routeData () {
|
||||
return page.evaluate(($vueMeta) => {
|
||||
return {
|
||||
path: $vueMeta.$route.path,
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import { createRenderer } from 'vue-server-renderer'
|
||||
|
||||
const renderer = createRenderer()
|
||||
|
||||
export function webpackRun(config) {
|
||||
export function webpackRun (config) {
|
||||
const compiler = webpack(config)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -21,7 +21,7 @@ export function webpackRun(config) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function buildFixture(fixture, config = {}) {
|
||||
export async function buildFixture (fixture, config = {}) {
|
||||
if (!fixture) {
|
||||
throw new Error('buildFixture should be called with a fixture name')
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export async function buildFixture(fixture, config = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
export function createWebpackConfig(config = {}) {
|
||||
export function createWebpackConfig (config = {}) {
|
||||
const publicPath = '.vue-meta'
|
||||
|
||||
return {
|
||||
|
||||
+12
-12
@@ -17,19 +17,19 @@ const newLineRegex = /\r?\n/
|
||||
* https://github.com/gwuhaolin/chrome-finder
|
||||
*/
|
||||
export default class ChromeDetector {
|
||||
constructor() {
|
||||
constructor () {
|
||||
this.platform = isWsl ? 'wsl' : process.platform
|
||||
}
|
||||
|
||||
detect(platform = this.platform) {
|
||||
detect (platform = this.platform) {
|
||||
const handler = this[platform]
|
||||
if (typeof handler !== 'function') {
|
||||
throw new Error(`${platform} is not supported.`)
|
||||
throw new TypeError(`${platform} is not supported.`)
|
||||
}
|
||||
return this[platform]()[0]
|
||||
}
|
||||
|
||||
darwin() {
|
||||
darwin () {
|
||||
const suffixes = [
|
||||
'/Contents/MacOS/Chromium',
|
||||
'/Contents/MacOS/Google Chrome Canary',
|
||||
@@ -88,7 +88,7 @@ export default class ChromeDetector {
|
||||
* 2. Look into the directories where .desktop are saved on gnome based distro's
|
||||
* 3. Look for google-chrome-stable & google-chrome executables by using the which command
|
||||
*/
|
||||
linux() {
|
||||
linux () {
|
||||
let installations = []
|
||||
// 1. Look into CHROME_PATH env variable
|
||||
const customChromePath = this.resolveChromePath()
|
||||
@@ -147,7 +147,7 @@ export default class ChromeDetector {
|
||||
return this.sort(uniq(installations.filter(Boolean)), priorities)
|
||||
}
|
||||
|
||||
wsl() {
|
||||
wsl () {
|
||||
// Manually populate the environment variables assuming it's the default config
|
||||
process.env.LOCALAPPDATA = this.getLocalAppDataPath(process.env.PATH)
|
||||
process.env.PROGRAMFILES = '/mnt/c/Program Files'
|
||||
@@ -155,7 +155,7 @@ export default class ChromeDetector {
|
||||
return this.win32()
|
||||
}
|
||||
|
||||
win32() {
|
||||
win32 () {
|
||||
const installations = []
|
||||
const sep = path.sep
|
||||
const suffixes = [
|
||||
@@ -185,7 +185,7 @@ export default class ChromeDetector {
|
||||
return installations
|
||||
}
|
||||
|
||||
resolveChromePath() {
|
||||
resolveChromePath () {
|
||||
if (this.canAccess(process.env.CHROME_PATH)) {
|
||||
return process.env.CHROME_PATH
|
||||
}
|
||||
@@ -198,13 +198,13 @@ export default class ChromeDetector {
|
||||
}
|
||||
}
|
||||
|
||||
getLocalAppDataPath(path) {
|
||||
getLocalAppDataPath (path) {
|
||||
const userRegExp = /\/mnt\/([a-z])\/Users\/([^/:]+)\/AppData\//
|
||||
const results = userRegExp.exec(path) || []
|
||||
return `/mnt/${results[1]}/Users/${results[2]}/AppData/Local`
|
||||
}
|
||||
|
||||
sort(installations, priorities) {
|
||||
sort (installations, priorities) {
|
||||
const defaultPriority = 10
|
||||
return installations
|
||||
.map((inst) => {
|
||||
@@ -219,7 +219,7 @@ export default class ChromeDetector {
|
||||
.map(pair => pair.path)
|
||||
}
|
||||
|
||||
canAccess(file) {
|
||||
canAccess (file) {
|
||||
if (!file) {
|
||||
return false
|
||||
}
|
||||
@@ -231,7 +231,7 @@ export default class ChromeDetector {
|
||||
}
|
||||
}
|
||||
|
||||
findChromeExecutables(folder) {
|
||||
findChromeExecutables (folder) {
|
||||
const argumentsRegex = /(^[^ ]+).*/ // Take everything up to the first space
|
||||
const chromeExecRegex = '^Exec=/.*/(google-chrome|chrome|chromium)-.*'
|
||||
const installations = []
|
||||
|
||||
+2
-2
@@ -13,11 +13,11 @@ export {
|
||||
VueMetaServerPlugin
|
||||
}
|
||||
|
||||
export function getVue() {
|
||||
export function getVue () {
|
||||
return createLocalVue()
|
||||
}
|
||||
|
||||
export function loadVueMetaPlugin(browser, options, localVue = getVue()) {
|
||||
export function loadVueMetaPlugin (browser, options, localVue = getVue()) {
|
||||
if (browser) {
|
||||
localVue.use(VueMetaBrowserPlugin, Object.assign({}, defaultOptions, options))
|
||||
} else {
|
||||
|
||||
@@ -5,7 +5,7 @@ const metaInfoData = {
|
||||
add: {
|
||||
data: 'Hello World',
|
||||
expect: ['<title>Hello World</title>'],
|
||||
test(side, defaultTest) {
|
||||
test (side, defaultTest) {
|
||||
if (side === 'client') {
|
||||
// client side vue-meta uses document.title and doesnt change the html
|
||||
return () => {
|
||||
@@ -65,7 +65,7 @@ const metaInfoData = {
|
||||
'<meta data-vue-meta="test" charset="utf-16">',
|
||||
'<meta data-vue-meta="test" property="a" content="c">'
|
||||
],
|
||||
test(side, defaultTest) {
|
||||
test (side, defaultTest) {
|
||||
if (side === 'client') {
|
||||
return () => {
|
||||
const tags = defaultTest()
|
||||
@@ -120,7 +120,7 @@ const metaInfoData = {
|
||||
'<script data-vue-meta="test" src="src" defer data-vmid="content"></script>',
|
||||
'<script data-vue-meta="test" src="src" defer data-body="true"></script>'
|
||||
],
|
||||
test(side, defaultTest) {
|
||||
test (side, defaultTest) {
|
||||
return () => {
|
||||
if (side === 'client') {
|
||||
for (const index in this.expect) {
|
||||
|
||||
Reference in New Issue
Block a user