"use strict"; prepended blindly to scripts in the wild

Brendan Eich brendan at mozilla.com
Wed Sep 8 17:57:48 PDT 2010


Until JSLint actually enforces ES5 strict mode, its docs should not be promoting "use strict".

In the SVG past, the dark ages so to speak, some popular tools generated invalid SVG-in-XML, and so did hand-coding authors. This begat missing xmlns= declaration error correction. Same story as HTML quirks mode, which goes back to when NCSA Mosaic had to keep content on ~80 web servers working even if it was not well-formed (from personal communication with Marc Andreessen).

Are there > 80 servers worth of content that has "use strict" but does not conform to ES5 strict mode? Can we evangelize them? See the Mozilla bugs cited in this thread, which are "Technology Evangelism" bugs, and kudos to Intel for its rapid response.

But JSLint shouldn't be writing checks it can't back that its users will want to cash in ES5-conformant browsers.

/be

On Sep 8, 2010, at 3:19 PM, Oliver Hunt wrote:

> The other problem with JSLint is that it can't run all of the code so JSLint won't pick up the runtime error in
> 
> function f() {
>    "use strict";
>    return this.foo;
> }
> 
> f();
> 
> I've seen a couple of sites that would break due to this.
> 
> --Oliver
> 
> 
> On Sep 8, 2010, at 3:16 PM, Marek Stępień wrote:
> 
>> On Tue, Sep 7, 2010 at 7:21 PM, Brendan Eich <brendan at mozilla.com> wrote:
>>> Anyone know of bad advice somewhere, or a code generator doing the prepending,
>>> or anything else we should evangelize aggressively either to stop pasting "use strict";
>>> blindly, or do do the testing to make sure the code passes in a conforming ES5
>>> implementation
>> 
>> JSLint.com (which is an awesome tool that I use pretty much every day)
>> tells you to add "use strict" if you choose the "Good Parts" option.
>> Its documentation says to "use it wisely", but people don't usually
>> read the docs.
>> 
>> Maybe JSLint should be fixed to disallow non-strict code with "use
>> strict;". The following code is said to be OK by JSLint with "Good
>> Parts" at the moment:
>> 
>> /*global window */
>> "use strict";
>> 
>> function someFun() {
>>   window.alert(arguments.callee);
>> }
>> 
>> someFun();
>> 
>> I'm not sure whether people often run concatenated scripts through
>> tools like JSLint, though. So maybe it should also warn you not to
>> concatenate scripts blindly...
>> 
>> PS. I already wrote most of the above in the Intel bug in Mozilla's
>> Bugzilla, but now I think posting it here makes more sense.
>> 
>> -- 
>> Marek Stępień
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list