question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable ES2015 parsing/globals by default

See original GitHub issue

Previous discussion (2 years ago): https://github.com/eslint/eslint/issues/8290

The version of ESLint you are using.

v5.x

The problem you want to solve.

New users are often confused by the fact that ESLint raises parsing errors by default for ES2015 code. This adds friction to the process of creating a config for the first time, and might delay or prevent users from using ESLint at all.

Your take on the correct solution to problem.

When not specified in a config, ESLint should enable the built-in es6 environment.

As a result, the default parser with the default options would allow ES2015 code, and the default set of globals would include ES2015 globals. Users who want to only allow ES5 could use env: { es6: false } to restore the previous behavior.

The current behavior is “noisy by default” – if we’re not sure what behavior the user wants and our default gets things wrong, an ES5 default makes the error manifest as a false positive rather than a false negative. This has some significant advantages – a user is much more likely to notice a false positive than a false negative, allowing them to correct the config error. However, at this point I think most of our users would expect ES6 parsing by default. As a result, I think the advantage of a false positive over a false negative is outweighed by the fact that by making this change, we would be replacing a very large number of false positives with a small number of false negatives. (Using similar reasoning, we recently updated eslint --init to set parserOptions.ecmaVersion to 2018 by default.)

I think the main downside of this proposal is that it would be a silent breaking change for existing users who do just want ES5 parsing. This doesn’t seem like something for which we could emit a deprecation warning, but we could prominently note the change in the migration guide.

Are you willing to submit a pull request to implement this change?

Yes

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
silverwindcommented, Feb 23, 2019

Given that most people transpile to ES5 for browsers, I think the default should be the latest ecmaVersion, which currently is 2019, or possibly one version before that to have a bit more stability. Stable Node.js is a concern, thought.

1reaction
mysticateacommented, Feb 22, 2019

Sounds good to me.

Or, an extreme personal opinion is, we remove the ecmaVersion option and use the latest version always.

If people want to disable newer syntax, they use rules which disallow newer syntax such as eslint-plugin-es. This way has two pros. One is that error messages are more understandable than “Unexpected token”. Another one is that they can catch the violation of static methods.

Read more comments on GitHub >

github_iconTop Results From Across the Web

enable ES2015 default parameters with Babel and JSPM
I'm setting up JSPM / Babel for the first time, and trying out a few ES6 features. It seems only certain features work...
Read more >
How to enable ES6 (and beyond) syntax with Node and Express
js and users.js import express from 'express'; var router = express.Router(); // ..stuff below export default router;.
Read more >
Learn ES2015 - Babel.js
ES2015 classes are syntactic sugar over the prototype-based OO pattern. Having a single convenient declarative form makes class patterns easier to use, ...
Read more >
ES2015 | Web - Google Developers
ES2015 is a fantastic step forward for the JavaScript language. ... Modules in ES6 allow you create classes and export / import classes ......
Read more >
TSConfig Option: esModuleInterop - TypeScript
TSConfig. esModuleInterop. By default (with esModuleInterop false or not set) TypeScript treats CommonJS/AMD/UMD modules similar to ES6 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found