Skip to content

Commit cf26c04

Browse files
authored
chore: set printWidth to 120 (#823)
1 parent 6ae3577 commit cf26c04

Some content is hidden

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

65 files changed

+238
-978
lines changed

.github/hypertrons.json

+5-40
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@
4545
"name": "kind/CICD",
4646
"description": "CI/CD related issue or pull",
4747
"color": "0099ff",
48-
"keywords": [
49-
"continuous integration",
50-
"continuous delivery",
51-
"[ci]",
52-
"[cd]",
53-
"[ci/cd]"
54-
]
48+
"keywords": ["continuous integration", "continuous delivery", "[ci]", "[cd]", "[ci/cd]"]
5549
}
5650
]
5751
},
@@ -65,48 +59,19 @@
6559
{
6660
"name": "committer",
6761
"description": "Committer of the project",
68-
"users": [
69-
"frank-zsy",
70-
"heming6666",
71-
"LiuChangFreeman",
72-
"tyn1998",
73-
"zhuxiangning",
74-
"wxharry",
75-
"lhbvvvvv"
76-
],
77-
"commands": [
78-
"/difficulty",
79-
"/rerun",
80-
"/complete-checklist",
81-
"/start-vote"
82-
]
62+
"users": ["frank-zsy", "heming6666", "LiuChangFreeman", "tyn1998", "zhuxiangning", "wxharry", "lhbvvvvv"],
63+
"commands": ["/difficulty", "/rerun", "/complete-checklist", "/start-vote"]
8364
},
8465
{
8566
"name": "replier",
8667
"description": "Replier is responsible for reply issues in time",
87-
"users": [
88-
"heming6666",
89-
"LiuChangFreeman",
90-
"xiaoya-Esther",
91-
"tyn1998",
92-
"zhuxiangning",
93-
"wxharry",
94-
"lhbvvvvv"
95-
],
68+
"users": ["heming6666", "LiuChangFreeman", "xiaoya-Esther", "tyn1998", "zhuxiangning", "wxharry", "lhbvvvvv"],
9669
"commands": []
9770
},
9871
{
9972
"name": "approver",
10073
"description": "After approvers' approve, pulls should be merged automatically",
101-
"users": [
102-
"frank-zsy",
103-
"heming6666",
104-
"LiuChangFreeman",
105-
"tyn1998",
106-
"zhuxiangning",
107-
"wxharry",
108-
"lhbvvvvv"
109-
],
74+
"users": ["frank-zsy", "heming6666", "LiuChangFreeman", "tyn1998", "zhuxiangning", "wxharry", "lhbvvvvv"],
11075
"commands": ["/approve"]
11176
},
11277
{

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"printWidth": 120,
23
"singleQuote": true,
34
"trailingComma": "es5",
45
"requirePragma": false,

src/api/common.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import { OSS_XLAB_ENDPOINT, ErrorCode } from '../constant';
22
import request from '../helpers/request';
33

4-
export const getMetricByName = async (
5-
owner: string,
6-
metricNameMap: Map<string, string>,
7-
metric: string
8-
) => {
4+
export const getMetricByName = async (owner: string, metricNameMap: Map<string, string>, metric: string) => {
95
try {
10-
return await request(
11-
`${OSS_XLAB_ENDPOINT}/open_digger/github/${owner}/${metricNameMap.get(
12-
metric
13-
)}.json`
14-
);
6+
return await request(`${OSS_XLAB_ENDPOINT}/open_digger/github/${owner}/${metricNameMap.get(metric)}.json`);
157
} catch (error) {
168
// the catched error being "404" means the metric file is not available so return a null
179
if (error === ErrorCode.NOT_FOUND) {

src/components/Bars.tsx

+2-13
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,11 @@ interface BarsProps {
2727
}
2828

2929
const Bars = (props: BarsProps): JSX.Element => {
30-
const {
31-
theme,
32-
height,
33-
legend1,
34-
legend2,
35-
yName1,
36-
yName2,
37-
data1,
38-
data2,
39-
onClick,
40-
} = props;
30+
const { theme, height, legend1, legend2, yName1, yName2, data1, data2, onClick } = props;
4131
const startTime = Number(data1[0][0].split('-')[0]);
4232
const endTime = Number(data1[data1.length - 1][0].split('-')[0]);
4333
const timeLength = endTime - startTime;
44-
const minInterval =
45-
timeLength > 2 ? 365 * 24 * 3600 * 1000 : 30 * 3600 * 24 * 1000;
34+
const minInterval = timeLength > 2 ? 365 * 24 * 3600 * 1000 : 30 * 3600 * 24 * 1000;
4635
const divEL = useRef(null);
4736

4837
const TH = theme == 'light' ? LIGHT_THEME : DARK_THEME;

src/components/Graph.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ interface GraphProps {
2121

2222
const NODE_SIZE = [10, 25];
2323

24-
const generateEchartsData = (
25-
data: any,
26-
focusedNodeID: string | undefined
27-
): any => {
24+
const generateEchartsData = (data: any, focusedNodeID: string | undefined): any => {
2825
const generateNodes = (nodes: any[]): any => {
2926
const values: number[] = nodes.map((item) => item[1]);
3027
const minMax = [Math.min(...values), Math.max(...values)];

src/components/TooltipTrigger/index.tsx

+2-12
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,8 @@ const TooltipTrigger: React.FC<ITooltipTriggerProps> = ({
1717
tooltipFontColor = '#242A2E',
1818
content,
1919
}) => (
20-
<Tooltip
21-
placement="top"
22-
title={<span style={{ color: tooltipFontColor }}>{content}</span>}
23-
color={tooltipBackground}
24-
>
25-
<svg
26-
className="tooltip-icon"
27-
width={`${size}px`}
28-
height={`${size}px`}
29-
viewBox="0 0 48 48"
30-
version="1.1"
31-
>
20+
<Tooltip placement="top" title={<span style={{ color: tooltipFontColor }}>{content}</span>} color={tooltipBackground}>
21+
<svg className="tooltip-icon" width={`${size}px`} height={`${size}px`} viewBox="0 0 48 48" version="1.1">
3222
<path fill={iconColor} d={iconTooltipTrigger}></path>
3323
</svg>
3424
</Tooltip>

src/constant.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export enum ErrorCode {
66

77
export const OSS_XLAB_ENDPOINT = 'https://oss.x-lab.info';
88

9-
export const HYPERTRONS_CRX_NEW_ISSUE =
10-
'https://github.com/hypertrons/hypertrons-crx/issues/new/choose';
9+
export const HYPERTRONS_CRX_NEW_ISSUE = 'https://github.com/hypertrons/hypertrons-crx/issues/new/choose';
1110

1211
export const HYPERCRX_GITHUB = 'https://github.com/hypertrons/hypertrons-crx';

src/feature-manager.ts

+5-23
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import exists from './helpers/exists';
77
import waitFor from './helpers/wait-for';
88
import sleep from './helpers/sleep';
99
import isRestorationVisit from './helpers/is-restoration-visit';
10-
import shouldFeatureRun, {
11-
ShouldRunConditions,
12-
} from './helpers/should-feature-run';
10+
import shouldFeatureRun, { ShouldRunConditions } from './helpers/should-feature-run';
1311
import optionsStorage from './options-storage';
1412
import { throttle } from 'lodash-es';
1513

@@ -88,10 +86,7 @@ const globalReady = new Promise<object>(async (resolve) => {
8886
resolve(options);
8987
});
9088

91-
const setupPageLoad = async (
92-
id: FeatureId,
93-
config: InternalRunConfig
94-
): Promise<void> => {
89+
const setupPageLoad = async (id: FeatureId, config: InternalRunConfig): Promise<void> => {
9590
const { asLongAs, include, exclude, init } = config;
9691

9792
if (!(await shouldFeatureRun({ asLongAs, include, exclude }))) {
@@ -138,27 +133,14 @@ const add = async (
138133

139134
for (const loader of loaders) {
140135
// Input defaults and validation
141-
const {
142-
asLongAs,
143-
include,
144-
exclude,
145-
init,
146-
restore,
147-
awaitDomReady = true,
148-
} = loader;
136+
const { asLongAs, include, exclude, init, restore, awaitDomReady = true } = loader;
149137

150138
if (include?.length === 0) {
151-
throw new Error(
152-
`${id}: \`include\` cannot be an empty array, it means "run nowhere"`
153-
);
139+
throw new Error(`${id}: \`include\` cannot be an empty array, it means "run nowhere"`);
154140
}
155141

156142
// 404 pages should only run 404-only features
157-
if (
158-
pageDetect.is404() &&
159-
!include?.includes(pageDetect.is404) &&
160-
!asLongAs?.includes(pageDetect.is404)
161-
) {
143+
if (pageDetect.is404() && !include?.includes(pageDetect.is404) && !asLongAs?.includes(pageDetect.is404)) {
162144
continue;
163145
}
164146

src/helpers/generate-data-by-month.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ const generateDataByMonth = (originalData: any, updatedAt?: number) => {
1616
// `originalData` is an object with keys like `2020-01`, `2020-02`, `2022`, `2022-Q1`, `all`.
1717
// A normal month is a key like `2020-01`(yyyy-mm). They are the keys we handle later in this function.
1818
// An unnormal month is a key like `2020`, `2020-Q1`, `all`. They are not used in any feature yet.
19-
const normalMonths = Object.keys(originalData).filter((key) =>
20-
isNormalMonth(key)
21-
);
19+
const normalMonths = Object.keys(originalData).filter((key) => isNormalMonth(key));
2220
const orderedMonths = normalMonths.sort((a, b) => {
2321
const dateA = new Date(a);
2422
const dateB = new Date(b);
@@ -33,16 +31,13 @@ const generateDataByMonth = (originalData: any, updatedAt?: number) => {
3331

3432
const oldestMonth = orderedMonths[0];
3533
const newestMonth =
36-
lastDataAvailableMonth.getFullYear() +
37-
'-' +
38-
(lastDataAvailableMonth.getMonth() + 1).toString().padStart(2, '0');
34+
lastDataAvailableMonth.getFullYear() + '-' + (lastDataAvailableMonth.getMonth() + 1).toString().padStart(2, '0');
3935
// insert no-event months (assigned to 0) and generate final data
4036
const arrayData: [string, number][] = [];
4137
const start = new Date(oldestMonth);
4238
const end = new Date(newestMonth);
4339
for (let i = start; i <= end; i.setMonth(i.getMonth() + 1)) {
44-
const date =
45-
i.getFullYear() + '-' + (i.getMonth() + 1).toString().padStart(2, '0');
40+
const date = i.getFullYear() + '-' + (i.getMonth() + 1).toString().padStart(2, '0');
4641
if (!originalData.hasOwnProperty(date)) {
4742
arrayData.push([date, 0]);
4843
} else {

src/helpers/get-developer-info.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export function getDeveloperName() {
88
}
99

1010
export async function isDeveloperWithMeta() {
11-
return (
12-
pageDetect.isUserProfile() && (await metaStore.has(getDeveloperName()))
13-
);
11+
return pageDetect.isUserProfile() && (await metaStore.has(getDeveloperName()));
1412
}
1513

1614
export function checkLogined() {

src/helpers/linear-map.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
export default function linearMap(
2-
val: number,
3-
domain: number[],
4-
range: number[]
5-
): number {
1+
export default function linearMap(val: number, domain: number[], range: number[]): number {
62
const d0 = domain[0];
73
const d1 = domain[1];
84
const r0 = range[0];

src/helpers/should-feature-run.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ export type ShouldRunConditions = {
44
exclude: ((() => boolean) | (() => Promise<boolean>))[] | undefined;
55
};
66

7-
export default async function shouldFeatureRun(
8-
props: ShouldRunConditions
9-
): Promise<boolean> {
7+
export default async function shouldFeatureRun(props: ShouldRunConditions): Promise<boolean> {
108
const {
119
/** Every condition must be true */
1210
asLongAs = [() => true],
@@ -16,14 +14,8 @@ export default async function shouldFeatureRun(
1614
exclude = [() => false],
1715
} = props;
1816
return (
19-
(await Promise.all(asLongAs.map((c) => c())).then((flags) =>
20-
flags.every((flag) => flag === true)
21-
)) &&
22-
(await Promise.all(include.map((c) => c())).then((flags) =>
23-
flags.some((flag) => flag === true)
24-
)) &&
25-
(await Promise.all(exclude.map((c) => c())).then((flags) =>
26-
flags.every((flag) => flag === false)
27-
))
17+
(await Promise.all(asLongAs.map((c) => c())).then((flags) => flags.every((flag) => flag === true))) &&
18+
(await Promise.all(include.map((c) => c())).then((flags) => flags.some((flag) => flag === true))) &&
19+
(await Promise.all(exclude.map((c) => c())).then((flags) => flags.every((flag) => flag === false)))
2820
);
2921
}

src/locales/en/messages.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@
8282
"status": "Data does not exist",
8383
"measure": {
8484
"text": "Possible causes:",
85-
"tips": [
86-
"Recently created, has not been computed",
87-
"No actions in selected period, nothing to be computed"
88-
]
85+
"tips": ["Recently created, has not been computed", "No actions in selected period, nothing to be computed"]
8986
}
9087
}
9188
},

src/locales/zh_CN/messages.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@
8282
"status": "对应数据不存在",
8383
"measure": {
8484
"text": "这可能是因为:",
85-
"tips": [
86-
"该对象为最近创建对象,数据还未被计算",
87-
"该对象在此周期内无任何有效活动,不予计算"
88-
]
85+
"tips": ["该对象为最近创建对象,数据还未被计算", "该对象在此周期内无任何有效活动,不予计算"]
8986
}
9087
}
9188
},

src/options-storage.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ export const defaults = Object.assign(
66
{
77
locale: 'en',
88
},
9-
Object.fromEntries(
10-
importedFeatures.map((name) => [`hypercrx-${name}` as FeatureId, true])
11-
)
9+
Object.fromEntries(importedFeatures.map((name) => [`hypercrx-${name}` as FeatureId, true]))
1210
);
1311

1412
class OptionsStorage {

src/pages/ContentScripts/components/NativePopover.tsx

+4-21
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,10 @@ interface NativePopoverProps extends PropsWithChildren<any> {
77
anchor: JQuery<HTMLElement>;
88
width: number;
99
// for now, only support top-middle
10-
arrowPosition:
11-
| 'top-left'
12-
| 'top-middle'
13-
| 'top-right'
14-
| 'bottom-left'
15-
| 'bottom-middle'
16-
| 'bottom-right';
10+
arrowPosition: 'top-left' | 'top-middle' | 'top-right' | 'bottom-left' | 'bottom-middle' | 'bottom-right';
1711
}
1812

19-
export const NativePopover = ({
20-
anchor,
21-
width,
22-
arrowPosition,
23-
children,
24-
}: NativePopoverProps): JSX.Element => {
13+
export const NativePopover = ({ anchor, width, arrowPosition, children }: NativePopoverProps): JSX.Element => {
2514
useEffect(() => {
2615
(async () => {
2716
await elementReady('div.Popover');
@@ -44,14 +33,8 @@ export const NativePopover = ({
4433
$popoverContent.css('padding', '10px 5px');
4534
$popoverContent.css('width', width);
4635
$popoverContainer.css('top', `${top + anchorHeight + 10}px`);
47-
$popoverContainer.css(
48-
'left',
49-
`${left - (width - anchorWidth) / 2}px`
50-
);
51-
$popoverContent.attr(
52-
'class',
53-
`Popover-message Box color-shadow-large Popover-message--${arrowPosition}`
54-
);
36+
$popoverContainer.css('left', `${left - (width - anchorWidth) / 2}px`);
37+
$popoverContent.attr('class', `Popover-message Box color-shadow-large Popover-message--${arrowPosition}`);
5538
render(children, $popoverContent[0]);
5639
$popoverContainer.css('display', 'block');
5740
}, 1000);

src/pages/ContentScripts/features/developer-activity-openrank-trends/index.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { render, Container } from 'react-dom';
33
import $ from 'jquery';
44

55
import features from '../../../../feature-manager';
6-
import {
7-
getDeveloperName,
8-
isDeveloperWithMeta,
9-
} from '../../../../helpers/get-developer-info';
6+
import { getDeveloperName, isDeveloperWithMeta } from '../../../../helpers/get-developer-info';
107
import { getActivity, getOpenrank } from '../../../../api/developer';
118
import { UserMeta, metaStore } from '../../../../api/common';
129
import View from './view';
@@ -24,10 +21,7 @@ const getData = async () => {
2421
};
2522

2623
const renderTo = (container: Container) => {
27-
render(
28-
<View activity={activity} openrank={openrank} meta={meta} />,
29-
container
30-
);
24+
render(<View activity={activity} openrank={openrank} meta={meta} />, container);
3125
};
3226

3327
const init = async (): Promise<void> => {

0 commit comments

Comments
 (0)