lint: Lint test/

This commit is contained in:
Atinux 2017-10-31 14:26:19 +01:00
parent b214972469
commit b132decf9d
39 changed files with 72 additions and 71 deletions

View File

@ -49,7 +49,7 @@
"scripts": { "scripts": {
"test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html", "test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"lint": "eslint --ext .js,.vue bin/** lib/** test/*.js --ignore-pattern app", "lint": "eslint --ext .js,.vue bin/** lib/** test/** --ignore-pattern app --ignore-pattern node_modules --ignore-pattern dist/",
"build": "rimraf dist/ && npm run build:nuxt && npm run build:core", "build": "rimraf dist/ && npm run build:nuxt && npm run build:core",
"build:nuxt": "rollup -c build/rollup.config.js --environment TARGET:nuxt", "build:nuxt": "rollup -c build/rollup.config.js --environment TARGET:nuxt",
"build:core": "rollup -c build/rollup.config.js --environment TARGET:core", "build:core": "rollup -c build/rollup.config.js --environment TARGET:core",

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
asyncData () { asyncData() {
return new Promise((resolve) => { return new Promise((resolve) => {
setTimeout(() => resolve({ name: 'Nuxt.js' }), 10) setTimeout(() => resolve({ name: 'Nuxt.js' }), 10)
}) })

View File

@ -10,8 +10,9 @@ const fetchData = () => {
} }
export default { export default {
async asyncData () { async asyncData() {
return await fetchData() const data = await fetchData()
return data
} }
} }
</script> </script>

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
async asyncData (context, callback) { async asyncData(context, callback) {
setTimeout(function () { setTimeout(function () {
callback(null, { name: 'Callback Nuxt.js' }) callback(null, { name: 'Callback Nuxt.js' })
}, 10) }, 10)

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
asyncData ({ req }) { asyncData({ req }) {
// Not for nuxt generate // Not for nuxt generate
if (req) { if (req) {
throw new Error('Error mouahahah') throw new Error('Error mouahahah')

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
asyncData ({ error }) { asyncData({ error }) {
error({ message: 'Custom error' }) error({ message: 'Custom error' })
} }
} }

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
fetch ({ redirect }) { fetch({ redirect }) {
return redirect('/') return redirect('/')
} }
} }

View File

@ -3,7 +3,7 @@
<script> <script>
export default { export default {
middleware: 'redirect', middleware: 'redirect',
created () { created() {
throw new Error('NOPE!') throw new Error('NOPE!')
} }
} }

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
fetch ({ beforeNuxtRender }) { fetch({ beforeNuxtRender }) {
if (process.server) { if (process.server) {
beforeNuxtRender(({ nuxtState }) => { beforeNuxtRender(({ nuxtState }) => {
nuxtState.test = true nuxtState.test = true

View File

@ -6,10 +6,10 @@
<script> <script>
export default { export default {
data () { data() {
return { answer: null } return { answer: null }
}, },
created () { created() {
this.answer = 42 this.answer = 42
} }
} }

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
asyncData ({ params, payload }) { asyncData({ params, payload }) {
if (payload) return payload if (payload) return payload
return { id: params.id } return { id: params.id }
} }

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
validate ({ query }) { validate({ query }) {
return Boolean(query.valid) return Boolean(query.valid)
} }
} }

View File

@ -3,7 +3,7 @@ export const state = () => ({
}) })
export const getters = { export const getters = {
baz (state) { baz(state) {
return state.baz return state.baz
} }
} }

View File

@ -3,7 +3,7 @@ export const state = () => ({
}) })
export const mutations = { export const mutations = {
increment (state) { increment(state) {
state.counter++ state.counter++
} }
} }

View File

@ -8,16 +8,16 @@
<script> <script>
export default { export default {
async asyncData({ route }) { async asyncData({ route }) {
const asyncData = {}; const asyncData = {}
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
setTimeout(() => { setTimeout(() => {
asyncData.name = 'parent' asyncData.name = 'parent'
resolve(); resolve()
}, 100) }, 100)
}); })
return asyncData; return asyncData
} }
} }
</script> </script>

View File

@ -5,16 +5,16 @@
<script> <script>
export default { export default {
async asyncData({ route }) { async asyncData({ route }) {
const asyncData = {}; const asyncData = {}
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
setTimeout(() => { setTimeout(() => {
asyncData.id = route.params.id; asyncData.id = route.params.id
resolve(); resolve()
}, 50) }, 50)
}); })
return asyncData; return asyncData
} }
} }
</script> </script>

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
validate ({ query }) { validate({ query }) {
return query.key === '12345' return query.key === '12345'
} }
} }

View File

@ -5,7 +5,7 @@
<script> <script>
/* eslint no-undef: 0 */ /* eslint no-undef: 0 */
export default { export default {
data () { data() {
throw new Error('test youch !') throw new Error('test youch !')
} }
} }

View File

@ -1,6 +1,6 @@
const path = require('path') const path = require('path')
module.exports = function basicModule (options, resolve) { module.exports = function basicModule(options, resolve) {
// Add vendor // Add vendor
this.addVendor('lodash') this.addVendor('lodash')

View File

@ -2,7 +2,7 @@
import Vue from 'vue' import Vue from 'vue'
function $reverseStr (str) { function $reverseStr(str) {
return str.split('').reverse().join('') return str.split('').reverse().join('')
} }

View File

@ -1,4 +1,4 @@
module.exports = function middlewareModule (options) { module.exports = function middlewareModule(options) {
// Empty module // Empty module
} }

View File

@ -1,9 +1,9 @@
module.exports = function middlewareModule (options) { module.exports = function middlewareModule(options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Add /api endpoint // Add /api endpoint
this.addServerMiddleware({ this.addServerMiddleware({
path: '/api', path: '/api',
handler (req, res, next) { handler(req, res, next) {
res.end('It works!') res.end('It works!')
} }
}) })

View File

@ -6,7 +6,7 @@ Vue.use(Router)
const indexPage = () => import('~/views/index.vue').then(m => m.default || m) const indexPage = () => import('~/views/index.vue').then(m => m.default || m)
const aboutPage = () => import('~/views/about.vue').then(m => m.default || m) const aboutPage = () => import('~/views/about.vue').then(m => m.default || m)
export function createRouter () { export function createRouter() {
return new Router({ return new Router({
mode: 'history', mode: 'history',
routes: [ routes: [

View File

@ -5,9 +5,9 @@
<script> <script>
export default { export default {
layout: 'custom', layout: 'custom',
mounted () { mounted() {
window.customMounted = (+window.customMounted) + 1 window.customMounted = (+window.customMounted) + 1
console.log('mounted') console.log('mounted') // eslint-disable-line no-console
} }
} }
</script> </script>

View File

@ -4,9 +4,9 @@
<script> <script>
export default { export default {
mounted () { mounted() {
window.indexMounted = (+window.indexMounted) + 1 window.indexMounted = (+window.indexMounted) + 1
console.log('mounted') console.log('mounted') // eslint-disable-line no-console
} }
} }
</script> </script>

View File

@ -8,10 +8,10 @@
import { nextId } from '@/lib/db' import { nextId } from '@/lib/db'
export default { export default {
data() { data() {
return { return {
id: nextId() id: nextId()
}
} }
}
} }
</script> </script>

View File

@ -8,7 +8,7 @@
const AsyncTest = () => import('@/components/test.vue').then((m) => m.default || m) const AsyncTest = () => import('@/components/test.vue').then((m) => m.default || m)
export default { export default {
components:{ components: {
AsyncTest AsyncTest
} }
} }

View File

@ -6,10 +6,10 @@
import { nextId } from '@/lib/db' import { nextId } from '@/lib/db'
export default { export default {
async asyncData() { async asyncData() {
return { return {
id: nextId() id: nextId()
}
} }
}
} }
</script> </script>

View File

@ -8,8 +8,8 @@
import test from '@/components/test' import test from '@/components/test'
export default { export default {
components : { components: {
test test
} }
} }
</script> </script>

View File

@ -6,10 +6,10 @@
import { nextId } from '@/lib/db' import { nextId } from '@/lib/db'
export default { export default {
data() { data() {
return { return {
id: nextId() id: nextId()
}
} }
}
} }
</script> </script>

View File

@ -6,9 +6,9 @@
import { nextId } from '@/lib/db' import { nextId } from '@/lib/db'
export default { export default {
async fetch({store}) { async fetch({store}) {
// We use store just as a shared reference // We use store just as a shared reference
store.__id = nextId() store.__id = nextId()
}, }
} }
</script> </script>

View File

@ -8,13 +8,13 @@ export const state = () => {
} }
export const mutations = { export const mutations = {
setId2 (state, id) { setId2(state, id) {
state.id2 = id state.id2 = id
} }
} }
export const actions = { export const actions = {
nuxtServerInit ({ commit, state }, { route }) { nuxtServerInit({ commit, state }, { route }) {
if (route.query.onServerInit === '1') { if (route.query.onServerInit === '1') {
commit('setId2', nextId()) commit('setId2', nextId())
} }

View File

@ -10,10 +10,10 @@ export default {
loading: false loading: false
}), }),
methods: { methods: {
start () { start() {
this.loading = true this.loading = true
}, },
finish () { finish() {
this.loading = false this.loading = false
} }
} }

View File

@ -1,3 +1,3 @@
export default function () { export default function () {
// NOOP! // NOOP!
} }

View File

@ -3,7 +3,7 @@ module.exports = {
router: { router: {
base: '/test/', base: '/test/',
middleware: 'noop', middleware: 'noop',
extendRoutes (routes) { extendRoutes(routes) {
return [ return [
...routes, ...routes,
{ {
@ -42,7 +42,7 @@ module.exports = {
analyzerMode: 'disabled', analyzerMode: 'disabled',
generateStatsFile: true generateStatsFile: true
}, },
extend (config, options) { extend(config, options) {
return Object.assign({}, config, { return Object.assign({}, config, {
devtool: 'nosources-source-map' devtool: 'nosources-source-map'
}) })

View File

@ -13,7 +13,7 @@ export default {
data() { data() {
return { processEnv: process.env.object } return { processEnv: process.env.object }
}, },
asyncData ({ env }) { asyncData({ env }) {
delete env.object delete env.object
return { env } return { env }
} }

View File

@ -4,7 +4,7 @@
<script> <script>
export default { export default {
fetch ({ error }) { fetch({ error }) {
error({ message: 'Nuxt Error', statusCode: 200 }) error({ message: 'Nuxt Error', statusCode: 200 })
} }
} }

View File

@ -5,7 +5,7 @@
<script> <script>
export default { export default {
middleware: 'user-agent', middleware: 'user-agent',
asyncData ({ userAgent }) { asyncData({ userAgent }) {
return { userAgent } return { userAgent }
} }
} }

View File

@ -8,7 +8,7 @@ const store = () => new Vuex.Store({
counter: 0 counter: 0
}, },
mutations: { mutations: {
increment (state) { increment(state) {
state.counter++ state.counter++
} }
} }