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

Does the type of quotes matter when using use strict?

I was wondering since I'm trying to use use strict, does it matter if I go with "use strict" or 'use strict'? Is any of those a «more correct» option?
Zentaurus
  • 758
  • 2
  • 11
  • 27
22
votes
3 answers

JSHint: How do disable the check for unsafe characters for comments?

When using "unsafe characters" (e.g. umlauts) in comments I get the following error: This character may get silently deleted by one or more browsers. Is there any way to disable this check for comments (globally)?
jpo
  • 2,550
  • 2
  • 19
  • 16
21
votes
10 answers

Maven plugins to analyze javascript code quality

Javascript code can be tough to maintain. I am looking for tools that will help me ensure a reasonable quality level. So far I have found JsUNit, a very nice unit test framework for javascript. Tests can be run automatically from ant on any browser…
Alexandre Victoor
  • 3,104
  • 2
  • 27
  • 27
21
votes
2 answers

Justifying Crockford claims

I have read Crockford's JavaScript: The Good Parts and have used his validator JSLint. I am sometimes left wondering the justification behind his recommendations. Below is a list of examples I want substantiated. Why does JSLint signal an error if…
Randomblue
  • 112,777
  • 145
  • 353
  • 547
21
votes
4 answers

JavaScript catch parameter already defined

I'm trying to understand why I'm getting the following error, not how to work around it. Passing the following code to JSLint or JSHint yields the error 'err' is already defined. /*jslint white: true, devel: true, onevar: true, browser: true, undef:…
Walt Stoneburner
  • 2,562
  • 4
  • 24
  • 37
21
votes
3 answers

handle-callback-err Expected error to be handled

I have eslint enabled in my vue webapp, I have following code: myApi.get('products/12').then((prodResponse) => { state.commit('ADD_PRODUCT', {product: prodResponse.data}) }, error => { console.log('Inside error, fetching product line items…
Saurabh
  • 71,488
  • 40
  • 181
  • 244
21
votes
3 answers

Suddenly Jslint plugin refuses to work (JSLint can operate only on JavaScript....)

Suddenly the JSLint plugin of my notepad++ stopped to work. Whenever i try to parse a .js file, it output this warning: JSLint can operate only on JavaScript, HTML or CSS files. The file is named main.js, and it's obviously a javascript file. It…
gerryino
  • 380
  • 2
  • 7
21
votes
6 answers

What side effects does the keyword 'new' have in JavaScript?

I'm working on a plug-in for jQuery and I'm getting this JSLint error: Problem at line 80 character 45: Do not use 'new' for side effects. (new jQuery.fasterTrim(this, options)); I haven't had much luck finding info on this JSLint error or on any…
travis
  • 35,751
  • 21
  • 71
  • 94
21
votes
6 answers

How should I define a JavaScript 'namespace' to satisfy JSLint?

I want to be able to package my JavaScript code into a 'namespace' to prevent name clashes with other libraries. Since the declaration of a namespace should be a simple piece of code I don't want to depend on any external libraries to provide me…
Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
20
votes
2 answers

jslint error: Unexpected 'in'. Compare with undefined, or use the hasOwnProperty

I have the following javascript function that fails a jslint check function hasActiveX() { return ('ActiveXObject' in window); } jslint error Unexpected 'in'. Compare with undefined, or use the hasOwnProperty method instead. should I just…
house9
  • 20,359
  • 8
  • 55
  • 61
20
votes
5 answers

How to make JSLint scan the whole file?

I am using JSLint to scan some Javascript code for potential errors. I'm using Notepad++ with the JSLint plugin. The problem is - it just scans, say x% of file and then stops. I have unchecked the Stop on first error option too but I get the same…
TheRookierLearner
  • 3,643
  • 8
  • 35
  • 53
20
votes
2 answers

Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function

I have the following code: if (typeof console === "object" && typeof console.error === "function") { function e(msg) {"use strict"; console.info(msg);} } For which jsLint gives the following error: Function statements should not be placed in…
Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291
18
votes
6 answers

JSLint warns that "document" is not fully defined on jQuery(document).ready

I get a 'document' has not been fully defined yet. $(document).ready(function () { warning from jsLint. I get why this happends but I would like my code to be warning free. My question is - how do I either solve this in code (assign document…
Ben
  • 10,020
  • 21
  • 94
  • 157
18
votes
1 answer

JSLint error: Expected 'ignore' and instead saw 'ex'

I use JSLint all the time, but just today, I came across an error that I've never seen before. With the following code, I got the error shown below: try { document.execCommand('BackgroundImageCache', false, true); } catch (ex)…
HartleySan
  • 7,404
  • 14
  • 66
  • 119
18
votes
1 answer

Pragmatic and widely agreed settings for jshint

We're just starting to use JSHint / JSLint and are looking for some "best practice" type settings that are widely considered to be a good compromise between strictness and pragmatism. I've had a look on the internet and not really been able to find…
cedd
  • 1,741
  • 1
  • 21
  • 34