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

Add whitespace rule for ExportDeclaration #4554

Merged
merged 1 commit into from
Mar 2, 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
16 changes: 16 additions & 0 deletions src/rules/whitespaceRule.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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