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

[Fix] jsx-boolean-value: make error messages clearer #3691

Merged
1 commit merged into from Mar 4, 2024

Conversation

developer-bandi
Copy link
Contributor

As mentioned in #3675, jsx-boolean-value error message is not clear.

in current code, 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.

{
      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
        }
      ],
    },

i think this is not make sense, so change the error message include single prop that has error. so fixed test case is it

    {
      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`' },
        },
        {
          messageId: 'omitBoolean',
          data: { exceptionsMessage: ' for the following props: `bar`' },
        },
        {
          messageId: 'setBoolean',
          data: { exceptionsMessage: ' for the following props: `baz`' },
        },
      ],
    },

other test case change is because of message format change

Copy link

codecov bot commented Feb 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.75%. Comparing base (2124d13) to head (4d83242).

❗ Current head 4d83242 differs from pull request most recent head 6cb0f00. Consider uploading reports for the commit 6cb0f00 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3691      +/-   ##
==========================================
- Coverage   97.76%   97.75%   -0.01%     
==========================================
  Files         133      133              
  Lines        9471     9462       -9     
  Branches     3472     3465       -7     
==========================================
- Hits         9259     9250       -9     
  Misses        212      212              

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

tests/lib/rules/jsx-boolean-value.js Outdated Show resolved Hide resolved
@ljharb ljharb marked this pull request as draft February 18, 2024 19:03
@developer-bandi developer-bandi marked this pull request as ready for review February 19, 2024 12:41
@ljharb ljharb changed the title [FIX] jsx-boolean-value error message makes clear [Fix] jsx-boolean-value: make error messages clearer Mar 3, 2024
@ljharb ljharb closed this pull request by merging all changes into jsx-eslint:master in 24d21ac Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants