Skip to content

Commit 5892746

Browse files
authored
Update @typescript-eslint/parser to v5 (#1555)
1 parent 2b1183c commit 5892746

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@babel/core": "^7.15.5",
6060
"@babel/eslint-parser": "^7.15.8",
6161
"@lubien/fixture-beta-package": "^1.0.0-beta.1",
62-
"@typescript-eslint/parser": "^4.32.0",
62+
"@typescript-eslint/parser": "^5.2.0",
6363
"ava": "^3.15.0",
6464
"chalk": "^4.1.2",
6565
"enquirer": "2.3.6",

rules/no-static-only-class.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function isStaticMember(node) {
4444
return false;
4545
}
4646

47-
if (!isStatic || isPrivate) {
47+
if (!isStatic || isPrivate || key.type === 'PrivateIdentifier') {
4848
return false;
4949
}
5050

@@ -54,6 +54,7 @@ function isStaticMember(node) {
5454
|| isReadonly
5555
|| typeof accessibility !== 'undefined'
5656
|| (Array.isArray(decorators) && decorators.length > 0)
57+
// TODO: Remove this when we drop support for `@typescript-eslint/parser` v4
5758
|| key.type === 'TSPrivateIdentifier'
5859
) {
5960
return false;

test/no-static-only-class.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ test.snapshot({
1616
'class A { constructor() {} }',
1717
'class A { get a() {} }',
1818
'class A { set a(value) {} }',
19+
// `private`
20+
'class A3 { static #a() {}; }',
21+
'class A3 { static #a = 1; }',
22+
'const A3 = class { static #a() {}; }',
23+
'const A3 = class { static #a = 1; }',
1924
// TODO: enable this test when ESLint support `StaticBlock`
2025
// Static block
2126
// 'class A2 { static {}; }',
@@ -216,6 +221,11 @@ test.babel({
216221
},
217222
},
218223
valid: [
224+
// `private`
225+
'class A2 { static #a() {}; }',
226+
'class A2 { static #a = 1; }',
227+
'const A2 = class { static #a() {}; }',
228+
'const A2 = class { static #a = 1; }',
219229
// Static block
220230
'class A2 { static {}; }',
221231
],

0 commit comments

Comments
 (0)