Skip to content

Commit

Permalink
Update: Amend keyword-spacing to validate default keywords (#11097)
Browse files Browse the repository at this point in the history
* Fix: Amend keyword-spacing to validate `default` keywords

* Chore: Add keyword-spacing test for `default` keyword
  • Loading branch information
binury authored and platinumazure committed Dec 3, 2018
1 parent 4bcdfd0 commit 62fd2b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 62fd2b9

Please sign in to comment.