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": {
"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",
"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:nuxt": "rollup -c build/rollup.config.js --environment TARGET:nuxt",
"build:core": "rollup -c build/rollup.config.js --environment TARGET:core",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
module.exports = function middlewareModule (options) {
module.exports = function middlewareModule(options) {
return new Promise((resolve, reject) => {
// Add /api endpoint
this.addServerMiddleware({
path: '/api',
handler (req, res, next) {
handler(req, res, next) {
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 aboutPage = () => import('~/views/about.vue').then(m => m.default || m)
export function createRouter () {
export function createRouter() {
return new Router({
mode: 'history',
routes: [

View File

@ -5,9 +5,9 @@
<script>
export default {
layout: 'custom',
mounted () {
mounted() {
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>
export default {
mounted () {
mounted() {
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'
export default {
data() {
return {
id: nextId()
}
data() {
return {
id: nextId()
}
}
}
</script>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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