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-boolean-value: add assumeUndefinedIsFalse option #3675

Merged
merged 1 commit into from Jan 11, 2024

Conversation

developer-bandi
Copy link
Contributor

Fixes #3234

A new option has been added referring to the comments on this issue.

I think there are some parts that need explanation, so I'll list them below.

  1. As you can see in the test case, if you remove both properties and values, a space remains, but that space can be modified with other rules such as jsx-props-no-multi-spaces, so it was left behind.

  2. While adding new options, I noticed that there was some issue with the options in the error message. After setting never or always in the second option, if the modification is made not only to the first option but also to the second option, an error message containing the properties of the second option is displayed as shown below. If it is confirmed to be an issue, a new mr will be created after working on the current issue. An example is below:

{
      code: '<App foo={true} bar={true} baz />;',
      output: '<App foo bar baz={true} />;',
      options: ['always', { never: ['foo', 'bar'] }],
      errors: [
        {
          messageId: 'omitBoolean',
          data: { exceptionsMessage: ' for the following props: `foo`, `bar`' },
        },
        {
          messageId: 'omitBoolean',
          data: { exceptionsMessage: ' for the following props: `foo`, `bar`' },
        },
        {
          messageId: 'setBoolean',
          data: { exceptionsMessage: ' for the following props: `foo`, `bar`' },
          // setBoolean attribute is not foo or bar but baz
        }
      ],
    },

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (67e669d) 97.65% compared to head (0ee0a2b) 97.65%.

❗ Current head 0ee0a2b differs from pull request most recent head 3730edb. Consider uploading reports for the commit 3730edb to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3675   +/-   ##
=======================================
  Coverage   97.65%   97.65%           
=======================================
  Files         132      132           
  Lines        9383     9397   +14     
  Branches     3436     3445    +9     
=======================================
+ Hits         9163     9177   +14     
  Misses        220      220           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ljharb
Copy link
Member

ljharb commented Jan 9, 2024

Yes, I think the second thing is a separate issue that should be fixed separately.

docs/rules/jsx-boolean-value.md Outdated Show resolved Hide resolved
lib/rules/jsx-boolean-value.js Outdated Show resolved Hide resolved
lib/rules/jsx-boolean-value.js Outdated Show resolved Hide resolved
lib/rules/jsx-boolean-value.js Outdated Show resolved Hide resolved
@ljharb ljharb changed the title [jsx-boolean-value]: add new option [New] jsx-boolean-value: add assumeUndefinedIsFalse option Jan 11, 2024
@ljharb ljharb merged commit 3730edb into jsx-eslint:master Jan 11, 2024
309 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

jsx-boolean-value: enhance configuration to handle false literals
2 participants