[英]TSLint and React stateless component naming (PascalCase vs. camelCase)
Stateless React components should be named in PascalCase , so React can distinguish between native elements and components. 无状态React组件应该在PascalCase中命名,因此React可以区分本机元素和组件。 Typescripts naming convention dictates that we should use lowerCamelCase or UPPER_CASE for the name of const variables.
Typescripts命名约定规定我们应该使用lowerCamelCase或UPPER_CASE作为const变量的名称。
How can I satisfy both (React and tslint)? 我怎样才能满足(React和tslint)?
I think you have two options here: 我想你有两个选择:
Use where appopriate comment like this 使用这样适当的评论
/* tslint:disable-next-line:variable-name */
to disable tslint warning at that particular line 禁用该特定行的tslint警告
Use class components instead of functional ones. 使用类组件而不是功能组件。
您可以在tslint.json中添加以下规则:
"variable-name": [true, "ban-keywords", "check-format", "allow-pascal-case"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.