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

function_strict warning and CommonJS modules

Expand Messages
  • mariuszn3
    Currently there s no way to switch off function_strict warning. This is not great as in some environments (like node.js) javascript file is really a module and
    Message 1 of 9 , May 28, 2011
    View Source
    • 0 Attachment
      Currently there's no way to switch off function_strict warning.

      This is not great as in some environments (like node.js) javascript file is really a module and is treated as separate sandbox/function and there is no risk associated with non function wrapped use of 'use strict'.

      I think there should be an option to turn off that warning and have it turned off by default in node mode.

      Is there any chance for that ?

      Currently all JavaScript I write is with Modules spec in mind. If I want to run my code in browser then I wrap modules in functions, and 'use strict' becomes function form.

      I'd like to clear this warnings when I lint my code as they make no sense for this case.
    • Douglas Crockford
      ... Stop turning on the option.strict option.
      Message 2 of 9 , Jun 2, 2011
      View Source
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "mariuszn3" <medikoo.yahxo.com@...> wrote:
        >
        > Currently there's no way to switch off function_strict warning.
        >
        > This is not great as in some environments (like node.js) javascript file is really a module and is treated as separate sandbox/function and there is no risk associated with non function wrapped use of 'use strict'.
        >
        > I think there should be an option to turn off that warning and have it turned off by default in node mode.
        >
        > Is there any chance for that ?
        >
        > Currently all JavaScript I write is with Modules spec in mind. If I want to run my code in browser then I wrap modules in functions, and 'use strict' becomes function form.
        >
        > I'd like to clear this warnings when I lint my code as they make no sense for this case.


        Stop turning on the option.strict option.
      • mariuszn3
        ... I m not turning on option.strict option. JSLint by itself recognizes strict mode.
        Message 3 of 9 , Jun 3, 2011
        View Source
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
          >
          > --- In jslint_com@yahoogroups.com, "mariuszn3" <medikoo.yahxo.com@> wrote:
          > >
          > > Currently there's no way to switch off function_strict warning.
          > >
          > > This is not great as in some environments (like node.js) javascript file is really a module and is treated as separate sandbox/function and there is no risk associated with non function wrapped use of 'use strict'.
          > >
          > > I think there should be an option to turn off that warning and have it turned off by default in node mode.
          > >
          > > Is there any chance for that ?
          > >
          > > Currently all JavaScript I write is with Modules spec in mind. If I want to run my code in browser then I wrap modules in functions, and 'use strict' becomes function form.
          > >
          > > I'd like to clear this warnings when I lint my code as they make no sense for this case.
          >
          >
          > Stop turning on the option.strict option.
          >

          I'm not turning on option.strict option.
          JSLint by itself recognizes strict mode.
        • Douglas Crockford
          ... I don t understand what you are asking for.
          Message 4 of 9 , Jun 3, 2011
          View Source
          • 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:
            > > >
            > > > Currently there's no way to switch off function_strict warning.
            > > >
            > > > This is not great as in some environments (like node.js) javascript file is really a module and is treated as separate sandbox/function and there is no risk associated with non function wrapped use of 'use strict'.
            > > >
            > > > I think there should be an option to turn off that warning and have it turned off by default in node mode.
            > > >
            > > > Is there any chance for that ?
            > > >
            > > > Currently all JavaScript I write is with Modules spec in mind. If I want to run my code in browser then I wrap modules in functions, and 'use strict' becomes function form.
            > > >
            > > > I'd like to clear this warnings when I lint my code as they make no sense for this case.
            > >
            > >
            > > Stop turning on the option.strict option.
            > >
            >
            > I'm not turning on option.strict option.
            > JSLint by itself recognizes strict mode.


            I don't understand what you are asking for.
          • mariuszn3
            ... 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
            Message 5 of 9 , Jun 3, 2011
            View Source
            • 0 Attachment
              --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
              >
              > --- 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:
              > > > >
              > > > > Currently there's no way to switch off function_strict warning.
              > > > >
              > > > > This is not great as in some environments (like node.js) javascript file is really a module and is treated as separate sandbox/function and there is no risk associated with non function wrapped use of 'use strict'.
              > > > >
              > > > > I think there should be an option to turn off that warning and have it turned off by default in node mode.
              > > > >
              > > > > Is there any chance for that ?
              > > > >
              > > > > Currently all JavaScript I write is with Modules spec in mind. If I want to run my code in browser then I wrap modules in functions, and 'use strict' becomes function form.
              > > > >
              > > > > I'd like to clear this warnings when I lint my code as they make no sense for this case.
              > > >
              > > >
              > > > Stop turning on the option.strict option.
              > > >
              > >
              > > I'm not turning on option.strict option.
              > > JSLint by itself recognizes strict mode.
              >
              >
              > I don't understand what you are asking for.
              >

              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.
            • Douglas Crockford
              ... When using the Assume node.js option, JSLint will now tolerate the file level use strict pragma. I think you would be smarter to use the function use
              Message 6 of 9 , Jun 3, 2011
              View Source
              • 0 Attachment
                --- 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.

                I think you would be smarter to use the function use strict pragma.
              • mariuszn3
                ... 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
                Message 7 of 9 , Jun 4, 2011
                View Source
                • 0 Attachment
                  --- 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.
                • mariuszn3
                  ... 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
                  Message 8 of 9 , Jun 4, 2011
                  View Source
                  • 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 :)
                  • Zhami
                    ... Great. Thanks. Validated. ... In the context we (the op, me, and other nodeJS module coders) are using, the code is effectively wrapped/contained in an
                    Message 9 of 9 , Jun 4, 2011
                    View Source
                    • 0 Attachment
                      --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:

                      >
                      > When using the Assume node.js option, JSLint will now tolerate the file level use strict pragma.

                      Great. Thanks. Validated.

                      >
                      > I think you would be smarter to use the function use strict pragma.

                      In the context we (the op, me, and other nodeJS module coders) are using, the code is effectively wrapped/contained in an anonymous function, though not one that appears in the file. It would be functionally redundant to wrap the content of a CommonJS module file in yet another (anonymous, immediate) function.
                    Your message has been successfully submitted and would be delivered to recipients shortly.