[improvement] update lint rules (#3970)

This commit is contained in:
neverland 2019-07-26 11:47:17 +08:00 committed by GitHub
parent 07a72307cc
commit 3a77666e49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 115 additions and 102 deletions

View File

@ -1,7 +1,4 @@
{
"root": true,
"extends": ["@vant"],
"rules": {
"no-unused-vars": ["error", { "vars": "all", "args": "none" }]
}
"extends": ["@vant"]
}

View File

@ -70,7 +70,7 @@
"@babel/preset-typescript": "^7.3.3",
"@types/jest": "^24.0.15",
"@vant/doc": "^2.3.6",
"@vant/eslint-config": "^1.2.0",
"@vant/eslint-config": "^1.2.3",
"@vant/markdown-loader": "^2.1.2",
"@vant/markdown-vetur": "^1.0.0",
"@vant/touch-emulator": "^1.1.0",

View File

@ -61,7 +61,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<Cell class={bem()}>
<Field

View File

@ -225,7 +225,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { data, errorInfo, searchResult } = this;
const onFocus = name => () => this.onFocus(name);

View File

@ -183,7 +183,7 @@ export default createComponent({
}
},
render(h) {
render() {
const on = {
...this.$listeners,
change: this.onChange

View File

@ -21,7 +21,7 @@ export default createComponent({
}
},
render(h) {
render() {
return <div class={bem()}>{this.slots()}</div>;
}
});

View File

@ -112,7 +112,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class={bem()} style={this.style}>
<svg viewBox="0 0 1060 1060">

View File

@ -23,7 +23,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { span, offset } = this;
return (
<this.tag class={bem({ [span]: span, [`offset-${offset}`]: offset })} style={this.style}>

View File

@ -107,7 +107,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { disabled, expanded } = this;
const titleSlots = CELL_SLOTS.reduce((slots, name) => {

View File

@ -27,7 +27,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class={[bem(), { 'van-hairline--top-bottom': this.border }]}>
{this.slots()}

View File

@ -88,7 +88,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { data, errorInfo } = this;
const onFocus = name => () => this.onFocus(name);

View File

@ -117,7 +117,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class={bem()}>
{this.slots('default', this.timeData) || this.formattedTime}

View File

@ -85,7 +85,7 @@ test('start method', async () => {
wrapper.vm.start();
wrapper.vm.start();
await later(20);
await later(50);
const laterShapShot = wrapper.html();

View File

@ -153,7 +153,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { coupons, disabledCoupons } = this;
const title = `${this.enabledTitle || t('enable')} (${coupons.length})`;
const disabledTitle = `${this.disabledTitle || t('disabled')} (${

View File

@ -61,7 +61,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { coupon, disabled } = this;
const description = (disabled && coupon.reason) || coupon.description;

View File

@ -313,7 +313,7 @@ export default createComponent({
}
},
render(h) {
render() {
const props = {};
Object.keys(pickerProps).forEach(key => {
props[key] = this[key];

View File

@ -73,7 +73,7 @@ export default createComponent({
}
},
render(h) {
render() {
if (!this.shouldRender) {
return;
}

View File

@ -63,7 +63,7 @@ export default createComponent({
this.onOpened = createEmitter('opened');
},
render(h) {
render() {
const {
zIndex,
offset,

View File

@ -76,7 +76,7 @@ export default createComponent({
}
},
render(h) {
render() {
const Titles = this.children.map((item, index) => (
<div
role="button"

View File

@ -263,7 +263,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { slots, labelAlign } = this;
const scopedSlots = {

View File

@ -35,7 +35,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<Button
class={bem([

View File

@ -23,7 +23,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div role="button" tabindex="0" class={bem()} onClick={this.onClick}>
{this.slots('icon') ? (

View File

@ -10,7 +10,7 @@ export default createComponent({
safeAreaInsetBottom: Boolean
},
render(h) {
render() {
return (
<div class={bem({ 'safe-area-inset-bottom': this.safeAreaInsetBottom })}>
{this.slots()}

View File

@ -72,7 +72,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { center, border, square, gutter, clickable } = this.parent;
return (

View File

@ -36,7 +36,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div
style={this.style}

View File

@ -254,7 +254,7 @@ export default createComponent({
}
},
render(h) {
render() {
if (!this.value) {
return;
}

View File

@ -141,7 +141,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class={bem({ round: this.round })} style={this.style} onClick={this.onClick}>
{this.renderImage()}

View File

@ -43,7 +43,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { sticky } = this;
return (

View File

@ -154,7 +154,7 @@ export default createComponent({
}
},
scrollToElement(element, setActive) {
scrollToElement(element) {
const { index } = element.dataset;
if (!index) {
return;
@ -177,7 +177,7 @@ export default createComponent({
}
},
render(h) {
render() {
const Indexes = this.indexList.map(index => {
const active = index === this.activeAnchorIndex;

View File

@ -104,7 +104,7 @@ export default createComponent({
}
},
render(h) {
render() {
const Placeholder = <div ref="placeholder" class={bem('placeholder')}/>;
return (

View File

@ -46,7 +46,7 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
}
},
render(h) {
render() {
const { slots, checked } = this;
const CheckIcon = slots('icon', { checked }) || (

View File

@ -76,7 +76,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { slots, mode, leftIcon, onClickIcon } = this;
const barStyle = {

View File

@ -39,7 +39,7 @@ export default createComponent({
this.active = true;
},
onBlur(event) {
onBlur() {
this.active = false;
},
@ -48,7 +48,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { onBlur } = this;
return (
<i

View File

@ -129,7 +129,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { title, theme, onPress, closeButtonText } = this;
const titleLeftSlot = this.slots('title-left');

View File

@ -114,7 +114,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { value } = this;
const simple = this.mode !== 'multi';

View File

@ -219,7 +219,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { itemHeight, visibleItemCount } = this;
const baseOffset = (itemHeight * (visibleItemCount - 1)) / 2;

View File

@ -32,7 +32,7 @@ export default createComponent({
this.onClosed = createEmitter('closed');
},
render(h) {
render() {
if (!this.shouldRender) {
return;
}

View File

@ -57,7 +57,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { pivotText, percentage } = this;
const text = isDef(pivotText) ? pivotText : percentage + '%';
const showPivot = this.showPivot && text;

View File

@ -147,7 +147,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { status, distance } = this;
const text = this[`${status}Text`] || t(status);
const style = {

View File

@ -17,7 +17,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class={bem()} role="radiogroup">
{this.slots()}

View File

@ -17,7 +17,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { align, justify } = this;
const flex = this.type === 'flex';
const margin = `-${Number(this.gutter) / 2}px`;

View File

@ -29,7 +29,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<a
class={[bem({ select: this.select }), 'van-hairline']}

View File

@ -17,7 +17,7 @@ export default createComponent({
}
},
render(h) {
render() {
return <div class={[bem(), 'van-hairline--top-bottom']}>{this.slots()}</div>;
}
});

View File

@ -427,7 +427,7 @@ export default createComponent({
}
},
render(h) {
render() {
if (this.isSkuEmpty) {
return;
}

View File

@ -77,7 +77,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class={bem()}>
{this.value && this.renderUploader(

View File

@ -121,7 +121,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<CellGroup class={bem()}>
{this.messages.map((message, index) => (message.type === 'image' ? (

View File

@ -35,7 +35,7 @@ export default createComponent({
}
},
render(h) {
render() {
const choosed = this.skuValue.id === this.selectedSku[this.skuKeyStr];
const imgUrl = this.skuValue.imgUrl || this.skuValue.img_url;

View File

@ -84,7 +84,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class="van-sku-stepper-stock">
<div class="van-sku-stepper-container">

View File

@ -115,7 +115,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { vertical } = this;
const style = {
background: this.inactiveColor

View File

@ -31,7 +31,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { slots, status } = this;
const { activeIcon, activeColor, inactiveIcon, direction } = this.$parent;
const titleStyle = status === 'process' && { color: activeColor };

View File

@ -165,7 +165,7 @@ export default createComponent({
}, LONG_PRESS_INTERVAL);
},
onTouchStart(type) {
onTouchStart() {
clearTimeout(this.longPressTimer);
this.isLongPress = false;
@ -185,7 +185,7 @@ export default createComponent({
}
},
render(h) {
render() {
const createListeners = type => ({
on: {
click: () => {

View File

@ -30,7 +30,7 @@ export default createComponent({
};
},
render(h) {
render() {
return (
<div class={bem([this.direction])}>
<div class={bem('items')}>{this.slots()}</div>

View File

@ -102,7 +102,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { fixed } = this;
const style = {
height: fixed ? `${this.height}px` : null

View File

@ -82,7 +82,7 @@ export default {
},
methods: {
onClose(clickPosition, instance, detail) {
onClose(clickPosition, instance) {
switch (clickPosition) {
case 'left':
case 'cell':

View File

@ -153,7 +153,7 @@ export default createComponent({
}
},
render(h) {
render() {
const onClick = (position, stop) => event => {
if (stop) {
event.stopPropagation();

View File

@ -17,7 +17,7 @@ export default createComponent({
this.$parent.swipes.splice(this.$parent.swipes.indexOf(this), 1);
},
render(h) {
render() {
const { vertical, computedWidth, computedHeight } = this.$parent;
const style = {

View File

@ -328,7 +328,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class={bem()}>
<div

View File

@ -41,7 +41,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { icon, slots } = this;
const active = this.parent.route ? this.routeActive : this.active;
const color = this.parent[active ? 'activeColor' : 'inactiveColor'];

View File

@ -54,7 +54,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div
style={{ zIndex: this.zIndex }}

View File

@ -66,7 +66,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div
class={bem('content', { animated: this.animated })}

View File

@ -60,7 +60,7 @@ export default {
}
},
render(h) {
render() {
return (
<div
role="tab"

View File

@ -251,7 +251,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { type, ellipsis, animated, scrollable } = this;
const Nav = this.children.map((item, index) => (

View File

@ -77,7 +77,7 @@ export default createComponent({
}
},
render(h) {
render() {
const { type, icon, message, iconPrefix, loadingType } = this;
const hasIcon = icon || (type === 'success' || type === 'fail');

View File

@ -248,7 +248,7 @@ export default createComponent({
}
},
render(h) {
render() {
return (
<div class={bem()}>
<div class={bem('wrapper')}>

View File

@ -1097,6 +1097,11 @@
dependencies:
"@types/jest-diff" "*"
"@types/json-schema@^7.0.3":
version "7.0.3"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636"
integrity sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==
"@types/minimatch@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
@ -1144,39 +1149,40 @@
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.12.tgz#45dd1d0638e8c8f153e87d296907659296873916"
integrity sha512-SOhuU4wNBxhhTHxYaiG5NY4HBhDIDnJF60GU+2LqHAdKKer86//e4yg69aENCtQ04n0ovz+tq2YPME5t5yp4pw==
"@typescript-eslint/eslint-plugin@^1.11.0":
version "1.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.11.0.tgz#870f752c520db04db6d3668af7479026a6f2fb9a"
integrity sha512-mXv9ccCou89C8/4avKHuPB2WkSZyY/XcTQUXd5LFZAcLw1I3mWYVjUu6eS9Ja0QkP/ClolbcW9tb3Ov/pMdcqw==
"@typescript-eslint/eslint-plugin@^1.13.0":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.13.0.tgz#22fed9b16ddfeb402fd7bcde56307820f6ebc49f"
integrity sha512-WQHCozMnuNADiqMtsNzp96FNox5sOVpU8Xt4meaT4em8lOG1SrOv92/mUbEHQVh90sldKSfcOc/I0FOb/14G1g==
dependencies:
"@typescript-eslint/experimental-utils" "1.11.0"
"@typescript-eslint/experimental-utils" "1.13.0"
eslint-utils "^1.3.1"
functional-red-black-tree "^1.0.1"
regexpp "^2.0.1"
tsutils "^3.7.0"
"@typescript-eslint/experimental-utils@1.11.0":
version "1.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-1.11.0.tgz#594abe47091cbeabac1d6f9cfed06d0ad99eb7e3"
integrity sha512-7LbfaqF6B8oa8cp/315zxKk8FFzosRzzhF8Kn/ZRsRsnpm7Qcu25cR/9RnAQo5utZ2KIWVgaALr+ZmcbG47ruw==
"@typescript-eslint/experimental-utils@1.13.0":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz#b08c60d780c0067de2fb44b04b432f540138301e"
integrity sha512-zmpS6SyqG4ZF64ffaJ6uah6tWWWgZ8m+c54XXgwFtUv0jNz8aJAVx8chMCvnk7yl6xwn8d+d96+tWp7fXzTuDg==
dependencies:
"@typescript-eslint/typescript-estree" "1.11.0"
"@types/json-schema" "^7.0.3"
"@typescript-eslint/typescript-estree" "1.13.0"
eslint-scope "^4.0.0"
"@typescript-eslint/parser@^1.11.0":
version "1.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.11.0.tgz#2f6d4f7e64eeb1e7c25b422f8df14d0c9e508e36"
integrity sha512-5xBExyXaxVyczrZvbRKEXvaTUFFq7gIM9BynXukXZE0zF3IQP/FxF4mPmmh3gJ9egafZFqByCpPTFm3dk4SY7Q==
"@typescript-eslint/parser@^1.13.0":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.13.0.tgz#61ac7811ea52791c47dc9fd4dd4a184fae9ac355"
integrity sha512-ITMBs52PCPgLb2nGPoeT4iU3HdQZHcPaZVw+7CsFagRJHUhyeTgorEwHXhFf3e7Evzi8oujKNpHc8TONth8AdQ==
dependencies:
"@types/eslint-visitor-keys" "^1.0.0"
"@typescript-eslint/experimental-utils" "1.11.0"
"@typescript-eslint/typescript-estree" "1.11.0"
"@typescript-eslint/experimental-utils" "1.13.0"
"@typescript-eslint/typescript-estree" "1.13.0"
eslint-visitor-keys "^1.0.0"
"@typescript-eslint/typescript-estree@1.11.0":
version "1.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.11.0.tgz#b7b5782aab22e4b3b6d84633652c9f41e62d37d5"
integrity sha512-fquUHF5tAx1sM2OeRCC7wVxFd1iMELWMGCzOSmJ3pLzArj9+kRixdlC4d5MncuzXpjEqc6045p3KwM0o/3FuUA==
"@typescript-eslint/typescript-estree@1.13.0":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz#8140f17d0f60c03619798f1d628b8434913dc32e"
integrity sha512-b5rCmd2e6DCC6tCTN9GSUAuxdYwCM/k/2wdjHGrIRGPSJotWMCe/dGpi66u42bhuh8q3QBzqM4TMA1GUUCJvdw==
dependencies:
lodash.unescape "4.0.1"
semver "5.5.0"
@ -1200,16 +1206,16 @@
fs-extra "^4.0.2"
shelljs "^0.8.2"
"@vant/eslint-config@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-1.2.0.tgz#d524547b1fd89554efe5abd1736bd6fcd5c8fbf1"
integrity sha512-FU5tvLYTjLoPZMFZwst6uqYfrUfhbO/VFIS6sECm3B5Ww1O3Cp5Rha/63DAuYf84jubV8G1/+g8EPuz/0U8KGQ==
"@vant/eslint-config@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-1.2.3.tgz#176697dd31eb119e1a412ba38282a0f07f70dfe4"
integrity sha512-qbjVOiDsFTw3kJNk/u3fICW9sYQz65iFITov7dwzO2d1UPKA/WxBrcpL1QjNeMYvZQggxLEGku918Y9exoapGA==
dependencies:
"@typescript-eslint/eslint-plugin" "^1.11.0"
"@typescript-eslint/parser" "^1.11.0"
"@typescript-eslint/eslint-plugin" "^1.13.0"
"@typescript-eslint/parser" "^1.13.0"
babel-eslint "^10.0.2"
eslint-config-airbnb-base "^13.2.0"
eslint-plugin-import "^2.18.0"
eslint-plugin-import "^2.18.2"
eslint-plugin-vue "^5.2.3"
"@vant/icons@1.1.9":
@ -3533,10 +3539,10 @@ eslint-module-utils@^2.4.0:
debug "^2.6.8"
pkg-dir "^2.0.0"
eslint-plugin-import@^2.18.0:
version "2.18.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.18.0.tgz#7a5ba8d32622fb35eb9c8db195c2090bd18a3678"
integrity sha512-PZpAEC4gj/6DEMMoU2Df01C5c50r7zdGIN52Yfi7CvvWaYssG7Jt5R9nFG5gmqodxNOz9vQS87xk6Izdtpdrig==
eslint-plugin-import@^2.18.2:
version "2.18.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.18.2.tgz#02f1180b90b077b33d447a17a2326ceb400aceb6"
integrity sha512-5ohpsHAiUBRNaBWAF08izwUGlbrJoJJ+W9/TBwsGoR1MnlgfwMIKrFeSjWbt6moabiXW9xNvtFz+97KHRfI4HQ==
dependencies:
array-includes "^3.0.3"
contains-path "^0.1.0"
@ -3545,8 +3551,8 @@ eslint-plugin-import@^2.18.0:
eslint-import-resolver-node "^0.3.2"
eslint-module-utils "^2.4.0"
has "^1.0.3"
lodash "^4.17.11"
minimatch "^3.0.4"
object.values "^1.1.0"
read-pkg-up "^2.0.0"
resolve "^1.11.0"
@ -6973,6 +6979,16 @@ object.pick@^1.3.0:
dependencies:
isobject "^3.0.1"
object.values@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.0.tgz#bf6810ef5da3e5325790eaaa2be213ea84624da9"
integrity sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==
dependencies:
define-properties "^1.1.3"
es-abstract "^1.12.0"
function-bind "^1.1.1"
has "^1.0.3"
obuf@^1.0.0, obuf@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e"