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, 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\"",