From 3e637c5d83028f6671ed0edf10b813dae523b347 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 31 Oct 2017 21:43:55 +0800 Subject: [PATCH] refactor: add examples to lint --- .eslintignore | 4 ++ .../async-component-injection/pages/_slug.vue | 2 +- examples/async-data/nuxt.config.js | 2 +- examples/async-data/pages/posts/_id.vue | 4 +- examples/async-data/pages/posts/index.vue | 8 +-- examples/auth-routes/api/index.js | 2 +- examples/auth-routes/pages/index.vue | 8 +-- examples/auth-routes/store/index.js | 6 +- examples/axios/pages/index.vue | 2 +- examples/cached-components/pages/index.vue | 4 +- examples/custom-build/nuxt.config.js | 2 +- examples/custom-layouts/pages/about.vue | 2 +- .../custom-loading/components/loading.vue | 4 +- examples/custom-loading/pages/about.vue | 2 +- examples/custom-loading/pages/index.vue | 2 +- examples/custom-routes/pages/index.vue | 2 +- examples/custom-routes/pages/users/_id.vue | 4 +- examples/custom-server/package.json | 1 - examples/custom-server/server.js | 2 - .../dynamic-components/components/chart.js | 2 +- .../dynamic-components/components/image.vue | 4 +- examples/dynamic-components/js/messages.js | 2 +- examples/dynamic-components/nuxt.config.js | 2 +- examples/dynamic-components/pages/index.vue | 2 +- examples/dynamic-layouts/pages/about.vue | 2 +- examples/dynamic-layouts/pages/index.vue | 2 +- examples/hello-world-jsx/pages/about.vue | 4 +- examples/hello-world-jsx/pages/index.js | 2 +- examples/hello-world/pages/about.vue | 2 +- examples/i18n/layouts/default.vue | 2 +- examples/i18n/nuxt.config.js | 2 +- examples/i18n/pages/_lang/about.vue | 2 +- examples/i18n/pages/_lang/index.vue | 2 +- examples/i18n/store/index.js | 2 +- examples/layout-transitions/pages/users.vue | 4 +- examples/markdownit/pages/index.vue | 2 +- examples/markdownit/pages/pug.vue | 2 +- examples/middleware/components/Visits.vue | 4 +- examples/middleware/pages/_slug.vue | 2 +- examples/middleware/store/index.js | 2 +- examples/nested-routes/pages/index.vue | 2 +- examples/nested-routes/pages/index/_id.vue | 6 +- examples/plugins-vendor/pages/about.vue | 2 +- examples/plugins-vendor/pages/index.vue | 2 +- examples/routes-transitions/pages/users.vue | 4 +- examples/spa/pages/about.vue | 2 +- examples/static-images/pages/about.vue | 2 +- examples/typescript/components/Card.vue | 6 +- examples/typescript/modules/typescript.js | 16 ++--- examples/typescript/pages/index.vue | 8 +-- examples/uikit/pages/about.vue | 2 +- examples/uikit/plugins/uikit.js | 2 +- examples/vue-apollo/pages/car/_id.vue | 2 +- examples/vue-chartjs/components/bar-chart.js | 2 +- .../vue-chartjs/components/doughnut-chart.js | 2 +- examples/vue-chartjs/pages/contributors.vue | 9 ++- .../vue-class-component/components/Base.vue | 8 +-- .../vue-class-component/components/Child.vue | 4 +- examples/vue-class-component/pages/index.vue | 2 +- examples/vuex-store-modules/pages/index.vue | 4 +- examples/vuex-store-modules/pages/todos.vue | 2 +- examples/vuex-store-modules/store/articles.js | 4 +- .../store/articles/comments.js | 4 +- examples/vuex-store-modules/store/index.js | 2 +- examples/vuex-store-modules/store/todos.js | 6 +- examples/vuex-store/pages/index.vue | 4 +- examples/vuex-store/store/mutations.js | 8 +-- examples/with-ava/pages/index.vue | 2 +- examples/with-cookies/pages/index.vue | 2 +- examples/with-feathers/.eslintrc.js | 36 ++++++++++++ examples/with-feathers/nuxt.config.js | 2 +- examples/with-feathers/package.json | 1 + examples/with-feathers/pages/about.vue | 2 +- examples/with-feathers/src/app.js | 48 +++++++-------- examples/with-feathers/src/hooks/index.js | 14 ++--- examples/with-feathers/src/index.js | 18 +++--- .../with-feathers/src/middleware/index.js | 12 ++-- .../src/services/authentication/index.js | 17 +++--- examples/with-feathers/src/services/index.js | 19 +++--- .../src/services/user/hooks/index.js | 12 ++-- .../with-feathers/src/services/user/index.js | 28 ++++----- examples/with-feathers/test/app.test.js | 56 +++++++++--------- .../test/services/user/index.test.js | 14 ++--- examples/with-firebase/pages/index.vue | 2 +- examples/with-firebase/pages/users/_key.vue | 2 +- examples/with-museui/nuxt.config.js | 50 ++++++++-------- examples/with-museui/pages/index.vue | 20 +++---- examples/with-museui/plugins/museui.js | 6 +- examples/with-sockets/pages/index.vue | 10 ++-- examples/with-tape/pages/index.vue | 16 ++--- examples/with-tape/test/index.test.js | 58 +++++++++---------- examples/with-tape/test/setup.js | 8 +-- examples/with-vuetify/nuxt.config.js | 3 - package.json | 2 +- 94 files changed, 360 insertions(+), 330 deletions(-) create mode 100644 .eslintignore create mode 100644 examples/with-feathers/.eslintrc.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..801d56deaa --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +app +node_modules +dist +.nuxt diff --git a/examples/async-component-injection/pages/_slug.vue b/examples/async-component-injection/pages/_slug.vue index 10b87643d3..32359858fb 100644 --- a/examples/async-component-injection/pages/_slug.vue +++ b/examples/async-component-injection/pages/_slug.vue @@ -12,7 +12,7 @@ const getPost = (slug) => ({ }) export default { - beforeCreate () { + beforeCreate() { this.component = () => getPost(this.$route.params.slug) } } diff --git a/examples/async-data/nuxt.config.js b/examples/async-data/nuxt.config.js index 9bd912b375..14c94a633e 100644 --- a/examples/async-data/nuxt.config.js +++ b/examples/async-data/nuxt.config.js @@ -12,7 +12,7 @@ module.exports = { }, generate: { routes: [ - '/posts/1', + '/posts/1' ] } } diff --git a/examples/async-data/pages/posts/_id.vue b/examples/async-data/pages/posts/_id.vue index d33d5c46bb..d7f33bb081 100644 --- a/examples/async-data/pages/posts/_id.vue +++ b/examples/async-data/pages/posts/_id.vue @@ -11,12 +11,12 @@ import axios from 'axios' export default { - async asyncData ({ params }) { + async asyncData({ params }) { // We can use async/await ES6 feature let { data } = await axios.get(`https://jsonplaceholder.typicode.com/posts/${params.id}`) return { post: data } }, - head () { + head() { return { title: this.post.title } diff --git a/examples/async-data/pages/posts/index.vue b/examples/async-data/pages/posts/index.vue index 404c127478..6a7014d4ed 100644 --- a/examples/async-data/pages/posts/index.vue +++ b/examples/async-data/pages/posts/index.vue @@ -15,12 +15,12 @@ import axios from 'axios' export default { - asyncData ({ req, params }) { + asyncData({ req, params }) { // We can return a Promise instead of calling the callback return axios.get('https://jsonplaceholder.typicode.com/posts') - .then((res) => { - return { posts: res.data.slice(0, 5) } - }) + .then((res) => { + return { posts: res.data.slice(0, 5) } + }) }, head: { title: 'List of posts' diff --git a/examples/auth-routes/api/index.js b/examples/auth-routes/api/index.js index c1943b789e..04d6febace 100644 --- a/examples/auth-routes/api/index.js +++ b/examples/auth-routes/api/index.js @@ -33,4 +33,4 @@ router.post('/logout', (req, res) => { module.exports = { path: '/api', handler: router -} \ No newline at end of file +} diff --git a/examples/auth-routes/pages/index.vue b/examples/auth-routes/pages/index.vue index ebfd771e60..1fe25b8373 100644 --- a/examples/auth-routes/pages/index.vue +++ b/examples/auth-routes/pages/index.vue @@ -20,7 +20,7 @@ diff --git a/examples/hello-world-jsx/pages/about.vue b/examples/hello-world-jsx/pages/about.vue index 7f7b2af070..26ed2649b8 100644 --- a/examples/hello-world-jsx/pages/about.vue +++ b/examples/hello-world-jsx/pages/about.vue @@ -1,11 +1,11 @@ diff --git a/examples/vue-class-component/components/Child.vue b/examples/vue-class-component/components/Child.vue index b3c5155dc0..8063fc7bc4 100644 --- a/examples/vue-class-component/components/Child.vue +++ b/examples/vue-class-component/components/Child.vue @@ -16,8 +16,8 @@ import Base from '@/components/Base' @Component export default class Child extends Base { // override parent method - greet () { - console.log('child greeting: ' + this.msg) + greet() { + console.log('child greeting: ' + this.msg) // eslint-disable-line no-console } } diff --git a/examples/vue-class-component/pages/index.vue b/examples/vue-class-component/pages/index.vue index ff468d2ed9..35e0116da2 100644 --- a/examples/vue-class-component/pages/index.vue +++ b/examples/vue-class-component/pages/index.vue @@ -11,7 +11,7 @@ import Child from '@/components/Child' components: { Child } }) export default class App extends Vue { - asyncData ({ req }) { + asyncData({ req }) { return { env: req ? 'server' : 'client' } } } diff --git a/examples/vuex-store-modules/pages/index.vue b/examples/vuex-store-modules/pages/index.vue index da3c9a4cac..33035823fc 100644 --- a/examples/vuex-store-modules/pages/index.vue +++ b/examples/vuex-store-modules/pages/index.vue @@ -23,14 +23,14 @@ import { mapState } from 'vuex' export default { // fetch(context) is called by the server-side // and before instantiating the component - fetch ({ store }) { + fetch({ store }) { store.commit('increment') }, computed: mapState([ 'counter' ]), methods: { - increment () { + increment() { this.$store.commit('increment') } } diff --git a/examples/vuex-store-modules/pages/todos.vue b/examples/vuex-store-modules/pages/todos.vue index a3aef45096..3c21b92a22 100644 --- a/examples/vuex-store-modules/pages/todos.vue +++ b/examples/vuex-store-modules/pages/todos.vue @@ -20,7 +20,7 @@ export default { todos: 'todos/todos' }), methods: { - addTodo (e) { + addTodo(e) { var text = e.target.value if (text.trim()) { this.$store.commit('todos/add', { text }) diff --git a/examples/vuex-store-modules/store/articles.js b/examples/vuex-store-modules/store/articles.js index e2fb76f674..a19b962c88 100644 --- a/examples/vuex-store-modules/store/articles.js +++ b/examples/vuex-store-modules/store/articles.js @@ -7,13 +7,13 @@ export const state = () => ({ }) export const mutations = { - add (state, title) { + add(state, title) { state.list.push(title) } } export const getters = { - get (state) { + get(state) { return state.list } } diff --git a/examples/vuex-store-modules/store/articles/comments.js b/examples/vuex-store-modules/store/articles/comments.js index dd7f3c47c0..4092086eee 100644 --- a/examples/vuex-store-modules/store/articles/comments.js +++ b/examples/vuex-store-modules/store/articles/comments.js @@ -7,13 +7,13 @@ export const state = () => ({ }) export const mutations = { - add (state, title) { + add(state, title) { state.list.push(title) } } export const getters = { - get (state) { + get(state) { return state.list } } diff --git a/examples/vuex-store-modules/store/index.js b/examples/vuex-store-modules/store/index.js index 63f1975bf2..b22221c9c7 100644 --- a/examples/vuex-store-modules/store/index.js +++ b/examples/vuex-store-modules/store/index.js @@ -3,7 +3,7 @@ export const state = () => ({ }) export const mutations = { - increment (state) { + increment(state) { state.counter++ } } diff --git a/examples/vuex-store-modules/store/todos.js b/examples/vuex-store-modules/store/todos.js index 5063cbd1b8..f482ec1242 100644 --- a/examples/vuex-store-modules/store/todos.js +++ b/examples/vuex-store-modules/store/todos.js @@ -3,20 +3,20 @@ export const state = () => ({ }) export const mutations = { - add (state, { text }) { + add(state, { text }) { state.list.push({ text, done: false }) }, - toggle (state, todo) { + toggle(state, todo) { todo.done = !todo.done } } export const getters = { - todos (state) { + todos(state) { return state.list } } diff --git a/examples/vuex-store/pages/index.vue b/examples/vuex-store/pages/index.vue index 0e9a15da3c..7406a84dd8 100644 --- a/examples/vuex-store/pages/index.vue +++ b/examples/vuex-store/pages/index.vue @@ -13,14 +13,14 @@ import { mapState } from 'vuex' export default { // fetch(context) is called by the server-side // and nuxt before instantiating the component - fetch ({ store }) { + fetch({ store }) { store.commit('increment') }, computed: mapState([ 'counter' ]), methods: { - increment () { + increment() { this.$store.commit('increment') } } diff --git a/examples/vuex-store/store/mutations.js b/examples/vuex-store/store/mutations.js index e85cce517e..81783007a1 100644 --- a/examples/vuex-store/store/mutations.js +++ b/examples/vuex-store/store/mutations.js @@ -1,7 +1,7 @@ const mutations = { - increment (state) { - state.counter++ - } + increment(state) { + state.counter++ + } } -export default mutations \ No newline at end of file +export default mutations diff --git a/examples/with-ava/pages/index.vue b/examples/with-ava/pages/index.vue index a3d80ae170..b411fa4762 100755 --- a/examples/with-ava/pages/index.vue +++ b/examples/with-ava/pages/index.vue @@ -4,7 +4,7 @@ diff --git a/examples/with-museui/plugins/museui.js b/examples/with-museui/plugins/museui.js index ae071085bb..623286c123 100644 --- a/examples/with-museui/plugins/museui.js +++ b/examples/with-museui/plugins/museui.js @@ -1,4 +1,4 @@ -import Vue from 'vue'; -import MuseUI from 'muse-ui'; +import Vue from 'vue' +import MuseUI from 'muse-ui' -Vue.use(MuseUI); +Vue.use(MuseUI) diff --git a/examples/with-sockets/pages/index.vue b/examples/with-sockets/pages/index.vue index 1e2fb24700..7184116d06 100644 --- a/examples/with-sockets/pages/index.vue +++ b/examples/with-sockets/pages/index.vue @@ -17,7 +17,7 @@ import socket from '~/plugins/socket.io.js' export default { - asyncData (context, callback) { + asyncData(context, callback) { socket.emit('last-messages', function (messages) { callback(null, { messages, @@ -28,16 +28,16 @@ export default { watch: { 'messages': 'scrollToBottom' }, - beforeMount () { + beforeMount() { socket.on('new-message', (message) => { this.messages.push(message) }) }, - mounted () { + mounted() { this.scrollToBottom() }, methods: { - sendMessage () { + sendMessage() { if (!this.message.trim()) return let message = { date: new Date().toJSON(), @@ -47,7 +47,7 @@ export default { this.message = '' socket.emit('send-message', message) }, - scrollToBottom () { + scrollToBottom() { this.$nextTick(() => { this.$refs.messages.scrollTop = this.$refs.messages.scrollHeight }) diff --git a/examples/with-tape/pages/index.vue b/examples/with-tape/pages/index.vue index 1ceb0086e2..b66e85f73e 100755 --- a/examples/with-tape/pages/index.vue +++ b/examples/with-tape/pages/index.vue @@ -7,14 +7,14 @@ diff --git a/examples/with-tape/test/index.test.js b/examples/with-tape/test/index.test.js index f586b68538..7d46c3d11e 100755 --- a/examples/with-tape/test/index.test.js +++ b/examples/with-tape/test/index.test.js @@ -3,41 +3,41 @@ import { shallow } from 'vue-test-utils' import Index from '../pages/index.vue' test('renders Index.vue correctly', t => { - t.plan(4) + t.plan(4) - const wrapper = shallow(Index, { - data: { - name: 'nuxt' - } - }) + const wrapper = shallow(Index, { + data: { + name: 'nuxt' + } + }) - const button = wrapper.find('button') + const button = wrapper.find('button') - t.equal( - wrapper.find('h1').text(), - 'Hello nuxt!', - 'renders "Hello nuxt!" text' - ) + t.equal( + wrapper.find('h1').text(), + 'Hello nuxt!', + 'renders "Hello nuxt!" text' + ) - t.equal( - wrapper.find('h1').hasClass('red'), - true, - 'h1 has a red class [default]' - ) + t.equal( + wrapper.find('h1').hasClass('red'), + true, + 'h1 has a red class [default]' + ) - button.trigger('click') + button.trigger('click') - t.equal( - wrapper.find('h1').hasClass('blue'), - true, - 'h1 class changes to blue [after 1st click]' - ) + t.equal( + wrapper.find('h1').hasClass('blue'), + true, + 'h1 class changes to blue [after 1st click]' + ) - button.trigger('click') + button.trigger('click') - t.equal( - wrapper.find('h1').hasClass('green'), - true, - 'h1 class changes to green [after 2nd click]' - ) + t.equal( + wrapper.find('h1').hasClass('green'), + true, + 'h1 class changes to green [after 2nd click]' + ) }) diff --git a/examples/with-tape/test/setup.js b/examples/with-tape/test/setup.js index 2e41fab524..69cf3aa353 100644 --- a/examples/with-tape/test/setup.js +++ b/examples/with-tape/test/setup.js @@ -5,10 +5,10 @@ require('browser-env')() // Setup vue files to be processed by `require-extension-hooks-vue` hooks('vue') - .plugin('vue') - .push() + .plugin('vue') + .push() // Setup vue and js files to be processed by `require-extension-hooks-babel` hooks(['vue', 'js']) - .plugin('babel') - .push() + .plugin('babel') + .push() diff --git a/examples/with-vuetify/nuxt.config.js b/examples/with-vuetify/nuxt.config.js index c1fc371f7a..df74955493 100644 --- a/examples/with-vuetify/nuxt.config.js +++ b/examples/with-vuetify/nuxt.config.js @@ -1,6 +1,3 @@ - -const { join } = require('path') - module.exports = { /* ** Head elements diff --git a/package.json b/package.json index 058e583002..8135fa0469 100644 --- a/package.json +++ b/package.json @@ -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/** --ignore-pattern app --ignore-pattern node_modules --ignore-pattern dist/", + "lint": "eslint --ext .js,.vue bin/** lib/** test/*.js examples/**", "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",