mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
lint: Lint test/
This commit is contained in:
parent
b214972469
commit
b132decf9d
@ -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",
|
||||||
|
2
test/fixtures/basic/pages/async-data.vue
vendored
2
test/fixtures/basic/pages/async-data.vue
vendored
@ -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)
|
||||||
})
|
})
|
||||||
|
@ -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>
|
||||||
|
@ -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)
|
||||||
|
2
test/fixtures/basic/pages/error.vue
vendored
2
test/fixtures/basic/pages/error.vue
vendored
@ -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')
|
||||||
|
2
test/fixtures/basic/pages/error2.vue
vendored
2
test/fixtures/basic/pages/error2.vue
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
asyncData ({ error }) {
|
asyncData({ error }) {
|
||||||
error({ message: 'Custom error' })
|
error({ message: 'Custom error' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/basic/pages/redirect.vue
vendored
2
test/fixtures/basic/pages/redirect.vue
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
fetch ({ redirect }) {
|
fetch({ redirect }) {
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/basic/pages/redirect2.vue
vendored
2
test/fixtures/basic/pages/redirect2.vue
vendored
@ -3,7 +3,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
middleware: 'redirect',
|
middleware: 'redirect',
|
||||||
created () {
|
created() {
|
||||||
throw new Error('NOPE!')
|
throw new Error('NOPE!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/basic/pages/special-state.vue
vendored
2
test/fixtures/basic/pages/special-state.vue
vendored
@ -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
|
||||||
|
4
test/fixtures/basic/pages/stateful.vue
vendored
4
test/fixtures/basic/pages/stateful.vue
vendored
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/basic/pages/users/_id.vue
vendored
2
test/fixtures/basic/pages/users/_id.vue
vendored
@ -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 }
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/basic/pages/validate.vue
vendored
2
test/fixtures/basic/pages/validate.vue
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
validate ({ query }) {
|
validate({ query }) {
|
||||||
return Boolean(query.valid)
|
return Boolean(query.valid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/basic/store/foo/bar.js
vendored
2
test/fixtures/basic/store/foo/bar.js
vendored
@ -3,7 +3,7 @@ export const state = () => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
baz (state) {
|
baz(state) {
|
||||||
return state.baz
|
return state.baz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/basic/store/index.js
vendored
2
test/fixtures/basic/store/index.js
vendored
@ -3,7 +3,7 @@ export const state = () => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
increment (state) {
|
increment(state) {
|
||||||
state.counter++
|
state.counter++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
test/fixtures/children/pages/parent.vue
vendored
8
test/fixtures/children/pages/parent.vue
vendored
@ -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>
|
||||||
|
10
test/fixtures/children/pages/parent/_id.vue
vendored
10
test/fixtures/children/pages/parent/_id.vue
vendored
@ -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>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
validate ({ query }) {
|
validate({ query }) {
|
||||||
return query.key === '12345'
|
return query.key === '12345'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/debug/pages/error.vue
vendored
2
test/fixtures/debug/pages/error.vue
vendored
@ -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 !')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/module/modules/basic/index.js
vendored
2
test/fixtures/module/modules/basic/index.js
vendored
@ -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')
|
||||||
|
|
||||||
|
@ -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('')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
test/fixtures/module/modules/empty/index.js
vendored
2
test/fixtures/module/modules/empty/index.js
vendored
@ -1,4 +1,4 @@
|
|||||||
module.exports = function middlewareModule (options) {
|
module.exports = function middlewareModule(options) {
|
||||||
// Empty module
|
// Empty module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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!')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
2
test/fixtures/module/router.js
vendored
2
test/fixtures/module/router.js
vendored
@ -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: [
|
||||||
|
6
test/fixtures/spa/pages/custom.vue
vendored
6
test/fixtures/spa/pages/custom.vue
vendored
@ -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>
|
||||||
|
6
test/fixtures/spa/pages/index.vue
vendored
6
test/fixtures/spa/pages/index.vue
vendored
@ -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>
|
||||||
|
8
test/fixtures/ssr/components/test.vue
vendored
8
test/fixtures/ssr/components/test.vue
vendored
@ -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>
|
2
test/fixtures/ssr/pages/asyncComponent.vue
vendored
2
test/fixtures/ssr/pages/asyncComponent.vue
vendored
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
test/fixtures/ssr/pages/asyncData.vue
vendored
8
test/fixtures/ssr/pages/asyncData.vue
vendored
@ -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>
|
||||||
|
6
test/fixtures/ssr/pages/component.vue
vendored
6
test/fixtures/ssr/pages/component.vue
vendored
@ -8,8 +8,8 @@
|
|||||||
import test from '@/components/test'
|
import test from '@/components/test'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components : {
|
components: {
|
||||||
test
|
test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
8
test/fixtures/ssr/pages/data.vue
vendored
8
test/fixtures/ssr/pages/data.vue
vendored
@ -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>
|
||||||
|
8
test/fixtures/ssr/pages/fetch.vue
vendored
8
test/fixtures/ssr/pages/fetch.vue
vendored
@ -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>
|
||||||
|
4
test/fixtures/ssr/store/index.js
vendored
4
test/fixtures/ssr/store/index.js
vendored
@ -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())
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
test/fixtures/with-config/middleware/noop.js
vendored
4
test/fixtures/with-config/middleware/noop.js
vendored
@ -1,3 +1,3 @@
|
|||||||
export default function () {
|
export default function () {
|
||||||
// NOOP!
|
// NOOP!
|
||||||
}
|
}
|
||||||
|
4
test/fixtures/with-config/nuxt.config.js
vendored
4
test/fixtures/with-config/nuxt.config.js
vendored
@ -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'
|
||||||
})
|
})
|
||||||
|
2
test/fixtures/with-config/pages/env.vue
vendored
2
test/fixtures/with-config/pages/env.vue
vendored
@ -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 }
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/with-config/pages/error.vue
vendored
2
test/fixtures/with-config/pages/error.vue
vendored
@ -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 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
middleware: 'user-agent',
|
middleware: 'user-agent',
|
||||||
asyncData ({ userAgent }) {
|
asyncData({ userAgent }) {
|
||||||
return { userAgent }
|
return { userAgent }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/with-config/store/index.js
vendored
2
test/fixtures/with-config/store/index.js
vendored
@ -8,7 +8,7 @@ const store = () => new Vuex.Store({
|
|||||||
counter: 0
|
counter: 0
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
increment (state) {
|
increment(state) {
|
||||||
state.counter++
|
state.counter++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user