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": { "scripts": {
"dev": "node build/dev.js", "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": "sh build/release.sh",
"release:site": "sh build/release-site.sh", "release:site": "sh build/release-site.sh",
"build:lib": "yarn && npx gulp -f build/compiler.js --series buildEs buildLib", "build:lib": "yarn && npx gulp -f build/compiler.js --series buildEs buildLib",
@ -47,7 +47,7 @@
"@babel/preset-env": "^7.5.5", "@babel/preset-env": "^7.5.5",
"@vant/cli": "^1.0.3", "@vant/cli": "^1.0.3",
"@vant/doc": "^2.5.5", "@vant/doc": "^2.5.5",
"@vant/eslint-config": "^2.2.0", "@vant/eslint-config": "^2.2.1",
"@vant/icons": "1.2.0", "@vant/icons": "1.2.0",
"@vant/markdown-loader": "^2.3.0", "@vant/markdown-loader": "^2.3.0",
"@vant/stylelint-config": "^1.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 namespace Weapp {
export interface FormField { export interface FormField {
data: { data: {
name: string name: string;
value: any value: any;
} };
} }
interface Target { interface Target {
id: string id: string;
tagName: string tagName: string;
dataset: { dataset: {
[key: string]: any [key: string]: any;
} };
} }
export interface Event { 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 { interface Touch {
/** /**
* *
*/ */
identifier: number identifier: number;
/** /**
* X轴Y轴 * X轴Y轴
*/ */
pageX: number pageX: number;
/** /**
* X轴Y轴 * X轴Y轴
*/ */
pageY: number pageY: number;
/** /**
* X轴Y轴 * X轴Y轴
*/ */
clientX: number clientX: number;
/** /**
* X轴Y轴 * X轴Y轴
*/ */
clientY: number clientY: number;
} }
export interface TouchEvent extends Event { export interface TouchEvent extends Event {
touches: Array<Touch> touches: Array<Touch>;
changedTouches: Array<Touch> changedTouches: Array<Touch>;
} }
/** /**
@ -72,11 +73,20 @@ export namespace Weapp {
/** 目标组件的相对关系 */ /** 目标组件的相对关系 */
type: 'parent' | 'child' | 'ancestor' | 'descendant'; type: 'parent' | 'child' | 'ancestor' | 'descendant';
/** 关系生命周期函数当关系被建立在页面节点树中时触发触发时机在组件attached生命周期之后 */ /** 关系生命周期函数当关系被建立在页面节点树中时触发触发时机在组件attached生命周期之后 */
linked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; linked?(
this: Instance,
target: WechatMiniprogram.Component.TrivialInstance
): void;
/** 关系生命周期函数当关系在页面节点树中发生改变时触发触发时机在组件moved生命周期之后 */ /** 关系生命周期函数当关系在页面节点树中发生改变时触发触发时机在组件moved生命周期之后 */
linkChanged?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; linkChanged?(
this: Instance,
target: WechatMiniprogram.Component.TrivialInstance
): void;
/** 关系生命周期函数当关系脱离页面节点树时触发触发时机在组件detached生命周期之后 */ /** 关系生命周期函数当关系脱离页面节点树时触发触发时机在组件detached生命周期之后 */
unlinked?(this: Instance, target: WechatMiniprogram.Component.TrivialInstance): void; unlinked?(
this: Instance,
target: WechatMiniprogram.Component.TrivialInstance
): void;
/** 如果这一项被设置则它表示关联的目标节点所应具有的behavior所有拥有这一behavior的组件节点都会被关联 */ /** 如果这一项被设置则它表示关联的目标节点所应具有的behavior所有拥有这一behavior的组件节点都会被关联 */
target?: string; target?: string;
} }
@ -88,18 +98,18 @@ export namespace Weapp {
this: Instance, this: Instance,
newVal: T, newVal: T,
oldVal: T, oldVal: T,
changedPath: Array<string | number>, changedPath: Array<string | number>
) => void; ) => void;
/** /**
* methods定义miniprogram-api-typings缺少this定义 * methods定义miniprogram-api-typings缺少this定义
*/ */
export interface MethodOption<Instance> { export interface MethodOption<Instance> {
[name: string]: (this: Instance, ...args: any[]) => any [name: string]: (this: Instance, ...args: any[]) => any;
} }
export interface ComputedOption<Instance> { export interface ComputedOption<Instance> {
[name: string]: (this: Instance) => any [name: string]: (this: Instance) => any;
} }
type PropertyType = type PropertyType =
@ -112,15 +122,20 @@ export namespace Weapp {
| null; | null;
export interface PropertyOption { export interface PropertyOption {
[name: string]: PropertyType | PropertyType[] | { [name: string]:
| PropertyType
| PropertyType[]
| {
/** 属性类型 */ /** 属性类型 */
type: PropertyType | PropertyType[]; type: PropertyType | PropertyType[];
/** 属性初始值 */ /** 属性初始值 */
value?: any; value?: any;
/** 属性值被更改时的响应函数 */ /** 属性值被更改时的响应函数 */
observer?: string | Observer<WechatMiniprogram.Component.TrivialInstance, any>; observer?:
| string
| Observer<WechatMiniprogram.Component.TrivialInstance, any>;
/** 属性的类型(可以指定多个) */ /** 属性的类型(可以指定多个) */
optionalTypes?: PropertyType[]; optionalTypes?: PropertyType[];
} };
} }
} }

View File

@ -16,7 +16,7 @@ VantComponent({
if (this.offset > 0) { if (this.offset > 0) {
this.swipeMove(leftWidth); this.swipeMove(leftWidth);
} }
} },
}, },
rightWidth: { rightWidth: {
type: Number, type: Number,
@ -25,19 +25,19 @@ VantComponent({
if (this.offset < 0) { if (this.offset < 0) {
this.swipeMove(-rightWidth); this.swipeMove(-rightWidth);
} }
} },
}, },
asyncClose: Boolean, asyncClose: Boolean,
name: { name: {
type: [Number, String], type: [Number, String],
value: '' value: '',
} },
}, },
mixins: [touch], mixins: [touch],
data: { data: {
catchMove: false catchMove: false,
}, },
created() { created() {
@ -46,7 +46,7 @@ VantComponent({
}, },
destroyed() { destroyed() {
ARRAY = ARRAY.filter(item => item !== this); ARRAY = ARRAY.filter((item) => item !== this);
}, },
methods: { methods: {
@ -57,7 +57,7 @@ VantComponent({
this.$emit('open', { this.$emit('open', {
position, position,
name: this.data.name name: this.data.name,
}); });
}, },
@ -65,7 +65,7 @@ VantComponent({
this.swipeMove(0); this.swipeMove(0);
}, },
swipeMove(offset: number = 0) { swipeMove(offset = 0) {
this.offset = range(offset, -this.data.rightWidth, this.data.leftWidth); this.offset = range(offset, -this.data.rightWidth, this.data.leftWidth);
const transform = `translate3d(${this.offset}px, 0, 0)`; const transform = `translate3d(${this.offset}px, 0, 0)`;
@ -79,7 +79,7 @@ VantComponent({
-webkit-transition: ${transition}; -webkit-transition: ${transition};
transform: ${transform}; transform: ${transform};
transition: ${transition}; transition: ${transition};
` `,
}); });
}, },
@ -120,7 +120,7 @@ VantComponent({
} }
this.dragging = true; 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.setData({ catchMove: true });
this.swipeMove(this.startOffset + this.deltaX); this.swipeMove(this.startOffset + this.deltaX);
}, },
@ -146,11 +146,11 @@ VantComponent({
this.$emit('close', { this.$emit('close', {
position, position,
instance: this, instance: this,
name: this.data.name name: this.data.name,
}); });
} else { } else {
this.swipeMove(0); 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" resolved "https://registry.npm.taobao.org/@vant/doc/download/@vant/doc-2.6.1.tgz#667db2ca32cd86f3def452a03c66076c1b97c969"
integrity sha1-Zn2yyjLNhvPe9FKgPGYHbBuXyWk= integrity sha1-Zn2yyjLNhvPe9FKgPGYHbBuXyWk=
"@vant/eslint-config@^2.2.0": "@vant/eslint-config@^2.2.1":
version "2.2.0" version "2.2.1"
resolved "https://registry.npm.taobao.org/@vant/eslint-config/download/@vant/eslint-config-2.2.0.tgz#b2802ff85a0b5b0b4e84b3d7825d5c8fff3d62e6" resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-2.2.1.tgz#3a4d492534f694ae2035c75fd6edfd9cc45bcb6a"
integrity sha1-soAv+FoLWwtOhLPXgl1cj/89YuY= integrity sha512-IqzSDsGynKTBi6cOnLbGQUQDY+bM2QZJxc+q14YRGHAbIWMcru7QeyIbjT2Vc94fBF/1gW9OaDj9eFTmSKGvOA==
dependencies: dependencies:
"@typescript-eslint/eslint-plugin" "^2.28.0" "@typescript-eslint/eslint-plugin" "^2.28.0"
"@typescript-eslint/parser" "^2.28.0" "@typescript-eslint/parser" "^2.28.0"