Comments (13)
Yes.
Done in #3754
from eslint-plugin-react.
i agree, this should be valid (altho !!firstCondition && !!anotherCondition
would be more idiomatic)
from eslint-plugin-react.
One more thing is frustrating to me.
number && value
might cause unintentional reslut but boolean && value
won't.
Why the plugin requires ternary all the time even when no potential unexpected result? Could we use the TypeScrypt parser to only report the potential errors? &&
conditional rendering is a JS feature not something developer should avoid.
from eslint-plugin-react.
@A7med3bdulBaset specifically because a 0
is falsy but will render a literal zero - that's the point of the rule, and indeed is why &&
conditional rendering is dangerous.
from eslint-plugin-react.
I understand well &&
and its cons/pros.
I know 0 && content
will render 0
. My point is why boolean && content
, contentOrNullOrUndefinedOrBoolean && content
is prevented?
from eslint-plugin-react.
I agree that neither of those should be prevented when the type is known.
from eslint-plugin-react.
Thanks @akulsr0 for working on this
from eslint-plugin-react.
I know
0 && content
will render0
. My point is whyboolean && content
,contentOrNullOrUndefinedOrBoolean && content
is prevented?I agree that neither of those should be prevented when the type is known.
@ljharb, should I create an issue for this?
from eslint-plugin-react.
@AhmedBaset if, with the latest unreleased code, you still have an issue, please do file one.
from eslint-plugin-react.
<Comp prop={cond1 && cond2} />
was solved. But, dataOrUndefined && data...
still an issue. IMO the rule should only complain if the left side is of type number.
from eslint-plugin-react.
More specifically, it should only complain if the left side is a known type and is not a number.
This should also be an option, I'd think, because TS isn't actually "type safety" and folks may not want to rely on it.
from eslint-plugin-react.
More specifically, it should only complain if the left side is a known type and is not a number.
This should also be an option, I'd think, because TS isn't actually "type safety" and folks may not want to rely on it.
hmm. then, worth be an issue?
from eslint-plugin-react.
Yes.
from eslint-plugin-react.
Related Issues (20)
- [Bug]: TypeError in version 7.34.1 HOT 1
- `jsx-handler-names` support skipping prop naming checks HOT 2
- [Suggestion]: Drop support for node <16.20 HOT 1
- Proposal for Stringent Type Checking HOT 3
- [Bug]: Support for Eslint 9.0.0? HOT 1
- [Bug]: react/boolean-prop-naming - Cannot read properties of undefined (reading 'properties') HOT 1
- [Bug]: peer dependency error with eslint@9 HOT 1
- [Bug]: An incomprehensible mistake HOT 3
- [help wanted] The functions option (defaultArguments) in the react/require-default-props rule does not work as expected.
- [Bug]: HOT 3
- Add "line-aligned" to react/jsx-closing-tag-location HOT 7
- [Bug]: Properties faulty identified as not declared for types in react-hook-form HOT 1
- [Bug]: checkKeyMustBeforeSpread of react/jsx-key doesn't work when generating array dynamically
- [Bug]: Endless listing cycle HOT 4
- [Bug]: The endless linting cycle HOT 1
- [Bug]: Rule "react/no-direct-mutation-state" failing in a stateless component HOT 1
- Remove `react/prop-types` from the recommended config HOT 1
- `jsx-no-leaked-render` should only complain if there is a certian leaked render HOT 3
- Quick question: does `settings.version` default to "detect" yet? HOT 3
- [Bug]: Unable to use with eslint 9.x HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-react.