From 05edb4a391970266fb189204d43216f0c51c4615 Mon Sep 17 00:00:00 2001 From: cookfront Date: Fri, 3 Mar 2017 16:40:48 +0800 Subject: [PATCH] fix lint --- .eslintrc.js | 3 ++- package.json | 2 +- packages/badge/src/badge.vue | 3 ++- packages/picker/src/picker.vue | 14 +++++++------- packages/steps/src/step.vue | 4 ++-- packages/steps/src/steps.vue | 4 ++-- packages/switch/src/switch.vue | 2 +- src/utils/merge.js | 6 +++--- src/utils/transition.js | 6 +++--- 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ba6d577fe..1e394e46e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,7 +21,8 @@ module.exports = { zanui: true, document: false, navigator: false, - window: false + window: false, + require: true }, env: { diff --git a/package.json b/package.json index 8d6f90a4b..917721b06 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "build:zanui-css": "gulp build --gulpfile packages/zanui-css/gulpfile.js && cp-cli packages/zanui-css/lib lib/zanui-css", "build:components": "cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.components.js", "build:zanui": "webpack --progress --hide-modules --config build/webpack.build.js && webpack --progress --hide-modules --config build/webpack.build.min.js", - "dist": "npm run clean && npm run build:file && npm run lint && npm run build:zanui && npm run build:utils && npm run build:zanui-css", + "dist": "npm run clean && npm run build:file && npm run lint && npm run build:zanui && npm run build:components && npm run build:utils && npm run build:zanui-css", "builddocs": "cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.config.js", "clean": "rimraf lib && rimraf packages/*/lib", "lint": "eslint src/**/*.js packages/**/*.{js,vue} --quiet", diff --git a/packages/badge/src/badge.vue b/packages/badge/src/badge.vue index 919324666..e0406b3c2 100644 --- a/packages/badge/src/badge.vue +++ b/packages/badge/src/badge.vue @@ -5,6 +5,7 @@ {{title}} + \ No newline at end of file + diff --git a/packages/picker/src/picker.vue b/packages/picker/src/picker.vue index 47670f5c6..22d56faf7 100644 --- a/packages/picker/src/picker.vue +++ b/packages/picker/src/picker.vue @@ -66,8 +66,8 @@ export default { computed: { values() { - let columns = this.columns || []; - let values = []; + const columns = this.columns || []; + const values = []; columns.forEach(column => { values.push(column.value || column.values[column.defaultIndex || 0]); @@ -89,7 +89,7 @@ export default { * 获取对应索引的列的实例 */ getColumn(index) { - let children = this.$children.filter(child => child.$options.name === 'zan-picker-column'); + const children = this.$children.filter(child => child.$options.name === 'zan-picker-column'); return children[index]; }, @@ -97,7 +97,7 @@ export default { * 获取对应列中选中的值 */ getColumnValue(index) { - let column = this.getColumn(index); + const column = this.getColumn(index); return column && column.values[column.valueIndex]; }, @@ -105,7 +105,7 @@ export default { * 设置对应列中选中的值 */ setColumnValue(index, value) { - let column = this.getColumn(index); + const column = this.getColumn(index); if (column) { column.currentValue = value; } @@ -115,7 +115,7 @@ export default { * 获取对应列中所有的备选值 */ getColumnValues(index) { - let column = this.getColumn(index); + const column = this.getColumn(index); return column && column.currentValues; }, @@ -123,7 +123,7 @@ export default { * 设置对应列中所有的备选值 */ setColumnValues(index, values) { - let column = this.getColumn(index); + const column = this.getColumn(index); if (column) { column.currentValues = values; } diff --git a/packages/steps/src/step.vue b/packages/steps/src/step.vue index 8e6fbcc9a..697d78468 100644 --- a/packages/steps/src/step.vue +++ b/packages/steps/src/step.vue @@ -21,8 +21,8 @@ export default { computed: { status() { - let index = this.$parent.steps.indexOf(this); - let active = this.$parent.active; + const index = this.$parent.steps.indexOf(this); + const active = this.$parent.active; if (index === -1) { return ''; diff --git a/packages/steps/src/steps.vue b/packages/steps/src/steps.vue index 0c403a963..336f91c9f 100644 --- a/packages/steps/src/steps.vue +++ b/packages/steps/src/steps.vue @@ -34,8 +34,8 @@ export default { computed: { computedIconClass() { - let iconName = `zan-icon-${this.icon}`; - let result = this.iconClass.split(' '); + const iconName = `zan-icon-${this.icon}`; + const result = this.iconClass.split(' '); result.push(iconName); return result; diff --git a/packages/switch/src/switch.vue b/packages/switch/src/switch.vue index 3b9df45f9..31da3494d 100644 --- a/packages/switch/src/switch.vue +++ b/packages/switch/src/switch.vue @@ -42,7 +42,7 @@ export default { }, computed: { switchStates: function() { - let switchStates = ['zan-switch--' + (this.checked ? 'on' : 'off'), + const switchStates = ['zan-switch--' + (this.checked ? 'on' : 'off'), 'zan-switch--' + (this.disabled ? 'disabled' : '')]; return switchStates; diff --git a/src/utils/merge.js b/src/utils/merge.js index 564a989a4..c73581621 100644 --- a/src/utils/merge.js +++ b/src/utils/merge.js @@ -1,9 +1,9 @@ export default function(target, ...sources) { for (let i = 0; i < sources.length; i++) { - let source = sources[i] || {}; - for (let prop in source) { + const source = sources[i] || {}; + for (const prop in source) { if (source.hasOwnProperty(prop)) { - let value = source[prop]; + const value = source[prop]; if (value !== undefined) { target[prop] = value; } diff --git a/src/utils/transition.js b/src/utils/transition.js index b98ff7e63..698e2d730 100644 --- a/src/utils/transition.js +++ b/src/utils/transition.js @@ -17,9 +17,9 @@ if (!Vue.prototype.$isServer) { engine = 'trident'; } - var cssPrefix = {trident: '-ms-', gecko: '-moz-', webkit: '-webkit-', presto: '-o-'}[engine]; + var cssPrefix = { trident: '-ms-', gecko: '-moz-', webkit: '-webkit-', presto: '-o-' }[engine]; - var vendorPrefix = {trident: 'ms', gecko: 'Moz', webkit: 'Webkit', presto: 'O'}[engine]; + var vendorPrefix = { trident: 'ms', gecko: 'Moz', webkit: 'Webkit', presto: 'O' }[engine]; var helperElem = document.createElement('div'); var perspectiveProperty = vendorPrefix + 'Perspective'; @@ -34,7 +34,7 @@ if (!Vue.prototype.$isServer) { } var getTranslate = function(element) { - var result = {left: 0, top: 0}; + var result = { left: 0, top: 0 }; if (element === null || element.style === null) return result; var transform = element.style[transformProperty];