Post has attachment
JSLint expects methods/objects of window to be predicated on window being declared as a global variable. Okay, no prob. JSLint also expects that sessionStorage be made explicit as window.sessionStorage. Okay, again.

However...the advanced compilation setting on the Google Closure Compiler rejects a reference to window.sessionStorage when it is returning a string in a JSON parse, instead requiring simply sessionStorage. E.g.:

JSON.parse(window.sessionStorage.getItem("chart")); // this works in JSLint, provided that window has been declared as a global, but the Google Closure Compiler rejects it in its advanced settings

JSON.parse(sessionStorage.getItem("chart")); // this fails in JSLint, but succeeds in the Google Closure Compiler in its advanced settings

How do I satisfy both JSLint and the Google Closure Compiler?

See: https://closure-compiler.appspot.com/home

The Software Crisis is 50 years old this year.

According to the JSLint spec:

JSLint introduces a new reserved word: ignore. It is used in parameter lists and in catch clauses to indicate a parameter that will be ignored. Unused warnings will not be produced for ignore.

function handler(ignore, value) {
return do_something_useful(value);
}

But what if I have more than one parameter that needs to be ignored in a function definition (this has come up with AJAX calls). I've tried ignore1, ignore2, etc., but those aren't recognized.

The comment-based solution /jslint unparam: true/ isn't tenable here. What can be done? (Can JSLint be revised to handle more than one appropriately named ignore parameter in these cases?)

JSLint objects to a standard JQuery ajax code:

$.ajax({
statusCode: {
404: function() {
alert( "page not found" );
}
}
});

JSLint responds:
Expected an identifier and instead saw '404'.
404: function() {

What is the solution? (Writing 404 as a string, i.e., "404"? But will that break the JQuery ajax call?

Post has attachment

option.convert

JSLint now prefers Number(x) to +x, Boolean(x) to !!x, and String(x) to "" + x and x + "".

There is a new "Tolerate conversion operators" option (convert), that will suppress those warnings.

var Number = 123;
var JSON = "foo";
var parseInt = "bar";

JSLint should warn when trying to write to a standard built-in variable (unless you are writing a polyfill for it).

JSLint won't allow to check whether a variable is a symbol:

const s = Symbol();
const isSymbol = typeof s === "symbol";

Expected a type string and instead saw 'symbol'.

/*jslint getset */
const math = {
get random() {
"use strict";
Math.random();
}
};

JSLint should warn when there is no "return" in a getter.

I propose that JSLint should warn on implicit type coercion.

These notations can be confusing:

var foo = !!bar;
var foo = +bar;
var foo = "" + bar;

These notations are explicit and self-explanatory, and therefore better:

var foo = Boolean(bar);
var foo = Number(bar);
var foo = String(bar);
Wait while more posts are being loaded