False negatives with sourceType: module and ecmaVersion <= 5
See original GitHub issueTell us about your environment
- ESLint Version: v4.12.1
- Node Version: 8.4.0
- npm Version: 5.3.0
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
module.exports = {
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 5,
}
}
Running against this file, ecmaVersion is ignored (could also be ‘3’):
// es6.js
const x = () => `hi`;
What did you expect to happen?
Either, I would see an error like the below, rejecting an unsupported config:
> eslint -c withoutModule.config.js es6.js
Incompatible config: sourceType: module cannot be used with ecmaVersion <= 5
or the (admittedly niche*) use-case of ES6 modules with ES5 syntax would be supported, and I’d see errors:
> eslint -c withoutModule.config.js es6.js
es6.js
1:1 error Parsing error: The keyword 'const' is reserved
✖ 1 problem (1 error, 0 warnings)
which I get correctly with this config:
// withoutModule.config.js
module.exports = {
"parserOptions": {
"ecmaVersion": 5,
}
}
*niche: I was using rollup with some old ES5 code, and only wanted to modify the code to add imports. I tried the above, and thought “cool, it’s working”, but actually it was silently ignoring the ecmaVersion.
What actually happened? Please include the actual, raw output from ESLint.
No errors are reported:
> eslint es6.js
> echo $?
0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:15 (9 by maintainers)
Using WebPack it’s possible to use ES6 modules without “really” using them in the output, so checking againt ES5 (or even ES3) would make sense.
It might be a good idea to do a major (pre)release of espree and update to that version in ESLint before we close this.