For the above code, ESLint reports Parsing error: Unexpected token at the optional chaining operator ?.
ESLint rules for optional chaining should work with parserOption: {ecmaVersion: 2020} or higher and which eslint automatically sets because env: {es2021: true} is used in the config above.
However when airbnb-base is used, an explicit parserOption: ecmaVersion: 12 seems to be required to resolve the above issue as such:
Although the fix is simply to explicitly state ecmaVersion it can take a while to figure out that the Parsing error: Unexpected token is because of airbnb-base.
When this issue occors, all other lint errors in the file are not reported which means eslint stops working!
For a better developer experience, this issue could be looked into or documented well.
The above issue occurred with:
Local ESLint version: ^8.7.0
Global ESLint version: ^8.7.0
Node version: v14.17.3
npm version: 6.14.13
Operating System: Linux
The text was updated successfully, but these errors were encountered:
kayomarz commentedJan 17, 2022
•
edited
Issue with
eslint-config-airbnb-baseand optional chaining operator?.(JavaScript)For the above code, ESLint reports
Parsing error: Unexpected tokenat the optional chaining operator?.ESLint rules for optional chaining should work with
parserOption: {ecmaVersion: 2020}or higher and which eslint automatically sets becauseenv: {es2021: true}is used in the config above.However when
airbnb-baseis used, an explicitparserOption: ecmaVersion: 12seems to be required to resolve the above issue as such:(Note: ecmaVersion: 11 should also work)
The error does not occur without airbnb-base as below:
Although the fix is simply to explicitly state
ecmaVersionit can take a while to figure out that theParsing error: Unexpected tokenis because of airbnb-base.When this issue occors, all other lint errors in the file are not reported which means eslint stops working!
For a better developer experience, this issue could be looked into or documented well.
The above issue occurred with:
The text was updated successfully, but these errors were encountered: