Skip to main content
Jump to: navigation, search

Difference between revisions of "Orion/ESLint"

(Rules)
Line 1: Line 1:
Orion 5.0 will replace our current [http://www.jslint.com/ JSLint validator] with [https://github.com/nzakas/eslint/ ESLint]. This page captures ongoing issues.
+
Orion 5.0 will replace our current [JSLint validator with [https://github.com/nzakas/eslint/ ESLint]. This page captures ongoing issues.
  
 
== Rules ==  
 
== Rules ==  
Here's a table showing the equivalent validation rules in JSLint and ESLint. If a rule has no "JSLint option", then JSLint always enforces it and it cannot be disabled.
+
Here's a table showing the equivalent validation rules in JSLint and ESLint. Rules that JSLint does not support are marked as Unsupported. If a rule has "-" in the JSLint option field, then JSLint always enforces it and it cannot be disabled.
  
 
{| class="wikitable" border="1" style="width: 100%;"
 
{| class="wikitable" border="1" style="width: 100%;"
Line 12: Line 12:
  
 
| block-scoped-var
 
| block-scoped-var
| -
+
| Always on
 
| '''{variable}' is already defined.''
 
| '''{variable}' is already defined.''
 
|
 
|
Line 20: Line 20:
  
 
| brace-style
 
| brace-style
| -
+
| Unsupported
| (Not supported)
+
|  
 
|-
 
|-
  
 
| camelcase
 
| camelcase
| -
+
| Unsupported
| (Not supported)
+
|  
 
|-
 
|-
  
 
| complexity
 
| complexity
| -
+
| Unsupported
| (Not supported)
+
|  
 
|-
 
|-
  
 
| consistent-this
 
| consistent-this
| -
+
| Unsupported
| (Not supported)
+
|  
 
|-
 
|-
  
 
| curly
 
| curly
| -
+
| Always on
 
|
 
|
 
* ''Statement body should be inside '{ }' braces.'' (Orion)
 
* ''Statement body should be inside '{ }' braces.'' (Orion)
Line 69: Line 69:
  
 
| max-depth
 
| max-depth
| -
+
| Unsupported
| (Not supported)
+
|  
 
| Enforces max depth of nested blocks within a function.
 
| Enforces max depth of nested blocks within a function.
 
|-
 
|-
Line 81: Line 81:
  
 
| max-params
 
| max-params
| -
+
| Unsupported
| (Not supported)
+
|
 
|-
 
|-
  
 
| max-statements
 
| max-statements
| -
+
| Unsupported
| (Not supported)
+
|  
 
|-
 
|-
  
 
| new-cap
 
| new-cap
 
| '''newcap'''
 
| '''newcap'''
| A constructor name should start with an uppercase letter.
+
| ''A constructor name should start with an uppercase letter.''
 
|-
 
|-
  
 
| new-parens
 
| new-parens
| -
+
| Always on
 
| ''Missing '()' invoking a constructor.''
 
| ''Missing '()' invoking a constructor.''
 
| Flags <code>new Whatever</code>  
 
| Flags <code>new Whatever</code>  
Line 114: Line 114:
  
 
| no-caller
 
| no-caller
| -
+
| Unsupported
| (Not supported)
+
|  
 
| Flags references to <code>arguments.callee</code> and <code>arguments.caller</code>.
 
| Flags references to <code>arguments.callee</code> and <code>arguments.caller</code>.
 
|-
 
|-
Line 125: Line 125:
  
 
| no-comma-dangle
 
| no-comma-dangle
| -
+
| Always on
 
| Unexpected comma.
 
| Unexpected comma.
 
| Flags trailing commas in object literals.
 
| Flags trailing commas in object literals.
Line 152: Line 152:
  
 
| no-delete-var
 
| no-delete-var
| -
+
| Always on
 
| ''Expected '.' and instead saw ';'.''
 
| ''Expected '.' and instead saw ';'.''
 
| Flags an attempt to <code>delete</code> a local variable.
 
| Flags an attempt to <code>delete</code> a local variable.
Line 163: Line 163:
  
 
| no-dupe-keys
 
| no-dupe-keys
| -
+
| Always on
 
| ''Duplicate key '{a}'.''
 
| ''Duplicate key '{a}'.''
 
| Flags object literals that contain the same key more than once.
 
| Flags object literals that contain the same key more than once.
Line 184: Line 184:
  
 
| no-empty
 
| no-empty
| -
+
| Unsupported
| (Not supported)
+
|  
 
| Flags an empty block like <code>if (something) { }</code>
 
| Flags an empty block like <code>if (something) { }</code>
 
|-
 
|-
  
 
| no-eq-null
 
| no-eq-null
| -
+
| Always on
 
| ''Use '===' to compare with 'null'.''
 
| ''Use '===' to compare with 'null'.''
 
| JSLint produces a similar warning when comparing against <code>undefined</code>.
 
| JSLint produces a similar warning when comparing against <code>undefined</code>.
Line 201: Line 201:
  
 
| no-ex-assign
 
| no-ex-assign
| -
+
| Always on
 
| ''Do not assign to the exception parameter.''
 
| ''Do not assign to the exception parameter.''
 
|-
 
|-
  
 
| no-extra-semi
 
| no-extra-semi
| -
+
| Always on
 
| ''Unnecessary semicolon.''
 
| ''Unnecessary semicolon.''
 
|-
 
|-
Line 241: Line 241:
  
 
| no-label-var
 
| no-label-var
| -
+
| Always on
 
| '''{label}' is already defined.''
 
| '''{label}' is already defined.''
 
| Flags labels that collide with an identifier.
 
| Flags labels that collide with an identifier.
Line 247: Line 247:
  
 
| no-loop-func
 
| no-loop-func
| -
+
| Always on
 
| ''Don't make functions within a loop.''
 
| ''Don't make functions within a loop.''
 
|
 
|
Line 263: Line 263:
  
 
| no-native-reassign
 
| no-native-reassign
| -
+
| Always on
 
|
 
|
 
* ''Read only.''
 
* ''Read only.''
Line 276: Line 276:
  
 
| no-new-array
 
| no-new-array
| -
+
| Always on
 
| ''Use the array literal notation [].''
 
| ''Use the array literal notation [].''
 
| Flags <code>new Array()</code>
 
| Flags <code>new Array()</code>
Line 287: Line 287:
  
 
| no-new-object
 
| no-new-object
| -
+
| Always on
 
| ''Use the object literal notation {}.''
 
| ''Use the object literal notation {}.''
 
|-
 
|-
Line 297: Line 297:
  
 
| no-new
 
| no-new
| -
+
| Always on
 
| ''Do not use 'new' for side effects.''
 
| ''Do not use 'new' for side effects.''
 
| Flags uses of <code>new</code> operator in an expression that is not assigned to anything.
 
| Flags uses of <code>new</code> operator in an expression that is not assigned to anything.
Line 325: Line 325:
  
 
| no-proto
 
| no-proto
| -
+
| Always on
 
|
 
|
 
* ''Reserved name '__proto__'.'' (if used as an identifier)
 
* ''Reserved name '__proto__'.'' (if used as an identifier)
Line 333: Line 333:
  
 
| no-redeclare
 
| no-redeclare
| -
+
| Always on
 
| '''{a}' is already defined.''
 
| '''{a}' is already defined.''
 
| Usually results from having two <code>for</code> loops in the same function that share a loop variable declaration like <code>var i=...</code>.
 
| Usually results from having two <code>for</code> loops in the same function that share a loop variable declaration like <code>var i=...</code>.
Line 339: Line 339:
  
 
| no-return-assign
 
| no-return-assign
| -
+
| Unsupported
| (Not supported)
+
|  
 
| Prevents assignment in a <code>return</code> statement.
 
| Prevents assignment in a <code>return</code> statement.
 
|-
 
|-
Line 378: Line 378:
  
 
| no-undef-init
 
| no-undef-init
| -
+
| Always on
 
| ''It is not necessary to initialize '{variable}' to 'undefined'.''
 
| ''It is not necessary to initialize '{variable}' to 'undefined'.''
 
|  
 
|  
Line 402: Line 402:
  
 
| no-unused-expressions
 
| no-unused-expressions
| -
+
| Always on
 
| ''Expected an assignment or function call and instead saw an expression.''
 
| ''Expected an assignment or function call and instead saw an expression.''
 
| Flags expressions that appear in a statement context and don't cause side effects.
 
| Flags expressions that appear in a statement context and don't cause side effects.
Line 408: Line 408:
  
 
| no-unused-vars
 
| no-unused-vars
| -
+
| Always on
 
| ''Function declares unused variable '{a}'.'' (Orion)
 
| ''Function declares unused variable '{a}'.'' (Orion)
 
| Newer JSlint versions have an '''unparam''' option which works similarly.
 
| Newer JSlint versions have an '''unparam''' option which works similarly.
Line 414: Line 414:
  
 
| no-use-before-define
 
| no-use-before-define
| -
+
| Always on
 
| '''{a}' was used before it was defined.''
 
| '''{a}' was used before it was defined.''
 
|-
 
|-
  
 
| no-with
 
| no-with
| -
+
| Always on
 
| Expected an identifier and instead saw 'with'.
 
| Expected an identifier and instead saw 'with'.
 
| Treated as fatal parse error in JSLint.
 
| Treated as fatal parse error in JSLint.
Line 440: Line 440:
  
 
| quotes
 
| quotes
| -
+
| Unsupported
| (Not supported)
+
 
|  
 
|  
 
|-
 
|-
  
 
| radix
 
| radix
| -
+
| Always on
 
| ''Missing radix parameter.''
 
| ''Missing radix parameter.''
 
| Affects parseInt().
 
| Affects parseInt().
Line 452: Line 451:
  
 
| regex-spaces
 
| regex-spaces
| -
+
| Always on
 
| ''Spaces are hard to count. Use {n}.''
 
| ''Spaces are hard to count. Use {n}.''
 
|-
 
|-
  
 
| semi
 
| semi
| -
+
| Always on
 
| ''Missing semicolon.''
 
| ''Missing semicolon.''
 
|
 
|
Line 474: Line 473:
  
 
| use-isnan
 
| use-isnan
| -
+
| Always on
 
| ''Use the isNaN function to compare with NaN.''
 
| ''Use the isNaN function to compare with NaN.''
 
|-
 
|-
Line 488: Line 487:
  
 
| wrap-regex
 
| wrap-regex
| -
+
| Always on
 
| ''Wrap the /regexp/ literal in parens to disambiguate the slash operator.''
 
| ''Wrap the /regexp/ literal in parens to disambiguate the slash operator.''
 
|-
 
|-

Revision as of 19:27, 15 November 2013

Orion 5.0 will replace our current [JSLint validator with ESLint. This page captures ongoing issues.

Rules

Here's a table showing the equivalent validation rules in JSLint and ESLint. Rules that JSLint does not support are marked as Unsupported. If a rule has "-" in the JSLint option field, then JSLint always enforces it and it cannot be disabled.

ESLint rule JSLint option JSLint message Details
block-scoped-var Always on '{variable}' is already defined.
  • Occurs when a function-scoped variable is treated as if it was block scoped.
  • ESLint calls this error '{variable} used outside of binding context.'
brace-style Unsupported
camelcase Unsupported
complexity Unsupported
consistent-this Unsupported
curly Always on
  • Statement body should be inside '{ }' braces. (Orion)
  • Expected '{'. (Regular JSLint)
dot-notation sub {a} is better written in dot notation.
eqeqeq eqeqeq or eqeq
  • Expected '===' and saw '=='.
  • Expected '!==' and saw '!='.
  • Newer versions of JSLint call this option eqeqeq.
  • Orion's version calls it eqeq, and inverts the flag's value.
guard-for-in forin The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
max-depth Unsupported Enforces max depth of nested blocks within a function.
max-len maxlen Line too long. Enforces a maximum line length.
max-params Unsupported
max-statements Unsupported
new-cap newcap A constructor name should start with an uppercase letter.
new-parens Always on Missing '()' invoking a constructor. Flags new Whatever
no-alert devel '{alert, confirm, prompt}' is not defined.
no-bitwise bitwise Unexpected use of '{operator}'. JSLint disallows bitwise ops by default.
no-caller Unsupported Flags references to arguments.callee and arguments.caller.
no-catch-shadow
no-comma-dangle Always on Unexpected comma. Flags trailing commas in object literals.
no-cond-assign
no-console devel
no-control-regex
no-debugger debug All 'debugger' statements should be removed.
no-delete-var Always on Expected '.' and instead saw ';'. Flags an attempt to delete a local variable.
no-div-regex
no-dupe-keys Always on Duplicate key '{a}'. Flags object literals that contain the same key more than once.
no-else-return
no-empty-class
no-empty-label
no-empty Unsupported Flags an empty block like if (something) { }
no-eq-null Always on Use '===' to compare with 'null'. JSLint produces a similar warning when comparing against undefined.
no-eval evil eval is evil.
no-ex-assign Always on Do not assign to the exception parameter.
no-extra-semi Always on Unnecessary semicolon.
no-fallthrough
no-floating-decimal
no-func-assign
no-global-strict
no-implied-eval
no-iterator
no-label-var Always on '{label}' is already defined. Flags labels that collide with an identifier.
no-loop-func Always on Don't make functions within a loop.
no-mixed-requires
no-multi-str
no-native-reassign Always on
  • Read only.
  • Bad assignment. (if assigning to undefined)
Flags an attempt to reassign a native object like Math, Array, undefined, etc.
no-negated-in-lhs
no-new-array Always on Use the array literal notation []. Flags new Array()
no-new-func
no-new-object Always on Use the object literal notation {}.
no-new-wrappers Do not use {String, Number, Boolean, Math, JSON} as a constructor.
no-new Always on Do not use 'new' for side effects. Flags uses of new operator in an expression that is not assigned to anything.
no-obj-calls
no-octal-escape
no-octal
no-plusplus plusplus
  • Unexpected use of '++'
  • Unexpected use of '--'
no-proto Always on
  • Reserved name '__proto__'. (if used as an identifier)
  • Stupid key '{a}'. (if used as a key)
Treated as a fatal parse error in JSLint.
no-redeclare Always on '{a}' is already defined. Usually results from having two for loops in the same function that share a loop variable declaration like var i=....
no-return-assign Unsupported Prevents assignment in a return statement.
no-script-url
no-self-compare
no-shadow
no-spaced-func
no-sync stupid Unexpected sync method: '{a}'.
  • Flags Node.js's synchronous I/O methods.
  • The stupid option is supported only in newer versions of JSLint (not Orion's).
no-ternary
no-undef-init Always on It is not necessary to initialize '{variable}' to 'undefined'.
no-undef undef '{variable}' is not defined.
  • Flags references to a global variable that is not listed in a /*global*/ or /*globals*/ block.
  • Predefined environments (eg. node, browser) can be set in the /*jslint */ block.
no-underscore-dangle nomen Dangling '_'
no-unreachable
no-unused-expressions Always on Expected an assignment or function call and instead saw an expression. Flags expressions that appear in a statement context and don't cause side effects.
no-unused-vars Always on Function declares unused variable '{a}'. (Orion) Newer JSlint versions have an unparam option which works similarly.
no-use-before-define Always on '{a}' was used before it was defined.
no-with Always on Expected an identifier and instead saw 'with'. Treated as fatal parse error in JSLint.
no-wrap-func
one-var vars
quote-props
quotes Unsupported
radix Always on Missing radix parameter. Affects parseInt().
regex-spaces Always on Spaces are hard to count. Use {n}.
semi Always on Missing semicolon.
strict strict Flags any code that lacks the "use strict" pragma.
unnecessary-strict
use-isnan Always on Use the isNaN function to compare with NaN.
wrap-iife immed
  • Wrap the entire immediate function invocation in parens.
  • Do not wrap function literals in parens unless they are to be immediately invoked.
  • Move the invocation into the parens that contain the function.
wrap-regex Always on Wrap the /regexp/ literal in parens to disambiguate the slash operator.

Rule priority

Here are the rules we want, in order of priority:

  1. no-undef

Copyright © Eclipse Foundation, Inc. All Rights Reserved.