Skip to content

Commit

Permalink
Allow inline hints with comment
Browse files Browse the repository at this point in the history
  • Loading branch information
teppeis committed May 30, 2014
1 parent 970b318 commit d35ac53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};

Expand Down Expand Up @@ -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.<string>} .
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/parse/suppress_require.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions test/fixtures/parse/suppress_unused.js
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d35ac53

Please sign in to comment.