This repository has been archived by the owner on Aug 18, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 208
RFC: Do not set a default ecmaVersion or sourceType #458
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,10 @@ $ npm install [email protected] babel-eslint@6 --save-dev | |
```json | ||
{ | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 8, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"strict": 0 | ||
} | ||
|
@@ -76,19 +80,42 @@ Check out the [ESLint docs](http://eslint.org/docs/rules/) for all possible rule | |
|
||
### Configuration | ||
|
||
`sourceType` can be set to `'module'`(default) or `'script'` if your code isn't using ECMAScript modules. | ||
`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. | ||
- 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 commentThe reason will be displayed to describe this comment to others. Learn more. Also, files will not automatically be in strict mode. |
||
* `allowImportExportEverywhere` (default `false`) 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. | ||
* `allowSuperOutsideMethod` (default `true`) can be set to `false` to disallow use of `super` outside of methods. **Note:** Babel's default is `false`. | ||
* `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. | ||
|
||
**.eslintrc** | ||
#### `.eslintrc` | ||
|
||
**Recommended:** | ||
|
||
```json | ||
{ | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaVersion": 8, | ||
"sourceType": "module" | ||
} | ||
} | ||
``` | ||
|
||
**Defaults:** | ||
|
||
```json | ||
{ | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 5, | ||
"sourceType": "script", | ||
"ecmaFeatures": { | ||
"globalReturn": false, | ||
"impliedStrict": false | ||
}, | ||
"allowImportExportEverywhere": false, | ||
"codeFrame": false | ||
"allowSuperOutsideMethod": true, | ||
"codeFrame": true | ||
} | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?