I'm using eslint in order to check valid JavaScript in a React project. However, I encountered an issue when I use --rule 'strict: 0' and --parser=babel-eslint in the same time. By example:
eslint --no-eslintrc file.js
Displays no output because it doesn't find error.
eslint --no-eslintrc --parser=babel-eslint file.js
Displays this error:
file.js
1:1 error Parsing error: Octal literal in strict mode
> 39 | language.french.value = ' caract\350res';
I tried to disable strict mode with --rule 'strict: 0' but it fails. I get still the precedent error.
Do you know a way to disable strict mode by using babel-parser ?
I've just run into the same issue, finally found an answer on github.
You can turn off the global strict mode by changing the sourceType
to script
within your .eslintrc file:
{
...
parser: 'babel-eslint',
parserOptions: {
sourceType: 'script'
}
...
}
Or, if you want to set this through the cli then simply:
eslint --no-eslintrc --parser=babel-eslint --parser-options=sourceType:script file.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With