Skip to content

Commit 2988a6c

Browse files
authored
Fix type linting and indent errors (#9843)
* Fix type linting and indent errors * Properly indent comments too
1 parent 7da77a5 commit 2988a6c

16 files changed

+326
-324
lines changed

types/.eslintrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ extends:
1010
rules:
1111
# Replace stock eslint rules with typescript-eslint equivalents for proper
1212
# TypeScript support.
13+
indent: "off"
14+
"@typescript-eslint/indent": ["error", 2]
1315
no-use-before-define: "off"
1416
'@typescript-eslint/no-use-before-define': "error"
1517
no-shadow: "off"

types/adapters.d.ts

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
11
export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
22

33
export interface DateAdapter {
4-
// Override one or multiple of the methods to adjust to the logic of the current date library.
5-
override(members: Partial<DateAdapter>): void;
6-
readonly options: unknown;
4+
// Override one or multiple of the methods to adjust to the logic of the current date library.
5+
override(members: Partial<DateAdapter>): void;
6+
readonly options: unknown;
77

8-
/**
9-
* Returns a map of time formats for the supported formatting units defined
10-
* in Unit as well as 'datetime' representing a detailed date/time string.
11-
* @returns {{string: string}}
12-
*/
13-
formats(): { [key: string]: string };
14-
/**
15-
* Parses the given `value` and return the associated timestamp.
16-
* @param {unknown} value - the value to parse (usually comes from the data)
17-
* @param {string} [format] - the expected data format
18-
*/
19-
parse(value: unknown, format?: TimeUnit): number | null;
20-
/**
21-
* Returns the formatted date in the specified `format` for a given `timestamp`.
22-
* @param {number} timestamp - the timestamp to format
23-
* @param {string} format - the date/time token
24-
* @return {string}
25-
*/
26-
format(timestamp: number, format: TimeUnit): string;
27-
/**
28-
* Adds the specified `amount` of `unit` to the given `timestamp`.
29-
* @param {number} timestamp - the input timestamp
30-
* @param {number} amount - the amount to add
31-
* @param {Unit} unit - the unit as string
32-
* @return {number}
33-
*/
34-
add(timestamp: number, amount: number, unit: TimeUnit): number;
35-
/**
36-
* Returns the number of `unit` between the given timestamps.
37-
* @param {number} a - the input timestamp (reference)
38-
* @param {number} b - the timestamp to subtract
39-
* @param {Unit} unit - the unit as string
40-
* @return {number}
41-
*/
42-
diff(a: number, b: number, unit: TimeUnit): number;
43-
/**
44-
* Returns start of `unit` for the given `timestamp`.
45-
* @param {number} timestamp - the input timestamp
46-
* @param {Unit|'isoWeek'} unit - the unit as string
47-
* @param {number} [weekday] - the ISO day of the week with 1 being Monday
48-
* and 7 being Sunday (only needed if param *unit* is `isoWeek`).
49-
* @return {number}
50-
*/
51-
startOf(timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number;
52-
/**
53-
* Returns end of `unit` for the given `timestamp`.
54-
* @param {number} timestamp - the input timestamp
55-
* @param {Unit|'isoWeek'} unit - the unit as string
56-
* @return {number}
57-
*/
58-
endOf(timestamp: number, unit: TimeUnit | 'isoWeek'): number;
8+
/**
9+
* Returns a map of time formats for the supported formatting units defined
10+
* in Unit as well as 'datetime' representing a detailed date/time string.
11+
* @returns {{string: string}}
12+
*/
13+
formats(): { [key: string]: string };
14+
/**
15+
* Parses the given `value` and return the associated timestamp.
16+
* @param {unknown} value - the value to parse (usually comes from the data)
17+
* @param {string} [format] - the expected data format
18+
*/
19+
parse(value: unknown, format?: TimeUnit): number | null;
20+
/**
21+
* Returns the formatted date in the specified `format` for a given `timestamp`.
22+
* @param {number} timestamp - the timestamp to format
23+
* @param {string} format - the date/time token
24+
* @return {string}
25+
*/
26+
format(timestamp: number, format: TimeUnit): string;
27+
/**
28+
* Adds the specified `amount` of `unit` to the given `timestamp`.
29+
* @param {number} timestamp - the input timestamp
30+
* @param {number} amount - the amount to add
31+
* @param {Unit} unit - the unit as string
32+
* @return {number}
33+
*/
34+
add(timestamp: number, amount: number, unit: TimeUnit): number;
35+
/**
36+
* Returns the number of `unit` between the given timestamps.
37+
* @param {number} a - the input timestamp (reference)
38+
* @param {number} b - the timestamp to subtract
39+
* @param {Unit} unit - the unit as string
40+
* @return {number}
41+
*/
42+
diff(a: number, b: number, unit: TimeUnit): number;
43+
/**
44+
* Returns start of `unit` for the given `timestamp`.
45+
* @param {number} timestamp - the input timestamp
46+
* @param {Unit|'isoWeek'} unit - the unit as string
47+
* @param {number} [weekday] - the ISO day of the week with 1 being Monday
48+
* and 7 being Sunday (only needed if param *unit* is `isoWeek`).
49+
* @return {number}
50+
*/
51+
startOf(timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number;
52+
/**
53+
* Returns end of `unit` for the given `timestamp`.
54+
* @param {number} timestamp - the input timestamp
55+
* @param {Unit|'isoWeek'} unit - the unit as string
56+
* @return {number}
57+
*/
58+
endOf(timestamp: number, unit: TimeUnit | 'isoWeek'): number;
5959
}
6060

6161
export const _adapters: {
62-
_date: DateAdapter;
62+
_date: DateAdapter;
6363
};

types/animation.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export class Animation {
1010
}
1111

1212
export interface AnimationEvent {
13-
chart: Chart;
14-
numSteps: number;
15-
initial: boolean;
16-
currentStep: number;
13+
chart: Chart;
14+
numSteps: number;
15+
initial: boolean;
16+
currentStep: number;
1717
}
1818

1919
export class Animator {

types/element.d.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import { AnyObject } from './basic';
22
import { Point } from './geometric';
33

44
export interface Element<T = AnyObject, O = AnyObject> {
5-
readonly x: number;
6-
readonly y: number;
7-
readonly active: boolean;
8-
readonly options: O;
5+
readonly x: number;
6+
readonly y: number;
7+
readonly active: boolean;
8+
readonly options: O;
99

10-
tooltipPosition(useFinalPosition?: boolean): Point;
11-
hasValue(): boolean;
12-
getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]>;
10+
tooltipPosition(useFinalPosition?: boolean): Point;
11+
hasValue(): boolean;
12+
getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]>;
1313
}
1414
export const Element: {
15-
prototype: Element;
16-
new <T = AnyObject, O = AnyObject>(): Element<T, O>;
15+
prototype: Element;
16+
new <T = AnyObject, O = AnyObject>(): Element<T, O>;
1717
};

types/helpers/helpers.canvas.d.ts

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export function clipArea(ctx: CanvasRenderingContext2D, area: ChartArea): void;
1010
export function unclipArea(ctx: CanvasRenderingContext2D): void;
1111

1212
export interface DrawPointOptions {
13-
pointStyle: PointStyle;
14-
rotation?: number;
15-
radius: number;
16-
borderWidth: number;
13+
pointStyle: PointStyle;
14+
rotation?: number;
15+
radius: number;
16+
borderWidth: number;
1717
}
1818

1919
export function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number): void;
@@ -26,76 +26,76 @@ export function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptio
2626
export function toFontString(font: { size: number; family: string; style?: string; weight?: string }): string | null;
2727

2828
export interface RenderTextOpts {
29-
/**
30-
* The fill color of the text. If unset, the existing
31-
* fillStyle property of the canvas is unchanged.
32-
*/
33-
color?: Color;
34-
35-
/**
36-
* The width of the strikethrough / underline
37-
* @default 2
38-
*/
39-
decorationWidth?: number;
40-
41-
/**
42-
* The max width of the text in pixels
43-
*/
44-
maxWidth?: number;
45-
46-
/**
47-
* A rotation to be applied to the canvas
48-
* This is applied after the translation is applied
49-
*/
50-
rotation?: number;
51-
52-
/**
53-
* Apply a strikethrough effect to the text
54-
*/
55-
strikethrough?: boolean;
56-
57-
/**
58-
* The color of the text stroke. If unset, the existing
59-
* strokeStyle property of the context is unchanged
60-
*/
61-
strokeColor?: Color;
62-
63-
/**
64-
* The text stroke width. If unset, the existing
65-
* lineWidth property of the context is unchanged
66-
*/
67-
strokeWidth?: number;
68-
69-
/**
70-
* The text alignment to use. If unset, the existing
71-
* textAlign property of the context is unchanged
72-
*/
73-
textAlign: CanvasTextAlign;
74-
75-
/**
76-
* The text baseline to use. If unset, the existing
77-
* textBaseline property of the context is unchanged
78-
*/
79-
textBaseline: CanvasTextBaseline;
80-
81-
/**
82-
* If specified, a translation to apply to the context
83-
*/
84-
translation?: [number, number];
85-
86-
/**
87-
* Underline the text
88-
*/
89-
underline?: boolean;
29+
/**
30+
* The fill color of the text. If unset, the existing
31+
* fillStyle property of the canvas is unchanged.
32+
*/
33+
color?: Color;
34+
35+
/**
36+
* The width of the strikethrough / underline
37+
* @default 2
38+
*/
39+
decorationWidth?: number;
40+
41+
/**
42+
* The max width of the text in pixels
43+
*/
44+
maxWidth?: number;
45+
46+
/**
47+
* A rotation to be applied to the canvas
48+
* This is applied after the translation is applied
49+
*/
50+
rotation?: number;
51+
52+
/**
53+
* Apply a strikethrough effect to the text
54+
*/
55+
strikethrough?: boolean;
56+
57+
/**
58+
* The color of the text stroke. If unset, the existing
59+
* strokeStyle property of the context is unchanged
60+
*/
61+
strokeColor?: Color;
62+
63+
/**
64+
* The text stroke width. If unset, the existing
65+
* lineWidth property of the context is unchanged
66+
*/
67+
strokeWidth?: number;
68+
69+
/**
70+
* The text alignment to use. If unset, the existing
71+
* textAlign property of the context is unchanged
72+
*/
73+
textAlign: CanvasTextAlign;
74+
75+
/**
76+
* The text baseline to use. If unset, the existing
77+
* textBaseline property of the context is unchanged
78+
*/
79+
textBaseline: CanvasTextBaseline;
80+
81+
/**
82+
* If specified, a translation to apply to the context
83+
*/
84+
translation?: [number, number];
85+
86+
/**
87+
* Underline the text
88+
*/
89+
underline?: boolean;
9090
}
9191

9292
export function renderText(
93-
ctx: CanvasRenderingContext2D,
94-
text: string | string[],
95-
x: number,
96-
y: number,
97-
font: CanvasFontSpec,
98-
opts?: RenderTextOpts
93+
ctx: CanvasRenderingContext2D,
94+
text: string | string[],
95+
x: number,
96+
y: number,
97+
font: CanvasFontSpec,
98+
opts?: RenderTextOpts
9999
): void;
100100

101101
export function addRoundedRectPath(ctx: CanvasRenderingContext2D, rect: RoundedRect): void;

types/helpers/helpers.collection.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export interface ArrayListener<T> {
2-
_onDataPush?(...item: T[]): void;
3-
_onDataPop?(): void;
4-
_onDataShift?(): void;
5-
_onDataSplice?(index: number, deleteCount: number, ...items: T[]): void;
6-
_onDataUnshift?(...item: T[]): void;
2+
_onDataPush?(...item: T[]): void;
3+
_onDataPop?(): void;
4+
_onDataShift?(): void;
5+
_onDataSplice?(index: number, deleteCount: number, ...items: T[]): void;
6+
_onDataUnshift?(...item: T[]): void;
77
}
88

99
/**

types/helpers/helpers.color.d.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
export function color(value: CanvasGradient): CanvasGradient;
22
export function color(value: CanvasPattern): CanvasPattern;
33
export function color(
4-
value:
5-
| string
6-
| { r: number; g: number; b: number; a: number }
7-
| [number, number, number]
8-
| [number, number, number, number]
4+
value:
5+
| string
6+
| { r: number; g: number; b: number; a: number }
7+
| [number, number, number]
8+
| [number, number, number, number]
99
): ColorModel;
1010

1111
export interface ColorModel {
12-
rgbString(): string;
13-
hexString(): string;
14-
hslString(): string;
15-
rgb: { r: number; g: number; b: number; a: number };
16-
valid: boolean;
17-
mix(color: ColorModel, weight: number): this;
18-
clone(): ColorModel;
19-
alpha(a: number): ColorModel;
20-
clearer(ration: number): ColorModel;
21-
greyscale(): ColorModel;
22-
opaquer(ratio: number): ColorModel;
23-
negate(): ColorModel;
24-
lighten(ratio: number): ColorModel;
25-
darken(ratio: number): ColorModel;
26-
saturate(ratio: number): ColorModel;
27-
desaturate(ratio: number): ColorModel;
28-
rotate(deg: number): this;
12+
rgbString(): string;
13+
hexString(): string;
14+
hslString(): string;
15+
rgb: { r: number; g: number; b: number; a: number };
16+
valid: boolean;
17+
mix(color: ColorModel, weight: number): this;
18+
clone(): ColorModel;
19+
alpha(a: number): ColorModel;
20+
clearer(ration: number): ColorModel;
21+
greyscale(): ColorModel;
22+
opaquer(ratio: number): ColorModel;
23+
negate(): ColorModel;
24+
lighten(ratio: number): ColorModel;
25+
darken(ratio: number): ColorModel;
26+
saturate(ratio: number): ColorModel;
27+
desaturate(ratio: number): ColorModel;
28+
rotate(deg: number): this;
2929
}
3030

3131
export function getHoverColor(value: CanvasGradient): CanvasGradient;

0 commit comments

Comments
 (0)