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

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