Skip to content

Commit

Permalink
Don't check space after import-ed type. Fixes palantir#3987 (palantir…
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobirukov authored and Josh Goldberg committed Nov 7, 2018
1 parent 78f7bc2 commit 1012e56
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/rules/whitespaceRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,14 @@ function walk(ctx: Lint.WalkContext<Options>) {
break;
case ts.SyntaxKind.ImportKeyword:
if (
parent.kind === ts.SyntaxKind.CallExpression &&
(parent as ts.CallExpression).expression.kind === ts.SyntaxKind.ImportKeyword
utils.isCallExpression(parent) &&
parent.expression.kind === ts.SyntaxKind.ImportKeyword
) {
return; // Don't check ImportCall
}
if (utils.isImportTypeNode(parent)) {
return; // Don't check TypeQuery
}
// falls through
case ts.SyntaxKind.ExportKeyword:
case ts.SyntaxKind.FromKeyword:
Expand Down
32 changes: 32 additions & 0 deletions test/rules/whitespace/all/import-type.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[typescript]: >=2.9.0

const foo: import("bar");
const foo: import ("bar");

function foo(a: import("bar")): import("baz") {}
function foo(a: import ("bar")): import ("baz") {}

const foo = (a: import("bar")): import("baz") => {};
const foo = (a: import ("bar")): import ("baz") => {};

type foo = { bar: import("baz") } & import("qux");
type foo = { bar: import ("baz") } & import ("qux");

interface Foo {
bar: import("baz");
qux: import ("quux");
}

class Foo {
bar: import("baz");
qux: import ("quux");
}

/**
* @param bar { import("qux") }
* @param baz { import ("qux") }
*/
function foo(bar, baz) { }

type foo = Bar<import("baz")>;
type foo = Bar<import ("baz")>;

0 comments on commit 1012e56

Please sign in to comment.