diff --git a/lib/parser.js b/lib/parser.js index 7d982b43..9cbcf266 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -113,7 +113,7 @@ Parser.prototype.getTypedefComments_ = function(comments) { Parser.prototype.getSuppressRequireComments_ = function(comments) { return comments.filter(function(comment) { return comment.type === 'Line' && - /^\s*fixclosure\s*:\s*suppressRequire\s*$/.test(comment.value); + /^\s*fixclosure\s*:\s*suppressRequire\b/.test(comment.value); }); }; @@ -162,7 +162,7 @@ Parser.prototype.extractToRequireFromJsDoc_ = function(comments) { }; /** - * Extract "goog.require('goog.foo') // fixclosure: suppress unused". + * Extract "goog.require('goog.foo') // fixclosure: suppressUnused". * @param {Array} parsed . * @param {Array} comments . * @return {Array.} . @@ -173,7 +173,7 @@ Parser.prototype.extractSuppressUnused_ = function(parsed, comments) { var a = comment.type === 'Line' && comment.loc.start.line >= this.min_ && comment.loc.start.line <= this.max_ && - /^\s*fixclosure\s*:\s*suppressUnused\s*$/.test(comment.value); + /^\s*fixclosure\s*:\s*suppressUnused\b/.test(comment.value); return a; }, this).reduce(function(prev, item) { prev[item.loc.start.line] = true; diff --git a/test/fixtures/parse/suppress_require.js b/test/fixtures/parse/suppress_require.js index dbe798e9..c740112e 100644 --- a/test/fixtures/parse/suppress_require.js +++ b/test/fixtures/parse/suppress_require.js @@ -2,6 +2,8 @@ goog.foo.foo(); // fixclosure: suppressRequire goog.bar.bar(); goog.baz.baz(); +// fixclosure: suppressRequire with comment +goog.bao.bao(); // toRequire: goog.baz // toRequire: goog.foo diff --git a/test/fixtures/parse/suppress_unused.js b/test/fixtures/parse/suppress_unused.js index 6b6495a3..41faef6f 100644 --- a/test/fixtures/parse/suppress_unused.js +++ b/test/fixtures/parse/suppress_unused.js @@ -1,8 +1,11 @@ goog.require('goog.foo'); goog.require('goog.bar'); // fixclosure: suppressUnused goog.require('goog.baz'); +goog.require('goog.bao'); // fixclosure: suppressUnused with comment +// required: goog.bao // required: goog.bar // required: goog.baz // required: goog.foo +// suppressed: goog.bao // suppressed: goog.bar