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

276
Visualizações
Unexpected token => on async using Firebase Functions (2022) default ESlint

My package.json

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "index.js",
  "dependencies": {
    "axios": "^0.27.2",
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^3.21.2"
  },
  "devDependencies": {
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "firebase-functions-test": "^0.2.0"
  },
  "private": true
}

My .eslintrc.js

module.exports = {
  root: true,
  env: {
    es6: true,
    node: true,
  },
  extends: [
    "eslint:recommended",
    "google",
  ],
  rules: {
    quotes: ["error", "double"],
  },
};

A scrubbed version of my index.js

const admin = require('firebase-admin')
admin.initializeApp()

exports.sendMessage = functions.https.onCall(async (input) => {
    // my code here
})

Error from terminal

error  Parsing error: Unexpected token =>

✖ 1 problem (1 error, 0 warnings)


Error: functions predeploy error: Command terminated with non-zero exit code1

I'm thinking that the ESLint version that is being applied may be out of date? If so, how do I update it? Do I need to use a babel-eslint package (or newer)? Do I need to apply ES7 or 8 rules instead, and how?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You've only enabled es6: true. However, async functions are part of ES8 (ES2017). You'll want to use something more modern than ES6. Alternatively, set the parser options specifically.

about 4 years ago · Juan Pablo Isaza Relatório

0

I updated my .eslintrc.js file

module.exports = {
  root: true,
  parserOptions: {
    ecmaVersion: "latest",
  },
  env: {
    node: true,
  },
  extends: [
    "eslint:recommended",
    "google",
  ],
  rules: {
    quotes: ["error", "double"],
  },
};

This way, es6 was removed as a true value in env, and parserOptions was added with ecmaVersion set to latest release. I then just applied the rules based on the failed items. It works, but was a bit of a hassle. I suppose the code is cleaner at least...

about 4 years ago · Juan Pablo Isaza 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