Quantcast
Channel: James Wiseman » Standards and Best Practice
Browsing index pages (15 articles)
↧

JSLint Messages – Coding Convention and Style Guide

Why Bother? JSLint contains a number of messages pertaining to the style, appearance and formatting of JavaScript code. This includes stipulations about bracing positions, indentation and spacing. As a...

View Article


Image may be NSFW.
Clik here to view.

JSLint Messages – Do not wrap function literals in parens unless they are to...

In JavaScript we can assign a function expression to a variable, like so: var foo = function() { return 1; }; //assign function expression to 'foo' This is perfectly valid, and often useful. It is also...

View Article


JSLint Messages – Wrap an immediate function invocation in parentheses…

This is the longest error message that JSLint boasts. In full it reads: “Wrap an immediate function invocation in parentheses to assist the reader in understanding that the expression is the result of...

View Article

JSLint Messages – Missing name in function statement

JSLint reports this error when a function name has been omitted from a functions statement. For example: function(a) { alert(a); } It is possible that the original intention was more like the...

View Article

JSLint Messages – Function statements should not be placed in blocks

This message was acutally too long for the subject title. In full, it reads: “Function statements should not be placed in blocks. Use a function expression or move the statement to the top of the outer...

View Article


JSLint Messages – Move the invocation into the parens that contain the function

With this message we move deep into the heart of JavaScript closures. Without wanting to engage into a discussion about what they or their relative merits are, we can examine how this message might...

View Article

JSLint Messages – Use the array literal notation []

JSLint has very specific constraints about how you use new. This message is displayed when JSLint encounters an object that has been constructed using new Array() instead of simply = []. In JavaScript...

View Article

JSLint Messages –‘{a}’ is a function.

JavaScript functions can be written as a declaration or as expression, as in the following examples: function a(){} //function declaration var a = function(){}; //function expression The first line...

View Article


Image may be NSFW.
Clik here to view.

JSLint Messages – Bad Assignment

JSLint prompts you with this message when it encounters what it perceives to be a dangerous, or “bad” assignment. For example: document.getElementById("text"+x) = function(){}; In the above code, we...

View Article


JSLint Messages – Don’t make functions within a loop.

In JavaScript we can declare a function anonymously, and using a concept known as late-binding we can attach the event to an HTML object: document.getElementById("control").onclick =...

View Article

JSLint Messages – Expected to see a statement and instead saw a block.

A programming convention that is frequently carried into JavaScript from other languages (often by C++ and C developers)  is the scoping of functionality within isolated blocks of code (i.e. between...

View Article

JSLint Messages – A leading decimal point can be confused with a dot ‘.{a}’

With this message, JSLint is warning you of a potentially hazardous use of the decimal point. The following code will yield this error: alert(.2); Here. JSLint is picking out conventions that may be...

View Article

JSLint Messages – A trailing decimal point can be confused with a dot ‘{a}’.

I kept stumbling across this one when investigating the message A dot following a number can be confused with a decimal point. This particular message proved easier to produce than the aforementioned...

View Article


Image may be NSFW.
Clik here to view.

JSLint Messages – A dot following a number can be confused with a decimal point.

This is a strange one, and took  some tracking down. Most attempts to bring about this message merely yielded another similar message: A trailing decimal point can be confused with a dot ‘{a}’....

View Article

JSLint Messages – Expected a conditional expression and instead saw an...

It could be argued that this is one of the family of messages under Expected ‘{a}’ and instead saw ‘{b}’. One of my university professor referred to as ‘error 1′, because it was the single most common...

View Article

Browsing index pages (15 articles)


Latest Images