-
-
Notifications
You must be signed in to change notification settings - Fork 208
RFC: Do not set a default ecmaVersion or sourceType #458
Conversation
I guess we should do this to keep consistent behavior in ESLint, would be breaking but we are doing a v7 atm. |
`allowImportExportEverywhere` can be set to true to allow import and export declarations to appear anywhere a statement is allowed if your build environment supports that. By default, import and export declarations can only appear at a program's top level. | ||
`codeFrame` can be set to false to disable the code frame in the reporter. This is useful since some eslint formatters don't play well with it. | ||
* `sourceType`, `ecmaVersion`, `ecmaFeatures.globalReturn` and `ecmaFeatures.impliedStrict` should be set in accordance with http://eslint.org/docs/user-guide/configuring#specifying-parser-options. | ||
- `ecmaVersion` is disregarded by `babel-eslint`, however, some ESlint rules depend on this value being set correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would it take to make the first part not true?
`codeFrame` can be set to false to disable the code frame in the reporter. This is useful since some eslint formatters don't play well with it. | ||
* `sourceType`, `ecmaVersion`, `ecmaFeatures.globalReturn` and `ecmaFeatures.impliedStrict` should be set in accordance with http://eslint.org/docs/user-guide/configuring#specifying-parser-options. | ||
- `ecmaVersion` is disregarded by `babel-eslint`, however, some ESlint rules depend on this value being set correctly. | ||
- If `sourceType` is not set to `"module"`, then using `import`/`export` will error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, files will not automatically be in strict mode.
I guess the reason we had the defaults earlier though is that babylon automatically parses what is spec so the ecmaversion should at least be es2017 atm? and we assume modules normally |
Unless I'm missing something, seems to me we shouldn't remove the defaults. I agree with @hzoo - I think default for "parserOptions": {
"ecmaVersion": 2017
}, Edit: Change |
Please let's make sure documentation uses year, not edition number - it was ES6/ES2015, but nobody calls it ES8 - it's ES2017. |
Related to this: I created this ticket eslint/eslint#8744 which is the opposite to this PR. :) |
@zertosh Is this still something you'd like to advocate for? |
@kaicataldo, I'd love to, but I just don't have time these days :( |
Okay! Will close this, but happy to have this discussion again in the future! |
This is a super breaking change, but it ensures correctness in ESLint's rules, and eliminates surprises.
Before this change,
babel-eslint
set defaults forsourceType
andecmaVersion
that it applied to Babylon and escope. However, these values could not propagate to the ESLint rules themselves or ESLint APIs. This resulted in incorrect behavior by certain rules. Consider these examples:Making things even more surprising is the fact that setting
env: es6
sets theecmaVersion
to6
but doesn't changesourceType
(https://github.com/eslint/eslint/blob/6a718ba/conf/environments.js#L98-L103).