Loading ...
Sorry, an error occurred while loading the content.

Re: /*global */

Expand Messages
  • Fred Lorrain
    I m building my final .js file thanks to Ant scripting. Currently I m validating every single pieces independently. Thanks to /*global */ I can ride of the
    Message 1 of 34 , Jun 1, 2009
    • 0 Attachment
      I'm building my final .js file thanks to Ant scripting.
      Currently I'm validating every single pieces independently.
      Thanks to /*global */ I can ride of the warning about undeclared variables and it help me to track dependencies.

      What could help is to keep the /*global*/ feature but highlight variables 'declared' this way in the variable report.

      Global variables are not the main issue we have to face in javascript validation. So please don't overload our work.
      Your tool is very excellent but don't push to deep the Quality Quest.


      --- In jslint_com@yahoogroups.com, "Randall Lee Spence" <analogueweb@...> wrote:
      >
      > --- In jslint_com@yahoogroups.com, "crlender" <crlender@> wrote:
      > >
      > > --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@> wrote:
      > > > I will be removing the /*global */ declarative comment. I am
      > > > persuaded that it is best to explicitly use var to declare all global
      > > > variables, even when accessing variables created by other compilation
      > > > units.
      > > >
      > > > /*global */ will just be a comment.
      > >
      > > Does that mean that we can't have two or more files that access the
      > > same global variable without explicitly declaring it in each and
      > > every file? For example:
      > >
      > > // file1.js
      > > var myNameSpace = {
      > > prop1: ...,
      > > prop2: ...
      > > };
      > >
      > > // file2.js
      > > myNameSpace.prop3 = {
      > > subprop1: ...,
      > > subprop2: ...
      > > }
      > >
      > > This is a very common situation. Up until now we could just tell
      > > JSLint to consider myNameSpace as global in file2.js. What's the
      > > advantage of removing /*global */? People who used it were already
      > > aware that undeclared globals are a bad idea, but now they don't
      > > have any recourse except to re-declare all global variables, again,
      > > in every file. Add to that the possibility that those files are
      > > automatically combined before they're sent to the client; re-declaring
      > > all globals would just litter the resulting script with duplicated
      > > var statements.
      > >
      > > Would it be possible to at least leave this as an optional feature?
      > >
      > >
      > > - Conrad
      > >
      >
      >
      > Although I understand the reasoning behind removing this feature, I
      > agree with Conrad. This will lead to a lot of extra declared
      > variables for those working across multiple files, just as he has
      > suggested. I think allowing it as an option would be a great idea,
      > especially for those working in these situations.
      >
      > Another question, if/when this feature is removed, will you be
      > supplementing the assume a browser option with more global names,
      > like HTMLElement, or IE8's Element, for example? Using var to declare
      > these items seems wrong. The /*global */ declaration really comes in handy when working with items such as this that are available in the
      > browsers, but not explicitly declared within JSLint.
      >
      > That being said, I really value JSLint as a quality tool, and
      > appreciate your continued efforts to improve it.
      >
      > -Randall Lee Spence
      >
    • Douglas Crockford
      ... Which do you think is more likely, that a program wants to change the global name, or that a var name declaration in a function was forgotten? We won t get
      Message 34 of 34 , Jun 12, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "pauanyu" <pcxunlimited@...> wrote:
        > "name" needs to be writable. It has no value by default,
        > but you can assign a string to it, indicating the name of
        > the window/tab.

        Which do you think is more likely, that a program wants to change the global name, or that a var name declaration in a function was forgotten? We won't get an implied global warning, but at least we can get a read only warning. I think that is the more useful default.
      Your message has been successfully submitted and would be delivered to recipients shortly.