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
36
votes
2 answers

How to use files with multiple extensions with Prettier?

I have following Prettier commands: prettier --parser typescript --write ./src/**/*.ts prettier --parser typescript --write ./src/**/*.tsx I would like to merge them to single one - use some king of regex to listen (write) on both .ts and also .tsx…
Jurosh
  • 6,984
  • 7
  • 40
  • 51
35
votes
2 answers

Why is JSLint wanting me to use double quotes instead of single quotes? Expected '"' and instead saw '''

I recently started seeing JSLint giving the following warning: JSLint: Expected '"' and instead saw '''. In other words, it's wanting me to use double quotes instead of single quotes. Why is JSLint warning me about that? Aren't single quotes and…
Thunderforge
  • 19,637
  • 18
  • 83
  • 130
34
votes
2 answers

How to turn off JSLint indentation warnings?

I find that JSLint produces lots of warnings of the form: Expected 'foo' to have an indentation at X instead at Y. The JSLint options documentation describes an indent option that recognizes a numerical value representing the amount of space for…
Greg Mattes
  • 33,090
  • 15
  • 73
  • 105
33
votes
8 answers

Any tool to automatically fix simple JSLint issues?

I've run JSLint for the first time on a rather lengthy file, and I have a lot of errors like expected exactly 1 space between "function" and "(" or unexpected ' '. I didn't realize this was important at all anywhere I learned about javascript and…
Damon
  • 10,493
  • 16
  • 86
  • 144
33
votes
5 answers

JavaScript: JSLint error "The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype"

I'm using the JSLint tool to ensure my JavaScript is "strict". I'm receiving the following error but don't understand how to fix it: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype For the…
HeatherK
  • 2,293
  • 4
  • 20
  • 12
33
votes
1 answer

JSLint - ignore sections of code

I have a huge script that passes JSLint (including avoidance of all bad parts). Except for one stretch, which is some very convoluted obfuscated code that is embedded within the larger context. JSLint generates quite a bit of complaints for this…
Zhami
  • 19,033
  • 14
  • 48
  • 47
33
votes
2 answers

Purpose of JSLint "disallow insecure in regex" option

I have a line of code that gets the following error when run through JSLint: Lint at line 604 character 48: Insecure '^'. numExp = parseInt(val[1].replace(/[^\-+\d]/g, ""), 10); This error seems to refer to the following description from JSLint's…
Jon Bringhurst
  • 1,340
  • 1
  • 10
  • 21
33
votes
3 answers

Using JSLint in Notepad++

I have seen other text editors use extensions to allow syntax checkers such as JSLint, is this possible with Notepad++?
alumb
  • 4,401
  • 8
  • 42
  • 52
32
votes
2 answers

How can you trigger the "What the hell is this?" JSLint message?

JSLint has some interesting messages, such as eval is evil. when you use an eval statement, and Weird relation. when comparing two literals, e.g. 1 == 2. I was looking through a list of the JSLint messages, and noticed this one at the bottom of the…
Peter Olson
  • 139,199
  • 49
  • 202
  • 242
32
votes
6 answers

Why should you not use Number as a constructor?

I entered this statement in JSLint: var number = new Number(3); And received the following message: Do not use Number as a constructor. Why is that? The statement is creating a number object, not a primitive value, so I don't see why using new is…
GR1000
31
votes
2 answers

Unexpected 'continue'

I have: while (i < l) { if (one === two) { continue; } i++; } But JSLint says: Problem at line 1 character 20: Unexpected 'continue'. if (one === two) { continue; } What mistake did I make? How should my code really look?
asifg
  • 411
  • 2
  • 5
  • 5
31
votes
3 answers

Is it possible to validate my jQuery JavaScript with JSLint?

I wanted to check my JavaScript with JSLint. I am also using jQuery and JSLint seems to be very unhappy about jQuery. So, if I have this code: $(document).ready{ $("a").click(function() { // foo }); }); I am getting a few JSLint…
newtogit
  • 553
  • 1
  • 8
  • 11
31
votes
2 answers

Solution for JSLint errors

I have started using JSLint. I checked my code and I am getting this errors: Problem at line 92 character 7: Move the invocation into the parens that contain the function. })(); Problem at line 92 character 7: Wrap the entire immediate function…
Yosy
30
votes
4 answers

How do I install JSLint on Ubuntu?

How do I install JSLint on Ubuntu? I downloaded the source jsl-0.3.0-src.tar.gz from http://www.javascriptlint.com/download.htm and then extracted it to a dir called jsl-0.3.0 on my Desktop. I then moved it to /usr/local/bin which I have read is my…
user883807
29
votes
16 answers

Is there an offline version of JSLint for Windows?

I would like to check my JavaScript files without going to JSLint web site. Is there a desktop version of this tool for Windows?
z-boss
  • 17,111
  • 12
  • 49
  • 81