[guide] Add backticks

This commit is contained in:
ParkSB
2018-05-05 03:04:38 +09:00
committed by Jordan Harband
parent 2bd77bc1e0
commit 2ba36de952

View File

@@ -370,7 +370,7 @@ Other Style Guides
```
<a name="arrays--from"></a><a name="4.4"></a>
- [4.4](#arrays--from) To convert an array-like object to an array, use spreads `...` instead of [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from).
- [4.4](#arrays--from) To convert an array-like object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from).
```javascript
const foo = document.querySelectorAll('.foo');
@@ -786,7 +786,7 @@ Other Style Guides
<a name="functions--constructor"></a><a name="7.10"></a>
- [7.10](#functions--constructor) Never use the Function constructor to create a new function. eslint: [`no-new-func`](https://eslint.org/docs/rules/no-new-func)
> Why? Creating a function in this way evaluates a string similarly to eval(), which opens vulnerabilities.
> Why? Creating a function in this way evaluates a string similarly to `eval()`, which opens vulnerabilities.
```javascript
// bad
@@ -1167,7 +1167,7 @@ Other Style Guides
```
<a name="constructors--tostring"></a><a name="9.4"></a>
- [9.4](#constructors--tostring) Its okay to write a custom toString() method, just make sure it works successfully and causes no side effects.
- [9.4](#constructors--tostring) Its okay to write a custom `toString()` method, just make sure it works successfully and causes no side effects.
```javascript
class Jedi {
@@ -1687,7 +1687,7 @@ Other Style Guides
```
<a name="variables--unary-increment-decrement"></a><a name="13.6"></a>
- [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus)
- [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (`++`, `--`). eslint [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus)
> Why? Per the eslint documentation, unary increment and decrement statements are subject to automatic semicolon insertion and can cause silent errors with incrementing or decrementing values within an application. It is also more expressive to mutate your values with statements like `num += 1` instead of `num++` or `num ++`. Disallowing unary increment and decrement statements also prevents you from pre-incrementing/pre-decrementing values unintentionally which can also cause unexpected behavior in your programs.
@@ -3295,7 +3295,7 @@ Other Style Guides
- [24.1](#accessors--not-required) Accessor functions for properties are not required.
<a name="accessors--no-getters-setters"></a><a name="23.2"></a>
- [24.2](#accessors--no-getters-setters) Do not use JavaScript getters/setters as they cause unexpected side effects and are harder to test, maintain, and reason about. Instead, if you do make accessor functions, use getVal() and setVal('hello').
- [24.2](#accessors--no-getters-setters) Do not use JavaScript getters/setters as they cause unexpected side effects and are harder to test, maintain, and reason about. Instead, if you do make accessor functions, use `getVal()` and `setVal('hello')`.
```javascript
// bad
@@ -3337,7 +3337,7 @@ Other Style Guides
```
<a name="accessors--consistent"></a><a name="23.4"></a>
- [24.4](#accessors--consistent) Its okay to create get() and set() functions, but be consistent.
- [24.4](#accessors--consistent) Its okay to create `get()` and `set()` functions, but be consistent.
```javascript
class Jedi {