lancew/DojoList

View on GitHub

Showing 1,940 of 1,940 total issues

Expected '===' and instead saw '=='.
Open

            if (args.zoom == 'large') {
Severity: Minor
Found in js/mapstraction.js by eslint

Require === and !== (eqeqeq)

It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

  • [] == false
  • [] == ![]
  • 3 == "03"

If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

Rule Details

This rule is aimed at eliminating the type-unsafe equality operators.

Examples of incorrect code for this rule:

/*eslint eqeqeq: "error"*/

if (x == 42) { }

if ("" == text) { }

if (obj.getStuff() != undefined) { }

The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

Options

always

The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

Examples of incorrect code for the "always" option:

/*eslint eqeqeq: ["error", "always"]*/

a == b
foo == true
bananas != 1
value == undefined
typeof foo == 'undefined'
'hello' != 'world'
0 == 0
true == true
foo == null

Examples of correct code for the "always" option:

/*eslint eqeqeq: ["error", "always"]*/

a === b
foo === true
bananas !== 1
value === undefined
typeof foo === 'undefined'
'hello' !== 'world'
0 === 0
true === true
foo === null

This rule optionally takes a second argument, which should be an object with the following supported properties:

  • "null": Customize how this rule treats null literals. Possible values:
    • always (default) - Always use === or !==.
    • never - Never use === or !== with null.
    • ignore - Do not apply this rule to null.

smart

The "smart" option enforces the use of === and !== except for these cases:

  • Comparing two literal values
  • Evaluating the value of typeof
  • Comparing against null

Examples of incorrect code for the "smart" option:

/*eslint eqeqeq: ["error", "smart"]*/

// comparing two variables requires ===
a == b

// only one side is a literal
foo == true
bananas != 1

// comparing to undefined requires ===
value == undefined

Examples of correct code for the "smart" option:

/*eslint eqeqeq: ["error", "smart"]*/

typeof foo == 'undefined'
'hello' != 'world'
0 == 0
true == true
foo == null

allow-null

Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

["error", "always", {"null": "ignore"}]

When Not To Use It

If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

'f' is already defined.
Open

                    for (var f = 0; f < this.filters.length; f++) {
Severity: Minor
Found in js/mapstraction.js by eslint

disallow variable redeclaration (no-redeclare)

In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

Rule Details

This rule is aimed at eliminating variables that have multiple declarations in the same scope.

Examples of incorrect code for this rule:

/*eslint no-redeclare: "error"*/

var a = 3;
var a = 10;

Examples of correct code for this rule:

/*eslint no-redeclare: "error"*/

var a = 3;
// ...
a = 10;

Options

This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

builtinGlobals

Examples of incorrect code for the { "builtinGlobals": true } option:

/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/

var Object = 0;

Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
/*eslint-env browser*/

var top = 0;

The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

'theInfo' is already defined.
Open

        var theInfo = this.infoDiv;
Severity: Minor
Found in js/mapstraction.js by eslint

disallow variable redeclaration (no-redeclare)

In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

Rule Details

This rule is aimed at eliminating variables that have multiple declarations in the same scope.

Examples of incorrect code for this rule:

/*eslint no-redeclare: "error"*/

var a = 3;
var a = 10;

Examples of correct code for this rule:

/*eslint no-redeclare: "error"*/

var a = 3;
// ...
a = 10;

Options

This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

builtinGlobals

Examples of incorrect code for the { "builtinGlobals": true } option:

/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/

var Object = 0;

Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

/*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
/*eslint-env browser*/

var top = 0;

The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

Heading (h2) has already been defined.
Open

#sidebar h2 {
Severity: Minor
Found in css/style.css by csslint

Using height with padding can sometimes make elements larger than you expect.
Open

    padding: 8px 0 2px 10px;
Severity: Minor
Found in css/style.css by csslint

Heading (h4) has already been defined.
Open

h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;}
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Heading (h1) has already been defined.
Open

h1 {font-size:3em;line-height:1;margin-bottom:0.5em;}
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Heading (h6) has already been defined.
Open

h6 {font-size:1em;font-weight:bold;}
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Rule doesn't have all its properties in alphabetical order.
Open

input.text, input.title {width:300px;padding:5px;}
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Rule doesn't have all its properties in alphabetical order.
Open

textarea {width:390px;height:250px;padding:5px;}
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Rule doesn't have all its properties in alphabetical order.
Open

#calendar tbody td {
Severity: Minor
Found in css/style.css by csslint

Heading (h3) has already been defined.
Open

         h3 {
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Heading (h1) has already been defined.
Open

h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;}
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Don't use IDs in selectors.
Open

         #header {
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Heading (h2) should not be qualified.
Open

#sidebar h2 {
Severity: Minor
Found in css/style.css by csslint

Heading (h2) has already been defined.
Open

h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;}
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Unexpected alert.
Open

                    alert('browser not compatible with Google Maps');
Severity: Minor
Found in js/mapstraction.js by eslint

Disallow Use of Alert (no-alert)

JavaScript's alert, confirm, and prompt functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. Furthermore, alert is often used while debugging code, which should be removed before deployment to production.

alert("here!");

Rule Details

This rule is aimed at catching debugging code that should be removed and popup UI elements that should be replaced with less obtrusive, custom UIs. As such, it will warn when it encounters alert, prompt, and confirm function calls which are not shadowed.

Examples of incorrect code for this rule:

/*eslint no-alert: "error"*/

alert("here!");

confirm("Are you sure?");

prompt("What's your name?", "John Doe");

Examples of correct code for this rule:

/*eslint no-alert: "error"*/

customAlert("Something happened!");

customConfirm("Are you sure?");

customPrompt("Who are you?");

function foo() {
    var alert = myCustomLib.customAlert;
    alert();
}

Related Rules

Rule doesn't have all its properties in alphabetical order.
Open

#footer p {
Severity: Minor
Found in css/style.css by csslint

Rule doesn't have all its properties in alphabetical order.
Open

         h1 {
Severity: Minor
Found in lib/limonade/public/css/screen.css by csslint

Unexpected newline between function and ( of function call.
Open

                    ( {
Severity: Minor
Found in js/mapstraction.js by eslint

disallow confusing multiline expressions (no-unexpected-multiline)

Semicolons are usually optional in JavaScript, because of automatic semicolon insertion (ASI). You can require or disallow semicolons with the [semi](./semi.md) rule.

The rules for ASI are relatively straightforward: As once described by Isaac Schlueter, a newline character always ends a statement, just like a semicolon, except where one of the following is true:

  • The statement has an unclosed paren, array literal, or object literal or ends in some other way that is not a valid way to end a statement. (For instance, ending with . or ,.)
  • The line is -- or ++ (in which case it will decrement/increment the next token.)
  • It is a for(), while(), do, if(), or else, and there is no {
  • The next line starts with [, (, +, *, /, -, ,, ., or some other binary operator that can only be found between two tokens in a single expression.

In the exceptions where a newline does not end a statement, a typing mistake to omit a semicolon causes two unrelated consecutive lines to be interpreted as one expression. Especially for a coding style without semicolons, readers might overlook the mistake. Although syntactically correct, the code might throw exceptions when it is executed.

Rule Details

This rule disallows confusing multiline expressions where a newline looks like it is ending a statement, but is not.

Examples of incorrect code for this rule:

/*eslint no-unexpected-multiline: "error"*/

var foo = bar
(1 || 2).baz();

var hello = 'world'
[1, 2, 3].forEach(addNumber);

let x = function() {}
`hello`

let x = function() {}
x
`hello`

Examples of correct code for this rule:

/*eslint no-unexpected-multiline: "error"*/

var foo = bar;
(1 || 2).baz();

var foo = bar
;(1 || 2).baz()

var hello = 'world';
[1, 2, 3].forEach(addNumber);

var hello = 'world'
void [1, 2, 3].forEach(addNumber);

let x = function() {};
`hello`

let tag = function() {}
tag `hello`

When Not To Use It

You can turn this rule off if you are confident that you will not accidentally introduce code like this.

Note that the patterns considered problems are not flagged by the [semi](semi.md) rule.

Related Rules

Severity
Category
Status
Source
Language