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

Consider nullish coalescing in code path analyzer #13237

Closed
gaearon opened this issue Apr 30, 2020 · 3 comments
Closed

Consider nullish coalescing in code path analyzer #13237

gaearon opened this issue Apr 30, 2020 · 3 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint new syntax This issue is related to new syntax that has reached stage 4

Comments

@gaearon
Copy link

gaearon commented Apr 30, 2020

We use the code path analyzer for react-plugin-react-hooks/rules-of-hooks.

Currently, it understands foo || useHook() is a conditional function call, but it doesn't understand that for nullish coalescing foo ?? useHook(). We have some bugs creeping into the codebase because of that missing coverage.

Now that ?? is Stage 4, would it be possible to teach the code path analyzer to handle it?

The last relevant change I know of was #10476, but that just made it so that the code does not crash altogether. We're happy to lend a hand with a fix (although someone who knows the codebase might be able to do that better than me).

@gaearon gaearon added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Apr 30, 2020
@aladdin-add
Copy link
Member

related #12642

@aladdin-add aladdin-add added accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint experimental syntax This change is related to experimental syntax (stage 3 or below) core Relates to ESLint's core APIs and features and removed bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Apr 30, 2020
@kaicataldo kaicataldo added new syntax This issue is related to new syntax that has reached stage 4 and removed experimental syntax This change is related to experimental syntax (stage 3 or below) labels Apr 30, 2020
@kaicataldo
Copy link
Member

Thanks for the issue. Now that this PR has been merged, we should be able to add support when Acorn publishes its next release.

For some more context around why we don’t support this yet, it’s been difficult to nail down the AST spec for optional chaining and nullish coalescing operator syntax in ESTree, and since we use Acorn as the underlying parser and Acorn follows the ESTree spec, we unfortunately have been blocked. The two proposals were eventually split into two separate issues, and consensus has been reached on the nullish coalescing operator.

@mysticatea
Copy link
Member

I'm closing this issue as a duplicate of #12642.

New syntax support needs time because we need to work on upstream that there are many stakeholders. Please check #13196 for progress.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 3, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint new syntax This issue is related to new syntax that has reached stage 4
Projects
None yet
Development

No branches or pull requests

4 participants