-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: react/boolean-prop-naming not working with TS & declaration #3763
Comments
I believe this is fixed but not yet released. See #3733. |
Released in v7.34.3. Happy to reopen if it's not fixed. |
I'm getting a similar error with Config:"react/sort-prop-types": [
"error",
{
"callbacksLast": true,
"requiredFirst": true,
"sortShapeProp": true,
"noSortAlphabetically": true,
"checkTypes": true
}
], Error:$ eslint "{src,tests}/**/*.{js,ts,tsx}" --fix
Oops! Something went wrong! :(
ESLint: 8.57.0
TypeError: Cannot read properties of undefined (reading 'typeAnnotation')
Occurred while linting /Users/tyler/Code/condor/paqarina/src/AppWithAuthentication.tsx:9
Rule: "react/sort-prop-types"
at handleFunctionComponent (/Users/tyler/Code/condor/paqarina/node_modules/eslint-plugin-react/lib/rules/sort-prop-types.js:233:39)
at ruleErrorHandler (/Users/tyler/Code/condor/paqarina/node_modules/eslint/lib/linter/linter.js:1076:28)
at /Users/tyler/Code/condor/paqarina/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/Users/tyler/Code/condor/paqarina/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/Users/tyler/Code/condor/paqarina/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
at NodeEventGenerator.applySelectors (/Users/tyler/Code/condor/paqarina/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
at NodeEventGenerator.enterNode (/Users/tyler/Code/condor/paqarina/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
at CodePathAnalyzer.enterNode (/Users/tyler/Code/condor/paqarina/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:803:23)
at /Users/tyler/Code/condor/paqarina/node_modules/eslint/lib/linter/linter.js:1111:32 |
Ooh yeah, ours is outdated since we didn't get around to updating our eslint config to the new JS style instead of JSON: |
hm, that's the same version I have locally (and the latest one we currently test against), which doesn't reproduce the problem. |
Here's our full config. It still repros after I deleted all other rules:
|
And here is our
|
nvm, it reprod, thanks :-) |
Is there an existing issue for this?
Description Overview
There is no indication in IDE that the prop is not correct.
Terminal is throwing:
The affected component code:
const Component = ({ color, withBackground }: ComponentProps & { withBackground?: boolean }) => (...);
I managed to fix the problem by moving the props definition in a separate type:
By doing this, the IDE is properly suggesting that "withBackground" is not covering the rules:
Packages versions:
Expected Behavior
Properly validate the props.
eslint-plugin-react version
v7.34.2
eslint version
v8.57.0
node version
v18.18.0
The text was updated successfully, but these errors were encountered: