Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

one-line: bugfix for multiline type parameters #3004

Merged
merged 1 commit into from
Aug 2, 2017
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
11 changes: 2 additions & 9 deletions src/rules/oneLineRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

import { getPreviousToken } from "tsutils";
import * as ts from "typescript";

import * as Lint from "../index";
Expand Down Expand Up @@ -262,16 +263,8 @@ class OneLineWalker extends Lint.RuleWalker {
}

private handleClassLikeDeclaration(node: ts.ClassDeclaration | ts.InterfaceDeclaration) {
let lastNodeOfDeclaration: ts.Node | undefined = node.name;
const openBraceToken = Lint.childOfKind(node, ts.SyntaxKind.OpenBraceToken)!;

if (node.heritageClauses != null) {
lastNodeOfDeclaration = node.heritageClauses[node.heritageClauses.length - 1];
} else if (node.typeParameters != null) {
lastNodeOfDeclaration = node.typeParameters[node.typeParameters.length - 1];
}

this.handleOpeningBrace(lastNodeOfDeclaration, openBraceToken);
this.handleOpeningBrace(getPreviousToken(openBraceToken), openBraceToken);
}

private handleIterationStatement(node: ts.IterationStatement) {
Expand Down
8 changes: 8 additions & 0 deletions test/rules/one-line/all/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,11 @@ if (true)
true;
else
false;

class Foo<
Bar,
Baz,
Bas
> {
// works for multiline type parameters
}