chore: run linter and fix

This commit is contained in:
chenjiahan 2020-04-24 22:39:51 +08:00 committed by neverland
parent 63d1f8382f
commit eeb03ce246
4 changed files with 69 additions and 54 deletions

View File

@ -10,7 +10,7 @@
},
"scripts": {
"dev": "node build/dev.js",
"lint": "eslint ./packages --ext .js,.ts && stylelint \"packages/**/*.less\" --fix",
"lint": "eslint ./packages --ext .js,.ts --fix && stylelint \"packages/**/*.less\" --fix",
"release": "sh build/release.sh",
"release:site": "sh build/release-site.sh",
"build:lib": "yarn && npx gulp -f build/compiler.js --series buildEs buildLib",
@ -47,7 +47,7 @@
"@babel/preset-env": "^7.5.5",
"@vant/cli": "^1.0.3",
"@vant/doc": "^2.5.5",
"@vant/eslint-config": "^2.2.0",
"@vant/eslint-config": "^2.2.1",
"@vant/icons": "1.2.0",
"@vant/markdown-loader": "^2.3.0",
"@vant/stylelint-config": "^1.3.0",

View File

@ -1,68 +1,69 @@
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Weapp {
export interface FormField {
data: {
name: string
value: any
}
name: string;
value: any;
};
}
interface Target {
id: string
tagName: string
id: string;
tagName: string;
dataset: {
[key: string]: any
}
[key: string]: any;
};
}
export interface Event {
/**
*
*/
type: string
type: string;
/**
*
*/
timeStamp: number
timeStamp: number;
/**
*
*/
target: Target
target: Target;
/**
*
*/
currentTarget: Target
currentTarget: Target;
/**
*
*/
detail: any
detail: any;
}
interface Touch {
/**
*
*/
identifier: number
identifier: number;
/**
* X轴Y轴
*/
pageX: number
pageX: number;
/**
* X轴Y轴
*/
pageY: number
pageY: number;
/**
* X轴Y轴
*/
clientX: number
clientX: number;
/**
* X轴Y轴
*/
clientY: number
clientY: number;
}
export interface TouchEvent extends Event {
touches: Array<Touch>
changedTouches: Array<Touch>
touches: Array<Touch>;
changedTouches: Array<Touch>;
}
/**
@ -72,11 +73,20 @@ export namespace Weapp {
/** 目标组件的相对关系 */
type: 'parent' | 'child' | 'ancestor' | 'descendant';
/** 关系生命周期函数当关系被建立在页面节点树中时触发触发时机在组件attached生命周期之后 */
linked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void;
linked?(
this: Instance,
target: WechatMiniprogram.Component.TrivialInstance
): void;
/** 关系生命周期函数当关系在页面节点树中发生改变时触发触发时机在组件moved生命周期之后 */
linkChanged?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void;
linkChanged?(
this: Instance,
target: WechatMiniprogram.Component.TrivialInstance
): void;
/** 关系生命周期函数当关系脱离页面节点树时触发触发时机在组件detached生命周期之后 */
unlinked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void;
unlinked?(
this: Instance,
target: WechatMiniprogram.Component.TrivialInstance
): void;
/** 如果这一项被设置则它表示关联的目标节点所应具有的behavior所有拥有这一behavior的组件节点都会被关联 */
target?: string;
}
@ -88,18 +98,18 @@ export namespace Weapp {
this: Instance,
newVal: T,
oldVal: T,
changedPath: Array<string | number>,
changedPath: Array<string | number>
) => void;
/**
* methods定义miniprogram-api-typings缺少this定义
*/
export interface MethodOption<Instance> {
[name: string]: (this: Instance, ...args: any[]) => any
[name: string]: (this: Instance, ...args: any[]) => any;
}
export interface ComputedOption<Instance> {
[name: string]: (this: Instance) => any
[name: string]: (this: Instance) => any;
}
type PropertyType =
@ -112,15 +122,20 @@ export namespace Weapp {
| null;
export interface PropertyOption {
[name: string]: PropertyType | PropertyType[] | {
/** 属性类型 */
type: PropertyType | PropertyType[];
/** 属性初始值 */
value?: any;
/** 属性值被更改时的响应函数 */
observer?: string | Observer<WechatMiniprogram.Component.TrivialInstance, any>;
/** 属性的类型(可以指定多个) */
optionalTypes?: PropertyType[];
}
[name: string]:
| PropertyType
| PropertyType[]
| {
/** 属性类型 */
type: PropertyType | PropertyType[];
/** 属性初始值 */
value?: any;
/** 属性值被更改时的响应函数 */
observer?:
| string
| Observer<WechatMiniprogram.Component.TrivialInstance, any>;
/** 属性的类型(可以指定多个) */
optionalTypes?: PropertyType[];
};
}
}

View File

@ -16,7 +16,7 @@ VantComponent({
if (this.offset > 0) {
this.swipeMove(leftWidth);
}
}
},
},
rightWidth: {
type: Number,
@ -25,19 +25,19 @@ VantComponent({
if (this.offset < 0) {
this.swipeMove(-rightWidth);
}
}
},
},
asyncClose: Boolean,
name: {
type: [Number, String],
value: ''
}
value: '',
},
},
mixins: [touch],
data: {
catchMove: false
catchMove: false,
},
created() {
@ -46,7 +46,7 @@ VantComponent({
},
destroyed() {
ARRAY = ARRAY.filter(item => item !== this);
ARRAY = ARRAY.filter((item) => item !== this);
},
methods: {
@ -57,7 +57,7 @@ VantComponent({
this.$emit('open', {
position,
name: this.data.name
name: this.data.name,
});
},
@ -65,7 +65,7 @@ VantComponent({
this.swipeMove(0);
},
swipeMove(offset: number = 0) {
swipeMove(offset = 0) {
this.offset = range(offset, -this.data.rightWidth, this.data.leftWidth);
const transform = `translate3d(${this.offset}px, 0, 0)`;
@ -79,7 +79,7 @@ VantComponent({
-webkit-transition: ${transition};
transform: ${transform};
transition: ${transition};
`
`,
});
},
@ -120,7 +120,7 @@ VantComponent({
}
this.dragging = true;
ARRAY.filter(item => item !== this).forEach(item => item.close());
ARRAY.filter((item) => item !== this).forEach((item) => item.close());
this.setData({ catchMove: true });
this.swipeMove(this.startOffset + this.deltaX);
},
@ -146,11 +146,11 @@ VantComponent({
this.$emit('close', {
position,
instance: this,
name: this.data.name
name: this.data.name,
});
} else {
this.swipeMove(0);
}
}
}
},
},
});

View File

@ -992,10 +992,10 @@
resolved "https://registry.npm.taobao.org/@vant/doc/download/@vant/doc-2.6.1.tgz#667db2ca32cd86f3def452a03c66076c1b97c969"
integrity sha1-Zn2yyjLNhvPe9FKgPGYHbBuXyWk=
"@vant/eslint-config@^2.2.0":
version "2.2.0"
resolved "https://registry.npm.taobao.org/@vant/eslint-config/download/@vant/eslint-config-2.2.0.tgz#b2802ff85a0b5b0b4e84b3d7825d5c8fff3d62e6"
integrity sha1-soAv+FoLWwtOhLPXgl1cj/89YuY=
"@vant/eslint-config@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-2.2.1.tgz#3a4d492534f694ae2035c75fd6edfd9cc45bcb6a"
integrity sha512-IqzSDsGynKTBi6cOnLbGQUQDY+bM2QZJxc+q14YRGHAbIWMcru7QeyIbjT2Vc94fBF/1gW9OaDj9eFTmSKGvOA==
dependencies:
"@typescript-eslint/eslint-plugin" "^2.28.0"
"@typescript-eslint/parser" "^2.28.0"