Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

270
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda