Skip to content

noRestrictedTypes

诊断类别:lint/nursery/noRestrictedTypes

¥Diagnostic Category: lint/nursery/noRestrictedTypes

自从:v1.9.0

¥Since: v1.9.0

来源:

¥Sources:

禁止用户定义的类型。

¥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.

{
"//": "...",
"options": {
"types": {
"Foo": {
"message": "Only bar is allowed",
"use": "bar"
},
"OldAPI": "Use NewAPI instead"
}
}
}

在上面的例子中,如果使用 FooOldAPI,规则将发出诊断信息。

¥In the example above, the rule will emit a diagnostics if Foo or OldAPI are used.

¥Related links