Skip to content

Commit efed800

Browse files
authored
Merge pull request #59 from mpvue/lintconfig
update: eslint 移除airbnb规则,默认standard规则
2 parents c7ff1ce + e332ea5 commit efed800

File tree

13 files changed

+82
-117
lines changed

13 files changed

+82
-117
lines changed

meta.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,28 @@ module.exports = {
5454
"type": "confirm",
5555
"message": "Use ESLint to lint your code?"
5656
},
57-
"lintConfig": {
58-
"when": "lint",
59-
"type": "list",
60-
"message": "Pick an ESLint preset",
61-
"choices": [
62-
{
63-
"name": "Standard (https://github.com/feross/standard)",
64-
"value": "standard",
65-
"short": "Standard"
66-
},
67-
{
68-
"name": "Airbnb (https://github.com/airbnb/javascript)",
69-
"value": "airbnb",
70-
"short": "Airbnb"
71-
},
72-
{
73-
"name": "none (configure it yourself)",
74-
"value": "none",
75-
"short": "none"
76-
}
77-
]
78-
},
57+
// "lintConfig": {
58+
// "when": "lint",
59+
// "type": "list",
60+
// "message": "Pick an ESLint preset",
61+
// "choices": [
62+
// {
63+
// "name": "Standard (https://github.com/feross/standard)",
64+
// "value": "standard",
65+
// "short": "Standard"
66+
// },
67+
// {
68+
// "name": "Airbnb (https://github.com/airbnb/javascript)",
69+
// "value": "airbnb",
70+
// "short": "Airbnb"
71+
// },
72+
// {
73+
// "name": "none (configure it yourself)",
74+
// "value": "none",
75+
// "short": "none"
76+
// }
77+
// ]
78+
// },
7979
"test": {
8080
"value": false,
8181
"message": "小程序测试,敬请关注最新微信开发者工具的“测试报告”功能"

template/.eslintrc.js

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,59 +11,32 @@ module.exports = {
1111
node: true,
1212
es6: true
1313
},
14-
{{#if_eq lintConfig "standard"}}
1514
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
1615
extends: 'standard',
17-
{{/if_eq}}
18-
{{#if_eq lintConfig "airbnb"}}
19-
extends: 'airbnb-base',
20-
{{/if_eq}}
2116
// required to lint *.vue files
2217
plugins: [
2318
'html'
2419
],
25-
{{#if_eq lintConfig "airbnb"}}
26-
// check if imports actually resolve
27-
'settings': {
28-
'import/resolver': {
29-
'webpack': {
30-
'config': 'build/webpack.base.conf.js'
31-
}
32-
}
33-
},
34-
{{/if_eq}}
3520
// add your custom rules here
3621
'rules': {
37-
{{#if_eq lintConfig "standard"}}
3822
// allow paren-less arrow functions
3923
'arrow-parens': 0,
4024
// allow async-await
4125
'generator-star-spacing': 0,
42-
{{/if_eq}}
43-
{{#if_eq lintConfig "airbnb"}}
44-
// don't require .vue extension when importing
45-
'import/extensions': ['error', 'always', {
46-
'js': 'never',
47-
'vue': 'never',
48-
'json': 'never'
49-
}],
50-
'import/no-unresolved': [2, {
51-
'caseSensitive': false
52-
}],
53-
// allow optionalDependencies
54-
'import/no-extraneous-dependencies': ['error', {
55-
'optionalDependencies': ['test/unit/index.js']
56-
}],
57-
{{/if_eq}}
5826
// allow debugger during development
5927
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
6028
},
6129
globals: {
6230
App: true,
6331
Page: true,
6432
wx: true,
33+
swan: true,
34+
tt: true,
35+
my: true,
6536
getApp: true,
6637
getPage: true,
67-
requirePlugin: true
38+
requirePlugin: true,
39+
mpvue: true,
40+
mpvuePlatform: true
6841
}
6942
}

template/package.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,10 @@
4949
"eslint-plugin-import": "^2.11.0",
5050
"eslint-plugin-node": "^6.0.1",
5151
"eslint-plugin-html": "^4.0.3",
52-
{{#if_eq lintConfig "standard"}}
5352
"eslint-config-standard": "^11.0.0",
5453
"eslint-plugin-promise": "^3.4.0",
5554
"eslint-plugin-standard": "^3.0.1",
56-
{{/if_eq}}
57-
{{#if_eq lintConfig "airbnb"}}
58-
"eslint-config-airbnb-base": "^12.1.0",
59-
"eslint-import-resolver-webpack": "^0.9.0",
60-
{{/if_eq}}
55+
"babel-eslint": "^8.2.3",
6156
{{/lint}}
6257
"eventsource-polyfill": "^0.9.6",
6358
"express": "^4.16.3",
@@ -75,9 +70,6 @@
7570
"prettier": "~1.12.1",
7671
"px2rpx-loader": "^0.1.10",
7772
"relative": "^3.0.2",
78-
{{#lint}}
79-
"babel-eslint": "^8.2.3",
80-
{{/lint}}
8173
"rimraf": "^2.6.0",
8274
"semver": "^5.3.0",
8375
"shelljs": "^0.8.1",

template/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525
}
2626
},
2727
log () {
28-
console.log(`log at:${Date.now()}`);
28+
console.log(`log at:${Date.now()}`)
2929
}
3030
}
3131
</script>

template/src/pages/counter/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import store from './store'
1414
1515
export default {
1616
computed: {
17-
count() {
17+
count () {
1818
return store.state.count
1919
}
2020
},
2121
methods: {
22-
increment() {
22+
increment () {
2323
store.commit('increment')
2424
},
25-
decrement() {
25+
decrement () {
2626
store.commit('decrement')
2727
}
2828
}

template/src/pages/index/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default {
6969
},
7070
7171
created () {
72-
let app = getApp()
72+
// let app = getApp()
7373
}
7474
}
7575
</script>

template/src/utils/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
function formatNumber(n) {
1+
function formatNumber (n) {
22
const str = n.toString()
33
return str[1] ? str : `0${str}`
44
}
55

6-
export function formatTime(date) {
6+
export function formatTime (date) {
77
const year = date.getFullYear()
88
const month = date.getMonth() + 1
99
const day = date.getDate()

template/test/e2e/custom-assertions/elementCount.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
// for how to write custom assertions see
88
// http://nightwatchjs.org/guide#writing-custom-assertions
99
exports.assertion = function (selector, count) {
10-
this.message = 'Testing if element <' + selector + '> has count: ' + count{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
11-
this.expected = count{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
10+
this.message = 'Testing if element <' + selector + '> has count: ' + count
11+
this.expected = count
1212
this.pass = function (val) {
13-
return val === this.expected{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
13+
return val === this.expected
1414
}
1515
this.value = function (res) {
16-
return res.value{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
16+
return res.value
1717
}
1818
this.command = function (cb) {
19-
var self = this{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
19+
var self = this
2020
return this.api.execute(function (selector) {
21-
return document.querySelectorAll(selector).length{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
21+
return document.querySelectorAll(selector).length
2222
}, [selector], function (res) {
23-
cb.call(self, res){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
24-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
23+
cb.call(self, res)
24+
})
2525
}
2626
}

template/test/e2e/runner.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// 1. start the dev server using production config
2-
process.env.NODE_ENV = 'testing'{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
3-
var server = require('../../build/dev-server.js'){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
2+
process.env.NODE_ENV = 'testing'
3+
var server = require('../../build/dev-server.js')
44

55
server.ready.then(() => {
66
// 2. run the nightwatch test suite against it
@@ -10,24 +10,24 @@ server.ready.then(() => {
1010
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
1111
// For more information on Nightwatch's config file, see
1212
// http://nightwatchjs.org/guide#settings-file
13-
var opts = process.argv.slice(2){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
13+
var opts = process.argv.slice(2)
1414
if (opts.indexOf('--config') === -1) {
15-
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js']){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
15+
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
1616
}
1717
if (opts.indexOf('--env') === -1) {
18-
opts = opts.concat(['--env', 'chrome']){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
18+
opts = opts.concat(['--env', 'chrome'])
1919
}
2020

21-
var spawn = require('cross-spawn'){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
22-
var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' }){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
21+
var spawn = require('cross-spawn')
22+
var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
2323

2424
runner.on('exit', function (code) {
25-
server.close(){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
26-
process.exit(code){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
27-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
25+
server.close()
26+
process.exit(code)
27+
})
2828

2929
runner.on('error', function (err) {
30-
server.close(){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
31-
throw err{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
32-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
33-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
30+
server.close()
31+
throw err
32+
})
33+
})

template/test/e2e/specs/test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
// http://nightwatchjs.org/guide#usage
33

44
module.exports = {
5-
'default e2e tests': function {{#if_eq lintConfig "airbnb"}}test{{/if_eq}}(browser) {
5+
'default e2e tests': function (browser) {
66
// automatically uses dev Server port from /config.index.js
77
// default: http://localhost:8080
88
// see nightwatch.conf.js
9-
const devServer = browser.globals.devServerURL{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
9+
const devServer = browser.globals.devServerURL
1010

1111
browser
1212
.url(devServer)
1313
.waitForElementVisible('#app', 5000)
1414
.assert.elementPresent('.hello')
1515
.assert.containsText('h1', 'Welcome to Your Vue.js App')
1616
.assert.elementCount('img', 1)
17-
.end(){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
18-
}{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
19-
}{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
17+
.end()
18+
}
19+
}

template/test/unit/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import Vue from 'vue'{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
1+
import Vue from 'vue'
22

3-
Vue.config.productionTip = false{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
3+
Vue.config.productionTip = false
44

55
// require all test files (files that ends with .spec.js)
6-
const testsContext = require.context('./specs', true, /\.spec$/){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
7-
testsContext.keys().forEach(testsContext){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
6+
const testsContext = require.context('./specs', true, /\.spec$/)
7+
testsContext.keys().forEach(testsContext)
88

99
// require all src files except main.js for coverage.
1010
// you can also change this to match only the subset of files that
1111
// you want coverage for.
12-
const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
13-
srcContext.keys().forEach(srcContext){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
12+
const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
13+
srcContext.keys().forEach(srcContext)

template/test/unit/karma.conf.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// we are also using it with karma-webpack
44
// https://github.com/webpack/karma-webpack
55

6-
var webpackConfig = require('../../build/webpack.test.conf'){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
6+
var webpackConfig = require('../../build/webpack.test.conf')
77

88
module.exports = function (config) {
99
config.set({
@@ -20,14 +20,14 @@ module.exports = function (config) {
2020
},
2121
webpack: webpackConfig,
2222
webpackMiddleware: {
23-
noInfo: true{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
23+
noInfo: true
2424
},
2525
coverageReporter: {
2626
dir: './coverage',
2727
reporters: [
2828
{ type: 'lcov', subdir: '.' },
29-
{ type: 'text-summary' }{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
29+
{ type: 'text-summary' }
3030
]
31-
}{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
32-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
33-
}{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
31+
}
32+
})
33+
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import Vue from 'vue'{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
2-
import Hello from '@/components/Hello'{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
1+
import Vue from 'vue'
2+
import Hello from '@/components/Hello'
33

44
describe('Hello.vue', () => {
55
it('should render correct contents', () => {
6-
const Constructor = Vue.extend(Hello){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
7-
const vm = new Constructor().$mount(){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
6+
const Constructor = Vue.extend(Hello)
7+
const vm = new Constructor().$mount()
88
expect(vm.$el.querySelector('.hello h1').textContent)
9-
.to.equal('Welcome to Your Vue.js App'){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
10-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
11-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
9+
.to.equal('Welcome to Your Vue.js App')
10+
})
11+
})

0 commit comments

Comments
 (0)