Skip to content

Commit

Permalink
Adds a lint warning for a constructor in a goog.module without a JSDoc.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=233631820
  • Loading branch information
terrono authored and tjgq committed Feb 12, 2019
1 parent 7ee68cd commit bf6d133
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/lint/CheckJSDocStyle.java
Expand Up @@ -240,7 +240,7 @@ private void checkMissingJsDoc(NodeTraversal t, Node function) {
* in the global scope, or a method on a class which is declared in the global scope.
*/
private boolean isFunctionThatShouldHaveJsDoc(NodeTraversal t, Node function) {
if (!(t.inGlobalHoistScope() || t.inModuleScope())) {
if (!(t.inGlobalHoistScope() || t.inModuleHoistScope())) {
return false;
}
if (NodeUtil.isFunctionDeclaration(function)) {
Expand Down
Expand Up @@ -351,6 +351,7 @@ public void testMissingJsDoc_noWarningOnEmptyConstructor_withES6Modules() {
public void testMissingJsDoc_googModule() {
testWarning("goog.module('a.b.c'); function f() {}", MISSING_JSDOC);
testWarning("goog.module('a.b.c'); var f = function() {};", MISSING_JSDOC);
testWarning("goog.module('a.b.c'); class Foo { constructor(x) {} }", MISSING_JSDOC);
}

@Test
Expand Down Expand Up @@ -382,6 +383,8 @@ public void testMissingJsDoc_ES6Module05() {
public void testMissingJsDoc_googModule_noWarning() {
testSame("goog.module('a.b.c'); /** @type {function()} */ function f() {}");
testSame("goog.module('a.b.c'); /** @type {function()} */ var f = function() {};");
// No JSDoc is required for a constructor with no parameters.
testSame("goog.module('a.b.c'); class Foo { constructor() {} }");
}

@Test
Expand Down

0 comments on commit bf6d133

Please sign in to comment.