5

The manual says I can use:

 --warnings_whitelist_file VAL          : A file containing warnings to
                                          suppress. Each line should be of the
                                          form
                                          <file-name>:<line-number>?  <warning-d
                                          escription>

This is what my whitelist looks like:

ef-utils.js:1  Redeclared variable: ef
ef-utils.js:1  Variable ef first declared in externs-ko.js
ef-validation.js:1  Redeclared variable: ef
ef-validation.js:1  Variable ef first declared in externs-ko.js

And I am still getting warnings while compiling:

ef-utils.js:1: WARNING - Redeclared variable: ef
?var ef = (function (ns, ko) {
     ^

ef-utils.js:1: WARNING - Variable ef first declared in externs-ko.js
?var ef = (function (ns, ko) {
     ^

ef-validation.js:1: WARNING - Redeclared variable: ef
?var ef = (function (ns, ko) {
     ^

ef-validation.js:1: WARNING - Variable ef first declared in externs-ko.js
?var ef = (function (ns, ko) {
     ^
Trident D'Gao
  • 18,973
  • 19
  • 95
  • 159

3 Answers3

3

I just toyed around with the current WhitelistWarningsGuard. I found out that

  • Line numbers are completely ignored: they are stripped both from the input file and the encountered warnings.
  • File names are formatted as they are for output, i.e. as they occur on the command line.
  • There is a colon after the file name, followed by two spaces, followed by the message text without indicator of the severity (WARNING, ERROR).
  • The main effect of the whitelist appears to be turning errors into warnings. So when applied to warnings, there will be no effect at all.
  • The WhitelistBuilder mentioned by Tibos is there in the code, but I see no way to use it from the command line.

As it is, that feature appears to be mostly useless for my use cases…

MvG
  • 57,380
  • 22
  • 148
  • 276
  • It would be great if there was a way to completely ignore some errors using a file like this one. – alex May 31 '16 at 11:58
1

You should use the WhitelistBuilder to build the whitelist file. From the looks of it, you need absolute paths to the files, not relative.

alex
  • 479,566
  • 201
  • 878
  • 984
Tibos
  • 27,507
  • 4
  • 50
  • 64
  • This web page does not works anymore. Also, I can't find this tool anymore on the web. – efficks Nov 06 '14 at 01:58
  • ClosureCompiler is now on GitHub. The WhitelistBuilder class is [here](https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/WhitelistWarningsGuard.java#L212), but it doesn't seem to be the preferred way to handle warnings anymore. I will update my answer when i determine the recommended process. – Tibos Nov 06 '14 at 06:58
0

As MvG correctly stated as this flag is implemented it's useless. Though, with pretty light changes to the compiler's code it can be turned to what we all expect from it: suppressing errors and warnings we don't want to see.

See details here: Suppressing or resolving compiler errors in goog.base

Community
  • 1
  • 1
real4x
  • 1,433
  • 12
  • 11