Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

476
Visualizações
eslint - Optional chaining error with vscode

I am seeing a a red underline when I'm using an optional chain, but the code runs fine as I am on node 14

Here's my setup:

node 14.1.0
eslint "^6.8.0"

.eslintrc.js

module.exports = {
    "env": {
        "node": true
    },
    "extends": [
        "eslint:recommended",
    ],
    "parserOptions": {
        "sourceType": "module",
        "ecmaVersion": 2020
    },
    "rules": {
    },
}

enter image description here

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You no longer need @babel/eslint-parser as eslint@^7.5 now supports optional chanining.

Run the following to update eslint within your project:

npm

npm install --save-dev eslint@^7.5

yarn

yarn add -D eslint@^7.5

And then, ensure your config is as follows:

.eslintrc

{
  "parserOptions": {
    "ecmaVersion": 2020
  }
}

.eslint.js

module.exports = {
    "parserOptions": {
        "ecmaVersion": 2020
    }
}

See https://eslint.org/blog/2020/07/eslint-v7.5.0-released#optional-chaining-support for more information.

over 4 years ago · Santiago Trujillo Relatório

0

You must use @babel/eslint-parser (previously called babel-eslint ) with your eslint configuration. This allows you to literate ALL valid Babel code with eslint. eslint supports all ES2020 features as of version v7.2.0

 $ npm install @babel/eslint-parser --save-dev # or $ yarn add @babel/eslint-parser -D

Then in your .eslintrc do:

 { parser: "@babel/eslint-parser", }
over 4 years ago · Santiago Trujillo Relatório

0

First, you should have a ESLint parser that supports the optional chaining:

npm install -D @babel/eslint-parser

If you're facing issues with peer dependencies then run by appending --legacy-peer-deps to the command.

Then, you should have the ESLint version that supports the optional chaining. This is that release version(7.5.0):

npm install eslint@^7.5

Tell your ESLint server to use the above-installed parser:

{
  "parserOptions": {
    "ecmaVersion": 2020
  }
  ...
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda