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

[jslint] Re: /*jslint is seen as a reserved word

Expand Messages
  • Douglas Crockford
    ... It acts as a pragma. I do not recommend this use. I regret having allowed it.
    Message 1 of 8 , Mar 4, 2011
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Joshua Bell <josh@...> wrote:
      >
      > On Fri, Mar 4, 2011 at 8:29 AM, Douglas Crockford <douglas@...>
      > wrote:
      > >
      > >
      > > No it shouldn't. JSLint allows those directives at statement position only.
      > >
      >
      > Does the jslint directive apply within a lexical scope, or does it function
      > like a pre-processor directive irrespective of lexical structure?
      >
      > i.e. which should be used:
      >
      > function twiddle(a, b) {
      > /*jslint bitwise: false*/ // allow bitwise operators for this lexical
      > scope
      > return a & b;
      > }


      It acts as a pragma. I do not recommend this use. I regret having allowed it.
    • Zhami
      Woomla: You could also move the pragma further in (rather than out) In my code, I disable such pragma immediately after the line of code I need it suspended
      Message 2 of 8 , Mar 5, 2011
      • 0 Attachment
        Woomla: You could also move the pragma further in (rather than out)

        In my code, I disable such pragma immediately after the line of code I need it suspended for.

        Douglas: In the following, JSLint reports the second appearance of the pragma as being unreachable, which is true were it executable (curiously though, the effect of that pragma is put into effect).

        (function () {
        "use strict";

        String.implement({
        getByteAt: function (index) {
        /*jslint bitwise: false*/
        return this.charCodeAt(index) & 0xFF;
        /*jslint bitwise: true*/
        }
        });
        }());


        --- In jslint_com@yahoogroups.com, "Woomla" <woomla@...> wrote:
        >
        > Hi,
        >
        > This code gives a message: Problem at line 5 character 9: Expected an identifier and instead saw '/*jslint' (a reserved word). That's correct and it's my intention to allow bitwise operator &.
        >
        >
        > (function () {
        > "use strict";
        >
        > String.implement({
        > /*jslint bitwise: false*/
        > getByteAt: function (index) {
        > return this.charCodeAt(index) & 0xFF;
        > }
        > });
        > }());
        >
        > If I move the /*jslint before String.implement, it is ok. But I guess it should be fine on the line in this example as well, shouldn't it?
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.