Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5868550

Browse filesBrowse files
g-planekaicataldo
andcommitted
Docs: add notice about function keyword in keyword-spacing (#12524)
* Docs: add notice about `function` keyword in keyword-spacing * Docs: publish Co-Authored-By: Kai Cataldo <7041728+kaicataldo@users.noreply.github.com>
1 parent bb556d5 commit 5868550
Copy full SHA for 5868550

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Collapse file

‎docs/rules/keyword-spacing.md‎

Copy file name to clipboardExpand all lines: docs/rules/keyword-spacing.md
+4-2Lines changed: 4 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# enforce consistent spacing before and after keywords (keyword-spacing)
22

3-
Keywords are syntax elements of JavaScript, such as `function` and `if`.
4-
These identifiers have special meaning to the language and so often appear in a different color in code editors.
3+
Keywords are syntax elements of JavaScript, such as `try` and `if`.
4+
These keywords have special meaning to the language and so often appear in a different color in code editors.
55
As an important part of the language, style guides often refer to the spacing that should be used around keywords.
66
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:
77

@@ -15,6 +15,8 @@ if (foo) {
1515

1616
Of course, you could also have a style guide that disallows spaces around keywords.
1717

18+
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).
19+
1820
## Rule Details
1921

2022
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.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.