首页 > 解决方案 > TSLint:现有规则的自定义错误消息

问题描述

我想使用 ts-lint 的no-console规则,并带有一些自定义错误消息。

这个想法是为开发人员提供更加用户友好的输出,并让他们使用我们的工具进行日志记录,而不是控制台。

而不是这样的

> npm run lint
ERROR: src/app/app.component.ts:84:5 - Calls to 'console.info' are not allowed.

我希望有这个

> npm run lint
ERROR: src/app/app.component.ts:84:5 - Calls to 'console.info' are not allowed.
You should only use console.log for local development, and you have probably forgotten
to remove this line.
If you want to have logs on production or preproduction, please use instead the
`Logger` class. To know more about this Logger, please refer to this documentation <link>.

知道是否可能吗?以及如何做到这一点?

谢谢 !

标签: angulartypescripteslinttslint

解决方案


推荐阅读