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

Bug: ESLint: Cannot read property 'type' of undefined Occurred while linting #21342

Closed
LeonardoRick opened this issue Apr 23, 2021 · 6 comments
Closed
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@LeonardoRick
Copy link

LeonardoRick commented Apr 23, 2021

React version:
17.0.2

eslint-plugin-react-hooks version:
4.2.0

Steps To Reproduce

  1. import useEfect from react library
  2. type useEfect(

Link to code example:
https://github.com/LeonardoRick/podcastr

The current behavior

image

output:

[Error - 16:40:28] ESLint stack trace:
[Error - 16:40:28] TypeError: Cannot read property 'type' of undefined
Occurred while linting D:\GIT\podcastr\src\Components\Player\index.tsx:16
    at visitCallExpression (D:\GIT\podcastr\node_modules\eslint-plugin-react-hooks\cjs\eslint-plugin-react-hooks.development.js:1736:24)
    at D:\GIT\podcastr\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (D:\GIT\podcastr\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (D:\GIT\podcastr\node_modules\eslint\lib\linter\node-event-generator.js:256:26)
    at NodeEventGenerator.applySelectors (D:\GIT\podcastr\node_modules\eslint\lib\linter\node-event-generator.js:285:22)
    at NodeEventGenerator.enterNode (D:\GIT\podcastr\node_modules\eslint\lib\linter\node-event-generator.js:299:14)
    at CodePathAnalyzer.enterNode (D:\GIT\podcastr\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:711:23)
    at D:\GIT\podcastr\node_modules\eslint\lib\linter\linter.js:954:32
    at Array.forEach (<anonymous>)

error line:

      // eslint-plugin-react-hooks\cjs\eslint-plugin-react-hooks.development.js:1736:24:
      switch (callback.type) {

The expected behavior

No errors showing, since I'm currently typing the code

@LeonardoRick LeonardoRick added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Apr 23, 2021
@gaearon
Copy link
Collaborator

gaearon commented Apr 23, 2021

Add an exact reproducing file, please?

@LeonardoRick
Copy link
Author

LeonardoRick commented Apr 23, 2021

reproducing file:

import { useEffect } from "react";

export default function Test(): JSX.Element {
  useEffect();
  return (
    <h1>Hello world</h1>
  );
}

@gaearon
Copy link
Collaborator

gaearon commented Apr 23, 2021

@gaearon
Copy link
Collaborator

gaearon commented Apr 23, 2021

This test case seems to imply that it should work.

code: normalizeIndent`
function MyComponent() {
useEffect()

@LeonardoRick LeonardoRick changed the title Bug: Bug: ESLint: Cannot read property 'type' of undefined Occurred while linting Apr 23, 2021
@eps1lon
Copy link
Collaborator

eps1lon commented Apr 23, 2021

Duplicate of #20343 which was fixed in #20385 3 months ago.

The last release of eslint-plugin-react-hooks was 6 months ago though.

@LeonardoRick
Copy link
Author

Ops, sorry about that. I taught it wasn't duplicate because that one was closed and the error persisted. I'll wait the update. Thanks @eps1lon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

3 participants