Skip to content
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

Fix: Amend keyword-spacing to validate default keywords #11097

Merged
merged 2 commits into from Dec 3, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/rules/keyword-spacing.js
Expand Up @@ -453,6 +453,10 @@ module.exports = {
checkSpacingBefore(firstToken, PREV_TOKEN_M);
checkSpacingAfter(firstToken, NEXT_TOKEN_M);

if (node.type === "ExportDefaultDeclaration") {
checkSpacingAround(sourceCode.getTokenAfter(firstToken));
}

if (node.source) {
const fromToken = sourceCode.getTokenBefore(node.source);

Expand Down Expand Up @@ -554,7 +558,7 @@ module.exports = {
// Statements - Declarations
ClassDeclaration: checkSpacingForClass,
ExportNamedDeclaration: checkSpacingForModuleDeclaration,
ExportDefaultDeclaration: checkSpacingAroundFirstToken,
ExportDefaultDeclaration: checkSpacingForModuleDeclaration,
ExportAllDeclaration: checkSpacingForModuleDeclaration,
FunctionDeclaration: checkSpacingForFunction,
ImportDeclaration: checkSpacingForModuleDeclaration,
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/keyword-spacing.js
Expand Up @@ -2023,6 +2023,12 @@ ruleTester.run("keyword-spacing", rule, {
parserOptions: { sourceType: "module" },
errors: expectedBefore("export")
},
{
code: "export default{a}",
output: "export default {a}",
parserOptions: { sourceType: "module" },
errors: expectedAfter("default")
},
{
code: "{}export* from \"a\"",
output: "{} export * from \"a\"",
Expand Down