From 1c0425445f6cc0f0fc5f153884ae8f58fddd4e47 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sun, 3 Nov 2019 15:55:12 +0800 Subject: [PATCH 1/2] Docs: add notice about `function` keyword in keyword-spacing --- docs/rules/keyword-spacing.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/rules/keyword-spacing.md b/docs/rules/keyword-spacing.md index becc9ef323a..b282e88805b 100644 --- a/docs/rules/keyword-spacing.md +++ b/docs/rules/keyword-spacing.md @@ -1,7 +1,7 @@ # enforce consistent spacing before and after keywords (keyword-spacing) -Keywords are syntax elements of JavaScript, such as `function` and `if`. -These identifiers have special meaning to the language and so often appear in a different color in code editors. +Keywords are syntax elements of JavaScript, such as `try` and `if`. +These keywords have special meaning to the language and so often appear in a different color in code editors. As an important part of the language, style guides often refer to the spacing that should be used around keywords. For example, you might have a style guide that says keywords should be always surrounded by spaces, which would mean `if-else` statements must look like this: @@ -15,6 +15,8 @@ if (foo) { Of course, you could also have a style guide that disallows spaces around keywords. +However, if you want to enforce the style of spacing between `function` keyword and parenthesis, please refer to [space-before-function-paren](space-before-function-paren.md). + ## Rule Details This rule enforces consistent spacing around keywords and keyword-like tokens: `as` (in module declarations), `async` (of async functions), `await` (of await expressions), `break`, `case`, `catch`, `class`, `const`, `continue`, `debugger`, `default`, `delete`, `do`, `else`, `export`, `extends`, `finally`, `for`, `from` (in module declarations), `function`, `get` (of getters), `if`, `import`, `in`, `instanceof`, `let`, `new`, `of` (in for-of statements), `return`, `set` (of setters), `static`, `super`, `switch`, `this`, `throw`, `try`, `typeof`, `var`, `void`, `while`, `with`, and `yield`. This rule is designed carefully not to conflict with other spacing rules: it does not apply to spacing where other rules report problems. From a095fa1f49a513a80486eb2e1578b0b100280c06 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Tue, 5 Nov 2019 07:49:18 +0800 Subject: [PATCH 2/2] Docs: publish Co-Authored-By: Kai Cataldo <7041728+kaicataldo@users.noreply.github.com> --- docs/rules/keyword-spacing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/keyword-spacing.md b/docs/rules/keyword-spacing.md index b282e88805b..ecc6bb0a49a 100644 --- a/docs/rules/keyword-spacing.md +++ b/docs/rules/keyword-spacing.md @@ -15,7 +15,7 @@ if (foo) { Of course, you could also have a style guide that disallows spaces around keywords. -However, if you want to enforce the style of spacing between `function` keyword and parenthesis, please refer to [space-before-function-paren](space-before-function-paren.md). +However, if you want to enforce the style of spacing between the `function` keyword and the following opening parenthesis, please refer to [space-before-function-paren](space-before-function-paren.md). ## Rule Details