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

eslint-plugin-react 7.20.1 - react/require-default-props - has no corresponding defaultProps declaration #2685

Closed
Tielem opened this issue Jun 29, 2020 · 5 comments

Comments

@Tielem
Copy link

Tielem commented Jun 29, 2020

Description

After upgrading from eslint-plugin-react 7.20.0 -> 7.20.1, my project errors on react/require-default-props

propType X is not required, but has no corresponding defaultProps declaration.

The project didn't have these errors on 7.20.0 (see main branch). The errors are thrown on a functional component with default values.

I am mainly curious as to whether this new error is intentional, and if so what the expected change should be that I need to make.

Steps to reproduce

git clone https://github.com/Tielem/gatsby-typescript-eslint-prettier-starter/tree/renovate/eslint-plugin-react-7.x
npm install
npm run build

Expected result

No errors

Actual result

See https://app.netlify.com/sites/gatsby-typescript-eslint-prettier-starter/deploys/5ef9113214fdb700081b9d35

@ljharb
Copy link
Member

ljharb commented Jun 29, 2020

I just published v7.20.2; can you try with that version?

@ljharb
Copy link
Member

ljharb commented Jun 29, 2020

Note, though, that the rule doesn't currently care about default values, since these aren't runtime-introspectable, and don't offer the same benefits that defaultProps does. See #2396 for discussion.

In other words, I think this is intentional, and it was a bug that you didn't get the warning previously, and the option discussed here might help you.

@Tielem
Copy link
Author

Tielem commented Jun 29, 2020

Thanks for the feedback! I quickly checked the discussion, but I assume that option is not yet available, right? Will read in more detail tomorrow.

Renovate will auto pull in 7.20.2 - I actually think it's already making a build with it atm

@ljharb
Copy link
Member

ljharb commented Jun 29, 2020

Correct, it's not yet available.

Semver with eslint plugins is tricky; many bugfixes will create more warnings, thus failing the build; it's got to be a judgement call every time.

@ljharb
Copy link
Member

ljharb commented Jun 30, 2020

I think pending the option in #2396, this is intentional and warrants an override comment if you don't want to use defaultProps. Happy to reopen if there's something actionable here tho!

@ljharb ljharb closed this as completed Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants