From 0aa913cf6eee20c9718e7022c61ff7814c167ee0 Mon Sep 17 00:00:00 2001 From: Bin Ury <1146921+teddy-error@users.noreply.github.com> Date: Sat, 17 Nov 2018 15:40:35 -0600 Subject: [PATCH 1/2] Fix: Amend keyword-spacing to validate `default` keywords --- lib/rules/keyword-spacing.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rules/keyword-spacing.js b/lib/rules/keyword-spacing.js index 66ce2cb34c0..790d7b031d8 100644 --- a/lib/rules/keyword-spacing.js +++ b/lib/rules/keyword-spacing.js @@ -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); @@ -554,7 +558,7 @@ module.exports = { // Statements - Declarations ClassDeclaration: checkSpacingForClass, ExportNamedDeclaration: checkSpacingForModuleDeclaration, - ExportDefaultDeclaration: checkSpacingAroundFirstToken, + ExportDefaultDeclaration: checkSpacingForModuleDeclaration, ExportAllDeclaration: checkSpacingForModuleDeclaration, FunctionDeclaration: checkSpacingForFunction, ImportDeclaration: checkSpacingForModuleDeclaration, From 29a3fd1abc0ee78da3de47fb28f3a50a64812a6e Mon Sep 17 00:00:00 2001 From: Bin Ury <1146921+teddy-error@users.noreply.github.com> Date: Sun, 2 Dec 2018 17:29:48 -0600 Subject: [PATCH 2/2] Chore: Add keyword-spacing test for `default` keyword --- tests/lib/rules/keyword-spacing.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/lib/rules/keyword-spacing.js b/tests/lib/rules/keyword-spacing.js index 33a9d50683e..cebd163673e 100644 --- a/tests/lib/rules/keyword-spacing.js +++ b/tests/lib/rules/keyword-spacing.js @@ -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\"",