Man*_*wan 1 typescript eslint jhipster
我想在我的应用程序中使用枚举:
export const enum typeEnum {
TVY = 'TVY',
USER = 'USER',
}
Run Code Online (Sandbox Code Playgroud)
在 npm run webpack:build 中,我收到以下错误:
12:111 错误 'typeEnum' 已经在上层作用域 no-shadow 中声明
我阅读了几个与此错误相关的链接,解决方案是将以下内容添加到 eslint 规则中:
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
Run Code Online (Sandbox Code Playgroud)
这就是我在 .eslintrc.json 文件中所做的:
{
"plugins": ["@typescript-eslint/tslint"],
"extends": ["jhipster"],
"parserOptions": {
"project": "./tsconfig.base.json"
},
"rules": {
"@typescript-eslint/tslint/config": [
"error",
{
"lintFile": "./tslint.json"
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": false
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
}
}
Run Code Online (Sandbox Code Playgroud)
但是现在,我也在 npm run:webpack:build 上收到此错误:
myPath\src\main\webapp\app\vendor.ts [INFO] 1:1 错误定义规则“@typescript-eslint/no-shadow”未找到@typescript-eslint/no-shadow
你知道我能做什么吗?
谢谢,
曼努埃拉
小智 9
事实证明,您需要关闭标准的 eslint 规则,而是使用 TypeScript 特定的值。
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
Run Code Online (Sandbox Code Playgroud)
(我刚遇到这个问题,做了这个改变,它为我解决了)
该错误基本上意味着您在更高级别的某个位置(可能在全局范围内)有另一个同名的枚举。尝试重命名您的枚举并查看。
顺便提一句。关闭规则是一种不好的做法。TS/ES linter 会告诉你的代码哪里有问题。在大多数情况下,您必须解决代码中的问题,而不是仅仅关闭 linter。
| 归档时间: |
|
| 查看次数: |
2454 次 |
| 最近记录: |