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

[New] jsx-no-leaked-render: add ignoreAttributes option #3441

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aleclarson
Copy link

@aleclarson aleclarson commented Sep 26, 2022

Fixes #3292

When ignoreAttributes is true, validation of JSX attribute values is skipped.

Todo

  • write docs

When true, validation of JSX attribute values is skipped.
@codecov
Copy link

codecov bot commented Sep 26, 2022

Codecov Report

Merging #3441 (9c84be6) into master (b52e0ca) will decrease coverage by 0.00%.
The diff coverage is 90.90%.

@@            Coverage Diff             @@
##           master    #3441      +/-   ##
==========================================
- Coverage   97.62%   97.61%   -0.01%     
==========================================
  Files         123      123              
  Lines        8959     8970      +11     
  Branches     3272     3275       +3     
==========================================
+ Hits         8746     8756      +10     
- Misses        213      214       +1     
Impacted Files Coverage Δ
lib/rules/jsx-no-leaked-render.js 97.33% <90.90%> (-1.11%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@levrik
Copy link

levrik commented Sep 27, 2022

I think ignoreProps would be a more suitable name here.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on the use case here?

Certainly the component you're passing the prop value to might not be directly rendering it - but I'm not sure why that makes it OK to pass a renderable falsy value.

@ljharb ljharb marked this pull request as draft September 27, 2022 20:02
@aleclarson
Copy link
Author

Can you elaborate on the use case here?

Certainly the component you're passing the prop value to might not be directly rendering it - but I'm not sure why that makes it OK to pass a renderable falsy value.

The use case is preferring to avoid false positives. The component receiving the prop is responsible for avoiding leaky render. Many prefer to keep the warning local to where the prop is actually rendered.

@ljharb
Copy link
Member

ljharb commented Sep 29, 2022

I see - so you're saying, you still want to report on leaky renders on DOM elements, but you don't want to do that on props on custom elements so that the custom component has the responsibility to check for it?

In that case, what i'd expect is that this could be ignoreNonDOMProps, and it would only suppress warning on props of non-DOM elements - would that meet your use case?

@ljharb ljharb force-pushed the master branch 6 times, most recently from 59af733 to 865ed16 Compare November 11, 2022 02:45
@ljharb ljharb force-pushed the master branch 4 times, most recently from 069314a to 181c68f Compare November 18, 2022 17:19
@tcl333
Copy link

tcl333 commented Nov 29, 2022

This rule is unusable to me until this PR is landed. I need to handle a very basic usecase of <Component isFooBar={isFoo && isBar}>. This rule currently auto-breaks that line by converting it into <Component isFooBar={isFoo ? isBar : null }>. My component doesn't take null as a prop, nor should it be required to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

False positive for react/jsx-no-leaked-render
4 participants