refactor: update eslint-config to 1.x

Co-authored-by: Alexander Lichter <manniL@gmx.net>
This commit is contained in:
pooya parsa 2019-07-10 15:15:49 +04:30
parent 1e65e638c4
commit e7cc2757c3
289 changed files with 831 additions and 742 deletions

View File

@ -1,4 +1,4 @@
function isBabelLoader(caller) { function isBabelLoader (caller) {
return caller && caller.name === 'babel-loader' return caller && caller.name === 'babel-loader'
} }

View File

@ -1,7 +1,7 @@
export default { export default {
build: true, build: true,
hooks: { hooks: {
async 'build:done'(pkg) { async 'build:done' (pkg) {
const mono = pkg.load('../..') const mono = pkg.load('../..')
const nuxt = pkg.load('../nuxt') const nuxt = pkg.load('../nuxt')

View File

@ -1,7 +1,7 @@
export default { export default {
build: false, build: false,
hooks: { hooks: {
async 'build:done'(pkg) { async 'build:done' (pkg) {
const mono = pkg.load('../..') const mono = pkg.load('../..')
const nuxt = pkg.load('../nuxt') const nuxt = pkg.load('../nuxt')

View File

@ -1,7 +1,7 @@
export default { export default {
build: true, build: true,
hooks: { hooks: {
async 'build:done'(pkg) { async 'build:done' (pkg) {
const mono = pkg.load('../..') const mono = pkg.load('../..')
await pkg.copyFilesFrom(mono, [ await pkg.copyFilesFrom(mono, [

View File

@ -12,7 +12,7 @@ const getPost = slug => ({
}) })
export default { export default {
beforeCreate() { beforeCreate () {
this.component = () => getPost(this.$route.params.slug) this.component = () => getPost(this.$route.params.slug)
} }
} }

View File

@ -15,12 +15,12 @@
import axios from 'axios' import axios from 'axios'
export default { export default {
async asyncData({ params }) { async asyncData ({ params }) {
// We can use async/await ES6 feature // We can use async/await ES6 feature
const { data } = await axios.get(`https://jsonplaceholder.typicode.com/posts/${params.id}`) const { data } = await axios.get(`https://jsonplaceholder.typicode.com/posts/${params.id}`)
return { post: data } return { post: data }
}, },
head() { head () {
return { return {
title: this.post.title title: this.post.title
} }

View File

@ -21,7 +21,7 @@
import axios from 'axios' import axios from 'axios'
export default { export default {
asyncData({ req, params }) { asyncData ({ req, params }) {
// We can return a Promise instead of calling the callback // We can return a Promise instead of calling the callback
return axios.get('https://jsonplaceholder.typicode.com/posts') return axios.get('https://jsonplaceholder.typicode.com/posts')
.then((res) => { .then((res) => {

View File

@ -25,7 +25,7 @@ const Cookie = process.client ? require('js-cookie') : undefined
export default { export default {
methods: { methods: {
logout() { logout () {
Cookie.remove('auth') Cookie.remove('auth')
this.$store.commit('setAuth', null) this.$store.commit('setAuth', null)
} }

View File

@ -22,7 +22,7 @@ const Cookie = process.client ? require('js-cookie') : undefined
export default { export default {
middleware: 'notAuthenticated', middleware: 'notAuthenticated',
methods: { methods: {
postLogin() { postLogin () {
setTimeout(() => { // we simulate the async request with timeout. setTimeout(() => { // we simulate the async request with timeout.
const auth = { const auth = {
accessToken: 'someStringGotFromApiServiceWithAjax' accessToken: 'someStringGotFromApiServiceWithAjax'

View File

@ -6,12 +6,12 @@ export const state = () => {
} }
} }
export const mutations = { export const mutations = {
setAuth(state, auth) { setAuth (state, auth) {
state.auth = auth state.auth = auth
} }
} }
export const actions = { export const actions = {
nuxtServerInit({ commit }, { req }) { nuxtServerInit ({ commit }, { req }) {
let auth = null let auth = null
if (req.headers.cookie) { if (req.headers.cookie) {
const parsed = cookieparser.parse(req.headers.cookie) const parsed = cookieparser.parse(req.headers.cookie)

View File

@ -30,7 +30,7 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
formError: null, formError: null,
formUsername: '', formUsername: '',
@ -38,7 +38,7 @@ export default {
} }
}, },
methods: { methods: {
async login() { async login () {
try { try {
await this.$store.dispatch('login', { await this.$store.dispatch('login', {
username: this.formUsername, username: this.formUsername,
@ -51,7 +51,7 @@ export default {
this.formError = e.message this.formError = e.message
} }
}, },
async logout() { async logout () {
try { try {
await this.$store.dispatch('logout') await this.$store.dispatch('logout')
} catch (e) { } catch (e) {

View File

@ -5,19 +5,19 @@ export const state = () => ({
}) })
export const mutations = { export const mutations = {
SET_USER: function (state, user) { SET_USER (state, user) {
state.authUser = user state.authUser = user
} }
} }
export const actions = { export const actions = {
// nuxtServerInit is called by Nuxt.js before server-rendering every page // nuxtServerInit is called by Nuxt.js before server-rendering every page
nuxtServerInit({ commit }, { req }) { nuxtServerInit ({ commit }, { req }) {
if (req.session && req.session.authUser) { if (req.session && req.session.authUser) {
commit('SET_USER', req.session.authUser) commit('SET_USER', req.session.authUser)
} }
}, },
async login({ commit }, { username, password }) { async login ({ commit }, { username, password }) {
try { try {
const { data } = await axios.post('/api/login', { username, password }) const { data } = await axios.post('/api/login', { username, password })
commit('SET_USER', data) commit('SET_USER', data)
@ -29,7 +29,7 @@ export const actions = {
} }
}, },
async logout({ commit }) { async logout ({ commit }) {
await axios.post('/api/logout') await axios.post('/api/logout')
commit('SET_USER', null) commit('SET_USER', null)
} }

View File

@ -9,7 +9,7 @@
export default { export default {
async asyncData({ app }) { async asyncData ({ app }) {
const { data: { message: dog } } = await app.$axios.get('/dog') const { data: { message: dog } } = await app.$axios.get('/dog')
return { dog } return { dog }
} }

View File

@ -9,11 +9,11 @@
<script> <script>
export default { export default {
name: 'Date', name: 'Date',
serverCacheKey() { serverCacheKey () {
// Will change every 10 secondes // Will change every 10 secondes
return Math.floor(Date.now() / 10000) return Math.floor(Date.now() / 10000)
}, },
data() { data () {
return { date: Date.now() } return { date: Date.now() }
} }
} }

View File

@ -10,7 +10,7 @@ export default function () {
// Add CoffeeScruot loader // Add CoffeeScruot loader
config.module.rules.push(coffeeLoader) config.module.rules.push(coffeeLoader)
// Add .coffee extension in webpack resolve // Add .coffee extension in webpack resolve
if (config.resolve.extensions.indexOf('.coffee') === -1) { if (!config.resolve.extensions.includes('.coffee')) {
config.resolve.extensions.push('.coffee') config.resolve.extensions.push('.coffee')
} }
}) })

View File

@ -5,7 +5,7 @@ export default {
manifest: 'manifest.[hash].js', // default: manifest.[hash].js manifest: 'manifest.[hash].js', // default: manifest.[hash].js
app: 'app.[chunkhash].js' // default: nuxt.bundle.[chunkhash].js app: 'app.[chunkhash].js' // default: nuxt.bundle.[chunkhash].js
}, },
extend(config, { isDev }) { extend (config, { isDev }) {
if (isDev) { if (isDev) {
config.devtool = 'eval-source-map' config.devtool = 'eval-source-map'
} }

View File

@ -10,7 +10,7 @@
<script> <script>
export default { export default {
layout: 'dark', layout: 'dark',
asyncData({ req }) { asyncData ({ req }) {
return { return {
name: req ? 'server' : 'client' name: req ? 'server' : 'client'
} }

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

@ -9,7 +9,7 @@
<script> <script>
export default { export default {
asyncData() { asyncData () {
return new Promise((resolve) => { return new Promise((resolve) => {
setTimeout(function () { setTimeout(function () {
resolve({}) resolve({})

View File

@ -9,7 +9,7 @@
<script> <script>
export default { export default {
asyncData() { asyncData () {
return new Promise((resolve) => { return new Promise((resolve) => {
setTimeout(function () { setTimeout(function () {
resolve({ name: 'world' }) resolve({ name: 'world' })

View File

@ -14,21 +14,21 @@
<script> <script>
export default { export default {
loading: false, loading: false,
asyncData() { asyncData () {
return new Promise((resolve) => { return new Promise((resolve) => {
setTimeout(function () { setTimeout(function () {
resolve({}) resolve({})
}, 1000) }, 1000)
}) })
}, },
mounted() { mounted () {
setTimeout(() => { setTimeout(() => {
// Extend loader for an additional 5s // Extend loader for an additional 5s
this.$nuxt.$loading.finish() this.$nuxt.$loading.finish()
}, 5000) }, 5000)
}, },
methods: { methods: {
goToFinal() { goToFinal () {
// Start loader immediately // Start loader immediately
this.$nuxt.$loading.start() this.$nuxt.$loading.start()
// Actually change route 5s later // Actually change route 5s later

View File

@ -9,7 +9,7 @@
<script> <script>
export default { export default {
asyncData() { asyncData () {
return new Promise((resolve) => { return new Promise((resolve) => {
setTimeout(function () { setTimeout(function () {
resolve({ name: 'world' }) resolve({ name: 'world' })

View File

@ -15,7 +15,7 @@
import axios from 'axios' import axios from 'axios'
export default { export default {
async asyncData() { async asyncData () {
const { data } = await axios.get('https://jsonplaceholder.typicode.com/users') const { data } = await axios.get('https://jsonplaceholder.typicode.com/users')
return { users: data } return { users: data }
} }

View File

@ -15,10 +15,10 @@
import axios from 'axios' import axios from 'axios'
export default { export default {
validate({ params }) { validate ({ params }) {
return !isNaN(+params.id) return !isNaN(+params.id)
}, },
async asyncData({ params, error }) { async asyncData ({ params, error }) {
try { try {
const { data } = await axios.get(`https://jsonplaceholder.typicode.com/users/${+params.id}`) const { data } = await axios.get(`https://jsonplaceholder.typicode.com/users/${+params.id}`)
return data return data

View File

@ -48,7 +48,7 @@ export default {
/* /*
** You can extend webpack config here ** You can extend webpack config here
*/ */
extend(config, ctx) { extend (config, ctx) {
} }
} }
} }

View File

@ -3,7 +3,7 @@ import { Bar } from 'vue-chartjs'
export default { export default {
extends: Bar, extends: Bar,
props: ['data'], props: ['data'],
mounted() { mounted () {
this.renderChart(this.data) this.renderChart(this.data)
} }
} }

View File

@ -46,7 +46,7 @@ export default {
data: () => ({ data: () => ({
loaded: false loaded: false
}), }),
beforeMount() { beforeMount () {
// Preload image // Preload image
const img = new Image() const img = new Image()
img.onload = () => { img.onload = () => {

View File

@ -18,8 +18,8 @@ export const messages = [
{ component: 'vText', data: 'End of demo 🎉' } { component: 'vText', data: 'End of demo 🎉' }
] ]
async function streamMessages(fn, i = 0) { async function streamMessages (fn, i = 0) {
if (i >= messages.length) return if (i >= messages.length) { return }
await fn(messages[i]) await fn(messages[i])
setTimeout(() => streamMessages(fn, i + 1), 1500) setTimeout(() => streamMessages(fn, i + 1), 1500)
} }

View File

@ -24,7 +24,7 @@ export default {
data: () => ({ data: () => ({
messages: [] messages: []
}), }),
mounted() { mounted () {
// Listen for incoming messages // Listen for incoming messages
streamMessages(async (message) => { streamMessages(async (message) => {
// Wait for the component to load before displaying it // Wait for the component to load before displaying it

View File

@ -10,7 +10,7 @@
<script> <script>
export default { export default {
layout: ({ isMobile }) => isMobile ? 'mobile' : 'default', layout: ({ isMobile }) => isMobile ? 'mobile' : 'default',
asyncData({ req }) { asyncData ({ req }) {
return { return {
name: req ? 'server' : 'client' name: req ? 'server' : 'client'
} }

View File

@ -9,7 +9,7 @@
<script> <script>
export default { export default {
asyncData() { asyncData () {
return { return {
name: process.static ? 'static' : (process.server ? 'server' : 'client') name: process.static ? 'static' : (process.server ? 'server' : 'client')
} }

View File

@ -1,10 +1,10 @@
export default function ({ isHMR, app, store, route, params, error, redirect }) { export default function ({ isHMR, app, store, route, params, error, redirect }) {
const defaultLocale = app.i18n.fallbackLocale const defaultLocale = app.i18n.fallbackLocale
// If middleware is called from hot module replacement, ignore it // If middleware is called from hot module replacement, ignore it
if (isHMR) return if (isHMR) { return }
// Get locale from params // Get locale from params
const locale = params.lang || defaultLocale const locale = params.lang || defaultLocale
if (store.state.locales.indexOf(locale) === -1) { if (!store.state.locales.includes(locale)) {
return error({ message: 'This page could not be found.', statusCode: 404 }) return error({ message: 'This page could not be found.', statusCode: 404 })
} }
// Set locale // Set locale

View File

@ -11,7 +11,7 @@
<script> <script>
export default { export default {
head() { head () {
return { title: this.$t('about.title') } return { title: this.$t('about.title') }
} }
} }

View File

@ -11,7 +11,7 @@
<script> <script>
export default { export default {
head() { head () {
return { title: this.$t('home.title') } return { title: this.$t('home.title') }
} }
} }

View File

@ -4,8 +4,8 @@ export const state = () => ({
}) })
export const mutations = { export const mutations = {
SET_LANG(state, locale) { SET_LANG (state, locale) {
if (state.locales.indexOf(locale) !== -1) { if (state.locales.includes(locale)) {
state.locale = locale state.locale = locale
} }
} }

View File

@ -11,7 +11,7 @@
<script> <script>
export default { export default {
asyncData() { asyncData () {
return { return {
name: process.static ? 'static' : (process.server ? 'server' : 'client') name: process.static ? 'static' : (process.server ? 'server' : 'client')
} }

View File

@ -17,7 +17,7 @@ export default {
clicked: false clicked: false
}), }),
methods: { methods: {
handleClick() { handleClick () {
this.clicked = true this.clicked = true
} }
} }

View File

@ -11,7 +11,7 @@ export default {
components: { components: {
Test Test
}, },
render() { render () {
return <div class='container'> return <div class='container'>
<h1>About page</h1> <h1>About page</h1>
<test data='I am test component' /> <test data='I am test component' />

View File

@ -11,7 +11,7 @@ export default {
{ src: '/defer.js', defer: '' } { src: '/defer.js', defer: '' }
] ]
}, },
render() { render () {
return <div class='container'> return <div class='container'>
<h1>Home page 🚀</h1> <h1>Home page 🚀</h1>
<NuxtLink to='/about'>About page</NuxtLink> <NuxtLink to='/about'>About page</NuxtLink>

View File

@ -33,13 +33,13 @@
import axios from 'axios' import axios from 'axios'
export default { export default {
data() { data () {
return { return {
transitionName: this.getTransitionName(this.page) transitionName: this.getTransitionName(this.page)
} }
}, },
watch: { watch: {
'$route.query.page': async function (page) { async '$route.query.page' (page) {
this.$nuxt.$loading.start() this.$nuxt.$loading.start()
const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`) const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`)
this.users = data.data this.users = data.data
@ -49,7 +49,7 @@ export default {
this.$nuxt.$loading.finish() this.$nuxt.$loading.finish()
} }
}, },
async asyncData({ query }) { async asyncData ({ query }) {
const page = +(query.page || 1) const page = +(query.page || 1)
const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`) const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`)
return { return {
@ -59,7 +59,7 @@ export default {
} }
}, },
methods: { methods: {
getTransitionName(newPage) { getTransitionName (newPage) {
return newPage < this.page ? 'slide-right' : 'slide-left' return newPage < this.page ? 'slide-right' : 'slide-left'
} }
}, },

View File

@ -36,11 +36,11 @@ export default {
// Key for <NuxtChild> (transitions) // Key for <NuxtChild> (transitions)
key: to => to.fullPath, key: to => to.fullPath,
// Called to know which transition to apply // Called to know which transition to apply
transition(to, from) { transition (to, from) {
if (!from) return 'slide-left' if (!from) { return 'slide-left' }
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left' return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
}, },
async asyncData({ query }) { async asyncData ({ query }) {
const page = +(query.page || 1) const page = +(query.page || 1)
const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`) const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`)
return { return {

View File

@ -10,7 +10,7 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
model: 'I am index' model: 'I am index'
} }

View File

@ -11,7 +11,7 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
model: '## Title h2\n### title h3\n\nLong text Long text Long text Long text Long text Long text Long text Long text Long text \n\n* gimme a list item\n* and one more yeehaw' model: '## Title h2\n### title h3\n\nLong text Long text Long text Long text Long text Long text Long text Long text Long text \n\n* gimme a list item\n* and one more yeehaw'
} }

View File

@ -9,12 +9,12 @@
<script> <script>
export default { export default {
filters: { filters: {
hours(date) { hours (date) {
return date.split('T')[1].split('.')[0] return date.split('T')[1].split('.')[0]
} }
}, },
computed: { computed: {
visits() { visits () {
return this.$store.state.visits.slice().reverse() return this.$store.state.visits.slice().reverse()
} }
} }

View File

@ -19,7 +19,7 @@
<script> <script>
export default { export default {
asyncData({ store, route, userAgent }) { asyncData ({ store, route, userAgent }) {
return { return {
userAgent, userAgent,
slugs: [ slugs: [

View File

@ -3,7 +3,7 @@ export const state = () => ({
}) })
export const mutations = { export const mutations = {
ADD_VISIT(state, path) { ADD_VISIT (state, path) {
state.visits.push({ state.visits.push({
path, path,
date: new Date().toJSON() date: new Date().toJSON()

View File

@ -1,6 +1,6 @@
export default { export default {
router: { router: {
extendRoutes(routes, resolve) { extendRoutes (routes, resolve) {
const indexIndex = routes.findIndex(route => route.name === 'index') const indexIndex = routes.findIndex(route => route.name === 'index')
let index = routes[indexIndex].children.findIndex(route => route.name === 'index-child-id') let index = routes[indexIndex].children.findIndex(route => route.name === 'index-child-id')
routes[indexIndex].children[index] = { routes[indexIndex].children[index] = {

View File

@ -8,11 +8,11 @@
<script> <script>
export default { export default {
name: 'Child', name: 'Child',
validate({ params }) { validate ({ params }) {
return !isNaN(+params.id) return !isNaN(+params.id)
}, },
computed: { computed: {
id() { id () {
return this.$route.params.id return this.$route.params.id
} }
} }

View File

@ -22,7 +22,7 @@
<script> <script>
export default { export default {
asyncData({ env }) { asyncData ({ env }) {
return { users: env.users } return { users: env.users }
} }
} }

View File

@ -7,17 +7,17 @@
<script> <script>
export default { export default {
validate({ params }) { validate ({ params }) {
return !isNaN(+params.id) return !isNaN(+params.id)
}, },
asyncData({ params, env, error }) { asyncData ({ params, env, error }) {
const user = env.users.find(user => String(user.id) === params.id) const user = env.users.find(user => String(user.id) === params.id)
if (!user) { if (!user) {
return error({ message: 'User not found', statusCode: 404 }) return error({ message: 'User not found', statusCode: 404 })
} }
return user return user
}, },
head() { head () {
return { return {
title: this.name title: this.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
head() { head () {
return { return {
title: this.$route.name title: this.$route.name
} }

View File

@ -13,7 +13,7 @@
import axios from 'axios' import axios from 'axios'
export default { export default {
asyncData() { asyncData () {
const nb = Math.max(1, Math.round(Math.random() * 10)) const nb = Math.max(1, Math.round(Math.random() * 10))
return axios.get(`https://jsonplaceholder.typicode.com/photos/${nb}`).then(res => res.data) return axios.get(`https://jsonplaceholder.typicode.com/photos/${nb}`).then(res => res.data)
} }

View File

@ -20,7 +20,7 @@ if (process.client) {
} }
export default { export default {
mounted() { mounted () {
miniToastr.init() miniToastr.init()
}, },
notifications: { notifications: {

View File

@ -6,7 +6,7 @@
<script> <script>
export default { export default {
asyncData() { asyncData () {
return { return {
name: process.static ? 'static' : (process.server ? 'server' : 'client') name: process.static ? 'static' : (process.server ? 'server' : 'client')
} }

View File

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

View File

@ -34,11 +34,11 @@ export default {
// Key for <NuxtChild> (transitions) // Key for <NuxtChild> (transitions)
key: to => to.fullPath, key: to => to.fullPath,
// Called to know which transition to apply // Called to know which transition to apply
transition(to, from) { transition (to, from) {
if (!from) return 'slide-left' if (!from) { return 'slide-left' }
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left' return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
}, },
async asyncData({ query }) { async asyncData ({ query }) {
const page = +query.page || 1 const page = +query.page || 1
const data = await fetch(`https://reqres.in/api/users?page=${page}`).then(res => res.json()) const data = await fetch(`https://reqres.in/api/users?page=${page}`).then(res => res.json())

View File

@ -35,11 +35,11 @@ export default {
// Key for <NuxtChild> (transitions) // Key for <NuxtChild> (transitions)
key: to => to.fullPath, key: to => to.fullPath,
// Called to know which transition to apply // Called to know which transition to apply
transition(to, from) { transition (to, from) {
if (!from) return 'slide-left' if (!from) { return 'slide-left' }
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left' return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
}, },
async asyncData({ query, $axios }) { async asyncData ({ query, $axios }) {
const page = +query.page || 1 const page = +query.page || 1
const data = await $axios.$get(`https://reqres.in/api/users?page=${page}`) const data = await $axios.$get(`https://reqres.in/api/users?page=${page}`)
return { return {

View File

@ -9,7 +9,7 @@
<script> <script>
export default { export default {
asyncData() { asyncData () {
return { return {
name: (process.server ? 'server' : 'client') name: (process.server ? 'server' : 'client')
} }

View File

@ -13,7 +13,7 @@
<script> <script>
export default { export default {
asyncData({ req }) { asyncData ({ req }) {
return { return {
name: req ? 'server' : 'client' name: req ? 'server' : 'client'
} }

View File

@ -3,7 +3,7 @@ import { Line } from 'vue-chartjs'
export default { export default {
extends: Line, extends: Line,
props: ['data', 'options'], props: ['data', 'options'],
mounted() { mounted () {
this.renderChart(this.data, this.options) this.renderChart(this.data, this.options)
} }
} }

View File

@ -83,7 +83,7 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
clipped: false, clipped: false,
drawer: true, drawer: true,

View File

@ -21,7 +21,7 @@ storiesOf('Features/Method for rendering Vue', module)
render: h => h('div', ['renders a div with some text in it..']) render: h => h('div', ['renders a div with some text in it..'])
})) }))
.add('render + component', () => ({ .add('render + component', () => ({
render(h) { render (h) {
return h(MyButton, { props: { color: 'pink' } }, ['renders component: MyButton']) return h(MyButton, { props: { color: 'pink' } }, ['renders component: MyButton'])
} }
})) }))
@ -49,7 +49,7 @@ storiesOf('Features/Method for rendering Vue', module)
})) }))
.add('JSX', () => ({ .add('JSX', () => ({
components: { MyButton }, components: { MyButton },
render() { render () {
return <my-button>MyButton rendered with JSX</my-button> return <my-button>MyButton rendered with JSX</my-button>
} }
})) }))
@ -59,14 +59,14 @@ storiesOf('Features/Method for rendering Vue', module)
store: new Vuex.Store({ store: new Vuex.Store({
state: { count: 0 }, state: { count: 0 },
mutations: { mutations: {
increment(state) { increment (state) {
state.count += 1; // eslint-disable-line state.count += 1; // eslint-disable-line
action('vuex state')(state) action('vuex state')(state)
} }
} }
}), }),
methods: { methods: {
log() { log () {
this.$store.commit('increment') this.$store.commit('increment')
} }
} }
@ -78,14 +78,14 @@ storiesOf('Features/Method for rendering Vue', module)
store: new Vuex.Store({ store: new Vuex.Store({
state: { count: 0 }, state: { count: 0 },
mutations: { mutations: {
increment(state) { increment (state) {
state.count += 1; // eslint-disable-line state.count += 1; // eslint-disable-line
action('vuex state')(state) action('vuex state')(state)
} }
} }
}), }),
methods: { methods: {
log() { log () {
this.$store.commit('increment') this.$store.commit('increment')
} }
} }
@ -108,7 +108,7 @@ storiesOf('Features/Decorator for Vue', module)
return { return {
components: { WrapButton }, components: { WrapButton },
template: '<div :style="{ border: borderStyle }"><wrap-button/></div>', template: '<div :style="{ border: borderStyle }"><wrap-button/></div>',
data() { data () {
return { borderStyle: 'medium solid red' } return { borderStyle: 'medium solid red' }
} }
} }
@ -116,7 +116,7 @@ storiesOf('Features/Decorator for Vue', module)
.addDecorator(() => ({ .addDecorator(() => ({
// Decorated with `story` component // Decorated with `story` component
template: '<div :style="{ border: borderStyle }"><story/></div>', template: '<div :style="{ border: borderStyle }"><story/></div>',
data() { data () {
return { return {
borderStyle: 'medium solid blue' borderStyle: 'medium solid blue'
} }
@ -126,7 +126,7 @@ storiesOf('Features/Decorator for Vue', module)
template: '<my-button>MyButton with template</my-button>' template: '<my-button>MyButton with template</my-button>'
})) }))
.add('render', () => ({ .add('render', () => ({
render(h) { render (h) {
return h(MyButton, { props: { color: 'pink' } }, ['renders component: MyButton']) return h(MyButton, { props: { color: 'pink' } }, ['renders component: MyButton'])
} }
})) }))

View File

@ -88,7 +88,7 @@ const menuItemsAlt = [
storiesOf('Vuetify/V-Btn', module) storiesOf('Vuetify/V-Btn', module)
.add('Square Button', () => ({ .add('Square Button', () => ({
components: {}, components: {},
data() { data () {
return { return {
items: menuItems items: menuItems
} }
@ -98,7 +98,7 @@ storiesOf('Vuetify/V-Btn', module)
})) }))
.add('with rounded button', () => ({ .add('with rounded button', () => ({
components: {}, components: {},
data() { data () {
return { return {
items: menuItemsAlt items: menuItemsAlt
} }

View File

@ -26,7 +26,7 @@ export default {
} }
} }
`, `,
data() { data () {
return { return {
fontSize: 60 fontSize: 60
} }

View File

@ -4,7 +4,7 @@ const purgecss = require('@fullhuman/postcss-purgecss')
const tailwindConfig = path.join(__dirname, 'tailwind.js') const tailwindConfig = path.join(__dirname, 'tailwind.js')
class TailwindExtractor { class TailwindExtractor {
static extract(content) { static extract (content) {
return content.match(/[A-Za-z0-9-_:\/]+/g) || [] // eslint-disable-line no-useless-escape return content.match(/[A-Za-z0-9-_:\/]+/g) || [] // eslint-disable-line no-useless-escape
} }
} }

View File

@ -142,7 +142,7 @@ module.exports = {
| |
*/ */
colors: colors, colors,
/* /*
|----------------------------------------------------------------------------- |-----------------------------------------------------------------------------

View File

@ -142,7 +142,7 @@ export default {
| |
*/ */
colors: colors, colors,
/* /*
|----------------------------------------------------------------------------- |-----------------------------------------------------------------------------

View File

@ -12,7 +12,7 @@
<script> <script>
export default { export default {
asyncData({ req }) { asyncData ({ req }) {
return { return {
name: req ? 'server' : 'client' name: req ? 'server' : 'client'
} }

View File

@ -19,13 +19,13 @@ export default {
Car: { Car: {
query: car, query: car,
prefetch: ({ route }) => ({ id: route.params.id }), prefetch: ({ route }) => ({ id: route.params.id }),
variables() { variables () {
return { id: this.$route.params.id } return { id: this.$route.params.id }
} }
} }
}, },
methods: { methods: {
formatCurrency(num) { formatCurrency (num) {
const formatter = new Intl.NumberFormat('en-US', { const formatter = new Intl.NumberFormat('en-US', {
style: 'currency', style: 'currency',
currency: 'USD', currency: 'USD',
@ -34,7 +34,7 @@ export default {
return formatter.format(num) return formatter.format(num)
} }
}, },
head() { head () {
return { return {
title: (this.Car ? `${this.Car.make} ${this.Car.model}` : 'Loading') title: (this.Car ? `${this.Car.make} ${this.Car.model}` : 'Loading')
} }

View File

@ -3,7 +3,7 @@ import { Bar } from 'vue-chartjs'
export default { export default {
extends: Bar, extends: Bar,
props: ['data', 'options'], props: ['data', 'options'],
mounted() { mounted () {
this.renderChart(this.data, this.options) this.renderChart(this.data, this.options)
} }
} }

View File

@ -3,7 +3,7 @@ import { Doughnut } from 'vue-chartjs'
export default { export default {
extends: Doughnut, extends: Doughnut,
props: ['data', 'options'], props: ['data', 'options'],
mounted() { mounted () {
this.renderChart(this.data, this.options) this.renderChart(this.data, this.options)
} }
} }

View File

@ -8,7 +8,7 @@
import axios from 'axios' import axios from 'axios'
import DoughnutChart from '~/components/doughnut-chart' import DoughnutChart from '~/components/doughnut-chart'
function getRandomColor() { function getRandomColor () {
const letters = '0123456789ABCDEF' const letters = '0123456789ABCDEF'
let color = '#' let color = '#'
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
@ -21,7 +21,7 @@ export default {
components: { components: {
DoughnutChart DoughnutChart
}, },
async asyncData({ env }) { async asyncData ({ env }) {
const res = await axios.get(`https://api.github.com/repos/nuxt/nuxt.js/stats/contributors?access_token=${env.githubToken}`) const res = await axios.get(`https://api.github.com/repos/nuxt/nuxt.js/stats/contributors?access_token=${env.githubToken}`)
return { return {
doughnutChartData: { doughnutChartData: {

View File

@ -13,7 +13,7 @@ export default {
components: { components: {
BarChart BarChart
}, },
async asyncData({ env }) { async asyncData ({ env }) {
const res = await axios.get(`https://api.github.com/repos/nuxt/nuxt.js/stats/commit_activity?access_token=${env.githubToken}`) const res = await axios.get(`https://api.github.com/repos/nuxt/nuxt.js/stats/commit_activity?access_token=${env.githubToken}`)
return { return {
barChartData: { barChartData: {

View File

@ -30,17 +30,17 @@ class Base extends Vue {
msg = 123 msg = 123
// lifecycle hook // lifecycle hook
mounted() { mounted () {
this.greet() this.greet()
} }
// computed // computed
get computedMsg() { get computedMsg () {
return 'computed ' + this.msg return 'computed ' + this.msg
} }
// method // method
greet() { greet () {
console.log('base greeting: ' + this.msg) // eslint-disable-line no-console console.log('base greeting: ' + this.msg) // eslint-disable-line no-console
} }
} }

View File

@ -23,7 +23,7 @@ export default
@Component @Component
class Child extends Base { class Child extends Base {
// override parent method // override parent method
greet() { greet () {
console.log('child greeting: ' + this.msg) // eslint-disable-line no-console console.log('child greeting: ' + this.msg) // eslint-disable-line no-console
} }
} }

View File

@ -12,7 +12,7 @@ export default
components: { Child } components: { Child }
}) })
class App extends Vue { class App extends Vue {
asyncData({ req }) { asyncData ({ req }) {
return { env: req ? 'server' : 'client' } return { env: req ? 'server' : 'client' }
} }
} }

View File

@ -32,11 +32,11 @@ export default {
]), ]),
// fetch(context) is called by the server-side // fetch(context) is called by the server-side
// and before instantiating the component // and before instantiating the component
fetch({ store }) { fetch ({ store }) {
store.commit('increment') store.commit('increment')
}, },
methods: { methods: {
increment() { increment () {
this.$store.commit('increment') this.$store.commit('increment')
} }
} }

View File

@ -24,7 +24,7 @@ export default {
todos: 'todos/todos' todos: 'todos/todos'
}), }),
methods: { methods: {
addTodo(e) { addTodo (e) {
const text = e.target.value const text = e.target.value
if (text.trim()) { if (text.trim()) {
this.$store.commit('todos/add', { text }) this.$store.commit('todos/add', { text })

View File

@ -7,13 +7,13 @@ export const state = () => ({
}) })
export const mutations = { export const mutations = {
add(state, title) { add (state, title) {
state.list.push(title) state.list.push(title)
} }
} }
export const getters = { export const getters = {
get(state) { get (state) {
return state.list return state.list
} }
} }

View File

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

Some files were not shown because too many files have changed in this diff Show More