One-liner to take some properties from object in ES 6

Here’s something slimmer, although it doesn’t avoid repeating the list of fields. It uses “parameter destructuring” to avoid the need for the v parameter. ({id, title}) => ({id, title}) (See a runnable example in this other answer). @EthanBrown’s solution is more general. Here is a more idiomatic version of it which uses Object.assign, and computed … Read more

Is it possible to destructure onto an existing object? (Javascript ES6)

While ugly and a bit repetitive, you can do ({x: oof.x, y: oof.y} = foo); which will read the two values of the foo object, and write them to their respective locations on the oof object. Personally I’d still rather read oof.x = foo.x; oof.y = foo.y; or [‘x’, ‘y’].forEach(prop => oof[prop] = foo[prop]); though.

What’s the difference between prettier-eslint, eslint-plugin-prettier and eslint-config-prettier?

tl;dr: Use eslint-config-prettier, you can ignore the rest. ESLint contains many rules and those that are formatting-related might conflict with Prettier, such as arrow-parens, space-before-function-paren, etc. Hence using them together will cause some issues. The following tools have been created to use ESLint and Prettier together. prettier-eslint eslint-plugin-prettier eslint-config-prettier What it is A JavaScript module … Read more