Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[help wanted] The functions option (defaultArguments) in the react/require-default-props rule does not work as expected. #3738

Open
2 tasks done
amisu1203 opened this issue Apr 17, 2024 · 0 comments
Labels

Comments

@amisu1203
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

i set the react/require-default-props rules with functions - defaultArguments option.
but i got an error that propType "asChild" is not required, but has no corresponding defaultProps declaration. in my shadcn/ui 'breadcrumb' component.

// breadcrumb.tsx
const BreadcrumbLink = React.forwardRef<
  HTMLAnchorElement,
  React.ComponentPropsWithoutRef<"a"> & {
    asChild?: boolean;
  }
>(({ asChild = false, className, ...props }, ref) => {
  const Comp = asChild ? Slot : "a";

  return (
    <Comp
      ref={ref}
      className={cn("transition-colors hover:text-foreground", className)}
      {...props}
    />
  );
});

// .eslintrc.json
{
   "rules": {
      "react/react-in-jsx-scope": "off",
      "react/jsx-props-no-spreading": "off", 
      "react/require-default-props": [2, { "functions" : "defaultArguments" }],
    },
    "overrides": [
      {
        "files": ["**/components/ui/*.tsx"], 
        "rules": {
          "react/prop-types": [2, { "ignore": ["className","sideOffset","checked"] }]
        }
      }
    ]
}

what should i do for resolve this problem?

Expected Behavior

.

eslint-plugin-react version

v7.34.1

eslint version

v8.57.0

node version

v20.11.0

@amisu1203 amisu1203 added the bug label Apr 17, 2024
@amisu1203 amisu1203 changed the title The functions option (defaultArguments) in the react/require-default-props rule does not work as expected. [help wanted] The functions option (defaultArguments) in the react/require-default-props rule does not work as expected. Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant