Skip to content

Commit f53e0c0

Browse files
[PLAY-1083] Linter implementation: Kits F - J (#3021)
https://nitro.powerhrg.com/runway/backlog_items/PLAY-1083 **What does this PR do?** A clear and concise description with your runway ticket url. **Task** Run our new linter on kits that start with F - J. **Because** We've implemented a linter config, but most/all of our library files are still failing its ruleset. We need to update all kits in groups to eventually clean up the entire library to confirm with the new linter configs. **Note** I also fixed as many warning as I could. N/A 💻 `yarn run eslint --quiet "./playbook/app/pb_kits/playbook/{pb_f,pb_g,pb_h,pb_i}*/**/*.{js,ts,tsx,jsx}"` ``` yarn run v1.22.15 $ /Users/stephen.marshall/code/playbook/node_modules/.bin/eslint --quiet './playbook/app/pb_kits/playbook/{pb_f,pb_g,pb_h,pb_i}*/**/*.{js,ts,tsx,jsx}' /Users/stephen.marshall/code/playbook/playbook/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx 44:21 error Unexpected empty arrow function @typescript-eslint/no-empty-function 83:30 error Prop `onClick` must be placed on a new line react/jsx-max-props-per-line 84:46 error Prop `fixedWidth` must be placed on a new line react/jsx-max-props-per-line 90:17 error Expected indentation of 18 space characters but found 16 react/jsx-indent-props 91:17 error Expected indentation of 18 space characters but found 16 react/jsx-indent-props 92:17 error Expected indentation of 18 space characters but found 16 react/jsx-indent-props 98:39 error Prop `cursor` must be placed on a new line react/jsx-max-props-per-line /Users/stephen.marshall/code/playbook/playbook/app/pb_kits/playbook/pb_flex/_flex.tsx 10:10 error Don't use `object` as a type. The `object` type is currently hard to use ([see this issue](microsoft/TypeScript#21732)). Consider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys @typescript-eslint/ban-types /Users/stephen.marshall/code/playbook/playbook/app/pb_kits/playbook/pb_form_group/_form_group.tsx 10:10 error Don't use `object` as a type. The `object` type is currently hard to use ([see this issue](microsoft/TypeScript#21732)). Consider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys @typescript-eslint/ban-types /Users/stephen.marshall/code/playbook/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx 34:21 error Unexpected empty arrow function @typescript-eslint/no-empty-function 51:26 error Prop `id` must be placed on a new line react/jsx-max-props-per-line /Users/stephen.marshall/code/playbook/playbook/app/pb_kits/playbook/pb_gauge/_gauge.tsx 20:10 error Don't use `Boolean` as a type. Use boolean instead @typescript-eslint/ban-types 193:7 error Expected indentation of 8 space characters but found 6 react/jsx-indent-props 200:7 error Expected indentation of 8 space characters but found 6 react/jsx-indent-props 201:7 error Expected indentation of 8 space characters but found 6 react/jsx-indent-props /Users/stephen.marshall/code/playbook/playbook/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx 66:7 error Expected indentation of 8 space characters but found 6 react/jsx-indent-props 67:7 error Expected indentation of 8 space characters but found 6 react/jsx-indent-props 68:7 error Expected indentation of 8 space characters but found 6 react/jsx-indent-props 69:7 error Expected indentation of 8 space characters but found 6 react/jsx-indent-props /Users/stephen.marshall/code/playbook/playbook/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx 16:10 error Don't use `object` as a type. The `object` type is currently hard to use ([see this issue](microsoft/TypeScript#21732)). Consider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys @typescript-eslint/ban-types /Users/stephen.marshall/code/playbook/playbook/app/pb_kits/playbook/pb_icon_value/_icon_value.tsx 15:10 error Don't use `object` as a type. The `object` type is currently hard to use ([see this issue](microsoft/TypeScript#21732)). Consider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys @typescript-eslint/ban-types ✖ 21 problems (21 errors, 0 warnings) 15 errors and 0 warnings potentially fixable with the `--fix` option. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ``` #### Checklist: - [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new kit`, `deprecated`, or `breaking`. See [Changelog & Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels) for details. - [x] **DEPLOY** I have added the `milano` label to show I'm ready for a review. - [x] **TESTS** I have added test coverage to my code.
1 parent 6a8f9ff commit f53e0c0

File tree

11 files changed

+87
-63
lines changed

11 files changed

+87
-63
lines changed

playbook/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import React, { useEffect, useState } from "react";
22
import classnames from "classnames";
33

44
import { globalProps } from "../utilities/globalProps";
5-
import { buildHtmlProps } from '../utilities/props'
5+
import { buildHtmlProps } from "../utilities/props";
6+
import { VoidCallback } from "../types";
67

78
import Icon from "../pb_icon/_icon";
89
import Title from "../pb_title/_title";
@@ -15,23 +16,23 @@ const iconMap = {
1516
};
1617

1718
type FixedConfirmationToastProps = {
18-
autoClose?: number,
19-
children?: React.ReactChild[] | React.ReactChild,
20-
className?: string,
21-
closeable?: boolean,
22-
data?: string,
23-
horizontal?: "right" | "left" | "center",
24-
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
25-
id?: string,
26-
multiLine?: boolean,
27-
onClose?: () => void,
28-
open?: boolean,
29-
status?: "success" | "error" | "neutral" | "tip",
30-
text?: string,
31-
vertical?: "top" | "bottom",
32-
}
19+
autoClose?: number;
20+
children?: React.ReactChild[] | React.ReactChild;
21+
className?: string;
22+
closeable?: boolean;
23+
data?: string;
24+
horizontal?: "right" | "left" | "center";
25+
htmlOptions?: { [key: string]: string | number | boolean | (VoidCallback) };
26+
id?: string;
27+
multiLine?: boolean;
28+
onClose?: VoidCallback;
29+
open?: boolean;
30+
status?: "success" | "error" | "neutral" | "tip";
31+
text?: string;
32+
vertical?: "top" | "bottom";
33+
};
3334

34-
const FixedConfirmationToast = (props: FixedConfirmationToastProps) => {
35+
const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.ReactElement => {
3536
const [showToast, toggleToast] = useState(true);
3637
const {
3738
autoClose = 0,
@@ -41,7 +42,7 @@ const FixedConfirmationToast = (props: FixedConfirmationToastProps) => {
4142
horizontal,
4243
htmlOptions = {},
4344
multiLine = false,
44-
onClose = () => { },
45+
onClose = () => undefined,
4546
open = true,
4647
status = "neutral",
4748
text,
@@ -65,7 +66,7 @@ const FixedConfirmationToast = (props: FixedConfirmationToastProps) => {
6566
onClose();
6667
}, autoClose);
6768
}
68-
}
69+
};
6970

7071
useEffect(() => {
7172
toggleToast(open);
@@ -80,22 +81,35 @@ const FixedConfirmationToast = (props: FixedConfirmationToastProps) => {
8081
return (
8182
<>
8283
{showToast && (
83-
<div className={css} onClick={handleClick} {...htmlProps}>
84-
{icon && <Icon className="pb_icon" fixedWidth icon={icon} />}
84+
<div
85+
className={css}
86+
onClick={handleClick}
87+
{...htmlProps}
88+
>
89+
{icon && (
90+
<Icon
91+
className="pb_icon"
92+
fixedWidth
93+
icon={icon}
94+
/>
95+
)}
8596

86-
{
87-
children && children ||
88-
text && (
97+
{(children && children) ||
98+
(text && (
8999
<Title
90-
className="pb_fixed_confirmation_toast_text"
91-
size={4}
92-
text={text}
100+
className="pb_fixed_confirmation_toast_text"
101+
size={4}
102+
text={text}
93103
/>
94-
)
95-
}
104+
))}
96105

97106
{closeable && (
98-
<Icon className="pb_icon" cursor="pointer" fixedWidth={false} icon="times" />
107+
<Icon
108+
className="pb_icon"
109+
cursor="pointer"
110+
fixedWidth={false}
111+
icon="times"
112+
/>
99113
)}
100114
</div>
101115
)}

playbook/app/pb_kits/playbook/pb_flex/_flex.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React from 'react'
22
import classnames from 'classnames'
33
import { buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
44
import { GlobalProps, globalProps } from '../utilities/globalProps'
5-
import { Sizes } from '../types'
5+
import { GenericObject, Sizes } from '../types'
66

77
type FlexProps = {
88
children: React.ReactChild[] | React.ReactNode,
99
className?: string,
10-
data?: object,
10+
data?: GenericObject,
1111
horizontal?: "left" | "center" | "right" | "stretch" | "none",
1212
justify?: "start" | "center" | "end" | "around" | "between" | "evenly" | "none",
1313
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
@@ -25,7 +25,7 @@ type FlexProps = {
2525
alignSelf?: "start" | "end" | "center" | "stretch" | "none"
2626
} & GlobalProps
2727

28-
const Flex = (props: FlexProps) => {
28+
const Flex = (props: FlexProps): React.ReactElement => {
2929
const {
3030
align = 'none',
3131
children,
@@ -45,7 +45,7 @@ const Flex = (props: FlexProps) => {
4545
wrap = false,
4646
alignSelf = 'none',
4747
} = props
48-
48+
4949
const orientationClass =
5050
orientation !== undefined ? `orientation_${orientation}` : ''
5151
const justifyClass =

playbook/app/pb_kits/playbook/pb_form_group/_form_group.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import React from 'react'
22
import classnames from 'classnames'
33
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
44
import { globalProps } from '../utilities/globalProps'
5+
import { GenericObject } from '../types'
56

67
type FormGroupProps = {
78
aria?: {[key: string]: string},
89
children?: Node,
910
className?: string,
10-
data?: object,
11+
data?: GenericObject,
1112
fullWidth?: boolean,
1213
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
1314
id?: string,
1415
}
1516

16-
const FormGroup = (props: FormGroupProps) => {
17+
const FormGroup = (props: FormGroupProps): React.ReactElement => {
1718
const {
1819
aria = {},
1920
className,

playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ type FormPillProps = {
2222
onClick?: React.MouseEventHandler<HTMLSpanElement>,
2323
onMouseDown?: React.MouseEventHandler<HTMLSpanElement>,
2424
onTouchEnd?: React.TouchEventHandler<HTMLSpanElement>,
25-
},
25+
},
2626
} & GlobalProps
27-
const FormPill = (props: FormPillProps) => {
27+
const FormPill = (props: FormPillProps): React.ReactElement => {
2828
const {
2929
className,
3030
htmlOptions = {},
3131
id,
3232
text,
3333
name,
34-
onClick = () => {},
34+
onClick = () => undefined,
3535
avatarUrl,
3636
closeProps = {},
3737
size = '',
@@ -48,7 +48,10 @@ const FormPill = (props: FormPillProps) => {
4848
const htmlProps = buildHtmlProps(htmlOptions)
4949

5050
return (
51-
<div className={css} id={id} {...htmlProps}>
51+
<div className={css}
52+
id={id}
53+
{...htmlProps}
54+
>
5255
{name &&
5356
<>
5457
<Avatar

playbook/app/pb_kits/playbook/pb_gauge/_gauge.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import typography from "../tokens/exports/_typography.scss";
1212

1313
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
1414
import { globalProps } from "../utilities/globalProps";
15+
import { GenericObject } from "../types";
1516

1617
type GaugeProps = {
1718
aria: { [key: string]: string };
1819
className?: string;
1920
chartData?: { name: string; value: number[] | number }[];
20-
dark?: Boolean;
21+
dark?: boolean;
2122
data?: { [key: string]: string };
2223
disableAnimation?: boolean;
2324
fullCircle?: boolean;
@@ -33,13 +34,12 @@ type GaugeProps = {
3334
title?: string;
3435
tooltipHtml?: string;
3536
colors: string[];
36-
minorTickInterval: any;
37+
minorTickInterval?: number;
3738
circumference: number[];
3839
};
3940

4041
const Gauge = ({
4142
aria = {},
42-
className,
4343
chartData,
4444
dark = false,
4545
data = {},
@@ -61,9 +61,9 @@ const Gauge = ({
6161
minorTickInterval = null,
6262
circumference = fullCircle ? [0, 360] : [-100, 100],
6363
...props
64-
}: GaugeProps) => {
64+
}: GaugeProps): React.ReactElement => {
6565
const ariaProps = buildAriaProps(aria);
66-
const dataProps = buildDataProps(data)
66+
const dataProps = buildDataProps(data)
6767
const htmlProps = buildHtmlProps(htmlOptions);
6868
highchartsMore(Highcharts);
6969
solidGauge(Highcharts);
@@ -89,7 +89,7 @@ const Gauge = ({
8989
const [options, setOptions] = useState({});
9090

9191
useEffect(() => {
92-
const formattedChartData = chartData.map((obj: any) => {
92+
const formattedChartData = chartData.map((obj: GenericObject) => {
9393
obj.y = obj.value;
9494
delete obj.value;
9595
return obj;
@@ -185,20 +185,20 @@ const Gauge = ({
185185
.querySelectorAll(".fix")
186186
.forEach((fix) => fix.setAttribute("y", "38"));
187187
}
188-
188+
// eslint-disable-next-line react-hooks/exhaustive-deps
189189
}, [chartData]);
190190

191191
return (
192192
<HighchartsReact
193-
containerProps={{
193+
containerProps={{
194194
className: classnames(css, globalProps(props)),
195195
id: id,
196196
...ariaProps,
197197
...dataProps,
198198
...htmlProps,
199199
}}
200-
highcharts={Highcharts}
201-
options={options}
200+
highcharts={Highcharts}
201+
options={options}
202202
/>
203203
);
204204
};

playbook/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Body from '../pb_body/_body'
88
import Hashtag from '../pb_hashtag/_hashtag'
99
import Title from '../pb_title/_title'
1010
import { buildAriaProps, buildDataProps, buildHtmlProps } from '../utilities/props'
11+
import { GenericObject } from '../types'
1112

1213
type HomeAddressStreetProps = {
1314
aria?: { [key: string]: string },
@@ -28,7 +29,7 @@ type HomeAddressStreetProps = {
2829
territory: string,
2930
}
3031

31-
const HomeAddressStreet = (props: HomeAddressStreetProps) => {
32+
const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement => {
3233
const {
3334
address,
3435
addressCont,
@@ -58,17 +59,17 @@ const HomeAddressStreet = (props: HomeAddressStreetProps) => {
5859
className
5960
)
6061

61-
const dataProps: { [key: string]: any } = buildDataProps(data)
62-
const ariaProps: { [key: string]: any } = buildAriaProps(aria)
62+
const dataProps: GenericObject = buildDataProps(data)
63+
const ariaProps: GenericObject = buildAriaProps(aria)
6364
const htmlProps = buildHtmlProps(htmlOptions)
6465
return (
65-
<div
66-
className={classes(className, dark)}
67-
{...ariaProps}
68-
{...dataProps}
69-
{...htmlProps}
66+
<div
67+
className={classes(className, dark)}
68+
{...ariaProps}
69+
{...dataProps}
70+
{...htmlProps}
7071
>
71-
{emphasis == 'street' &&
72+
{emphasis == 'street' &&
7273
<div>
7374
<Title
7475
className="pb_home_address_street_address"

playbook/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import Caption from '../pb_caption/_caption'
99
import Flex from '../pb_flex/_flex'
1010
import IconCircle from '../pb_icon_circle/_icon_circle'
1111
import Title from '../pb_title/_title'
12+
import { GenericObject } from '../types'
1213

1314
type IconStatValueProps = {
1415
aria?: { [key: string]: string },
1516
className?: string,
16-
data?: object,
17+
data?: GenericObject,
1718
dark?: boolean,
1819
icon: string,
1920
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
@@ -34,7 +35,7 @@ type IconStatValueProps = {
3435
| "green",
3536
}
3637

37-
const IconStatValue = (props: IconStatValueProps) => {
38+
const IconStatValue = (props: IconStatValueProps): React.ReactElement => {
3839
const {
3940
aria = {},
4041
className,

playbook/app/pb_kits/playbook/pb_icon_value/_icon_value.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ import { globalProps } from '../utilities/globalProps'
66

77
import Body from '../pb_body/_body'
88
import Icon from '../pb_icon/_icon'
9+
import { GenericObject } from '../types'
910

1011
type IconValueProps = {
1112
align?: "left" | "center" | "right",
1213
aria?: { [key: string]: string; },
1314
className?: string,
1415
dark?: boolean,
15-
data?: object,
16+
data?: GenericObject,
1617
icon: string,
1718
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
1819
id?: string,
1920
text: string,
2021
}
2122

22-
const IconValue = (props: IconValueProps) => {
23+
const IconValue = (props: IconValueProps): React.ReactElement => {
2324
const {
2425
align = 'left',
2526
aria = {},

playbook/app/pb_kits/playbook/types/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { SyntheticEvent } from "react"
44
export const BitValues = [0, 1] as const
55
export type Binary = typeof BitValues[number]
66
export type Callback<T, K> = (arg: T) => K
7+
export type VoidCallback = () => void
78
export type EmptyObject = Record<string, unknown>
89
export type InputCallback<T> = Callback<SyntheticEvent<T>, void>
910
export type Noop = () => void
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type GenericObject = Record<string, unknown>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from './base'
22
export * from './colors'
3+
export * from './data'
34
export * from './display'
45
export * from './sizes'
56
export * from './spacing'

0 commit comments

Comments
 (0)