How do you implement a “raceToSuccess” helper, given a list of promises?

This is a classic example where inverting your logic makes it much clearer. Your “race” in this case is that you want your rejection behavior to in fact be success behavior. function oneSuccess(promises){ return Promise.all(promises.map(p => { // If a request fails, count that as a resolution so it will keep // waiting for other … Read more

ESLint warning ES6 consistent-return rule

http://eslint.org/docs/rules/consistent-return says: This rule requires return statements to either always or never specify values. When your if-condition is not met, the arrow function will terminate without encountering a return statement, which violates this rule. Your second version violates this rule because your second return does not specify a value, contrary to the first return. The … Read more

cannot export const arrow function

You’re trying to export a default and declare a variable at the same time, which is invalid syntax. Consider the following, since we know that you can declare multiple variables using only one instance of the keyword, var a, b, c; the export definition wouldn’t make sense at all. export default var a, b, c; … Read more

Importing node modules from root directory using es6 and babel-node

Like (almost) any tool ‘/x’ means ‘x’ in the root of your filesystem. Babel doesn’t actually look at the paths, it just compiles import {myFunc} from ‘/my-module’; into var _myModule = require(‘/my-module’); And node actually looks up the module. If you really want to import relative to the root of the project, you could use … Read more

Export const arrow function or basic function?

The differences are minuscule. Both declare a variable. A const variable is constant also within your module, while a function declaration theoretically could be overwritten from inside the module An arrow function is a function expression, not a function declaration, and the assignment can lead to problems for circular dependencies An arrow function cannot be … Read more

How can I turn off ESLint’s no-restricted-syntax rule just for ForOfStatement?

Check existing config Based on the current master branch, eslint-config-airbnb currently disables four syntax forms: ForInStatement ForOfStatement LabeledStatement WithStatement You can verify this or see if there are any differences by using ESLint’s –print-config CLI flag: $ eslint –print-config file.js ESLint will print out the config it would use to lint file.js, and you can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)