support class static blocks (stage-4)
See original GitHub issueWhat is the name of the syntax to implement? class static blocks
Please provide the TC39 URL for the syntax proposal: https://github.com/tc39/proposal-class-static-block
Please provide some example code for the new syntax:
// with static blocks:
class C {
static x = ...;
static y;
static z;
static {
try {
const obj = doSomethingWith(this.x);
this.y = obj.y;
this.z = obj.z;
}
catch {
this.y = ...;
this.z = ...;
}
}
}
Implementation Checklist
Please check off all items that have already been completed. Be sure to paste the pull request URLs next to each item so we can verify the work as done.
- Ecma262 update: https://github.com/tc39/ecma262/pull/2440
- ESTree update: https://github.com/estree/estree/pull/254
- Acorn update: https://github.com/acornjs/acorn/pull/1063
-
eslint-visitor-keys
update: https://github.com/eslint/eslint-visitor-keys/pull/29, https://github.com/eslint/eslint/pull/15277 -
espree
update: https://github.com/eslint/espree/pull/518 -
eslint-scope
update: https://github.com/eslint/eslint-scope/pull/80, https://github.com/eslint/eslint/pull/15321 -
eslint
update:- Code Path Analysis https://github.com/eslint/eslint/pull/15282
- Rules
-
block-scoped-var
https://github.com/eslint/eslint/pull/15302 -
block-spacing
https://github.com/eslint/eslint/pull/15297 -
brace-style
https://github.com/eslint/eslint/pull/15322 -
class-methods-use-this
https://github.com/eslint/eslint/pull/15298 -
complexity
https://github.com/eslint/eslint/pull/15328 -
indent
https://github.com/eslint/eslint/pull/15324 -
keyword-spacing
https://github.com/eslint/eslint/pull/15289 -
lines-around-comment
https://github.com/eslint/eslint/pull/15323 -
max-depth
https://github.com/eslint/eslint/pull/15316 -
max-statements
https://github.com/eslint/eslint/pull/15315 -
no-lone-blocks
https://github.com/eslint/eslint/pull/15295 - ~
no-empty
(orno-empty-function
?)~ neither, possibly a new rule. -
no-eval
https://github.com/eslint/eslint/pull/15300 -
no-extra-semi
https://github.com/eslint/eslint/pull/15287 -
no-inner-declarations
https://github.com/eslint/eslint/pull/15290 -
no-invalid-this
https://github.com/eslint/eslint/pull/15300 -
no-redeclare
https://github.com/eslint/eslint/pull/15313 -
no-unused-expressions
https://github.com/eslint/eslint/pull/15283 -
no-use-before-define
https://github.com/eslint/eslint/pull/15312 -
one-var
https://github.com/eslint/eslint/pull/15317 -
padded-blocks
https://github.com/eslint/eslint/pull/15333 -
padding-line-between-statements
https://github.com/eslint/eslint/pull/15318 -
prefer-const
https://github.com/eslint/eslint/pull/15325 -
semi
https://github.com/eslint/eslint/pull/15286 -
semi-style
https://github.com/eslint/eslint/pull/15309 -
strict
https://github.com/eslint/eslint/pull/15314 -
vars-on-top
https://github.com/eslint/eslint/pull/15306
-
Are you willing to submit a pull request to implement this syntax? y
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:12 (12 by maintainers)
Top Results From Across the Web
ES2022 feature: class static initialization blocks - 2ality
The ECMAScript proposal “Class static initialization blocks” by Ron Buckton is at stage 4 and scheduled to be included in ECMAScript 2022.
Read more >Static initialization blocks - JavaScript - MDN Web Docs
Static blocks allow statements to be evaluated during initialization, which allows initializations that (for example) include try...catch or set multiple fields ...
Read more >Class Static Block details - ECMAScript Proposals
Class static blocks provide a mechanism to perform additional static initialization during class definition evaluation. This is not intended as a replacement ...
Read more >ES2022: A Complete Guide on Private Class Fields, Methods ...
Static blocks allow us to address different use cases for class initialization. In the following example, the class D's static block can access ......
Read more >Intent to Ship: Class static initializer blocks - Google Groups
This is a stage 3 proposal in TC39, which is a solid indication of support. Assuming that the answer to the testing question...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This looks like it will need a new scope in
eslint-scope
and a new code path type.All currently-known work to implement class static blocks just shipped in ESLint v8.3.0!