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)
(Rules)
Line 79: Line 79:
  
 
| new-cap
 
| new-cap
| -
+
| '''newcap'''
 
| A constructor name should start with an uppercase letter.
 
| A constructor name should start with an uppercase letter.
 
|-
 
|-
  
 
| new-parens
 
| new-parens
|  
+
| -
|  
+
| Missing '()' invoking a constructor.
 +
| Flags <code>new Whatever</code>
 
|-
 
|-
  
Line 94: Line 95:
  
 
| no-bitwise
 
| no-bitwise
|  
+
| '''bitwise'''
|  
+
| Unexpected use of '{{operator}}.
 +
| JSLint disallows bitwise ops by default.
 
|-
 
|-
  
 
| no-caller
 
| no-caller
|  
+
| -
|  
+
| (Not supported)
 +
| Flags references to <code>arguments.callee</code> and <code>arguments.caller</code>.
 
|-
 
|-
  
Line 145: Line 148:
  
 
| no-dupe-keys
 
| no-dupe-keys
|  
+
| -
|  
+
| Duplicate key '{a}'.
 +
| Flags object literals that contain the same key more than once.
 
|-
 
|-
  
Line 165: Line 169:
  
 
| no-empty
 
| no-empty
|  
+
| -
|  
+
| (Not supported)
 +
| Flags an empty block like if (..) { }
 
|-
 
|-
  
Line 175: Line 180:
  
 
| no-eval
 
| no-eval
|  
+
| '''evil'''
|  
+
| eval is evil.
 
|-
 
|-
  
 
| no-ex-assign
 
| no-ex-assign
|  
+
| -
|  
+
| Do not assign to the exception parameter.
 
|-
 
|-
  
 
| no-extra-semi
 
| no-extra-semi
|  
+
| -
|  
+
| Unnecessary semicolon.
 
|-
 
|-
  
Line 250: Line 255:
  
 
| no-new-array
 
| no-new-array
|  
+
| -
|  
+
| Use the array literal notation [].
 +
| 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 {}.
 
|-
 
|-
  
 
| no-new-wrappers
 
| no-new-wrappers
 
|  
 
|  
|  
+
| Do not use {String, Number, Boolean, Math, JSON} as a constructor.
 
|-
 
|-
  
Line 290: Line 297:
  
 
| no-plusplus
 
| no-plusplus
|  
+
| '''plusplus'''
|  
+
| Unexpected use of '{++, --}'
 
|-
 
|-
  
 
| no-proto
 
| no-proto
|  
+
| -
|  
+
| "Reserved name '__proto__'. (if used as an identifier)<br>Stupid key '{a}' (if used as a key)
 +
| Treated as a fatal parse error in JSLint.
 
|-
 
|-
  
Line 306: Line 314:
  
 
| no-return-assign
 
| no-return-assign
|  
+
| -
|  
+
| (Not supported)
 +
| Prevents assignment in a <code>return</code> statement.
 
|-
 
|-
  
Line 341: Line 350:
  
 
| no-undef-init
 
| no-undef-init
|  
+
| -
|  
+
| It is not necessary to initialize 'x' to 'undefined'.
 
|-
 
|-
  
 
| no-undef
 
| no-undef
| -
+
| '''undef'''
 
| '{variable}' is not defined.
 
| '{variable}' is not defined.
| Any global variables must be listed in a /*global*/ or /*globals*/ block.<br>Predefined environments (eg. '''node''', '''browser''', '''require''') can be set in /*jslint */ options.
+
| Flags references to a global variable that is not listed in a /*global*/ or /*globals*/ block.<br>Predefined environments (eg. '''node''', '''browser''') can be set as /*jslint */ block.
 
|-
 
|-
  
 
| no-underscore-dangle
 
| no-underscore-dangle
|  
+
| '''nomen'''
|  
+
| dangling '_'
 
|-
 
|-
  
Line 362: Line 371:
  
 
| no-unused-expressions
 
| no-unused-expressions
|  
+
| -
|  
+
| Expected an assignment or function call and instead saw an expression.
 +
| Flags non-side-effect-ful expressions
 
|-
 
|-
  
Line 410: Line 420:
  
 
| regex-spaces
 
| regex-spaces
|  
+
| -
|  
+
| Spaces are hard to count. Use {n}.
 
|-
 
|-
  

Revision as of 12:58, 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
camelcase
complexity
consistent-this
curly
dot-notation sub {a} is better written in dot notation.
eqeqeq eqeqeq
eqeq
Expected '===' and saw '=='.
Expected '!==' and saw '!='.
eqeq only appears in old versions of JSLint (like Orion's), has opposite on/off state to eqeqeq.
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
max-len
max-params
max-statements
new-cap newcap A constructor name should start with an uppercase letter.
new-parens - Missing '()' invoking a constructor. Flags new Whatever
no-alert
no-bitwise bitwise Unexpected use of 'Template: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
no-control-regex
no-debugger
no-delete-var
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 (..) { }
no-eq-null
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
no-loop-func
no-mixed-requires
no-multi-str
no-native-reassign
no-negated-in-lhs
no-new-array - Use the array literal notation []. Flags new Array()
no-new-func - Do not use 'new' for side effects. Flags uses of new operator in an expression that is not assigned to anything.
no-new-object - Use the object literal notation {}.
no-new-wrappers Do not use {String, Number, Boolean, Math, JSON} as a constructor.
no-new
no-obj-calls
no-octal-escape
no-octal
no-plusplus plusplus 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
no-ternary
no-undef-init - It is not necessary to initialize 'x' 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 as /*jslint */ block.
no-underscore-dangle nomen dangling '_'
no-unreachable
no-unused-expressions - Expected an assignment or function call and instead saw an expression. Flags non-side-effect-ful expressions
no-unused-vars
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
quote-props
quotes Strings must use doublequote. Only if "jsonmode"
radix - Missing radix parameter. Affects parseInt()
regex-spaces - Spaces are hard to count. Use {n}.
semi - Missing semicolon.
strict strict Requires "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.