Skip to content

Commit

Permalink
Docs: add notice about function keyword in keyword-spacing (#12524)
Browse files Browse the repository at this point in the history
* Docs: add notice about `function` keyword in keyword-spacing

* Docs: publish

Co-Authored-By: Kai Cataldo <7041728+kaicataldo@users.noreply.github.com>
  • Loading branch information
g-plane and kaicataldo committed Nov 5, 2019
1 parent bb556d5 commit 5868550
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions 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:

Expand All @@ -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 the `function` keyword and the following opening 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.
Expand Down

0 comments on commit 5868550

Please sign in to comment.