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

2255Re: function_strict warning and CommonJS modules

Expand Messages
  • mariuszn3
    Jun 4, 2011
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "mariuszn3" <medikoo.yahxo.com@...> wrote:
      >
      >
      >
      >
      > --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@> wrote:
      > >
      > > --- In jslint_com@yahoogroups.com, "mariuszn3" <medikoo.yahxo.com@> wrote:
      > > > Sorry, if I wasn't clear enough.
      > > > It's about this warning:
      > > > "Use the function form of 'use strict'."
      > > >
      > > > I use JSLint against modules I write for Node.js (modules according to CommonJS spec).
      > > > Module is file that is handled in Node.js differently than file in browser.
      > > > Each module is executed in it's own sandbox (as if it was anonymous function instantly executed).
      > > >
      > > > So what I meant is that in that case, when I put 'use strict' at begin of file, this warning doesn't make sense. Implications of using 'use strict' in global mode doesn't apply to this case, as it doesn't invoke strict mode in global mode.
      > > >
      > > > It would be good to have an option to turn off this warning and make it by default off for node mode, with current version of JSLint I cannot turn off this warning.
      > >
      > >
      > > When using the Assume node.js option, JSLint will now tolerate the file level use strict pragma.
      >
      > Thanks for answer.
      > What option you exactly mean ? option.node ? I have this on, but even when I look into JSlint code it seems that all this option does is predefining globals that Node.js introduces, and that's it.
      >
      > No matter what setting I have for option.node or option.strict I still get this warning.
      >
      > Other thing is, that probably it won't be good to tie that to option.node, as Modules are not Node.js specific thing, but rather CommonJS specific thing, so it's probably also case for Narwhal and other engines that implements CommonJS modules.
      >
      > I think the best would be to have new option, option.module for that.
      >
      > >
      > > I think you would be smarter to use the function use strict pragma.
      > >
      >
      > The thing is, that's what I'm doing. This file is only executed as module, which means it becomes function use strict pragma.
      > If I decide to run it in browser I wrap code with anonymous function so then again it becomes function use strict pragma.
      >

      ah, sorry! I didn't notice that you've updated JSLint :) Thanks!
      Yes it works great for option.node, that's what I was questioning.

      On a side note, it might be good to have this feature as separate option.
      e.g. option.module and make it true when option.node is true.
      This is because Modules are not specific to Node.js, they are CommonJS thing and are implemented by some other engines as well (like Narwhal).
      For example sometimes I write modules that I don't write specifically for Node.js then I'd like to have same feature but without turning option.node to true.

      Anyway, great thanks! JSLint is not replaceable :)
    • Show all 9 messages in this topic