Skip to content

no-typos: TypeError: only function nodes are expected #3036

Closed
@AriPerkkio

Description

@AriPerkkio

Hello, no-typos rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything.

I don't think these bugs are included in any releases yet.

#2963 (comment)

eslint-plugin-react@master

Minimal repro:

Failing test cases:

  {
    code: `
    const MyComponent = React.forwardRef((props, ref) => <div />);
    MyComponent.defaultProps = { value: "" };
    `,
    parserOptions
  },
  {
    code: `
    import styled from "styled-components";

    const MyComponent = styled.div;
    MyComponent.defaultProps = { value: "" };
    `,
    parserOptions
  }
TypeError: only function nodes are expected
Occurred while linting <input>:3
      at Object.traverseReturns (lib/util/ast.js:87:11)
      at Object.isReturningJSX (lib/util/jsx.js:97:11)
      at Object.isReturningJSX (lib/util/Components.js:413:22)
      at Object.MemberExpression (lib/rules/no-typos.js:245:74)
      at updatedRuleInstructions.<computed> (lib/util/Components.js:935:45)
      at /workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/safe-emitter.js:45:58
      at Array.forEach (<anonymous>)
      at Object.emit (node_modules/eslint/lib/linter/safe-emitter.js:45:38)
      at NodeEventGenerator.applySelector (node_modules/eslint/lib/linter/node-event-generator.js:293:26)
      at NodeEventGenerator.applySelectors (node_modules/eslint/lib/linter/node-event-generator.js:322:22)
      at NodeEventGenerator.enterNode (node_modules/eslint/lib/linter/node-event-generator.js:336:14)
      at CodePathAnalyzer.enterNode (node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
      at /workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/linter.js:960:32
      at Array.forEach (<anonymous>)
      at runRules (node_modules/eslint/lib/linter/linter.js:955:15)
Crash reports from real projects

Rule: no-typos

  • Message: only function nodes are expected Occurred while linting /workspaces/eslint-plugin-react/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/mozilla/Spoke/src/ui/inputs/StringInput.js:17
  • Path: mozilla/Spoke/src/ui/inputs/StringInput.js
  • Link
  15 | StringInput.displayName = "StringInput";
  16 |
> 17 | StringInput.defaultProps = {
  18 |   value: "",
  19 |   onChange: () => {},
  20 |   type: "text",
TypeError: only function nodes are expected
Occurred while linting /workspaces/eslint-plugin-react/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/mozilla/Spoke/src/ui/inputs/StringInput.js:17
    at Object.traverseReturns (/workspaces/eslint-plugin-react/lib/util/ast.js:87:11)
    at Object.isReturningJSX (/workspaces/eslint-plugin-react/lib/util/jsx.js:97:11)
    at Object.isReturningJSX (/workspaces/eslint-plugin-react/lib/util/Components.js:413:22)
    at Object.MemberExpression (/workspaces/eslint-plugin-react/lib/rules/no-typos.js:245:74)
    at updatedRuleInstructions.<computed> (/workspaces/eslint-plugin-react/lib/util/Components.js:935:45)
    at /workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/node-event-generator.js:293:26)
    at NodeEventGenerator.applySelectors (/workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/node-event-generator.js:322:22)

Rule: no-typos

  • Message: only function nodes are expected Occurred while linting /workspaces/eslint-plugin-react/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/mozilla/Spoke/src/ui/layout/MediaGrid.js:38
  • Path: mozilla/Spoke/src/ui/layout/MediaGrid.js
  • Link
  36 | `;
  37 |
> 38 | MediaGridItemContainer.propTypes = {
  39 |   aspectRatio: PropTypes.number.isRequired,
  40 |   borderRadius: PropTypes.number.isRequired,
  41 |   selected: PropTypes.bool
TypeError: only function nodes are expected
Occurred while linting /workspaces/eslint-plugin-react/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/mozilla/Spoke/src/ui/layout/MediaGrid.js:38
    at Object.traverseReturns (/workspaces/eslint-plugin-react/lib/util/ast.js:87:11)
    at Object.isReturningJSX (/workspaces/eslint-plugin-react/lib/util/jsx.js:97:11)
    at Object.isReturningJSX (/workspaces/eslint-plugin-react/lib/util/Components.js:413:22)
    at Object.MemberExpression (/workspaces/eslint-plugin-react/lib/rules/no-typos.js:245:74)
    at updatedRuleInstructions.<computed> (/workspaces/eslint-plugin-react/lib/util/Components.js:935:45)
    at /workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/node-event-generator.js:293:26)
    at NodeEventGenerator.applySelectors (/workspaces/eslint-plugin-react/node_modules/eslint/lib/linter/node-event-generator.js:322:22)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions