[英]@typescript-eslint/no-unused-vars raises a warn where it shouldn't
我正在尝试使用 webpack、typescript 和 eslint 启动一个项目。 我在这里收到警告@typescript-eslint/no-unused-vars
:
如果不实现env
我就无法实现argv
值。 在这种情况下避免错误的唯一方法是模拟变量env
的使用吗?
我的eslint.json :
{
"env": {
"browser": true,
"node": true,
"es2020": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true,
"arrowFunctions": true,
"classes": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint",
"import"
],
"rules": {
"no-console": ["error", {
"allow": ["timeEnd", "warn"]
}],
"func-names": "off",
"linebreak-style": ["error", "windows"],
"no-plusplus": "off",
"max-len": ["error", {"code": 120}],
"indent": ["error", 4, {
"ignoredNodes": ["JSXElement *"]
}],
"arrow-parens": ["error", "as-needed"],
"import/order": ["error", {
"pathGroups": [{
"pattern": "@*/**",
"group": "parent",
"position": "before"
}],
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
"alphabetize": {"order": "asc"}
}]
}
}
您可以为此 eslint 规则定义一个正则表达式,以使用属性argsIgnorePattern
指示已知未使用的函数参数。 一种常见的正则表达式是"argsIgnorePattern": "^_"
忽略所有以下划线开头的变量。 使用此配置,您可以编写:
module.exports = (_: {} = {}, argv: {} = {}) => {
有关信息,这是我的配置:
'@typescript-eslint/no-unused-vars':
- error
- argsIgnorePattern: '^_'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.