[eslint config] [*] [new] set ecmaVersion to 2017; enable object rest/spread; update babel-preset-airbnb

This commit is contained in:
Jordan Harband
2016-09-21 17:17:27 -07:00
parent e5f4eb57b4
commit e8b51b2785
8 changed files with 37 additions and 9 deletions

View File

@@ -293,6 +293,26 @@ Other Style Guides
console.log(has.call(object, key));
```
<a name="objects--rest-spread"></a>
- [3.10](#objects--rest-spread) Prefer the object spread operator over `Object.assign` to shallow-copy objects. Use the object rest operator to get a new object with certain properties omitted.
```javascript
// very bad
const original = { a: 1, b: 2 };
const copy = Object.assign(original, { c: 3 }); // this mutates `original` ಠ_ಠ
delete copy.a; // so does this
// bad
const original = { a: 1, b: 2 };
const copy = Object.assign({}, original, { c: 3 }); // copy => { a: 1, b: 2, c: 3 }
// good
const original = { a: 1, b: 2 };
const copy = { ...original, c: 3 }; // copy => { a: 1, b: 2, c: 3 }
const { a, ...noA } = copy; // noA => { b: 2, c: 3 }
```
**[⬆ back to top](#table-of-contents)**
## Arrays