简体   繁体   English

由于 Eslint 错误,Vue Js 未部署到 Firebase

[英]Vue Js not deploying to Firebase because of Eslint Error

I am getting this error for the past hours and i have not been able to resolve it.我在过去几个小时内收到此错误,但无法解决。 I have tried all the solutions online including uninstalling aslant globally and in the project and installing it again.我已经尝试了所有在线解决方案,包括在全局和项目中卸载 aslant 并再次安装。 Unfortunately the most common answer does not really apply in my case since my package.json file does not really have that file structure.不幸的是,最常见的答案并不真正适用于我的情况,因为我的 package.json 文件并没有真正的文件结构。

Running command: npm --prefix "$RESOURCE_DIR" run lint

> lint
> eslint .


/Users/KingdomMac/Downloads/ermnl-dashboard-master/functions/index.js
  22:71  error  Parsing error: Unexpected token =>

✖ 1 problem (1 error, 0 warnings)


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

My package.json file我的 package.json 文件

{
  "name": "vue-white-dashboard",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.35",
    "@fortawesome/free-brands-svg-icons": "^5.15.3",
    "@fortawesome/free-regular-svg-icons": "^5.15.3",
    "@fortawesome/free-solid-svg-icons": "^5.15.3",
    "@fortawesome/vue-fontawesome": "^2.0.2",
    "axios": "^0.21.1",
    "chart.js": "^2.8.0",
    "core-js": "^2.6.5",
    "firebase": "^8.6.8",
    "node-sass": "^4.9.0",
    "vue": "^2.6.10",
    "vue-chartjs": "^3.4.2",
    "vue-click-outside": "^1.0.7",
    "vue-clickaway": "^2.2.2",
    "vue-github-buttons": "^3.1.0",
    "vue-i18n": "^8.14.1",
    "vue-router": "^3.0.3",
    "vue-social-sharing": "^2.4.6",
    "vue2-transitions": "^0.3.0",
    "vuetify": "^2.4.0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.11.0",
    "@vue/cli-plugin-eslint": "^3.1.1",
    "@vue/cli-service": "^3.5.3",
    "@vue/eslint-config-prettier": "^5.0.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^8.1.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-vue": "^7.20.0",
    "prettier": "^1.18.2",
    "sass": "~1.32",
    "sass-loader": "^10.0.0",
    "vue-cli-plugin-vuetify": "~2.4.1",
    "vue-template-compiler": "^2.6.10",
    "vuetify-loader": "^1.7.0"
  }
}

Also my .eslintrc.js file还有我的 .eslintrc.js 文件

module.exports = {
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": "plugin:vue/essential",
    "parserOptions": {
        "ecmaVersion": 13
    },
    "plugins": [
        "vue"
    ],
    "rules": {
    }
};

And my index.js file还有我的 index.js 文件

const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
const db = admin.firestore();

// exports.addAdminRole = functions.https.onCall((data, context) => {
//   // Get user and add custom claim (admin)
//   const customClaims = {
//     admin: true,
//   };
//   return admin.auth().getUserByEmail(data.email).then((user) => {
//     return admin.auth().setCustomUserClaims(user.uid, customClaims);
//   }).then((authUser) => {
//     return {
//       message: `Success! ${data.email} has been made an admin.`,
//     };
//   }).catch((error) => {
//     return error;
//   });
// });

exports.addUserRole = functions.auth.user().onCreate(async (authUser) => {
  if (authUser.email) {
    const customClaims = {
      admin: true,
    };
    try {
      let _ = await admin.auth().setCustomUserClaims(authUser.uid, customClaims);
      return db.collection("roles").doc(authUser.uid).set({
        email: authUser.email,
        role: customClaims,
      });
    } catch (error) {
      console.log(error);
    }
  }
});

exports.setUserRole = functions.https.onCall(async (data, context) => {
  if (!context.auth.token.admin) return
  try {
    let _ = await admin.auth().setCustomUserClaims(data.uid, data.role)
    return db.collection("roles").doc(data.uid).update({
      role: data.role
    })
  } catch (error) {
    console.log(error)
  }
});


try changing "lint": "eslint ."尝试更改"lint": "eslint ." to "lint": "eslint ", in your package.json"lint": "eslint ",在你的 package.json 中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM