Commit 3e9fc2f5 authored by dbeam@chromium.org's avatar dbeam@chromium.org

web_dev_style: add check for ending jsdoc comments with **/ instead of */.

R=tbreisacher@chromium.org
BUG=366972
NOTRY=true

Review URL: https://codereview.chromium.org/251713002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266430 0039d316-1c4b-4281-b951-d872f2087c98
parent decf5cf1
......@@ -127,6 +127,39 @@ class JsStyleGuideTest(SuperMoxTestBase):
for line in lines:
self.ShouldPassChromeSendCheck(line)
def ShouldFailEndJsDocCommentCheck(self, line):
"""Checks that the **/ checker flags |line| as a style error."""
error = self.checker.EndJsDocCommentCheck(1, line)
self.assertNotEqual('', error,
'Should be flagged as style error: ' + line)
self.assertEqual(self.GetHighlight(line, error), '**/')
def ShouldPassEndJsDocCommentCheck(self, line):
"""Checks that the **/ checker doesn't flag |line| as a style error."""
self.assertEqual('', self.checker.EndJsDocCommentCheck(1, line),
'Should not be flagged as style error: ' + line)
def testEndJsDocCommentFails(self):
lines = [
"/** @override **/",
"/** @type {number} @const **/",
" **/",
"**/ ",
]
for line in lines:
self.ShouldFailEndJsDocCommentCheck(line)
def testEndJsDocCommentPasses(self):
lines = [
"/***************/", # visual separators
" */", # valid JSDoc comment ends
"*/ ",
"/**/", # funky multi-line comment enders
"/** @override */", # legit JSDoc one-liners
]
for line in lines:
self.ShouldPassEndJsDocCommentCheck(line)
def ShouldFailGetElementByIdCheck(self, line):
"""Checks that the 'getElementById' checker flags |line| as a style
error.
......
......@@ -50,6 +50,12 @@ class JSChecker(object):
return self.RegexCheck(i, line, r'(?:^|\s|\()(const)\s',
'Use /** @const */ var varName; instead of const varName;')
def EndJsDocCommentCheck(self, i, line):
msg = 'End JSDoc comments with */ instead of **/'
def _check(regex):
return self.RegexCheck(i, line, regex, msg)
return _check(r'^\s*(\*\*/)\s*$') or _check(r'/\*\* @[a-zA-Z]+.* (\*\*/)')
def GetElementByIdCheck(self, i, line):
"""Checks for use of 'document.getElementById' instead of '$'."""
return self.RegexCheck(i, line, r"(document\.getElementById)\('",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment