[英]NextJS Typescript - Setup tslint configuration to force error when have unused import/declarations
can anyone tell me how to force error when I have an unused import/declaration written in next typescript?当我在下一个 typescript 中写入未使用的导入/声明时,谁能告诉我如何强制错误?
the use case is: example I have import { Accordion, AccordionButton } from '@chakra-ui/react';
用例是:例如我
import { Accordion, AccordionButton } from '@chakra-ui/react';
the Accordion component is used , but for AccordionButton is unused , I want when I save the file I got an error compile cause of AccordionButton is not used.使用了 Accordion 组件,但是对于 AccordionButton未使用,我希望在保存文件时出现错误,因为 AccordionButton 没有使用。
Note: I already add: "noUnusedLocals": true, "noUnusedParameters": true
注意:我已经添加:
"noUnusedLocals": true, "noUnusedParameters": true
in tsconfig.json but still not resolved my problem在 tsconfig.json 但仍然没有解决我的问题
It can very much depend on the editor you use.它在很大程度上取决于您使用的编辑器。 In VScode I have it set up to grey out unused imports so you can easily notice and remove them.
在 VScode 中,我将它设置为灰色未使用的导入,以便您可以轻松地注意到并删除它们。
In your VScode config:在您的 VScode 配置中:
{
"javascript.validate.enable": true,
"editor.showUnused": true
}
As far as getting an error, there is an eslint plugin which can show a linting error for unused imports here:至于出现错误,有一个 eslint 插件可以在这里显示未使用的导入的 linting 错误:
https://www.npmjs.com/package/eslint-plugin-unused-imports https://www.npmjs.com/package/eslint-plugin-unused-imports
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.