Skip to content

Commit c05f2a4

Browse files
authored
add PropTypes validation and fix linter errors (#43)
* add PropTypes validation and fix linter errors * run formatter * fix typo
1 parent 4b7fdaf commit c05f2a4

File tree

9 files changed

+53
-28
lines changed

9 files changed

+53
-28
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"@testing-library/jest-dom": "^6.4.6",
7373
"@testing-library/react": "^16.0.0",
7474
"@types/eslint": "^9",
75+
"@types/prop-types": "^15",
7576
"@types/react": "^18.3.3",
7677
"@types/react-dom": "^18.3.0",
7778
"@typescript-eslint/eslint-plugin": "^8.4.0",
@@ -84,6 +85,7 @@
8485
"jest-environment-jsdom": "^29.7.0",
8586
"postcss": "^8.4.38",
8687
"prettier": "^3.3.3",
88+
"prop-types": "^15.8.1",
8789
"react": "^17.0.0 || ^18.0.0",
8890
"react-dom": "^17.0.0 || ^18.0.0",
8991
"semantic-release": "^24.0.0",

src/components/search/Search.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from "react";
21
import type { Meta, StoryObj } from "@storybook/react";
32
import { Search } from "./Search";
43

@@ -124,9 +123,9 @@ export const AllStates: Story = {
124123
parameters: {
125124
docs: {
126125
description: {
127-
story: "This story shows the search component in its default state. You can interact with it to see hover and focus states.",
126+
story:
127+
"This story shows the search component in its default state. You can interact with it to see hover and focus states.",
128128
},
129129
},
130130
},
131131
};
132-

src/components/search/Search.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { forwardRef, useState } from "react";
2+
import PropTypes from "prop-types";
23
import { cn } from "../../utils/cn";
34
import searchIcon from "../../assets/search-icon.svg";
45

@@ -108,3 +109,14 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
108109

109110
Search.displayName = "Search";
110111

112+
Search.propTypes = {
113+
containerClassName: PropTypes.string,
114+
inputClassName: PropTypes.string,
115+
iconClassName: PropTypes.string,
116+
showIcon: PropTypes.bool,
117+
size: PropTypes.oneOf(["small", "default", "large"]),
118+
placeholder: PropTypes.string,
119+
className: PropTypes.string,
120+
onFocus: PropTypes.func,
121+
onBlur: PropTypes.func,
122+
};

src/components/search/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export { Search } from "./Search";
22
export type { SearchProps } from "./Search";
3-

src/components/select/useSelectNavigate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useRef, useState } from "react";
22
import { isInViewport } from "../../utils/navigation";
33

4-
type ChekboxNavigateProps = {
4+
type CheckboxNavigateProps = {
55
checkboxContainer: React.MutableRefObject<HTMLDivElement> | null;
66
searchEl: React.MutableRefObject<HTMLInputElement> | null;
77
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -12,7 +12,7 @@ const useCheckboxNavigate = ({
1212
checkboxContainer,
1313
searchEl,
1414
options,
15-
}: ChekboxNavigateProps) => {
15+
}: CheckboxNavigateProps) => {
1616
const checkboxNavIndex = useRef<number>(null);
1717

1818
const [currentNavigateCheckbox, setcurrentNavigateCheckbox] = useState("");

src/stories/Configure.mdx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ import Accessibility from "./assets/accessibility.png";
1515
import Theming from "./assets/theming.png";
1616
import AddonLibrary from "./assets/addon-library.png";
1717

18-
export const RightArrow = () => <svg
19-
viewBox="0 0 14 14"
20-
width="8px"
21-
height="14px"
22-
style={{
23-
marginLeft: '4px',
24-
display: 'inline-block',
25-
shapeRendering: 'inherit',
26-
verticalAlign: 'middle',
27-
fill: 'currentColor',
28-
'path fill': 'currentColor'
18+
export const RightArrow = () => (
19+
<svg
20+
viewBox="0 0 14 14"
21+
width="8px"
22+
height="14px"
23+
style={{
24+
marginLeft: "4px",
25+
display: "inline-block",
26+
shapeRendering: "inherit",
27+
verticalAlign: "middle",
28+
fill: "currentColor",
29+
"path fill": "currentColor",
2930
}}
30-
>
31-
<path d="m11.1 7.35-5.5 5.5a.5.5 0 0 1-.7-.7L10.04 7 4.9 1.85a.5.5 0 1 1 .7-.7l5.5 5.5c.2.2.2.5 0 .7Z" />
32-
</svg>
31+
>
32+
<path d="m11.1 7.35-5.5 5.5a.5.5 0 0 1-.7-.7L10.04 7 4.9 1.85a.5.5 0 1 1 .7-.7l5.5 5.5c.2.2.2.5 0 .7Z" />
33+
</svg>
34+
);
3335

3436
<Meta title="Configure your project" />
3537

@@ -38,6 +40,7 @@ export const RightArrow = () => <svg
3840
# Configure your project
3941

4042
Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community.
43+
4144
</div>
4245
<div className="sb-section">
4346
<div className="sb-section-item">
@@ -84,6 +87,7 @@ export const RightArrow = () => <svg
8487
# Do more with Storybook
8588

8689
Now that you know the basics, let's explore other parts of Storybook that will improve your experience. This list is just to get you started. You can customise Storybook in many ways to fit your needs.
90+
8791
</div>
8892

8993
<div className="sb-section">
@@ -203,6 +207,7 @@ export const RightArrow = () => <svg
203207
target="_blank"
204208
>Discover tutorials<RightArrow /></a>
205209
</div>
210+
206211
</div>
207212

208213
<style>

src/styles/tailwind.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap');
1+
@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap");
22

33
@tailwind base;
44
@tailwind components;

src/types/images.d.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
declare module '*.png' {
1+
declare module "*.png" {
22
const value: string;
33
export default value;
44
}
55

6-
declare module '*.jpg' {
6+
declare module "*.jpg" {
77
const value: string;
88
export default value;
99
}
1010

11-
declare module '*.jpeg' {
11+
declare module "*.jpeg" {
1212
const value: string;
1313
export default value;
1414
}
1515

16-
declare module '*.svg' {
16+
declare module "*.svg" {
1717
const value: string;
1818
export default value;
1919
}
2020

21-
declare module '*.gif' {
21+
declare module "*.gif" {
2222
const value: string;
2323
export default value;
2424
}
2525

26-
declare module '*.webp' {
26+
declare module "*.webp" {
2727
const value: string;
2828
export default value;
2929
}
30-

yarn.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,7 @@ __metadata:
14851485
"@testing-library/jest-dom": "npm:^6.4.6"
14861486
"@testing-library/react": "npm:^16.0.0"
14871487
"@types/eslint": "npm:^9"
1488+
"@types/prop-types": "npm:^15"
14881489
"@types/react": "npm:^18.3.3"
14891490
"@types/react-dom": "npm:^18.3.0"
14901491
"@typescript-eslint/eslint-plugin": "npm:^8.4.0"
@@ -1498,6 +1499,7 @@ __metadata:
14981499
jest-environment-jsdom: "npm:^29.7.0"
14991500
postcss: "npm:^8.4.38"
15001501
prettier: "npm:^3.3.3"
1502+
prop-types: "npm:^15.8.1"
15011503
react: "npm:^17.0.0 || ^18.0.0"
15021504
react-dom: "npm:^17.0.0 || ^18.0.0"
15031505
semantic-release: "npm:^24.0.0"
@@ -4072,6 +4074,13 @@ __metadata:
40724074
languageName: node
40734075
linkType: hard
40744076

4077+
"@types/prop-types@npm:^15":
4078+
version: 15.7.15
4079+
resolution: "@types/prop-types@npm:15.7.15"
4080+
checksum: 10c0/b59aad1ad19bf1733cf524fd4e618196c6c7690f48ee70a327eb450a42aab8e8a063fbe59ca0a5701aebe2d92d582292c0fb845ea57474f6a15f6994b0e260b2
4081+
languageName: node
4082+
linkType: hard
4083+
40754084
"@types/qs@npm:*":
40764085
version: 6.9.15
40774086
resolution: "@types/qs@npm:6.9.15"

0 commit comments

Comments
 (0)