Skip to content

Commit

Permalink
Docs: change when not to use object spread (#10621)
Browse files Browse the repository at this point in the history
Object spread is not just syntax sugar. It actually performs better in browsers. The "When Not To Use It" section should therefore give a more nuanced opinion on when Object.assign is desireable.
  • Loading branch information
bennypowers authored and platinumazure committed Jul 28, 2018
1 parent 7f496e2 commit 8084bfc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/rules/prefer-object-spread.md
Expand Up @@ -2,6 +2,8 @@

When Object.assign is called using an object literal as the first argument, this rule requires using the object spread syntax instead. This rule also warns on cases where an `Object.assign` call is made using a single argument that is an object literal, in this case, the `Object.assign` call is not needed.

Object spread is a declarative alternative which may perform better than the more dynamic, imperative `Object.assign`.

## Rule Details

Examples of **incorrect** code for this rule:
Expand Down Expand Up @@ -44,4 +46,4 @@ Object.assign(foo, { ...baz });

## When Not To Use It

When you don't care about syntactic sugar added by the object spread property.
When object spread is not available in your codebase.

0 comments on commit 8084bfc

Please sign in to comment.