Hi Guys,
We are using the latest build of closure compiler [7th April 2014]. We also happen to use some 3rd party javascript libraries, for which the closure compiler gives a warning and we want to ignore them.
For this I tried the warning white-list option, but it doesn't seem to work. Below are the warnings from 3rd part libraries that we get
java -jar lib/compiler.jar --js toMin.js --js_output_file ./src/main/static/webapp/js/min.js
toMin.js:490: WARNING - Type annotations are not allowed here. Are you missing parentheses?
var arr = /**@type {Array.<number|string|boolean>}*/this.buffer_;
^
toMin.js:2944: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
arr[ preferredDoc.childNodes.length ].nodeType;
^
toMin.js:4103: WARNING - Suspicious code. This code lacks side-effects. Is there a bug?
if ( elem.parentNode ) {
^
toMin.js:4104: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
elem.parentNode.selectedIndex;
^
toMin.js:9288: WARNING - Suspicious code. This code lacks side-effects. Is there a bug?
if ( parent && parent.parentNode ) {
^
toMin.js:9289: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
parent.parentNode.selectedIndex;
^
toMin.js:16037: WARNING - If this if/for/while really shouldnt have a body, use {}
if (self.messageCallback && $.isFunction(self.messageCallback));
^
toMin.js:16121: WARNING - unreachable code
return true;
I created a white-list file of warnings, based on the above format
toMin.js:490 Type annotations are not allowed here. Are you missing parentheses?
toMin.js:2944 Suspicious code. The result of the 'getprop' operator is not being used.
toMin.js:4103 Suspicious code. This code lacks side-effects. Is there a bug?
toMin.js:4104 Suspicious code. The result of the 'getprop' operator is not being used.
toMin.js:9288 Suspicious code. This code lacks side-effects. Is there a bug?
toMin.js:9289 Suspicious code. The result of the 'getprop' operator is not being used.
toMin.js:16037 If this if/for/while really shouldnt have a body, use {}
toMin.js:16121 unreachable code
I re-ran with the white-list option, but it didn't seem to like it
java -jar lib/compiler.jar --warnings_whitelist_file closure_third_party_warning_whitelist --js toMin.js --js_output_file ./src/main/static/webapp/js/min.js
Can someone let me know what am I missing here?
The warning_level QUIET option works but we don't want to ignore warnings in our own code and only third party code.
Sagar