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] destructuring-assignment, no-multi-comp, no-unstable-nested-components, component detection: improve component detection #3001

Merged
merged 1 commit into from Jun 7, 2021

Conversation

vedadeepta
Copy link
Contributor

@vedadeepta vedadeepta commented Jun 5, 2021

Fixes: #2956

Description:

Example code that shows incorrect error:

const columns = [
  {
    render: (val) => {
      if (val.url) {
        return (
          <a href={val.url} rel="noopener noreferrer" target="_blank">
            {val.fileName || 'PDF'}
          </a>
        );
      }
      return null;
    },
  },
];

Error shows up because getParentComponent calls getParentStatelessComponent that calls getStatelessComponent on the ArrowFunctionExpression (val =>...) in the example code above which incorrectly returns the same ArrowFunctionExpression instead of undefined.

…d-components`, component detection: improve component detection
@codecov-commenter
Copy link

codecov-commenter commented Jun 5, 2021

Codecov Report

Merging #3001 (79a7bcc) into master (faadccb) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3001   +/-   ##
=======================================
  Coverage   97.21%   97.22%           
=======================================
  Files         110      110           
  Lines        7297     7305    +8     
  Branches     2657     2663    +6     
=======================================
+ Hits         7094     7102    +8     
  Misses        203      203           
Impacted Files Coverage Δ
lib/util/Components.js 95.36% <100.00%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update faadccb...79a7bcc. Read the comment docs.

@vedadeepta vedadeepta marked this pull request as ready for review June 5, 2021 20:45
lib/util/Components.js Outdated Show resolved Hide resolved
@ljharb ljharb force-pushed the fix/2956-component-detection branch from 0d9ef7b to 860ebea Compare June 7, 2021 06:12
@ljharb ljharb changed the title [Fix]: destructuring-assignment, Components: improve component detection [Fix] destructuring-assignment, no-multi-comp, no-unstable-nested-components, component detection: improve component detection Jun 7, 2021
@ljharb ljharb merged commit 860ebea into jsx-eslint:master Jun 7, 2021
@yoyo837
Copy link
Contributor

yoyo837 commented Jun 7, 2021

Thanks for your work.

@ThiefMaster
Copy link
Contributor

ThiefMaster commented Oct 30, 2021

Not sure if it's caused by the changes in this PR, but after updating from 7.24 to 7.26, I noticed a bunch of false positives showing up in my code:

.../indico/modules/events/editing/client/js/editing/timeline/util.js
  55:14  warning  Must use destructuring revision assignment  react/destructuring-assignment

.../indico/modules/rb/client/js/common/map/reducers.js
  59:9  warning  Must use destructuring action assignment  react/destructuring-assignment
  64:9  warning  Must use destructuring action assignment  react/destructuring-assignment

ThiefMaster added a commit to ThiefMaster/indico that referenced this pull request Oct 30, 2021
There were some false positives when checking for destructuring:
jsx-eslint/eslint-plugin-react#3001 (comment)
@ljharb
Copy link
Member

ljharb commented Oct 31, 2021

@ThiefMaster i agree those are false positives. Can you file a new issue so we can track fixing it?

duartegalvao pushed a commit to duartegalvao/indico that referenced this pull request Dec 7, 2021
There were some false positives when checking for destructuring:
jsx-eslint/eslint-plugin-react#3001 (comment)
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.

Optional Chaining report destructuring-assignment
5 participants