Skip to content

Commit 5972ea0

Browse files
committed
Add eslint
1 parent 77bf914 commit 5972ea0

File tree

8 files changed

+55
-7
lines changed

8 files changed

+55
-7
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/*.js

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
root: true,
3+
parser: 'babel-eslint',
4+
parserOptions: {
5+
sourceType: 'module'
6+
},
7+
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
8+
extends: 'standard',
9+
// required to lint *.vue files
10+
plugins: [
11+
'html'
12+
],
13+
// add your custom rules here
14+
'rules': {
15+
// allow paren-less arrow functions
16+
'arrow-parens': 0,
17+
// allow async-await
18+
'generator-star-spacing': 0,
19+
// allow debugger during development
20+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
21+
}
22+
}

build/webpack.base.config.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path')
2-
2+
const projectRoot = path.resolve(__dirname, '../')
33
module.exports = {
44
devtool: '#source-map',
55
entry: {
@@ -15,6 +15,20 @@ module.exports = {
1515
root: path.join(__dirname, '../node_modules'),
1616
},
1717
module: {
18+
preLoaders: [
19+
{
20+
test: /\.vue$/,
21+
loader: 'eslint',
22+
include: projectRoot,
23+
exclude: /node_modules/
24+
},
25+
{
26+
test: /\.js$/,
27+
loader: 'eslint',
28+
include: projectRoot,
29+
exclude: /node_modules/
30+
}
31+
],
1832
loaders: [
1933
{
2034
test: /\.vue$/,
@@ -32,6 +46,9 @@ module.exports = {
3246
name: '[name].[ext]?[hash]'
3347
}
3448
}
35-
]
49+
],
50+
eslint: {
51+
formatter: require('eslint-friendly-formatter')
52+
}
3653
}
3754
}

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,18 @@
4242
},
4343
"devDependencies": {
4444
"babel-core": "^6.13.2",
45+
"babel-eslint": "^6.1.2",
4546
"babel-loader": "^6.0.0",
4647
"babel-preset-es2015": "^6.13.2",
4748
"babel-preset-stage-2": "^6.13.0",
4849
"css-loader": "^0.23.1",
50+
"eslint": "^3.2.2",
51+
"eslint-config-standard": "^6.0.0-beta.2",
52+
"eslint-friendly-formatter": "^2.0.6",
53+
"eslint-loader": "^1.5.0",
54+
"eslint-plugin-html": "^1.5.2",
55+
"eslint-plugin-promise": "^2.0.1",
56+
"eslint-plugin-standard": "^2.0.0",
4957
"extract-text-webpack-plugin": "^2.0.0-beta.3",
5058
"file-loader": "^0.8.4",
5159
"vue-loader": "^9.2.2",

src/client-entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { app } from './app'
22

3-
app.$mount('#app')
3+
app.$mount('#app')

src/router/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ const router = new VueRouter({
1818
]
1919
})
2020

21-
export default router
21+
export default router

src/vuex/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import request from 'axios'
22

3-
request.defaults.baseURL = 'https://cnodejs.org/api/v1/';
3+
request.defaults.baseURL = 'https://cnodejs.org/api/v1/'
44

55
export const getTopics = ({ commit, state }) => {
66
return request.get('topics').then((response) => {

src/vuex/store.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ const mutations = {
2020
state.topics = topics
2121
},
2222

23-
INCREMENT: (state) => {
23+
INCREMENT: (state) => {
2424
state.count++
2525
},
2626

27-
DECREMENT: (state) => {
27+
DECREMENT: (state) => {
2828
state.count--
2929
}
3030
}

0 commit comments

Comments
 (0)