Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

feat!: support class static blocks #80

Merged
merged 1 commit into from
Nov 14, 2021
Merged

Conversation

mdjermanovic
Copy link
Member

This PR adds new "class-static-block" scopes. Each StaticBlock node creates a "class-static-block" scope.

https://github.com/tc39/proposal-class-static-block

Notes:

  • Class static blocks are technically functions, so they have arguments. However, referencing those arguments is a parse-time error, so I didn't add those variables to class static block scopes because they have no observable effects. This is consistent with class field initializers, we didn't add arguments there either.
  • Logic for properties that are deprecated per this document, such as Scope#isThisMaterialized, is not updated.
  • An alternative to the new "class-static-block" type could be to use the existing "function" type, which might be more practical for some use cases, but also confusing for others. I think it's better to introduce a new scope type.

I tagged this as a breaking change as I'd like to suggest that we bump major version. While this is a new syntax for eslint-scope, parsers (including Espree) already support this syntax, and inserting a new scope where it didn't exist before looks like a relatively big change in scope analysis (from wrong to right, but still).

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I agree that a major version bump makes sense.

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

Successfully merging this pull request may close these issues.

2 participants