google / closure-linter

Automatically exported from code.google.com/p/closure-linter
Apache License 2.0
109 stars 37 forks source link

Incorrect warning and fix for "goog.provide" #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I have code that I want to be able to run without goog tools, thus I sniff for 
goog at the top of the file.

--- INPUT file.js ----
if (typeof goog != 'undefined' && typeof goog.provide == 'function') {
    goog.provide('MyLib.Base');
}
---------------------

gjslint complains: 
"Line 1, E:0141: goog.provide classes must be alphabetized.  The correct code 
is:
goog.provide('MochiKit.Base');
goog.provide('function');"

Running fixjsstyle outputs this... 
--- OUTPUT -----
if (typeof goog != 'undefined' && typeof goog.provide == 'MyLib.Base') {
    goog.provide('function');
}
----------------------

What version of the product are you using? On what operating system?
Latest build (Jan 17), Python 2.5.4, Windows 7 64bit

// Fredrik Blomqvist

Original issue reported on code.google.com by fblomqvist@gmail.com on 20 Feb 2011 at 1:23

GoogleCodeExporter commented 9 years ago

Original comment by a...@google.com on 21 Feb 2011 at 4:26

GoogleCodeExporter commented 9 years ago
Just a thought, couldn't a linter quite easily (and I guess also the Closure 
compiler) include a warning for code like the above? i.e: "if (typeof foo == 
'MISSPELLED_TYPE_THAT_CANNOT_EXIST') .." ?

I guess we all have typed "undefid" some time for example..

Original comment by fblomqvist@gmail.com on 24 Feb 2011 at 10:08

GoogleCodeExporter commented 9 years ago

Original comment by michaelt...@google.com on 7 Mar 2011 at 8:24

GoogleCodeExporter commented 9 years ago
Great! (though it doesn't seem to be available in the trunk yet?)
FYI, I also cross-posted the typeof check feature idea as a Clousure Compiler 
issue: http://code.google.com/p/closure-compiler/issues/detail?id=370

Original comment by fblomqvist@gmail.com on 8 Mar 2011 at 11:17