Przeglądaj źródła

improve linting

Evan You 10 lat temu
rodzic
commit
e649795596

+ 6 - 2
.eslintrc.js

@@ -2,8 +2,12 @@ module.exports = {
   root: true,
   extends: 'standard',
   'rules': {
-    'arrow-parens': 0,
+    'arrow-parens': [2, 'as-needed'],
     'no-new-func': 0,
-    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
+    'no-new': 0,
+    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
+    'standard/object-curly-even-spacing': [2, 'always', {
+      objectsInObjects: false
+    }]
   }
 }

+ 0 - 1
build/webpack.ssr.dev.config.js

@@ -1,6 +1,5 @@
 var path = require('path')
 var alias = require('./alias')
-var webpack = require('webpack')
 
 module.exports = {
   entry: path.resolve(__dirname, 'ssr.dev.entry.js'),

+ 1 - 1
package.json

@@ -15,7 +15,7 @@
     "dev-ssr": "webpack --watch --config build/webpack.ssr.dev.config.js",
     "test": "npm run unit && npm run e2e",
     "build": "NODE_ENV=production node build/build.js",
-    "lint": "eslint src build",
+    "lint": "eslint src build test",
     "unit": "karma start build/karma.unit.config.js",
     "cover": "karma start build/karma.cover.config.js",
     "e2e": "npm run build && node test/e2e/runner.js"

+ 5 - 0
test/e2e/.eslintrc

@@ -0,0 +1,5 @@
+{
+  "rules": {
+    "indent": 0
+  }
+}

+ 3 - 3
test/e2e/custom-commands/waitFor.js

@@ -1,18 +1,18 @@
 var util = require('util')
 var events = require('events')
 
-var waitFor = function() {
+var waitFor = function () {
   events.EventEmitter.call(this)
 }
 
 util.inherits(waitFor, events.EventEmitter)
 
-waitFor.prototype.command = function(ms, cb) {
+waitFor.prototype.command = function (ms, cb) {
   var self = this
 
   ms = ms || 1000
 
-  setTimeout(function() {
+  setTimeout(function () {
     // if we have a callback, call it right before the complete event
     if (cb) {
       cb.call(self.client.api)

+ 1 - 0
test/e2e/specs/select2.js

@@ -1,3 +1,4 @@
+/* globals vm */
 module.exports = {
   'select2': function (browser) {
     browser

+ 1 - 0
test/e2e/specs/svg.js

@@ -1,3 +1,4 @@
+/* globals stats, valueToPoint */
 module.exports = {
   'svg': function (browser) {
     browser

+ 5 - 0
test/unit/.eslintrc

@@ -0,0 +1,5 @@
+{
+  "env": {
+    "jasmine": true
+  }
+}

+ 1 - 1
test/unit/features/global-api/global-api.spec.js

@@ -49,7 +49,7 @@ describe('Global API', () => {
     const vm = new Vue({
       el: document.createElement('div'),
       template: '<div><foo></foo><bar></bar></div>',
-      components: {foo, bar}
+      components: { foo, bar }
     })
     expect(vm.$el.innerHTML).toBe('<span>foo</span><span>bar</span>')
   })

+ 10 - 10
test/unit/features/global-api/global-observer-api.spec.js

@@ -2,11 +2,11 @@ import Vue from 'vue'
 
 describe('Global Data Observer API', () => {
   describe('Vue.set', () => {
-    it('should update a vue object', (done) => {
+    it('should update a vue object', done => {
       const vm = new Vue({
         el: document.createElement('div'),
         template: '<div>{{x}}</div>',
-        data: {x: 1}
+        data: { x: 1 }
       })
       expect(vm.$el.innerHTML).toBe('1')
       Vue.set(vm, 'x', 2)
@@ -16,11 +16,11 @@ describe('Global Data Observer API', () => {
       })
     })
 
-    it('should update a observing object', (done) => {
+    it('should update a observing object', done => {
       const vm = new Vue({
         el: document.createElement('div'),
         template: '<div>{{foo.x}}</div>',
-        data: {foo: {x: 1}}
+        data: { foo: { x: 1 }}
       })
       expect(vm.$el.innerHTML).toBe('1')
       Vue.set(vm.foo, 'x', 2)
@@ -30,11 +30,11 @@ describe('Global Data Observer API', () => {
       })
     })
 
-    it('should update a observing array', (done) => {
+    it('should update a observing array', done => {
       const vm = new Vue({
         el: document.createElement('div'),
         template: '<div><div v-for="v,k in list">{{k}}-{{v}}</div></div>',
-        data: {list: ['a', 'b', 'c']}
+        data: { list: ['a', 'b', 'c'] }
       })
       expect(vm.$el.innerHTML).toBe('<div>0-a</div><div>1-b</div><div>2-c</div>')
       Vue.set(vm.list, 1, 'd')
@@ -44,11 +44,11 @@ describe('Global Data Observer API', () => {
       })
     })
 
-    it('should update a vue object with nothing', (done) => {
+    it('should update a vue object with nothing', done => {
       const vm = new Vue({
         el: document.createElement('div'),
         template: '<div>{{x}}</div>',
-        data: {x: 1}
+        data: { x: 1 }
       })
       expect(vm.$el.innerHTML).toBe('1')
       Vue.set(vm, 'x', null)
@@ -64,11 +64,11 @@ describe('Global Data Observer API', () => {
   })
 
   describe('Vue.delete', () => {
-    it('should delete a key', (done) => {
+    it('should delete a key', done => {
       const vm = new Vue({
         el: document.createElement('div'),
         template: '<div>{{x}}</div>',
-        data: {x: 1}
+        data: { x: 1 }
       })
       expect(vm.$el.innerHTML).toBe('1')
       vm.x = 2