Skip to content

Commit d4ce499

Browse files
authored
Drop support for legacy node type ClassProperty (#1566)
1 parent 3ef389d commit d4ce499

File tree

5 files changed

+11
-32
lines changed

5 files changed

+11
-32
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"devDependencies": {
5858
"@babel/code-frame": "^7.14.5",
5959
"@babel/core": "^7.15.5",
60-
"@babel/eslint-parser": "^7.15.8",
60+
"@babel/eslint-parser": "^7.16.0",
6161
"@lubien/fixture-beta-package": "^1.0.0-beta.1",
6262
"@typescript-eslint/parser": "^5.2.0",
6363
"ava": "^3.15.0",

rules/custom-error-definition.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,11 @@ const isAssignmentExpression = (node, name) => {
5353
return lhs.property.name === name;
5454
};
5555

56-
const isPropertyDefinition = (node, name) => {
57-
const {type, computed, key} = node;
58-
if (type !== 'PropertyDefinition' && type !== 'ClassProperty') {
59-
return false;
60-
}
61-
62-
if (computed) {
63-
return false;
64-
}
65-
66-
if (key.type !== 'Identifier') {
67-
return false;
68-
}
69-
70-
return key.name === name;
71-
};
56+
const isPropertyDefinition = (node, name) =>
57+
node.type === 'PropertyDefinition'
58+
&& !node.computed
59+
&& node.key.type === 'Identifier'
60+
&& node.key.name === name;
7261

7362
function * customErrorDefinition(context, node) {
7463
if (!hasValidSuperClass(node)) {

rules/no-static-only-class.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ const isDeclarationOfExportDefaultDeclaration = node =>
2222
&& node.parent.type === 'ExportDefaultDeclaration'
2323
&& node.parent.declaration === node;
2424

25-
// https://github.com/estree/estree/blob/master/stage3/class-features.md#propertydefinition
26-
const isPropertyDefinition = node => node.type === 'PropertyDefinition'
27-
// Legacy node type
28-
|| node.type === 'ClassProperty';
25+
const isPropertyDefinition = node => node.type === 'PropertyDefinition';
2926
const isMethodDefinition = node => node.type === 'MethodDefinition';
3027

3128
function isStaticMember(node) {

rules/prevent-abbreviations.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,10 @@ const shouldReportIdentifierAsProperty = identifier => {
292292
}
293293

294294
if (
295-
identifier.parent.type === 'MethodDefinition'
296-
&& identifier.parent.key === identifier
297-
&& !identifier.parent.computed
298-
) {
299-
return true;
300-
}
301-
302-
if (
303-
(identifier.parent.type === 'ClassProperty' || identifier.parent.type === 'PropertyDefinition')
295+
(
296+
identifier.parent.type === 'MethodDefinition'
297+
|| identifier.parent.type === 'PropertyDefinition'
298+
)
304299
&& identifier.parent.key === identifier
305300
&& !identifier.parent.computed
306301
) {

rules/selectors/reference-identifier-selector.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const nonReferenceSelectors = [
1313
'ClassDeclaration > .id',
1414
// `const foo = class Identifier() {}`
1515
'ClassExpression > .id',
16-
// TODO: remove `ClassProperty` when `babel` and `typescript` support `PropertyDefinition`
17-
'ClassProperty[computed!=true] > .key',
1816
// `class Foo {Identifier = 1}`
1917
'PropertyDefinition[computed!=true] > .key',
2018
// `class Foo {Identifier() {}}`

0 commit comments

Comments
 (0)