|
1 |
| -# Airbnb JavaScript Style Guide() { |
| 1 | +# Unity JavaScript Style Guide() { |
2 | 2 |
|
3 | 3 | *A mostly reasonable approach to JavaScript*
|
4 | 4 |
|
5 |
| -[](https://www.npmjs.com/package/eslint-config-airbnb) |
6 |
| -[](https://www.npmjs.com/package/eslint-config-airbnb-base) |
7 |
| -[](https://gitter.im/airbnb/javascript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) |
8 |
| - |
9 | 5 | Other Style Guides
|
10 | 6 | - [ES5](es5/)
|
11 |
| - - [React](react/) |
12 |
| - - [CSS & Sass](https://github.com/airbnb/css) |
13 |
| - - [Ruby](https://github.com/airbnb/ruby) |
14 | 7 |
|
15 | 8 | ## Table of Contents
|
16 | 9 |
|
@@ -106,25 +99,6 @@ Other Style Guides
|
106 | 99 | const b = 2;
|
107 | 100 | ```
|
108 | 101 |
|
109 |
| - <a name="references--disallow-var"></a><a name="2.2"></a> |
110 |
| - - [2.2](#references--disallow-var) If you must reassign references, use `let` instead of `var`. eslint: [`no-var`](http://eslint.org/docs/rules/no-var.html) jscs: [`disallowVar`](http://jscs.info/rule/disallowVar) |
111 |
| -
|
112 |
| - > Why? `let` is block-scoped rather than function-scoped like `var`. |
113 |
| -
|
114 |
| - ```javascript |
115 |
| - // bad |
116 |
| - var count = 1; |
117 |
| - if (true) { |
118 |
| - count += 1; |
119 |
| - } |
120 |
| -
|
121 |
| - // good, use the let. |
122 |
| - let count = 1; |
123 |
| - if (true) { |
124 |
| - count += 1; |
125 |
| - } |
126 |
| - ``` |
127 |
| -
|
128 | 102 | <a name="references--block-scope"></a><a name="2.3"></a>
|
129 | 103 | - [2.3](#references--block-scope) Note that both `let` and `const` are block-scoped.
|
130 | 104 |
|
@@ -2195,53 +2169,6 @@ Other Style Guides
|
2195 | 2169 | };
|
2196 | 2170 | ```
|
2197 | 2171 |
|
2198 |
| - <a name="commas--dangling"></a><a name="19.2"></a> |
2199 |
| - - [19.2](#commas--dangling) Additional trailing comma: **Yup.** eslint: [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle.html) jscs: [`requireTrailingComma`](http://jscs.info/rule/requireTrailingComma) |
2200 |
| - |
2201 |
| - > Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don't have to worry about the [trailing comma problem](es5/README.md#commas) in legacy browsers. |
2202 |
| -
|
2203 |
| - ```javascript |
2204 |
| - // bad - git diff without trailing comma |
2205 |
| - const hero = { |
2206 |
| - firstName: 'Florence', |
2207 |
| - - lastName: 'Nightingale' |
2208 |
| - + lastName: 'Nightingale', |
2209 |
| - + inventorOf: ['coxcomb chart', 'modern nursing'] |
2210 |
| - }; |
2211 |
| -
|
2212 |
| - // good - git diff with trailing comma |
2213 |
| - const hero = { |
2214 |
| - firstName: 'Florence', |
2215 |
| - lastName: 'Nightingale', |
2216 |
| - + inventorOf: ['coxcomb chart', 'modern nursing'], |
2217 |
| - }; |
2218 |
| -
|
2219 |
| - // bad |
2220 |
| - const hero = { |
2221 |
| - firstName: 'Dana', |
2222 |
| - lastName: 'Scully' |
2223 |
| - }; |
2224 |
| -
|
2225 |
| - const heroes = [ |
2226 |
| - 'Batman', |
2227 |
| - 'Superman' |
2228 |
| - ]; |
2229 |
| -
|
2230 |
| - // good |
2231 |
| - const hero = { |
2232 |
| - firstName: 'Dana', |
2233 |
| - lastName: 'Scully', |
2234 |
| - }; |
2235 |
| -
|
2236 |
| - const heroes = [ |
2237 |
| - 'Batman', |
2238 |
| - 'Superman', |
2239 |
| - ]; |
2240 |
| - ``` |
2241 |
| -
|
2242 |
| -**[⬆ back to top](#table-of-contents)** |
2243 |
| -
|
2244 |
| -
|
2245 | 2172 | ## Semicolons
|
2246 | 2173 |
|
2247 | 2174 | <a name="semicolons--required"></a><a name="20.1"></a>
|
|
0 commit comments