Skip to content

feat: update abstract class node #75

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

Merged
merged 1 commit into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ module.exports = {
switch (decl.type) {
case 'ClassDeclaration':
case 'ClassExpression':
friendlyName = 'Class';
break;
case 'TSAbstractClassDeclaration':
friendlyName = 'Abstract class';
friendlyName = decl.abstract ? 'Abstract class' : 'Class';
break;
case 'TSInterfaceDeclaration':
friendlyName = 'Interface';
Expand All @@ -81,9 +78,7 @@ module.exports = {
//----------------------------------------------------------------------

return {
'ClassDeclaration, TSInterfaceDeclaration, TSAbstractClassDeclaration, ClassExpression'(
node
) {
'ClassDeclaration, TSInterfaceDeclaration, ClassExpression'(node) {
// class expressions (i.e. export default class {}) are OK
if (node.id && !isPascalCase(node.id.name)) {
report(node);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin-typescript/lib/rules/indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const KNOWN_NODES = new Set([
'TSNullKeyword',

// ts specific nodes we want to support
'TSAbstractClassDeclaration',
'TSAbstractClassProperty',
'TSAbstractMethodDefinition',
'TSArrayType',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ ruleTester.run('no-shadow', rule, {
`
type foo = any;
function bar(foo: any) {}
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/20
`
export abstract class Foo {}
export class FooBar extends Foo {}
`
],
invalid: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ interface Runnable {
export type SomeThing = {
id: string;
}
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/20
`
export abstract class Foo {}
export class FooBar extends Foo {}
`
],
invalid: []
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin-typescript/tests/lib/rules/indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function nonTsTestCase(example) {

const individualNodeTests = [
{
node: 'TSAbstractClassDeclaration',
node: 'ClassDeclaration',
code: [
`
abstract class Foo {
Expand Down Expand Up @@ -157,7 +157,7 @@ interface Foo {
]
},
{
node: 'TSEmptyBodyDeclareFunction',
node: 'TSDeclareFunction',
code: [
`
declare function foo() : {
Expand Down
5 changes: 1 addition & 4 deletions packages/typescript-eslint-parser/src/analyze-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class Referencer extends OriginalReferencer {
/**
* Override.
* Visit decorators.
* @param {ClassDeclaration|ClassExpression|TSAbstractClassDeclaration} node The class node to visit.
* @param {ClassDeclaration|ClassExpression} node The class node to visit.
* @returns {void}
*/
visitClass(node: any) {
Expand Down Expand Up @@ -709,9 +709,6 @@ class Referencer extends OriginalReferencer {
this.close(node);
}

TSAbstractClassDeclaration(node: any) {
this.ClassDeclaration(node);
}
TSAbstractClassProperty(node: any) {
this.ClassProperty(node);
}
Expand Down
9 changes: 0 additions & 9 deletions packages/typescript-eslint-parser/src/visitor-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ export const visitorKeys = eslintVisitorKeys.unionWith({
ClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
Decorator: ['expression'],
TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
TSAbstractClassDeclaration: [
'decorators',
'id',
'typeParameters',
'superClass',
'superTypeParameters',
'implements',
'body'
],
TSAbstractKeyword: [],
TSAbstractMethodDefinition: ['key', 'value'],
TSAnyKeyword: [],
Expand Down
Loading