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

Commit

Permalink
Add whitespace rule for ExportDeclaration (fixes #4014) (#4554)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew McCune authored and Josh Goldberg committed Mar 2, 2019
1 parent 30bb50a commit e72d553
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/rules/whitespaceRule.ts
Expand Up @@ -170,6 +170,22 @@ function walk(ctx: Lint.WalkContext<Options>) {
}
break;

case ts.SyntaxKind.ExportDeclaration:
const { exportClause } = node as ts.ExportDeclaration;
if (options.module && exportClause !== undefined) {
exportClause.elements.forEach((element, idx, arr) => {
if (idx === arr.length - 1) {
const token = exportClause.getLastToken()!;
checkForTrailingWhitespace(token.getFullStart());
}
if (idx === 0) {
const startPos = element.getStart() - 1;
checkForTrailingWhitespace(startPos, startPos + 1);
}
});
}
break;

case ts.SyntaxKind.FunctionType:
checkEqualsGreaterThanTokenInNode(node);
break;
Expand Down
6 changes: 5 additions & 1 deletion test/rules/whitespace/all/test.ts.fix
Expand Up @@ -84,9 +84,13 @@ export function each(obj, iterator, context) {
//
}

export {each as forEach};
export { each as forEach };
import "libE";

const E = 123;
const F = 123;
export { E, F };

function foobar() {}

function foorbar()
Expand Down
9 changes: 9 additions & 0 deletions test/rules/whitespace/all/test.ts.lint
Expand Up @@ -144,8 +144,17 @@ export function each(obj, iterator, context) {
}

export {each as forEach};
~ [missing whitespace]
~ [missing whitespace]
import "libE";

const E = 123;
const F = 123;
export {E,F};
~ [missing whitespace]
~ [missing whitespace]
~ [missing whitespace]

function foobar(){}
~ [missing whitespace]

Expand Down

0 comments on commit e72d553

Please sign in to comment.