问题描述
我正在尝试使用 typescript 云函数并在其中使用 ESlint,但我想将未使用的变量仅作为警告,而不是标记为错误。我很困惑如何在我的云功能项目中配置它,在我的 .eslintrc
中总是出现这样的错误,请帮助
这是我的 .eslintrc 配置
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
},};
解决方法
您需要将 no-unused-vars
用引号括起来,因为它的属性名称中包含 -
。
破折号在 javascript 变量中是不合法的。变量名必须以字母、美元符号或下划线开头,后跟相同或数字。字符串中可以有破折号。
"no-unused-vars": ["warn"],