[英]How do I avoid shadowed variable warnings when using Enums in recent eslint?
Consider the following file:考虑以下文件:
export enum WorkshopOrderByType {
featuredAt = "featuredAt",
updatedAt = "updatedAt",
createdAt = "createdAt",
workshopStartDate = "workshopStartDate",
attendingBatchStart = "attendingBatchStart",
}
The most recent eslint will complain that:最近的 eslint 会抱怨:
'WorkshopOrderByType' is already declared in the upper scope.
'WorkshopOrderByType' 已经在上层范围中声明。
This is described in the following eslint issue .这在以下 eslint 问题中有所描述。
The no-identifier-enum-member
and prefer-literal-enum-member
are apparently related to this, and there was talk of creating an exception for Enums as an option for no-shadow
. no-identifier-enum-member
和prefer-literal-enum-member
显然与此相关,并且有人谈论为 Enums 创建一个例外作为no-shadow
的选项。
But, as of now - how do I refactor the code above to fix the no-shadow
warning?但是,截至目前 - 如何重构上面的代码以修复
no-shadow
警告?
The error comes from using the no-shadow
rule instead of @typescript-eslint/no-shadow
.错误来自使用
no-shadow
规则而不是@typescript-eslint/no-shadow
。
We added the:我们添加了:
"@typescript-eslint/no-shadow": "error",
And removed the corresponding并删除了相应的
"no-shadow": ...
rule which removed the warnings.删除警告的规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.