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

Error: VariableDeclarator ASTNodes are not handled by markPropTypesAsUsed #2319

Closed
johnridesabike opened this issue Jun 24, 2019 · 5 comments · Fixed by #2320
Closed

Error: VariableDeclarator ASTNodes are not handled by markPropTypesAsUsed #2319

johnridesabike opened this issue Jun 24, 2019 · 5 comments · Fixed by #2320

Comments

@johnridesabike
Copy link

ESLint started crashing with this error shortly after I upgraded to 7.14.0.

I suspect it's related to prop destructuring. I tried opening different JSX files and ESLint didn't seem to have a problem except for files with components that destructure their props.

Full error log:

[Error - 8:04:55 PM] ESLint stack trace:
[Error - 8:04:55 PM] Error: VariableDeclarator ASTNodes are not handled by markPropTypesAsUsed
Occurred while linting /Users/.../src/pages/tournament/status.jsx:8
    at markPropTypesAsUsed (/Users/.../node_modules/eslint-plugin-react/lib/util/usedPropTypes.js:338:15)
    at Object.VariableDeclarator (/Users/.../node_modules/eslint-plugin-react/lib/util/usedPropTypes.js:492:9)
    at updatedRuleInstructions.(anonymous function) (/Users/.../node_modules/eslint-plugin-react/lib/util/Components.js:780:47)
    at listeners.(anonymous function).forEach.listener (/Users/.../node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/.../node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/.../node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/.../node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/Users/.../node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/Users/.../node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
@golopot
Copy link
Contributor

golopot commented Jun 24, 2019

Can you share the code that produce the bug?

@johnridesabike
Copy link
Author

Here's one example:

import {Panel, PanelContainer} from "../../components/utility";
import PropTypes from "prop-types";
import React from "react";
import RoundTable from "./round/round-table";
import {ScoreTable} from "./scores";

export default function Status({tournament}) {
    const {tourney, getPlayer} = tournament;
    const lastRound = (function () {
        if (tourney.roundList.length === 0) {
            return <p>No rounds played yet.</p>;
        }
        const lastRoundId = tourney.roundList.length - 1;
        if (tourney.roundList[lastRoundId].length === 0) {
            return (
                <p>Matched players in the current round will be shown here.</p>
            );
        }
        return (
            <RoundTable
                roundId={lastRoundId}
                tournament={tournament}
                compact
            />
        );
    }());
    return (
        <>
            <h2 style={{textAlign: "center"}}>Tournament status</h2>
            <PanelContainer
                style={{justifyContent: "center"}}
            >
                <Panel>
                    {lastRound}
                </Panel>
                <Panel>
                    <ScoreTable
                        getPlayer={getPlayer}
                        title="Rankings"
                        tourney={tourney}
                        compact
                    />
                </Panel>
            </PanelContainer>
        </>
    );
}
Status.propTypes = {
    tournament: PropTypes.object.isRequired
};

If I remove the line const {tourney, getPlayer} = tournament; then ESLint doesn't crash.

@jjarthur
Copy link

I started getting this error today also, with a very similar example to yours.

@golopot
Copy link
Contributor

golopot commented Jun 24, 2019

I opened a pr on this. A minimal reproducing example is:

/* react/prop-types: 2 */

const PropTypes = require('prop-types');

function Foo({a}) {
  const {b} = a;
  return <p>{b.nope}</p>;
}
Foo.propTypes = {
  a: PropTypes.shape({
    b: PropTypes.shape({
      _: PropTypes.string,
    }),
  }),
};

afc163 added a commit to ant-design/ant-design that referenced this issue Jun 24, 2019
@ljharb
Copy link
Member

ljharb commented Jun 24, 2019

What version of eslint?

martinpitt added a commit to martinpitt/cockpit that referenced this issue Jun 24, 2019
7.14.0 has a grave bug which breaks our build:
jsx-eslint/eslint-plugin-react#2319

Until the fix is released, pin down to the previous version.
martinpitt added a commit to cockpit-project/cockpit that referenced this issue Jun 24, 2019
7.14.0 has a grave bug which breaks our build:
jsx-eslint/eslint-plugin-react#2319

Until the fix is released, pin down to the previous version.

Closes #12136
sunu added a commit to alephdata/aleph that referenced this issue Jun 24, 2019
wichert added a commit to Crypho/eslint-config-crypho that referenced this issue Jun 24, 2019
fonghehe pushed a commit to fonghehe/fabric that referenced this issue Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants