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
14
votes
3 answers

window.location.href = window.location.href and JSLint

If using window.location.href = window.location.href; to reload a page (without re-POSTing) is not bad practice, what should we make of JSLint's "Weird assignment" complaint? EDIT window.location.reload() is not suitable when you don't want to POST…
user213154
14
votes
2 answers

How to ignore '$' is not defined JsLint Error. (Visual Studio 2010 JsLint Extentsion)

I am trying to get my error count down. Lots of the things that JsLint complains about I don't find are really errors but more personal preference in my option(like braces on their own line). It comes up with JS Lint: '$' is not defined. In all…
chobo2
  • 83,322
  • 195
  • 530
  • 832
14
votes
4 answers

JSLint Error Report - Whats wrong with this?

I got this error and dont know what could be the cause. Any idea? Problem at line 2127 character 18: Bad for in variable 'sport'. for (sport in sugested_sports) // make array var sugested_sports = data.split(","); …
Björn
  • 12,587
  • 12
  • 51
  • 70
14
votes
3 answers

Treat the use of @author as code style violation

Goal: Issue a warning in case an @author tag is used anywhere inside the .js files in the project. Question: Is it something that jshint or other static code check tools can help with? If not, what options do I have? Description: I completely agree…
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
14
votes
2 answers

jslint: why does this code result in a "Strict violation" error message?

Running the following simple code results in a "Strict violation." error message. I have been trying to find documentation on why, and how to fix it. Any input will be much appreciated. The error: Error: Problem at line 6 character 4: Strict…
Egil Hansen
  • 15,028
  • 8
  • 37
  • 54
14
votes
1 answer

Why does NodeJS prefer the comma-first coding style?

I have been learning NodeJS recently. It seems to be standard in the Node world to write code with commas first: var connect = require('connect') , HTTPSServer = require('./https') , HTTPServer = require('./http') , Route =…
jamjam
  • 3,171
  • 7
  • 34
  • 39
13
votes
2 answers

JSLint and Bookmarklets

I'm running JSLint checks in Rhino using jslintant.js. I found something a bit strange and was wondering if I could gets some input from other programmers. Basically, the following line gets a JSLint 'Script URL' error: var a = '
Steven de Salas
  • 20,944
  • 9
  • 74
  • 82
13
votes
3 answers

how to fix jslint message Insecure '.'

jslint reports message Insecure '.'. at line html = /([\s\S]*)<\/body>/.exec(responseText); How to fix this ? Update After body and before closing bracket there may be attributes so \s? cannot used. Javascript is running in browser, jQuery…
Andrus
  • 26,339
  • 60
  • 204
  • 378
13
votes
5 answers

How do I safely "eval" user code in a webpage?

I'm working on a webapp to teach programming concepts. Webpages have some text about a programming concept, then let the user type in javascript code into a text editor window to try to answer a programming problem. When the user clicks "submit",…
Nathan Whitehead
  • 1,942
  • 2
  • 16
  • 19
13
votes
3 answers

How do I address the JSLint warning "Do not use 'new' for side effects"?

Why do I get these errors? Problem at line 329 character 60: Do not use 'new' for side effects. new widget.StyledDropdown(dojo.byId("sTitle")); Problem at line 330 character 61: Do not use 'new' for side effects. new…
Amen Ra
  • 2,843
  • 8
  • 47
  • 85
13
votes
1 answer

JSlint on TypeScript code - can it still teach me to write better code?

Can using JSlint on TypeScript generated code still teach me to write better code? If yes en can you please provide one or two examples? Thanks
daniel.sedlacek
  • 8,129
  • 9
  • 46
  • 77
13
votes
2 answers

Putting ; at the end of a function definition

Why is it considered best practise to put a ; at the end of a function definition. e.g. var tony = function () { console.log("hello there"); }; is better than: var tony = function () { console.log("hello there"); }
More Than Five
  • 9,959
  • 21
  • 77
  • 127
13
votes
7 answers

JSLint "eval is evil." alternatives

I am have some JavaScript functions that run on both the client (browser) and the server (within a Java Rhino context). These are small functions - basically little validators that are well defined and don't rely upon globals or closures -…
Jake Feasel
  • 16,785
  • 5
  • 53
  • 66
12
votes
1 answer

JSLint "document.write can be a form of eval" - How is this so?

I've come across this message in JSLint... document.write can be a form of eval. and was wondering exactly how so? The JSLint instructions page states: The eval function...provide access to the JavaScript compiler. This is sometimes…
James Wiseman
  • 29,946
  • 17
  • 95
  • 158
12
votes
2 answers

Defining JavaScript functions

In my project (browser context only) I want to use a JS code quality tool. I've tried both jslint and eslint. I want linter to help me make my code clean, clear, errorproof and improve its overall quality. What I don't want to do is I don't want to…
Kolyunya
  • 5,973
  • 7
  • 46
  • 81