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-plugin-react-hooks (4.1.2) - The prop value with an expression type of ChainExpression could not be resolved #19940

Closed
LauraBeatris opened this issue Oct 1, 2020 · 13 comments

Comments

@LauraBeatris
Copy link

React version: ^16.10.2

Steps To Reproduce

  1. Install [email protected]
  2. Run yarn eslint src --ext=js,jsx,ts,tsx

Related issue: #19810 (comment)

The current behavior

The linter is showing the following message:

The prop value with an expression type of ChainExpression could not be resolved. Please file issue to get this fixed immediately.

It started to appear on [email protected]

The expected behavior

Do not show the message

@LauraBeatris LauraBeatris added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Oct 1, 2020
@eps1lon
Copy link
Collaborator

eps1lon commented Oct 1, 2020

Thanks for the report. Including the linted code (and the parser e.g. @typescript-eslint/parser or @babel/eslint-parser) that produced this error would help immensely. Otherwise we would need to guess what kind of code produced this which would take a lot more time to fix this issue.

You can detect the line of code that caused it by linting fewer files (similar to git-bisect) until you no longer receive that error.

@eps1lon eps1lon added Component: ESLint Rules Type: Needs Investigation and removed Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Oct 1, 2020
@gaearon
Copy link
Collaborator

gaearon commented Oct 1, 2020

Where is this message coming from? I don’t think it’s ours. ESLint?

@LauraBeatris
Copy link
Author

LauraBeatris commented Oct 1, 2020

@eps1lon

The parser dependency is @typescript-eslint/[email protected]

Line of code that caused the isse:

    <Member
	  {...}
      role={item?.role} // Accessing ``role`` property with optional chaining is raising the error
    />

The prop value is being accessed via optional chaining and that's what's throwing the error apparently. If I remove it item.role, the message disappears.

The type of the prop:

export enum MemberRoleEnum {
  CoHost = 'CO_HOST',
  Host = 'HOST',
  Member = 'MEMBER'
}

export interface FormattedFundMember extends BaseFlatListItem {
  role: MemberRoleEnum;
}

@LauraBeatris
Copy link
Author

LauraBeatris commented Oct 1, 2020

@gaearon As you said, I think the issue it's not related to React at all... Should be better to create the issue on the @typescript-eslint/parser repo?

I created it here because it started to appear on [email protected]

@LauraBeatris LauraBeatris changed the title Bug: eslint-plugin-react-hooks (4.1.2)- Bug: eslint-plugin-react-hooks (4.1.2) - The prop value with an expression type of ChainExpression could not be resolved Oct 1, 2020
@junoatwork
Copy link

I also started seeing this output (upgrading an existing project).

The error string is coming from the jsx-ast-utils package used by eslint-plugin-react-hooks. The AST type ChainExpression is not supported in this list of node types https://github.com/jsx-eslint/jsx-ast-utils/blob/master/src/values/expressions/index.js#L24-L47 and will need to be added.

I'll open an issue on that repo; posting my findings here because this issue is currently the only searchable result.

@junoatwork
Copy link

This is fixed in [email protected] jsx-eslint/jsx-ast-utils#102

@gaearon
Copy link
Collaborator

gaearon commented Oct 9, 2020

I don't think eslint-plugin-react-hooks depends on that package? Does it transitively?

@junoatwork
Copy link

eslint-plugin-react depends on jsx-ast-utils

@gaearon
Copy link
Collaborator

gaearon commented Oct 9, 2020

eslint-plugin-react has no relation to this repository. We're discussing eslint-plugin-react-hooks.

@LauraBeatris
Copy link
Author

LauraBeatris commented Oct 9, 2020

@gaearon It's strange because this output disappears when downgrading eslint-plugin-react-hooks

@gaearon
Copy link
Collaborator

gaearon commented Oct 9, 2020

In either case it seems like this is solved upstream so not actionable for us.

@gaearon gaearon closed this as completed Oct 9, 2020
@ahsanplusplus
Copy link

This is fixed in [email protected] jsx-eslint/jsx-ast-utils#102

It works well on my end. I appreciate

@Freddy-Gong
Copy link

run npx browserslist@latest --update-db can fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants