mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
lint: Lint test/
This commit is contained in:
parent
b214972469
commit
b132decf9d
@ -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",
|
||||
|
2
test/fixtures/basic/pages/async-data.vue
vendored
2
test/fixtures/basic/pages/async-data.vue
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
asyncData () {
|
||||
asyncData() {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => resolve({ name: 'Nuxt.js' }), 10)
|
||||
})
|
||||
|
@ -10,8 +10,9 @@ const fetchData = () => {
|
||||
}
|
||||
|
||||
export default {
|
||||
async asyncData () {
|
||||
return await fetchData()
|
||||
async asyncData() {
|
||||
const data = await fetchData()
|
||||
return data
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
async asyncData (context, callback) {
|
||||
async asyncData(context, callback) {
|
||||
setTimeout(function () {
|
||||
callback(null, { name: 'Callback Nuxt.js' })
|
||||
}, 10)
|
||||
|
2
test/fixtures/basic/pages/error.vue
vendored
2
test/fixtures/basic/pages/error.vue
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
asyncData ({ req }) {
|
||||
asyncData({ req }) {
|
||||
// Not for nuxt generate
|
||||
if (req) {
|
||||
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>
|
||||
export default {
|
||||
asyncData ({ error }) {
|
||||
asyncData({ 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>
|
||||
export default {
|
||||
fetch ({ redirect }) {
|
||||
fetch({ redirect }) {
|
||||
return redirect('/')
|
||||
}
|
||||
}
|
||||
|
2
test/fixtures/basic/pages/redirect2.vue
vendored
2
test/fixtures/basic/pages/redirect2.vue
vendored
@ -3,7 +3,7 @@
|
||||
<script>
|
||||
export default {
|
||||
middleware: 'redirect',
|
||||
created () {
|
||||
created() {
|
||||
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>
|
||||
export default {
|
||||
fetch ({ beforeNuxtRender }) {
|
||||
fetch({ beforeNuxtRender }) {
|
||||
if (process.server) {
|
||||
beforeNuxtRender(({ nuxtState }) => {
|
||||
nuxtState.test = true
|
||||
|
4
test/fixtures/basic/pages/stateful.vue
vendored
4
test/fixtures/basic/pages/stateful.vue
vendored
@ -6,10 +6,10 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return { answer: null }
|
||||
},
|
||||
created () {
|
||||
created() {
|
||||
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>
|
||||
export default {
|
||||
asyncData ({ params, payload }) {
|
||||
asyncData({ params, payload }) {
|
||||
if (payload) return payload
|
||||
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>
|
||||
export default {
|
||||
validate ({ query }) {
|
||||
validate({ query }) {
|
||||
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 = {
|
||||
baz (state) {
|
||||
baz(state) {
|
||||
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 = {
|
||||
increment (state) {
|
||||
increment(state) {
|
||||
state.counter++
|
||||
}
|
||||
}
|
||||
|
8
test/fixtures/children/pages/parent.vue
vendored
8
test/fixtures/children/pages/parent.vue
vendored
@ -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>
|
||||
|
10
test/fixtures/children/pages/parent/_id.vue
vendored
10
test/fixtures/children/pages/parent/_id.vue
vendored
@ -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>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
validate ({ query }) {
|
||||
validate({ query }) {
|
||||
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>
|
||||
/* eslint no-undef: 0 */
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
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')
|
||||
|
||||
module.exports = function basicModule (options, resolve) {
|
||||
module.exports = function basicModule(options, resolve) {
|
||||
// Add vendor
|
||||
this.addVendor('lodash')
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import Vue from 'vue'
|
||||
|
||||
function $reverseStr (str) {
|
||||
function $reverseStr(str) {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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!')
|
||||
}
|
||||
})
|
||||
|
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 aboutPage = () => import('~/views/about.vue').then(m => m.default || m)
|
||||
|
||||
export function createRouter () {
|
||||
export function createRouter() {
|
||||
return new Router({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
|
6
test/fixtures/spa/pages/custom.vue
vendored
6
test/fixtures/spa/pages/custom.vue
vendored
@ -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>
|
||||
|
6
test/fixtures/spa/pages/index.vue
vendored
6
test/fixtures/spa/pages/index.vue
vendored
@ -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>
|
||||
|
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'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
id: nextId()
|
||||
}
|
||||
data() {
|
||||
return {
|
||||
id: nextId()
|
||||
}
|
||||
}
|
||||
}
|
||||
</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)
|
||||
|
||||
export default {
|
||||
components:{
|
||||
components: {
|
||||
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'
|
||||
|
||||
export default {
|
||||
async asyncData() {
|
||||
return {
|
||||
id: nextId()
|
||||
}
|
||||
async asyncData() {
|
||||
return {
|
||||
id: nextId()
|
||||
}
|
||||
}
|
||||
}
|
||||
</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'
|
||||
|
||||
export default {
|
||||
components : {
|
||||
test
|
||||
}
|
||||
components: {
|
||||
test
|
||||
}
|
||||
}
|
||||
</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'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
id: nextId()
|
||||
}
|
||||
data() {
|
||||
return {
|
||||
id: nextId()
|
||||
}
|
||||
}
|
||||
}
|
||||
</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'
|
||||
|
||||
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>
|
||||
|
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 = {
|
||||
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())
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ export default {
|
||||
loading: false
|
||||
}),
|
||||
methods: {
|
||||
start () {
|
||||
start() {
|
||||
this.loading = true
|
||||
},
|
||||
finish () {
|
||||
finish() {
|
||||
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 () {
|
||||
// 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: {
|
||||
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'
|
||||
})
|
||||
|
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() {
|
||||
return { processEnv: process.env.object }
|
||||
},
|
||||
asyncData ({ env }) {
|
||||
asyncData({ env }) {
|
||||
delete env.object
|
||||
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>
|
||||
export default {
|
||||
fetch ({ error }) {
|
||||
fetch({ error }) {
|
||||
error({ message: 'Nuxt Error', statusCode: 200 })
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<script>
|
||||
export default {
|
||||
middleware: 'user-agent',
|
||||
asyncData ({ userAgent }) {
|
||||
asyncData({ 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
|
||||
},
|
||||
mutations: {
|
||||
increment (state) {
|
||||
increment(state) {
|
||||
state.counter++
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user