Fix issue #2029: Replace defaultProps with JavaScript default parameters (#2106)

* updated basemodal

Updated the basemodal.tsx file by removing the  BaseModal.defaultProps block and including the default values directly within the function parameters.

* Removed DefaultProps from the files

Removed DefaultProps from the files:
AgentControlBar.tsx, ChatInput.tsx, ExplorerTree.tsx, TreeNode.tsx, IconButton.tsx, HeaderContent.tsx, AutocompleteCombobox.tsx

and replaced the usage of defaultProps with JavaScript default parameters in the given components.

* Removed comments and updated eslintrc

Removed all the comments (Removed the defaultProps block comment), and updated the ESLint rules to ignore the defaultProps warning thrown by ESLint.

* Finished Linting Succesfully.

Ran the lint command with the --fix and --write arg to fix all remaining issues and errors before pushing. Thanks a lot @amanape for the support!

---------

Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>
This commit is contained in:
Prithvi 2024-05-28 23:49:50 -07:00 committed by GitHub
parent 9b371b1b5f
commit 13d04fa36c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 12 additions and 43 deletions

View File

@ -44,6 +44,7 @@
}],
// For https://stackoverflow.com/questions/55844608/stuck-with-eslint-error-i-e-separately-loops-should-be-avoided-in-favor-of-arra
"no-restricted-syntax": "off",
"react/require-default-props": "off",
"import/prefer-default-export": "off",
"no-underscore-dangle": "off",
"jsx-a11y/no-static-element-interactions": "off",

View File

@ -9037,6 +9037,7 @@
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz",
"integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",

View File

@ -41,7 +41,7 @@ function ActionButton({
action,
handleAction,
children,
large,
large = false,
}: React.PropsWithChildren<ButtonProps>): React.ReactNode {
return (
<Tooltip content={content} closeDelay={100}>
@ -57,10 +57,6 @@ function ActionButton({
);
}
ActionButton.defaultProps = {
large: false,
};
function AgentControlBar() {
const { curAgentState } = useSelector((state: RootState) => state.agent);
const [desiredState, setDesiredState] = React.useState(AgentState.INIT);

View File

@ -12,7 +12,7 @@ function IconButton({
icon,
onClick,
ariaLabel,
testId,
testId = "",
}: IconButtonProps): React.ReactElement {
return (
<Button
@ -28,8 +28,4 @@ function IconButton({
);
}
IconButton.defaultProps = {
testId: "",
};
export default IconButton;

View File

@ -10,7 +10,7 @@ interface ChatInputProps {
onSendMessage: (message: string) => void;
}
function ChatInput({ disabled, onSendMessage }: ChatInputProps) {
function ChatInput({ disabled = false, onSendMessage }: ChatInputProps) {
const { t } = useTranslation();
const [message, setMessage] = React.useState("");
@ -70,8 +70,4 @@ function ChatInput({ disabled, onSendMessage }: ChatInputProps) {
);
}
ChatInput.defaultProps = {
disabled: false,
};
export default ChatInput;

View File

@ -16,8 +16,4 @@ function ExplorerTree({ files, defaultOpen = false }: ExplorerTreeProps) {
);
}
ExplorerTree.defaultProps = {
defaultOpen: false,
};
export default ExplorerTree;

View File

@ -94,8 +94,4 @@ function TreeNode({ path, defaultOpen = false }: TreeNodeProps) {
);
}
TreeNode.defaultProps = {
defaultOpen: false,
};
export default React.memo(TreeNode);

View File

@ -24,9 +24,9 @@ function BaseModal({
onOpenChange,
title,
isDismissable = true,
subtitle,
actions,
children,
subtitle = undefined,
actions = [],
children = null,
}: BaseModalProps) {
return (
<Modal
@ -60,11 +60,4 @@ function BaseModal({
);
}
BaseModal.defaultProps = {
isDismissable: true,
subtitle: undefined,
actions: [],
children: null,
};
export default BaseModal;

View File

@ -5,7 +5,10 @@ interface HeaderContentProps {
subtitle?: string;
}
export function HeaderContent({ title, subtitle }: HeaderContentProps) {
export function HeaderContent({
title,
subtitle = undefined,
}: HeaderContentProps) {
return (
<>
<h3>{title}</h3>
@ -15,7 +18,3 @@ export function HeaderContent({ title, subtitle }: HeaderContentProps) {
</>
);
}
HeaderContent.defaultProps = {
subtitle: undefined,
};

View File

@ -77,8 +77,3 @@ export function AutocompleteCombobox({
</Tooltip>
);
}
AutocompleteCombobox.defaultProps = {
allowCustomValue: false,
disabled: false,
};