Skip to content

Commit

Permalink
Updated comment-format rule to allow for starting with ///
Browse files Browse the repository at this point in the history
  • Loading branch information
gscshoyru committed Dec 11, 2013
1 parent 8f8d32e commit 898828d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Supported Rules
* `class-name` enforces PascalCased class and interface names.
* `comment-format` enforces rules for single-line comments. Rule options:
* `"check-space"` enforces the rule that all single-line comments must begin with a space, as in `// comment`
* note that comments starting with `///` are also allowed, for things such as ///<reference>
* `"check-lowercase"` enforces the rule that the first non-whitespace character of a comment must be lowercase, if applicable
* `curly` enforces braces for `if`/`for`/`do`/`while` statements.
* `eofline` enforces the file to end with a newline.
Expand Down
3 changes: 2 additions & 1 deletion src/rules/commentFormatRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class CommentWalker extends Lint.RuleWalker {
}

var firstCharacter = commentText.charAt(2); // first character after the space
return firstCharacter === " ";
// three slashes (///) also works, to allow for ///<reference>
return firstCharacter === " " || firstCharacter === "/";
}

private startsWithLowercase(commentText: string): boolean {
Expand Down
1 change: 1 addition & 0 deletions test/files/rules/comment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class Clazz { // this comment is correct
//This comment is on its own line, and starts with a capital _and_ no space
console.log("test"); //this comment has no space
}
/// <reference or something>
}
1 change: 1 addition & 0 deletions test/rules/commentFormatRuleTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ describe("<comment-format>", () => {
Lint.Test.assertContainsFailure(actualFailures, expectedFailure2);
Lint.Test.assertContainsFailure(actualFailures, expectedFailure3);
Lint.Test.assertContainsFailure(actualFailures, expectedFailure4);
assert.lengthOf(actualFailures, 4);
});
});

0 comments on commit 898828d

Please sign in to comment.