Questions tagged [jslint]

JSLint is a "code quality" tool for JavaScript developed by Douglas Crockford, a well-known developer also responsible for JSON, JSMin, ADSafe and parts of YUI. JSLint is parallel to C's lint.

JSLint is a static analysis “code quality” tool for JavaScript developed by Douglas Crockford, a well-known developer also responsible for JSON, JSMin, ADSafe and parts of YUI.

The term “linting” originates from fabric lint-rollers that help remove fluff from clothing. In the same way, a code “linter” helps the developer remove fluff from their code.

The first linting tool was developed for the C programming language when early compilers were not sophisticated enough to identify common programming errors. As the language and compilers matured, so the C linter became redundant and obsolete.

As much of the JavaScript written will not have been near a compiler, the requirement for an equivalent linting tool emerged. This is where JSLint comes in.

A similar tool, exists. It was forked from JSLint.

In the words of its creator:

Warning!

JSLint will hurt your feelings.

Resources

Related Tags

1004 questions
46
votes
1 answer

lint warning: parseInt missing radix parameter

I have the following code that gives the warning described in the title: year: parseInt(dateParts[0]), ......................^ Any help is much appreciated
user1723894
  • 599
  • 1
  • 4
  • 6
45
votes
9 answers

JSLint: control comments (selective ignore)

Does JSLint have anything like JavaScript Lint's control comments (e.g. /*jsl:fallthru*/) to make it ignore certain passages?
AnC
45
votes
5 answers

Why does JSHint argue against bitwise operators? How should I express this code?

I am using this bit of JavaScript to generate a UID: (original:) //If ID has not been defined then generate a new unique ID. if(!id){ id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v =…
Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
43
votes
5 answers

Suppress "Expected '===' and instead saw '=='." error in jslint

How can I stop the error message Expected '===' and instead saw '=='. from appearing in jslint. Doesn't seem to be an option.
usertest
  • 27,132
  • 30
  • 72
  • 94
43
votes
3 answers

JSLint "insecure ^" in regular expression

JSLint reports Insecure '^' for the following line. Why is that? Or is it just going to complain any time I want to negate a character class? // remove all non alphanumeric, comma and dash characters "!$7s-gd,&j5d-a#".replace(/[^\w,\-]/g, '');
Thomas R
  • 3,026
  • 5
  • 32
  • 31
43
votes
1 answer

JSLint's 'Tolerate Stupidity'

Anyone know what JSLint's 'Tolerate Stupidity' option is all about? What family of warnings does it disable? I've found some reference to Node.js and "Sync" methods (including Crockford's comment that "it is very well named") but no clear…
biril
  • 1,975
  • 1
  • 19
  • 30
43
votes
3 answers

Suppress "mixed spaces and tabs" warning in JSHint / JSLint or alternative service?

JSHint and JSLint are awesome tools. However, the "mixed spaces and tabs" warning dominates the report. Is there a way to suppress these warnings, or is there a similar service that allows white space warnings to get suppressed?
Crashalot
  • 33,605
  • 61
  • 269
  • 439
42
votes
6 answers

JSLint Error: Unexpected 'this'

Having trouble understanding why JSLint is surprised by my use of this in the following code: function testConstr (x) { 'use strict'; this.joker = "Whyyy sooo seriousss?"; this.x = x; } For both property assignments, JSLint says:…
jdw
  • 3,755
  • 3
  • 17
  • 16
41
votes
5 answers

What's wrong with var x = new Array();

In JSLint, it warns that var x = new Array(); (That's not a real variable name) should be var result = []; What is wrong with the 1st syntax? What's the reasoning behind the suggestion?
Chris S
  • 64,770
  • 52
  • 221
  • 239
41
votes
2 answers

Where can I find a list of JSHint numeric error codes?

I'm using JSHint for Visual Studio. It's not uncommon for JSHint to issue a warning about an issue that I know it safe to ignore. I have been putting // ignore jslint on the relevant line, but I see that we can also ignore specific error codes. …
Josh
  • 7,232
  • 8
  • 48
  • 75
40
votes
4 answers

Angular-cli : Using ng lint

I'm aware the angular-cli uses codelyzer which uses lint.js When using the command: ng lint Can it automatically fix formatting? or will it only notify of formatting errors? ng lint --help outputs all help commands for the angular-cli.
Ben Winding
  • 10,208
  • 4
  • 80
  • 67
39
votes
4 answers

Expected an assignment or function call and instead saw an expression

I'm totally cool with this JSLint error. How can I tolerate it? Is there a flag or checkbox for it? You get it when you do stuff like: v && arr.push(v); as opposed to: if (v) { arr.push(v); } Both do the same exact thing. If you put:…
ryanve
  • 50,076
  • 30
  • 102
  • 137
39
votes
7 answers

Getting Facebook's react.js library JSX syntax to play nicely with jslint?

I am playing around with the Facebook's react.js library. I am trying to use their JSX syntax which describes creating a view in the following way. /** @jsx React.DOM */ var HelloMessage = React.createClass({ render: function() { return…
TYRONEMICHAEL
  • 4,174
  • 4
  • 30
  • 47
39
votes
3 answers

Have jshint ignore certain files when building Twitter Bootstrap

I often have this problem when using Twitter Bootstrap with other 3rd-party JS libraries, such as html5.js from WordPress' "Twenty Twelve" theme, where the build fails because jshint (or jslint in previous versions of TB I think) throws an error due…
Lèse majesté
  • 7,923
  • 2
  • 33
  • 44
38
votes
3 answers

Jquery and Jslint - '$' was used before it was defined

I have some third party javascript im working with, I added some jquery code into it the javascript file. But it seems to fail on the above code when validating using Jslint '$' was used before it was defined. I can see at the top of the…
user1555190
  • 2,803
  • 8
  • 47
  • 80