spaced-line-comment
此规则在ESLint v1.0中已删除,并由间隔评论规则取代。
一些样式指南//在行注释的最初之后立即要求或不允许空白。之后的空格//可以更容易地阅读评论中的文本。另一方面,注释代码更容易,而不必在后面留下空格//。
规则细节
此规则将在行注释开始后强制间距的一致性//。
这条规则有两个参数。如果第一个是"always"那么//必须至少有一个空格。如果"never"接下来应该没有空白。默认是"always"。
第二个参数是一个有一个键的对象,"exceptions"。该值是一个字符串模式数组,它被视为规则的例外。重要的是要注意,如果第一个参数是异常,则忽略这些异常"never"。例外情况不能混合使用。
此规则的错误代码示例:
// When ["never"]
// This is a comment with a whitespace at the beginning//When ["always"]
//This is a comment with no whitespace at the beginning
var foo = 5;// When ["always",{"exceptions":["-","+"]}]
//------++++++++
// Comment block
//------++++++++此规则的正确代码示例:
// When ["always"]
// This is a comment with a whitespace at the beginning
var foo = 5;//When ["never"]
//This is a comment with no whitespace at the beginning
var foo = 5;// When ["always",{"exceptions":["-"]}]
//--------------
// Comment block
//--------------// When ["always",{"exceptions":["-+"]}]
//-+-+-+-+-+-+-+
// Comment block
//-+-+-+-+-+-+-+相关规则
- spaced-commentVersion此规则在ESLint 0.9.0中引入,并在1.0.0-rc-1.Resources中删除
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

