Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Orion/ESLint"

(Rules)
Line 13: Line 13:
 
| block-scoped-var
 
| block-scoped-var
 
| -
 
| -
| '{variable}' is already defined.
+
| '''{variable}' is already defined.''
 
|
 
|
 
* Occurs when a function-scoped variable is treated as if it was block scoped.
 
* Occurs when a function-scoped variable is treated as if it was block scoped.
Line 42: Line 42:
 
| -
 
| -
 
|
 
|
* Statement body should be inside '{ }' braces. (Orion)
+
* ''Statement body should be inside '{ }' braces.'' (Orion)
* Expected '{'. (Regular JSLint)
+
* ''Expected '{'.'' (Regular JSLint)
 
|  
 
|  
 
|-
 
|-
Line 49: Line 49:
 
| dot-notation
 
| dot-notation
 
| '''sub'''
 
| '''sub'''
| {a} is better written in dot notation.
+
| ''{a} is better written in dot notation.''
 
|  
 
|  
 
|-
 
|-
Line 56: Line 56:
 
| '''eqeqeq''' or '''eqeq'''
 
| '''eqeqeq''' or '''eqeq'''
 
|
 
|
* Expected '===' and saw '=='.
+
* ''Expected '===' and saw '=='.''
* Expected '!==' and saw '!='.
+
* ''Expected '!==' and saw '!='.''
 
|
 
|
 
* Newer versions of JSLint call this option '''eqeqeq'''.  
 
* Newer versions of JSLint call this option '''eqeqeq'''.  
Line 65: Line 65:
 
| guard-for-in
 
| guard-for-in
 
| '''forin'''
 
| '''forin'''
| The body of a <code>for in</code> should be wrapped in an <code>if</code> statement to filter unwanted properties from the prototype.
+
| ''The body of a <code>for in</code> should be wrapped in an <code>if</code> statement to filter unwanted properties from the prototype.''
 
|-
 
|-
  
Line 76: Line 76:
 
| max-len
 
| max-len
 
| '''maxlen'''
 
| '''maxlen'''
| Line too long.
+
| ''Line too long.''
 
| Enforces a maximum line length.
 
| Enforces a maximum line length.
 
|-
 
|-
  
 
| max-params
 
| max-params
|  
+
| -
|  
+
| (Not supported)
 
|-
 
|-
  
 
| max-statements
 
| max-statements
|  
+
| -
|  
+
| (Not supported)
 
|-
 
|-
  
Line 97: Line 97:
 
| new-parens
 
| new-parens
 
| -
 
| -
| Missing '()' invoking a constructor.
+
| ''Missing '()' invoking a constructor.''
 
| Flags <code>new Whatever</code>  
 
| Flags <code>new Whatever</code>  
 
|-
 
|-
  
 
| no-alert
 
| no-alert
|  
+
| '''devel'''
 +
| '''{alert, confirm, prompt}' is not defined.''
 
|  
 
|  
 
|-
 
|-
Line 135: Line 136:
  
 
| no-console
 
| no-console
|  
+
| '''devel'''
 
|  
 
|  
 
|-
 
|-
Line 145: Line 146:
  
 
| no-debugger
 
| no-debugger
|  
+
| '''debug'''
 +
| ''All 'debugger' statements should be removed.''
 
|  
 
|  
 
|-
 
|-
  
 
| no-delete-var
 
| no-delete-var
|  
+
| -
|  
+
| ''Expected '.' and instead saw ';'.''
 +
| Flags an attempt to <code>delete</code> a local variable.
 
|-
 
|-
  
Line 161: Line 164:
 
| no-dupe-keys
 
| no-dupe-keys
 
| -
 
| -
| 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 183: Line 186:
 
| -
 
| -
 
| (Not supported)
 
| (Not supported)
| Flags an empty block like if (..) { }  
+
| Flags an empty block like <code>if (something) { }</code>
 
|-
 
|-
  
 
| no-eq-null
 
| no-eq-null
 
| -
 
| -
| Use '===' to compare with 'null'.
+
| ''Use '===' to compare with 'null'.''
| JSLint produces similar warnings when comparing against <code>undefined</code>.
+
| JSLint produces a similar warning when comparing against <code>undefined</code>.
 
|-
 
|-
  
 
| no-eval
 
| no-eval
 
| '''evil'''
 
| '''evil'''
| eval is evil.
+
| ''eval is evil.''
 
|-
 
|-
  
 
| no-ex-assign
 
| no-ex-assign
 
| -
 
| -
| Do not assign to the exception parameter.
+
| ''Do not assign to the exception parameter.''
 
|-
 
|-
  
 
| no-extra-semi
 
| no-extra-semi
 
| -
 
| -
| Unnecessary semicolon.
+
| ''Unnecessary semicolon.''
 
|-
 
|-
  
Line 239: Line 242:
 
| no-label-var
 
| no-label-var
 
| -
 
| -
| '{label}' is already defined.
+
| '''{label}' is already defined.''
 
| Flags labels that collide with an identifier.
 
| Flags labels that collide with an identifier.
 
|-
 
|-
Line 245: Line 248:
 
| no-loop-func
 
| no-loop-func
 
| -
 
| -
| Don't make functions within a loop.
+
| ''Don't make functions within a loop.''
 
|
 
|
 
|-
 
|-
Line 262: Line 265:
 
| -
 
| -
 
|
 
|
* Read only.
+
* ''Read only.''
* Bad assignment.
+
* ''Bad assignment.'' (if assigning to <code>undefined</code>)
 
| Flags an attempt to reassign a native object like <code>Math</code>, Array, <code>undefined</code>, etc.
 
| Flags an attempt to reassign a native object like <code>Math</code>, Array, <code>undefined</code>, etc.
 
|-
 
|-
Line 274: Line 277:
 
| no-new-array
 
| no-new-array
 
| -
 
| -
| Use the array literal notation [].
+
| ''Use the array literal notation [].''
 
| Flags <code>new Array()</code>
 
| Flags <code>new Array()</code>
 
|-
 
|-
  
 
| no-new-func
 
| no-new-func
| -
+
|  
| Do not use 'new' for side effects.
+
|  
| Flags uses of <code>new</code> operator in an expression that is not assigned to anything.
+
 
|-
 
|-
  
 
| no-new-object
 
| no-new-object
 
| -
 
| -
| Use the object literal notation {}.
+
| ''Use the object literal notation {}.''
 
|-
 
|-
  
Line 295: Line 297:
  
 
| no-new
 
| no-new
|  
+
| -
|  
+
| ''Do not use 'new' for side effects.''
 +
| Flags uses of <code>new</code> operator in an expression that is not assigned to anything.
 
|-
 
|-
  
Line 316: Line 319:
 
| no-plusplus
 
| no-plusplus
 
| '''plusplus'''
 
| '''plusplus'''
| Unexpected use of '{++, --}'
+
|  
 +
* ''Unexpected use of '++'''
 +
* ''Unexpected use of '--'''
 
|-
 
|-
  
Line 322: Line 327:
 
| -
 
| -
 
|
 
|
* Reserved name '__proto__'. (if used as an identifier)
+
* ''Reserved name '__proto__'.'' (if used as an identifier)
* Stupid key '{a}' (if used as a key)
+
* ''Stupid key '{a}'.'' (if used as a key)
 
| Treated as a fatal parse error in JSLint.
 
| Treated as a fatal parse error in JSLint.
 
|-
 
|-
Line 329: Line 334:
 
| no-redeclare
 
| no-redeclare
 
| -
 
| -
| '{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 361: Line 366:
 
| no-sync
 
| no-sync
 
| '''stupid'''
 
| '''stupid'''
| Unexpected sync method: '{a}'.
+
| ''Unexpected sync method: '{a}'.''
 
|
 
|
 
* Flags Node.js's synchronous I/O methods.
 
* Flags Node.js's synchronous I/O methods.
Line 374: Line 379:
 
| no-undef-init
 
| no-undef-init
 
| -
 
| -
| It is not necessary to initialize 'x' to 'undefined'.
+
| ''It is not necessary to initialize '{variable}' to 'undefined'.''
 +
|
 
|-
 
|-
  
 
| no-undef
 
| no-undef
 
| '''undef'''
 
| '''undef'''
| '{variable}' is not defined.
+
| '''{variable}' is not defined.''
 
|
 
|
 
* Flags references to a global variable that is not listed in a /*global*/ or /*globals*/ block.
 
* Flags references to a global variable that is not listed in a /*global*/ or /*globals*/ block.
Line 387: Line 393:
 
| no-underscore-dangle
 
| no-underscore-dangle
 
| '''nomen'''
 
| '''nomen'''
| dangling '_'
+
| ''Dangling '_'''
 
|-
 
|-
  
Line 397: Line 403:
 
| no-unused-expressions
 
| no-unused-expressions
 
| -
 
| -
| 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 403: Line 409:
 
| no-unused-vars
 
| no-unused-vars
 
| -
 
| -
| 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 409: Line 415:
 
| no-use-before-define
 
| no-use-before-define
 
| -
 
| -
| '{a}' was used before it was defined.
+
| '''{a}' was used before it was defined.''
 
|-
 
|-
  
Line 441: Line 447:
 
| radix
 
| radix
 
| -
 
| -
| Missing radix parameter.
+
| ''Missing radix parameter.''
| Affects parseInt()
+
| Affects parseInt().
 
|-
 
|-
  
 
| regex-spaces
 
| regex-spaces
 
| -
 
| -
| Spaces are hard to count. Use {n}.
+
| ''Spaces are hard to count. Use {n}.''
 
|-
 
|-
  
 
| semi
 
| semi
 
| -
 
| -
| Missing semicolon.
+
| ''Missing semicolon.''
 
|
 
|
 
|-
 
|-
Line 459: Line 465:
 
| '''strict'''
 
| '''strict'''
 
|  
 
|  
| Requires <code>"use strict"</code> pragma.
+
| Flags any code that lacks the <code>"use strict"</code> pragma.
 
|-
 
|-
  
Line 469: Line 475:
 
| use-isnan
 
| use-isnan
 
| -
 
| -
| Use the isNaN function to compare with NaN.
+
| ''Use the isNaN function to compare with NaN.''
 
|-
 
|-
  
Line 475: Line 481:
 
| '''immed'''
 
| '''immed'''
 
|
 
|
* Wrap the entire immediate function invocation in parens.
+
* ''Wrap the entire immediate function invocation in parens.''
* Do not wrap function literals in parens unless they are to be immediately invoked.
+
* ''Do not wrap function literals in parens unless they are to be immediately invoked.''
* Move the invocation into the parens that contain the function.
+
* ''Move the invocation into the parens that contain the function.''
 
|  
 
|  
 
|-
 
|-
Line 483: Line 489:
 
| wrap-regex
 
| wrap-regex
 
| -
 
| -
| 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:02, 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. If a rule has no "JSLint option", then JSLint always enforces it and it cannot be disabled.

ESLint rule JSLint option JSLint message Details
block-scoped-var - '{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 - (Not supported)
camelcase - (Not supported)
complexity - (Not supported)
consistent-this - (Not supported)
curly -
  • 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 - (Not supported) Enforces max depth of nested blocks within a function.
max-len maxlen Line too long. Enforces a maximum line length.
max-params - (Not supported)
max-statements - (Not supported)
new-cap newcap A constructor name should start with an uppercase letter.
new-parens - 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 - (Not supported) Flags references to arguments.callee and arguments.caller.
no-catch-shadow
no-comma-dangle - 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 - Expected '.' and instead saw ';'. Flags an attempt to delete a local variable.
no-div-regex
no-dupe-keys - 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 - (Not supported) Flags an empty block like if (something) { }
no-eq-null - Use '===' to compare with 'null'. JSLint produces a similar warning when comparing against undefined.
no-eval evil eval is evil.
no-ex-assign - Do not assign to the exception parameter.
no-extra-semi - Unnecessary semicolon.
no-fallthrough
no-floating-decimal
no-func-assign
no-global-strict
no-implied-eval
no-iterator
no-label-var - '{label}' is already defined. Flags labels that collide with an identifier.
no-loop-func - Don't make functions within a loop.
no-mixed-requires
no-multi-str
no-native-reassign -
  • 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 - Use the array literal notation []. Flags new Array()
no-new-func
no-new-object - Use the object literal notation {}.
no-new-wrappers Do not use {String, Number, Boolean, Math, JSON} as a constructor.
no-new - 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 -
  • 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 - '{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 - (Not supported) 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 - 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 - 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 - Function declares unused variable '{a}'. (Orion) Newer JSlint versions have an unparam option which works similarly.
no-use-before-define - '{a}' was used before it was defined.
no-with - Expected an identifier and instead saw 'with'. Treated as fatal parse error in JSLint.
no-wrap-func
one-var vars
quote-props
quotes - (Not supported)
radix - Missing radix parameter. Affects parseInt().
regex-spaces - Spaces are hard to count. Use {n}.
semi - Missing semicolon.
strict strict Flags any code that lacks the "use strict" pragma.
unnecessary-strict
use-isnan - 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 - 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.