Skip to content

Commit

Permalink
docs: add more examples for prefer-object-spread (#15831)
Browse files Browse the repository at this point in the history
* docs: prefer-object-spread: update docs according to tests

* Update docs/src/rules/prefer-object-spread.md
  • Loading branch information
coderaiser committed May 2, 2022
1 parent c2d0a83 commit 810adda
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions docs/src/rules/prefer-object-spread.md
Expand Up @@ -20,17 +20,15 @@ Examples of **incorrect** code for this rule:
```js
/*eslint prefer-object-spread: "error"*/

Object.assign({}, foo)
Object.assign({}, foo);

Object.assign({}, {foo: 'bar'})
Object.assign({}, {foo: 'bar'});

Object.assign({ foo: 'bar'}, baz)
Object.assign({ foo: 'bar'}, baz);

Object.assign({ foo: 'bar' }, Object.assign({ bar: 'foo' }))
Object.assign({}, baz, { foo: 'bar' });

Object.assign({}, { foo, bar, baz })

Object.assign({}, { ...baz })
Object.assign({}, { ...baz });

// Object.assign with a single argument that is an object literal
Object.assign({});
Expand All @@ -43,14 +41,16 @@ Examples of **correct** code for this rule:
```js
/*eslint prefer-object-spread: "error"*/

Object.assign(...foo);
({ ...foo });

({ ...baz, foo: 'bar' });

// Any Object.assign call without an object literal as the first argument
Object.assign(foo, { bar: baz });

Object.assign(foo, Object.assign(bar));
Object.assign(foo, bar);

Object.assign(foo, { bar, baz })
Object.assign(foo, { bar, baz });

Object.assign(foo, { ...baz });
```
Expand Down

0 comments on commit 810adda

Please sign in to comment.