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

node:true masks 'use strict' outside function

Expand Messages
  • Marcos Zanona
    use strict ; function test() { return 2 + 2;} with node: false Error: Problem at line 1 character 1: Use the function form of use strict . use strict ; with
    Message 1 of 4 , Jul 14, 2011
    • 0 Attachment
      'use strict';
      function test() {
      return 2 + 2;}

      with node: false

      Error: Problem at line 1 character 1: Use the function form of 'use strict'.
      'use strict';

      with node: true

      ok


      [Non-text portions of this message have been removed]
    • Douglas Crockford
      ... This is intended.
      Message 2 of 4 , Jul 14, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, Marcos Zanona <marcos@...> wrote:
        >
        > 'use strict';
        > function test() {
        > return 2 + 2;}
        >
        > with node: false
        >
        > Error: Problem at line 1 character 1: Use the function form of 'use strict'.
        > 'use strict';
        >
        > with node: true
        >
        > ok

        This is intended.
      • mariuszn3
        As Douglas said, if you turn on node option it means that you re validating file which is CommonJS module, which will not be run in global scope but in it s
        Message 3 of 4 , Jul 14, 2011
        • 0 Attachment
          As Douglas said, if you turn on 'node' option it means that you're validating file which is CommonJS module, which will not be run in global scope but in it's own sandbox (same if it was wrapped with anonymous function) that's why this warning shouldn't appear.

          Anyway it'll be good to have separate 'module' option for that, as CommonJS modules are not specific only to Node.js, but I'll brag about it later in another post :)

          --- In jslint_com@yahoogroups.com, Marcos Zanona <marcos@...> wrote:
          >
          > 'use strict';
          > function test() {
          > return 2 + 2;}
          >
          > with node: false
          >
          > Error: Problem at line 1 character 1: Use the function form of 'use strict'.
          > 'use strict';
          >
          > with node: true
          >
          > ok
          >
          >
          > [Non-text portions of this message have been removed]
          >
        • Marcos Zanona
          that was a good explanation, thanks so much it makes a lot of sense :) [Non-text portions of this message have been removed]
          Message 4 of 4 , Jul 14, 2011
          • 0 Attachment
            that was a good explanation, thanks so much it makes a lot of sense :)


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.