没有非null断言有esint角色。我的问题是如何禁止在类属性中使用非null断言?
class A{
someProp!:string
}
是否有某种类型脚本配置或esint角色?
查看AST资源管理器,该产品被称为PropertyDefinition
,添加!
会将definite: true
添加到对象中。因此,您可以将选择器PropertyDefinition[definite=true]
与no-restricted-syntax
结合使用。
rules: {
'no-restricted-syntax': ['error',
{
selector: 'PropertyDefinition[definite=true]',
message: 'Non-null property assertions are forbidden',
},
],
},