Skip to content

Commit e5d4290

Browse files
authored
refactor: add eslint-plugin-vue && lint code (#976)
1 parent 8f58baf commit e5d4290

File tree

124 files changed

+1327
-1082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1327
-1082
lines changed

Diff for: .eslintrc.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
module.exports = {
22
root: true,
3-
parser: 'babel-eslint',
43
parserOptions: {
4+
parser: 'babel-eslint',
55
sourceType: 'module'
66
},
77
env: {
88
browser: true,
99
node: true,
1010
es6: true,
1111
},
12-
extends: 'eslint:recommended',
13-
// required to lint *.vue files
14-
plugins: [
15-
'html'
16-
],
17-
// check if imports actually resolve
18-
'settings': {
19-
'import/resolver': {
20-
'webpack': {
21-
'config': 'build/webpack.base.conf.js'
22-
}
23-
}
24-
},
12+
extends: ['plugin:vue/recommended', 'eslint:recommended'],
13+
2514
// add your custom rules here
2615
//it is base on https://github.com/vuejs/eslint-config-vue
27-
'rules': {
16+
rules: {
17+
"vue/max-attributes-per-line": [2, {
18+
"singleline": 10,
19+
"multiline": {
20+
"max": 1,
21+
"allowFirstLine": false
22+
}
23+
}],
24+
"vue/name-property-casing": ["error", "PascalCase"],
2825
'accessor-pairs': 2,
2926
'arrow-spacing': [2, {
3027
'before': true,
@@ -196,4 +193,3 @@ module.exports = {
196193
'array-bracket-spacing': [2, 'never']
197194
}
198195
}
199-

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@
8282
"eslint": "4.19.1",
8383
"eslint-friendly-formatter": "4.0.1",
8484
"eslint-loader": "2.0.0",
85-
"eslint-plugin-html": "4.0.5",
85+
"eslint-plugin-vue": "4.7.1",
8686
"file-loader": "1.1.11",
8787
"friendly-errors-webpack-plugin": "1.7.0",
88-
"hash-sum": "^1.0.2",
88+
"hash-sum": "1.0.2",
8989
"html-webpack-plugin": "^4.0.0-alpha",
9090
"husky": "0.14.3",
9191
"lint-staged": "7.2.2",

Diff for: src/App.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div id="app">
3-
<router-view></router-view>
3+
<router-view/>
44
</div>
55
</template>
66

77
<script>
8-
export default{
9-
name: 'App'
10-
}
8+
export default{
9+
name: 'App'
10+
}
1111
</script>

Diff for: src/components/BackToTop/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<transition :name="transitionName">
3-
<div class="back-to-ceiling" @click="backToTop" v-show="visible" :style="customStyle">
3+
<div v-show="visible" :style="customStyle" class="back-to-ceiling" @click="backToTop">
44
<svg width="16" height="16" viewBox="0 0 17 17" xmlns="http://www.w3.org/2000/svg" class="Icon Icon--backToTopArrow" aria-hidden="true" style="height: 16px; width: 16px;">
55
<title>回到顶部</title>
66
<g>
7-
<path d="M12.036 15.59c0 .55-.453.995-.997.995H5.032c-.55 0-.997-.445-.997-.996V8.584H1.03c-1.1 0-1.36-.633-.578-1.416L7.33.29c.39-.39 1.026-.385 1.412 0l6.878 6.88c.782.78.523 1.415-.58 1.415h-3.004v7.004z" fill-rule="evenodd"></path>
7+
<path d="M12.036 15.59c0 .55-.453.995-.997.995H5.032c-.55 0-.997-.445-.997-.996V8.584H1.03c-1.1 0-1.36-.633-.578-1.416L7.33.29c.39-.39 1.026-.385 1.412 0l6.878 6.88c.782.78.523 1.415-.58 1.415h-3.004v7.004z" fill-rule="evenodd"/>
88
</g>
99
</svg>
1010
</div>

Diff for: src/components/Breadcrumb/index.vue

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<el-breadcrumb class="app-breadcrumb" separator="/">
33
<transition-group name="breadcrumb">
4-
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path" v-if='item.meta.title'>
5-
<span v-if='item.redirect==="noredirect"||index==levelList.length-1' class="no-redirect">{{generateTitle(item.meta.title)}}</span>
6-
<router-link v-else :to="item.redirect||item.path">{{generateTitle(item.meta.title)}}</router-link>
4+
<el-breadcrumb-item v-for="(item,index) in levelList" v-if="item.meta.title" :key="item.path">
5+
<span v-if="item.redirect===&quot;noredirect&quot;||index==levelList.length-1" class="no-redirect">{{ generateTitle(item.meta.title) }}</span>
6+
<router-link v-else :to="item.redirect||item.path">{{ generateTitle(item.meta.title) }}</router-link>
77
</el-breadcrumb-item>
88
</transition-group>
99
</el-breadcrumb>
@@ -13,9 +13,6 @@
1313
import { generateTitle } from '@/utils/i18n'
1414
1515
export default {
16-
created() {
17-
this.getBreadcrumb()
18-
},
1916
data() {
2017
return {
2118
levelList: null
@@ -26,12 +23,15 @@ export default {
2623
this.getBreadcrumb()
2724
}
2825
},
26+
created() {
27+
this.getBreadcrumb()
28+
},
2929
methods: {
3030
generateTitle,
3131
getBreadcrumb() {
3232
let matched = this.$route.matched.filter(item => item.name)
3333
const first = matched[0]
34-
if (first && first.name !== 'dashboard') {
34+
if (first && first.name.trim().toLocaleLowerCase() !== 'Dashboard'.toLocaleLowerCase()) {
3535
matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)
3636
}
3737
this.levelList = matched

Diff for: src/components/Charts/keyboard.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="className" :id="id" :style="{height:height,width:width}"></div>
2+
<div :class="className" :id="id" :style="{height:height,width:width}"/>
33
</template>
44

55
<script>

Diff for: src/components/Charts/lineMarker.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="className" :id="id" :style="{height:height,width:width}"></div>
2+
<div :class="className" :id="id" :style="{height:height,width:width}"/>
33
</template>
44

55
<script>

Diff for: src/components/Charts/mixChart.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :class="className" :id="id" :style="{height:height,width:width}"></div>
2+
<div :class="className" :id="id" :style="{height:height,width:width}"/>
33
</template>
44

55
<script>

Diff for: src/components/DndList/index.vue

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<template>
22
<div class="dndList">
3-
<div class="dndList-list" :style="{width:width1}">
4-
<h3>{{list1Title}}</h3>
5-
<draggable :list="list1" class="dragArea" :options="{group:'article'}">
6-
<div class="list-complete-item" v-for="element in list1" :key='element.id'>
7-
<div class="list-complete-item-handle">[{{element.author}}] {{element.title}}</div>
3+
<div :style="{width:width1}" class="dndList-list">
4+
<h3>{{ list1Title }}</h3>
5+
<draggable :list="list1" :options="{group:'article'}" class="dragArea">
6+
<div v-for="element in list1" :key="element.id" class="list-complete-item">
7+
<div class="list-complete-item-handle">[{{ element.author }}] {{ element.title }}</div>
88
<div style="position:absolute;right:0px;">
99
<span style="float: right ;margin-top: -20px;margin-right:5px;" @click="deleteEle(element)">
10-
<i style="color:#ff4949" class="el-icon-delete"></i>
10+
<i style="color:#ff4949" class="el-icon-delete"/>
1111
</span>
1212
</div>
1313
</div>
1414
</draggable>
1515
</div>
16-
<div class="dndList-list" :style="{width:width2}">
17-
<h3>{{list2Title}}</h3>
18-
<draggable :list="filterList2" class="dragArea" :options="{group:'article'}">
19-
<div class="list-complete-item" v-for="element in filterList2" :key='element.id'>
20-
<div class='list-complete-item-handle2' @click="pushEle(element)"> [{{element.author}}] {{element.title}}</div>
16+
<div :style="{width:width2}" class="dndList-list">
17+
<h3>{{ list2Title }}</h3>
18+
<draggable :list="filterList2" :options="{group:'article'}" class="dragArea">
19+
<div v-for="element in filterList2" :key="element.id" class="list-complete-item">
20+
<div class="list-complete-item-handle2" @click="pushEle(element)"> [{{ element.author }}] {{ element.title }}</div>
2121
</div>
2222
</draggable>
2323
</div>
@@ -30,16 +30,6 @@ import draggable from 'vuedraggable'
3030
export default {
3131
name: 'DndList',
3232
components: { draggable },
33-
computed: {
34-
filterList2() {
35-
return this.list2.filter(v => {
36-
if (this.isNotInList1(v)) {
37-
return v
38-
}
39-
return false
40-
})
41-
}
42-
},
4333
props: {
4434
list1: {
4535
type: Array,
@@ -70,6 +60,16 @@ export default {
7060
default: '48%'
7161
}
7262
},
63+
computed: {
64+
filterList2() {
65+
return this.list2.filter(v => {
66+
if (this.isNotInList1(v)) {
67+
return v
68+
}
69+
return false
70+
})
71+
}
72+
},
7373
methods: {
7474
isNotInList1(v) {
7575
return this.list1.every(k => v.id !== k.id)

Diff for: src/components/Dropzone/index.vue

+74-71
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div :ref="id" :action="url" class="dropzone" :id="id">
2+
<div :ref="id" :action="url" :id="id" class="dropzone">
33
<input type="file" name="file">
44
</div>
55
</template>
@@ -12,12 +12,81 @@ import 'dropzone/dist/dropzone.css'
1212
Dropzone.autoDiscover = false
1313
1414
export default {
15+
props: {
16+
id: {
17+
type: String,
18+
required: true
19+
},
20+
url: {
21+
type: String,
22+
required: true
23+
},
24+
clickable: {
25+
type: Boolean,
26+
default: true
27+
},
28+
defaultMsg: {
29+
type: String,
30+
default: '上传图片'
31+
},
32+
acceptedFiles: {
33+
type: String,
34+
default: ''
35+
},
36+
thumbnailHeight: {
37+
type: Number,
38+
default: 200
39+
},
40+
thumbnailWidth: {
41+
type: Number,
42+
default: 200
43+
},
44+
showRemoveLink: {
45+
type: Boolean,
46+
default: true
47+
},
48+
maxFilesize: {
49+
type: Number,
50+
default: 2
51+
},
52+
maxFiles: {
53+
type: Number,
54+
default: 3
55+
},
56+
autoProcessQueue: {
57+
type: Boolean,
58+
default: true
59+
},
60+
useCustomDropzoneOptions: {
61+
type: Boolean,
62+
default: false
63+
},
64+
defaultImg: {
65+
default: '',
66+
type: [String, Array]
67+
},
68+
couldPaste: {
69+
type: Boolean,
70+
default: false
71+
}
72+
},
1573
data() {
1674
return {
1775
dropzone: '',
1876
initOnce: true
1977
}
2078
},
79+
watch: {
80+
defaultImg(val) {
81+
if (val.length === 0) {
82+
this.initOnce = false
83+
return
84+
}
85+
if (!this.initOnce) return
86+
this.initImages(val)
87+
this.initOnce = false
88+
}
89+
},
2190
mounted() {
2291
const element = document.getElementById(this.id)
2392
const vm = this
@@ -95,6 +164,10 @@ export default {
95164
vm.$emit('dropzone-successmultiple', file, error, xhr)
96165
})
97166
},
167+
destroyed() {
168+
document.removeEventListener('paste', this.pasteImg)
169+
this.dropzone.destroy()
170+
},
98171
methods: {
99172
removeAllFiles() {
100173
this.dropzone.removeAllFiles(true)
@@ -128,76 +201,6 @@ export default {
128201
}
129202
}
130203
131-
},
132-
destroyed() {
133-
document.removeEventListener('paste', this.pasteImg)
134-
this.dropzone.destroy()
135-
},
136-
watch: {
137-
defaultImg(val) {
138-
if (val.length === 0) {
139-
this.initOnce = false
140-
return
141-
}
142-
if (!this.initOnce) return
143-
this.initImages(val)
144-
this.initOnce = false
145-
}
146-
},
147-
props: {
148-
id: {
149-
type: String,
150-
required: true
151-
},
152-
url: {
153-
type: String,
154-
required: true
155-
},
156-
clickable: {
157-
type: Boolean,
158-
default: true
159-
},
160-
defaultMsg: {
161-
type: String,
162-
default: '上传图片'
163-
},
164-
acceptedFiles: {
165-
type: String
166-
},
167-
thumbnailHeight: {
168-
type: Number,
169-
default: 200
170-
},
171-
thumbnailWidth: {
172-
type: Number,
173-
default: 200
174-
},
175-
showRemoveLink: {
176-
type: Boolean,
177-
default: true
178-
},
179-
maxFilesize: {
180-
type: Number,
181-
default: 2
182-
},
183-
maxFiles: {
184-
type: Number,
185-
default: 3
186-
},
187-
autoProcessQueue: {
188-
type: Boolean,
189-
default: true
190-
},
191-
useCustomDropzoneOptions: {
192-
type: Boolean,
193-
default: false
194-
},
195-
defaultImg: {
196-
default: false
197-
},
198-
couldPaste: {
199-
default: false
200-
}
201204
}
202205
}
203206
</script>

0 commit comments

Comments
 (0)