noRestrictedTypes
¥Summary
-
规则生效日期:
v1.9.0¥Rule available since:
v1.9.0 -
诊断类别:
lint/style/noRestrictedTypes¥Diagnostic Category:
lint/style/noRestrictedTypes -
此规则包含 safe 修复程序。
¥This rule has a safe fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
-
来源:
¥Sources:
¥How to configure
{ "linter": { "rules": { "style": { "noRestrictedTypes": "error" } } }}¥Description
禁止用户定义的类型。
¥Disallow user defined types.
此规则允许你指定不想在应用中使用的类型名称。
¥This rule allows you to specify type names that you don’t want to use in your application.
为防止使用常见的误导类型,你可以参考 noBannedTypes
¥To prevent use of commonly misleading types, you can refer to noBannedTypes
¥Options
使用选项指定要在源代码中限制的其他类型。
¥Use the options to specify additional types that you want to restrict in your source code.
{ "linter": { "rules": { "style": { "noRestrictedTypes": { "options": { "types": { "Foo": { "message": "Only bar is allowed", "use": "bar" }, "OldAPI": "Use NewAPI instead" } } } } } }}在上面的例子中,如果使用 Foo 或 OldAPI,规则将发出诊断信息。
¥In the example above, the rule will emit a diagnostics if Foo or OldAPI are used.
¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号