Skip to content

Commit 975f902

Browse files
betavsnovlan1
andauthored
chore: format with prettier (#4504)
* chore: format with prettier * chore: update lint-staged patterns for prettier and eslint * chore: update snapshot content formatting in demo test * chore: format --------- Co-authored-by: novlan1 <1576271227@qq.com>
1 parent 376516b commit 975f902

790 files changed

Lines changed: 7334 additions & 15694 deletions

File tree

Some content is hidden

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@
122122
}
123123
},
124124
"lint-staged": {
125-
"{packages/components,example,script}/**/*.{js,ts,wxs,wxml,wxss,html,json,less}": [
125+
"{packages/components,packages/pro-components,packages/tdesign-miniprogram/example,script}/**/*.{js,ts,wxss,less,wxml,html,json,md,wxs}": [
126126
"prettier --write"
127127
],
128-
"{packages/components,example}/**/*.{js,ts}": [
128+
"{packages/components,packages/pro-components,packages/tdesign-miniprogram/example}/**/*.{js,ts}": [
129129
"eslint --fix"
130130
],
131131
"{packages/uniapp-components,packages/uniapp-pro-components,packages/tdesign-uniapp,packages/tdesign-uniapp-chat}/**/*.{ts,js,vue}": [
132132
"eslint --fix"
133133
]
134134
}
135-
}
135+
}

packages/components/cascader/cascader.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ function parseOptions(options: OptionsType, keys: KeysType) {
3636
const value = keys?.value ?? 'value';
3737
const disabled = keys?.disabled ?? 'disabled';
3838

39-
return options.map((item) => {
40-
return {
41-
[label]: item[label],
42-
[value]: item[value],
43-
[disabled]: item[disabled],
44-
};
45-
});
39+
return options.map((item) => ({
40+
[label]: item[label],
41+
[value]: item[value],
42+
[disabled]: item[disabled],
43+
}));
4644
}
4745

4846
function flattenPaths(options: OptionsType, keys: KeysType): FlatPath[] {

packages/components/common/src/control.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ function useControl(this: any, option: ControlOption = {}): ControlInstance {
9595
controlled,
9696
initValue: controlled ? value : defaultValue,
9797
set,
98-
get: () => {
99-
return this.data[`_${valueKey}`];
100-
},
98+
get: () => this.data[`_${valueKey}`],
10199
change: (newVal, customChangeData, customUpdateFn) => {
102100
this.triggerEvent(changeEventName, typeof customChangeData !== 'undefined' ? customChangeData : newVal);
103101
// 完全受控模式,使用了受控属性,必须配合change事件来更新

packages/components/common/utils.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,13 @@ interface TreeNode {
125125
[key: string]: any;
126126
}
127127

128-
export const getTreeDepth = (tree: TreeNode[], key?: string) => {
129-
return tree.reduce((maxDepth: number, node: TreeNode) => {
128+
export const getTreeDepth = (tree: TreeNode[], key?: string) =>
129+
tree.reduce((maxDepth: number, node: TreeNode) => {
130130
if (node[key ?? 'children'] && node[key ?? 'children'].length > 0) {
131131
return Math.max(maxDepth, getTreeDepth(node[key ?? 'children'], key) + 1);
132132
}
133133
return Math.max(maxDepth, 1);
134134
}, 0);
135-
};
136135

137136
export const isIOS = function (): boolean {
138137
return !!(deviceInfo?.system?.toLowerCase().search('ios') + 1);
@@ -317,10 +316,9 @@ export const isOverSize = (size, sizeLimit) => {
317316

318317
export const rpx2px = (rpx) => Math.floor((systemInfo.windowWidth * rpx) / 750);
319318

320-
export const nextTick = () => {
321-
return new Promise<void>((resolve) => {
319+
export const nextTick = () =>
320+
new Promise<void>((resolve) => {
322321
wx.nextTick(() => {
323322
resolve();
324323
});
325324
});
326-
};

packages/components/common/validator.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ export function isFunction(val: unknown): val is Function {
22
return typeof val === 'function';
33
}
44

5-
export const isString = (val: unknown): val is string => {
6-
return typeof val === 'string';
7-
};
5+
export const isString = (val: unknown): val is string => typeof val === 'string';
86

9-
export const isNull = <T>(value: T | null): value is null => {
10-
return value === null;
11-
};
7+
export const isNull = <T>(value: T | null): value is null => value === null;
128

139
export const isUndefined = <T>(value: T | undefined): value is undefined => value === undefined;
1410

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
export const getObserver = (context, selector: string) => {
2-
return new Promise<WechatMiniprogram.IntersectionObserverObserveCallbackResult>((resolve) => {
1+
export const getObserver = (context, selector: string) =>
2+
new Promise<WechatMiniprogram.IntersectionObserverObserveCallbackResult>((resolve) => {
33
context
44
.createIntersectionObserver({ nativeMode: true })
55
.relativeToViewport()
66
.observe(selector, (res) => {
77
resolve(res);
88
});
99
});
10-
};
1110

1211
/**
1312
* 背景:单页模式下, getWindowInfo、getAppBaseInfo、getDeviceInfo 等接口均返回 undefined。
1413
* 复现路径:分享到朋友圈,再打开单页模式的该页面,wx.getWindowInfo() 等接口返回 undefined
1514
* 代码片段:https://developers.weixin.qq.com/s/mzvZ8FmH7vVW
1615
*/
1716

18-
export const getWindowInfo = () => {
19-
return wx.getWindowInfo ? wx.getWindowInfo() || wx.getSystemInfoSync() : wx.getSystemInfoSync();
20-
};
17+
export const getWindowInfo = () =>
18+
wx.getWindowInfo ? wx.getWindowInfo() || wx.getSystemInfoSync() : wx.getSystemInfoSync();
2119

22-
export const getAppBaseInfo = () => {
23-
return wx.getAppBaseInfo ? wx.getAppBaseInfo() || wx.getSystemInfoSync() : wx.getSystemInfoSync();
24-
};
20+
export const getAppBaseInfo = () =>
21+
wx.getAppBaseInfo ? wx.getAppBaseInfo() || wx.getSystemInfoSync() : wx.getSystemInfoSync();
2522

26-
export const getDeviceInfo = () => {
27-
return wx.getDeviceInfo ? wx.getDeviceInfo() || wx.getSystemInfoSync() : wx.getSystemInfoSync();
28-
};
23+
export const getDeviceInfo = () =>
24+
wx.getDeviceInfo ? wx.getDeviceInfo() || wx.getSystemInfoSync() : wx.getSystemInfoSync();

packages/components/message/__test__/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import Message from '../index';
44
import * as Util from '../../common/utils';
55

66
const mockGetRect = jest.spyOn(Util, 'getRect');
7-
mockGetRect.mockImplementation(() => {
8-
return new Promise((resolve) => resolve({ height: 46, width: 156 }));
9-
});
7+
mockGetRect.mockImplementation(() => new Promise((resolve) => resolve({ height: 46, width: 156 })));
108

119
const mockInstance = jest.spyOn(Util, 'getInstance');
1210

packages/components/mixins/page-scroll.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const onPageScroll = function (event?: IPageScrollOption) {
1919
});
2020
};
2121

22-
export default (funcName = 'onScroll') => {
23-
return Behavior({
22+
export default (funcName = 'onScroll') =>
23+
Behavior({
2424
attached() {
2525
const page = getCurrentPage<{ pageScroller: Scroller[] }>();
2626
if (!page) return;
@@ -47,4 +47,3 @@ export default (funcName = 'onScroll') => {
4747
page.pageScroller = page.pageScroller?.filter((item) => item !== this._pageScroller) || [];
4848
},
4949
});
50-
};

packages/components/notice-bar/__test__/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ const mockGetAnimationFrame = jest.spyOn(Util, 'getAnimationFrame');
1212
const mockGetRect = jest.spyOn(Util, 'getRect');
1313

1414
// 设置每次调用函数的值
15-
mockGetAnimationFrame.mockImplementation((context, cb) => {
16-
return cb();
17-
});
15+
mockGetAnimationFrame.mockImplementation((context, cb) => cb());
1816

1917
// 调用函数第1次的返回值 nodeRect
2018
mockGetRect.mockImplementation((context, id) => {

packages/components/picker-item/picker-item.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ export default class PickerItem extends SuperComponent {
224224
formatOption(options: PickerItemOption[], columnIndex: number, format: any) {
225225
if (typeof format !== 'function') return options;
226226

227-
return options.map((ele: PickerItemOption) => {
228-
return format(ele, columnIndex);
229-
});
227+
return options.map((ele: PickerItemOption) => format(ele, columnIndex));
230228
},
231229

232230
updateSelected(index: number, trigger: boolean) {

0 commit comments

Comments
 (0)