Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
473 views
in Technique[技术] by (71.8m points)

firebase - how to configure my eslintrc in cloud function typescript project?

I am trying to use typescript cloud function and use ESlint in it, but I want to make unused variable as a warning only, not marked as an error. I am confused how to configure it in my cloud function project, it always error like this in my .eslintrc , please help

enter image description here

enter image description here

here is my .eslintrc configuration

module.exports = {
  root: true,
  env: {
    es6: true,
    node: true,
  },
  extends: [
    "eslint:recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:import/typescript",
    "google",
  ],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: ["tsconfig.json", "tsconfig.dev.json"],
    sourceType: "module",
  },
  ignorePatterns: [
    "/lib/**/*", // Ignore built files.
  ],
  plugins: [
    "@typescript-eslint",
    "import",
  ],
  rules: {
    quotes: ["error", "double"],
    no-unused-vars: ["warn"] <---- this one
  },
};
question from:https://stackoverflow.com/questions/65867105/how-to-configure-my-eslintrc-in-cloud-function-typescript-project

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to wrap no-unused-vars in quotes since it contains - in its property name.

Dashes are not legal in javascript variables. A variable name must start with a letter, dollar sign or underscore and can be followed by the same or a number. You can have dashes in strings.

"no-unused-vars": ["warn"],

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...