Skip to content

Commit 81b351e

Browse files
committed
feat: 统一eslint规范
2 parents aa79143 + 50a570d commit 81b351e

File tree

115 files changed

+6930
-6156
lines changed

Some content is hidden

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

115 files changed

+6930
-6156
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/script/.cache
55
/*.js
66
/node_modules/
7+
/tests/unit/LIcon.test.js

.eslintrc.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ module.exports = {
33
env: {
44
node: true,
55
},
6-
plugins: [
7-
'vue',
8-
],
9-
extends: [
10-
'plugin:vue/essential',
11-
'@vue/airbnb',
12-
],
6+
plugins: ['vue'],
7+
extends: ['plugin:vue/essential', '@vue/airbnb'],
138
rules: {
149
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
1510
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
@@ -19,6 +14,7 @@ module.exports = {
1914
'no-underscore-dangle': 0, // 无下划线
2015
camelcase: 0, // 变量可以用下划线
2116
semi: ['error', 'never'], // 无分号
17+
'no-extra-semi': 0, // 和prettier冲突
2218
'no-plusplus': 0, // 禁止使用++,--
2319
// 'no-tabs': [o],
2420
'guard-for-in': 0,
@@ -28,6 +24,15 @@ module.exports = {
2824
'no-restricted-syntax': 0,
2925
'class-methods-use-this': 'off',
3026
'consistent-return': 'off',
27+
'arrow-parens': ['error', 'as-needed'],
28+
'object-curly-newline': [
29+
'error',
30+
{
31+
ImportDeclaration: 'never',
32+
},
33+
],
34+
'comma-dangle': ['error', 'only-multiline'],
35+
'no-param-reassign': ['error', { props: false }],
3136
},
3237
parserOptions: {
3338
parser: 'babel-eslint',

.prettierrc.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
singleQuote: true, //字符串是否使用单引号,默认为false,使用双引号
33
semi: false, //行位是否使用分号,默认为true
4-
trailingComma: 'es5', //是否使用尾逗号,有三个可选值"<none|es5|all>"
5-
arrowParens: 'always'
6-
};
4+
trailingComma: 'all', //是否使用尾逗号,有三个可选值"<none|es5|all>"
5+
printWidth: 120,
6+
arrowParens: 'avoid',
7+
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
},
8585
"lint-staged": {
8686
"*.{js,vue}": [
87-
"vue-cli-service lint",
88-
"git add"
87+
"prettier --write",
88+
"vue-cli-service lint"
8989
]
9090
}
9191
}

src/App.vue

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<template>
2-
<div id="app">
3-
<router-view />
4-
</div>
2+
<div id="app"><router-view /></div>
53
</template>
64

75
<script>
@@ -31,7 +29,6 @@ export default {
3129
</script>
3230

3331
<style lang="scss">
34-
3532
#app {
3633
-webkit-font-smoothing: antialiased;
3734
-moz-osx-font-smoothing: grayscale;

src/components/base/date-picker/lin-date-picker.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div class="container">
3-
<el-date-picker v-model="value"
3+
<el-date-picker
4+
v-model="value"
45
type="daterange"
56
range-separator=""
67
start-placeholder="开始日期"
@@ -10,7 +11,8 @@
1011
popper-class="date-box"
1112
value-format="yyyy-MM-dd HH:mm:ss"
1213
:default-time="['00:00:00', '23:59:59']"
13-
:picker-options="pickerOptions">
14+
:picker-options="pickerOptions"
15+
>
1416
</el-date-picker>
1517
</div>
1618
</template>
+3-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
<template>
22
<div class="container">
33
<el-dialog title="编辑分组" :append-to-body="true" :visible.sync="dialogFormVisible">
4-
<slot name="content"></slot>
5-
<slot name="footer"></slot>
4+
<slot name="content"></slot> <slot name="footer"></slot>
65
</el-dialog>
76
</div>
87
</template>
98

109
<script>
1110
export default {
1211
data() {
13-
return {
14-
15-
}
12+
return {}
1613
},
1714
}
1815
</script>
1916

20-
<style scoped lang="stylus">
21-
</style>
17+
<style scoped lang="stylus"></style>

src/components/base/dropdown/lin-dropdown.vue

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<template>
22
<div class="container">
33
<el-dropdown @command="handleCommand">
4-
<el-button>
5-
{{title}}
6-
<i class="el-icon-arrow-down el-icon--right"></i>
7-
</el-button>
4+
<el-button> {{ title }} <i class="el-icon-arrow-down el-icon--right"></i> </el-button>
85
<el-dropdown-menu slot="dropdown">
9-
<el-dropdown-item v-for="single in list" :key="single" :command="single">
10-
{{single}}
11-
</el-dropdown-item>
6+
<el-dropdown-item v-for="single in list" :key="single" :command="single"> {{ single }} </el-dropdown-item>
127
</el-dropdown-menu>
138
</el-dropdown>
149
</div>

src/components/base/preview/preview.vue

+18-29
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@
22
<div v-if="data.length">
33
<div ref="myGallery" class="my-gallery" :data-pswp-uid="radom">
44
<div v-if="slides.length">
5-
<div :key="radom + '_' + index" v-for="(l ,index) in slides">
6-
<img preview :src="l" alt="">
7-
</div>
5+
<div :key="radom + '_' + index" v-for="(l, index) in slides"><img preview :src="l" alt="" /></div>
86
</div>
97
</div>
10-
<div
11-
ref="pswpWrap"
12-
class="pswp"
13-
tabindex="-1"
14-
role="dialog"
15-
aria-hidden="true">
8+
<div ref="pswpWrap" class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
169
<div class="pswp__bg"></div>
1710
<div class="pswp__scroll-wrap">
1811
<div class="pswp__container">
@@ -29,22 +22,16 @@
2922
<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
3023
<div class="pswp__preloader">
3124
<div class="pswp__preloader__icn">
32-
<div class="pswp__preloader__cut">
33-
<div class="pswp__preloader__donut"></div>
34-
</div>
25+
<div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div>
3526
</div>
3627
</div>
3728
</div>
3829
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
3930
<div class="pswp__share-tooltip"></div>
4031
</div>
41-
<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
42-
</button>
43-
<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
44-
</button>
45-
<div class="pswp__caption">
46-
<div class="pswp__caption__center"></div>
47-
</div>
32+
<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button>
33+
<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button>
34+
<div class="pswp__caption"><div class="pswp__caption__center"></div></div>
4835
</div>
4936
</div>
5037
</div>
@@ -61,7 +48,9 @@ import PhotoSwipe from 'photoswipe/dist/photoswipe'
6148
import PhotoSwipeUIDefault from 'photoswipe/dist/photoswipe-ui-default'
6249
/** 生成随机字符串 */
6350
function createId() {
64-
return Math.random().toString(36).substring(2)
51+
return Math.random()
52+
.toString(36)
53+
.substring(2)
6554
}
6655
export default {
6756
name: 'PreviewImage',
@@ -127,22 +116,22 @@ export default {
127116
})
128117
const loadingInstance = Loading.service()
129118
const galleryElement = this.$refs.myGallery
130-
this.radom = createId();
119+
this.radom = createId()
131120
let pswpElement = this.$refs.pswpWrap
132121
const items = await this.transThumbnailElements()
133122
let photoSwipeOptions = {
134123
galleryUID: this.radom,
135-
getThumbBoundsFn: function (index) {
124+
getThumbBoundsFn: function(index) {
136125
let thumbnail = items[index].el
137126
let pageYScroll = window.pageYOffset || document.documentElement.scrollTop
138127
let rect = thumbnail.getBoundingClientRect()
139128
return {
140129
x: rect.left,
141130
y: rect.top + pageYScroll,
142-
w: rect.width
131+
w: rect.width,
143132
}
144133
},
145-
...options
134+
...options,
146135
}
147136
this.gallery = new PhotoSwipe(pswpElement, PhotoSwipeUIDefault, items, photoSwipeOptions)
148137
this.gallery.init()
@@ -159,17 +148,17 @@ export default {
159148
},
160149
async getWH(elem) {
161150
return new Promise((resolve, reject) => {
162-
if (typeof elem.naturalWidth === "undefined") {
151+
if (typeof elem.naturalWidth === 'undefined') {
163152
// IE 6/7/8
164153
let img = new window.Image()
165154
img.src = elem.getAttribute('src')
166-
img.onload = function () {
155+
img.onload = function() {
167156
resolve({
168157
w: this.width,
169158
h: this.height,
170159
})
171160
}
172-
img.onerror = function () {
161+
img.onerror = function() {
173162
reject({
174163
w: 0,
175164
h: 0,
@@ -182,7 +171,7 @@ export default {
182171
h: elem.naturalHeight,
183172
})
184173
} else {
185-
elem.onload = function () {
174+
elem.onload = function() {
186175
resolve({
187176
w: this.naturalWidth,
188177
h: this.naturalHeight,
@@ -217,7 +206,7 @@ export default {
217206
destroy() {
218207
// 销毁
219208
if (this.gallery) {
220-
this.gallery.close();
209+
this.gallery.close()
221210
this.gallery = null
222211
}
223212
},

src/components/base/search/lin-search.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="lin-search">
3-
<el-input size="medium" :placeholder="placeholder" clearable v-model="keyword" class="input-with-select">
3+
<el-input size="medium" :placeholder="placeholder" clearable v-model="keyword" class="input-with-select">
44
<el-button slot="append" icon="el-icon-search"></el-button>
55
</el-input>
66
</div>
@@ -25,7 +25,7 @@ export default {
2525
// 节流搜索
2626
this.$watch(
2727
'keyword',
28-
Utils.debounce((newQuery) => {
28+
Utils.debounce(newQuery => {
2929
this.$emit('query', newQuery)
3030
}, 1000),
3131
)

src/components/base/source-code/source-code.vue

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
</div>
55
</template>
66

7-
87
<script type="text/ecmascript-6">
98
export default {
109
props: {
@@ -36,14 +35,14 @@ export default {
3635
border-radius: 4px;
3736
padding: 7px 15px;
3837
padding-right: 19px;
39-
background-color: rgba(0,0,0,.7);
38+
background-color: rgba(0, 0, 0, 0.7);
4039
border: 1px solid #000;
4140
color: #fff;
42-
-webkit-transition: all .3s;
43-
transition: all .3s;
41+
-webkit-transition: all 0.3s;
42+
transition: all 0.3s;
4443
&:hover {
4544
right: -4px;
46-
background-color: rgba(0,0,0,.9);
45+
background-color: rgba(0, 0, 0, 0.9);
4746
}
4847
}
4948
</style>
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<template>
2-
<div class="wrapper">
3-
<slot></slot>
4-
</div>
2+
<div class="wrapper"><slot></slot></div>
53
</template>
64

75
<style lang="scss" scoped>
86
.wrapper {
97
position: sticky;
108
top: 0;
119
z-index: 9;
12-
background:#fff;
10+
background: #fff;
1311
}
1412
</style>

0 commit comments

Comments
 (0)