Skip to content

Commit 2960b65

Browse files
committed
fix: linting warnings
1 parent 30f0b00 commit 2960b65

File tree

4 files changed

+42
-28
lines changed

4 files changed

+42
-28
lines changed

apps/developer-hub/src/components/Callout/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { InfoBox, VARIANTS } from "@pythnetwork/component-library/InfoBox";
22
import type { ComponentProps, ReactNode } from "react";
3+
34
import { Case } from "../Case";
45

56
type Props = ComponentProps<"div"> & {
@@ -26,7 +27,7 @@ export const Callout = ({
2627
}: Props) => {
2728
return (
2829
<InfoBox
29-
icon={icon ?? DEFAULT_ICONS[variant] ?? DEFAULT_ICONS["info"]}
30+
icon={icon ?? DEFAULT_ICONS[variant]}
3031
header={header ?? <Case variant="APA Title Case">{variant}</Case>}
3132
variant={variant}
3233
{...rest}

apps/developer-hub/src/components/Case/index.tsx

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,42 @@ export const Case = ({ children, variant }: Props) => {
2626

2727
const convertCase = (text: string, variant: CaseVariant): string => {
2828
switch (variant) {
29-
case "Uppercase":
29+
case "Uppercase": {
3030
return text.toUpperCase();
31-
case "Lowercase":
31+
}
32+
case "Lowercase": {
3233
return text.toLowerCase();
33-
case "Title Case":
34+
}
35+
case "Title Case": {
3436
return toTitleCase(text);
35-
case "APA Title Case":
37+
}
38+
case "APA Title Case": {
3639
return toAPATitleCase(text);
37-
case "Sentence Case":
40+
}
41+
case "Sentence Case": {
3842
return toSentenceCase(text);
39-
case "Snake Case":
43+
}
44+
case "Snake Case": {
4045
return toSnakeCase(text);
41-
case "Kebab Case":
46+
}
47+
case "Kebab Case": {
4248
return toKebabCase(text);
43-
case "Pascal Case":
49+
}
50+
case "Pascal Case": {
4451
return toPascalCase(text);
45-
case "Camel Case":
52+
}
53+
case "Camel Case": {
4654
return toCamelCase(text);
47-
case "Train Case":
55+
}
56+
case "Train Case": {
4857
return toTrainCase(text);
49-
case "Macro Case":
58+
}
59+
case "Macro Case": {
5060
return toMacroCase(text);
51-
default:
61+
}
62+
default: {
5263
return text;
64+
}
5365
}
5466
};
5567

@@ -64,7 +76,7 @@ const toTitleCase = (text: string): string => {
6476

6577
// Convert to APA Title Case (capitalize first letter of each word except articles, prepositions, and conjunctions)
6678
const toAPATitleCase = (text: string): string => {
67-
const minorWords = [
79+
const minorWords = new Set([
6880
"a",
6981
"an",
7082
"the",
@@ -80,7 +92,7 @@ const toAPATitleCase = (text: string): string => {
8092
"by",
8193
"in",
8294
"of",
83-
];
95+
]);
8496

8597
const words = text.toLowerCase().split(" ");
8698

@@ -93,7 +105,7 @@ const toAPATitleCase = (text: string): string => {
93105
}
94106

95107
// Check if the word is a minor word
96-
if (minorWords.includes(word)) {
108+
if (minorWords.has(word)) {
97109
return word;
98110
}
99111

@@ -112,27 +124,27 @@ const toSentenceCase = (text: string): string => {
112124
// Convert to Snake Case (lowercase with underscores between words)
113125
const toSnakeCase = (text: string): string => {
114126
return text
115-
.replace(/([A-Z])/g, " $1") // Add space before capital letters
127+
.replaceAll(/([A-Z])/g, " $1") // Add space before capital letters
116128
.trim()
117129
.toLowerCase()
118-
.replace(/[^\w\s]/g, "") // Remove special characters
119-
.replace(/\s+/g, "_"); // Replace spaces with underscores
130+
.replaceAll(/[^\w\s]/g, "") // Remove special characters
131+
.replaceAll(/\s+/g, "_"); // Replace spaces with underscores
120132
};
121133

122134
// Convert to Kebab Case (lowercase with hyphens between words)
123135
const toKebabCase = (text: string): string => {
124136
return text
125-
.replace(/([A-Z])/g, " $1") // Add space before capital letters
137+
.replaceAll(/([A-Z])/g, " $1") // Add space before capital letters
126138
.trim()
127139
.toLowerCase()
128-
.replace(/[^\w\s]/g, "") // Remove special characters
129-
.replace(/\s+/g, "-"); // Replace spaces with hyphens
140+
.replaceAll(/[^\w\s]/g, "") // Remove special characters
141+
.replaceAll(/\s+/g, "-"); // Replace spaces with hyphens
130142
};
131143

132144
// Convert to Pascal Case (capitalize first letter of each word, no spaces)
133145
const toPascalCase = (text: string): string => {
134146
return text
135-
.replace(/[^\w\s]/g, "") // Remove special characters
147+
.replaceAll(/[^\w\s]/g, "") // Remove special characters
136148
.split(/\s+/)
137149
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
138150
.join("");
@@ -147,7 +159,7 @@ const toCamelCase = (text: string): string => {
147159
// Convert to Train Case (capitalize first letter of each word, hyphens between words)
148160
const toTrainCase = (text: string): string => {
149161
return text
150-
.replace(/[^\w\s]/g, "") // Remove special characters
162+
.replaceAll(/[^\w\s]/g, "") // Remove special characters
151163
.split(/\s+/)
152164
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
153165
.join("-");

apps/developer-hub/src/components/CopyAddress/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { CopyButton } from "@pythnetwork/component-library/CopyButton";
55
import TruncateToMiddle from "../TruncateToMiddle";
66

77
const CopyAddress = ({ address, url }: { address: string; url?: string }) => {
8-
return Boolean(url) ? (
8+
return url ? (
99
<form>
10-
<CopyButton text={address} formAction={url as string} type="submit">
10+
<CopyButton text={address} formAction={url} type="submit">
1111
<TruncateToMiddle text={address} />
1212
</CopyButton>
1313
</form>

apps/developer-hub/src/components/TruncateToMiddle/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type React from "react";
2+
23
import styles from "./index.module.scss";
34

45
export type Props = {
@@ -18,8 +19,8 @@ const TruncateToMiddle = ({
1819
// (e.g., 'i' is narrower than 'W'), the exact count of visible characters
1920
// might differ slightly from the specified 'ch' value.
2021
const style = {
21-
"--min-chars-start-ch": `${minCharsStart}ch`,
22-
"--min-chars-end-ch": `${minCharsEnd}ch`,
22+
"--min-chars-start-ch": `${minCharsStart.toString()}ch`,
23+
"--min-chars-end-ch": `${minCharsEnd.toString()}ch`,
2324
} as React.CSSProperties;
2425

2526
return (

0 commit comments

Comments
 (0)