Zhami
Zhami

Reputation: 19153

JSLint: I can't appease it on whitespace in a "var" statement

I use JSLint and have a huge library of code that is 100% JSLint clean. As of 1.20.2011, JSLint reports errors whitespacing errors on every var statement. Take, for example, this (now hollowed out) function:

var dateStrFromTimestamp;
dateStrFromTimestamp = function (t) {
    "use strict";
    var a, d;
    d = new Date(t * 1000);
    a = [];
};

JSLint reports:

Problem at line 1 character 5: Expected 'dateStrFromTimestamp' at column 3, not column 5.

    var dateStrFromTimestamp;

Problem at line 4 character 7: Expected 'a' at column 5, not column 7.

    var a, d;

How am I supposed to write my code? If I follow the recommendation, I'd have to remove the whitespace after the keyword "var" -- but that can't be. So, is the current version of JSLint buggy? Or am I currently blind to something obvious?

Upvotes: 3

Views: 4774

Answers (2)

duncan
duncan

Reputation: 31912

Looks like he's fixed it. I continued getting the problem, then did a Shift+refresh to clear his JS file from my cache, and that seemed to fix it I think.

Upvotes: 2

JB Nizet
JB Nizet

Reputation: 691635

This is probably because you mixed tabs ans spaces, and JSLint supposes that a tab is the equivalent of 4 spaces.

Upvotes: 0

Related Questions