Enable ES2015 parsing/globals by default
See original GitHub issuePrevious 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:
- Created 5 years ago
- Reactions:5
- Comments:5 (5 by maintainers)
Top GitHub Comments
Given that most people transpile to ES5 for browsers, I think the default should be the latest
ecmaVersion
, which currently is2019
, or possibly one version before that to have a bit more stability. Stable Node.js is a concern, thought.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.