Skip to main content
Jump to: navigation, search

Difference between revisions of "Orion/ESLint"

(Rules)
(Potential Programming Problems: Fix bad formatting on no-irregular-whitespace rule)
 
(197 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Orion 5.0 moved to [https://github.com/nzakas/eslint/ ESLint] as the validator that ships with Orion. This page captures ongoing issues.
+
Orion 5.0 introduced [https://github.com/nzakas/eslint/ ESLint] as the validator that ships with Orion. This page captures ongoing issues.
  
 
== Rules ==  
 
== Rules ==  
The following table describes all of the rules currently available in Orion and ones that we plan to add in the future.
+
The following sections describe all of the rules currently available in Orion and ones that we plan to add in the future.
  
Rules that are currently available are <del>struck out</del>.
+
'''To view this table in the same order as the Orion Settings page, hover over the ''Setting Message'' column title and press the down arrow to sort.'''
  
{| class="wikitable" border="1" cellpadding="5" cellspacing="0" style="width: 100%;"
+
=== Potential Programming Problems ===
! style="background:#efefef;" width=5% | Rule
+
These rules report about problems with your code that might have undesired or incorrect results. Warnings from these
! style="background:#efefef;" width=5% | Default Severity
+
rules should be addressed.
! style="background:#efefef;" width=5% | Available Since
+
! style="background:#efefef;" width=40%| Problem Message
+
! style="background:#efefef;" width=40% | Details
+
|-
+
  
!| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428433 block-scoped-var]
+
{| class="wikitable sortable" border="1" cellpadding="5" cellspacing="0" style="width: 100%;"
| Error
+
! width=13% | Rule
| -
+
! width=5% | Default Severity
| '''{variable}' is already defined.''
+
! width=3% | Available Since
|
+
! width=24% | Setting Message
* Occurs when a function-scoped variable is treated as if it was block scoped.
+
! width=24%| Problem Message
* ESLint calls this error '{variable} used outside of binding context.'
+
! width=24% | Details
 +
! width=3% | Quick Fix?
 +
! width=3% | Fix All?
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=455253 no-comma-dangle]
!| brace-style
+
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;"| 8.0
| &nbsp;
+
|Trailing commas in object expressions
| &nbsp;
+
| ''Trailing commas in object expressions are discouraged.''
 +
| Flags trailing commas in object expressions.
 +
|style="text-align:center;" | ✔
 +
|style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=455250 no-cond-assign]
!| camelcase
+
| Error
| Ignore
+
|style="text-align:center;"| 8.0
| -
+
|Assignments in conditional expressions
| &nbsp;
+
| ''Expected a conditional expression and instead saw an assignment.''
| &nbsp;
+
| Flags assignment in an <code>if/while/do..while/for</code> condition.
 +
| style="text-align:center;" | ✔
 +
|style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=455371 no-console]
!| complexity
+
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;"| 8.0
| &nbsp;
+
|Discouraged console use in browser code
| &nbsp;
+
| ''Discouraged use of console in browser-based code.''
 +
| Flags the use of console in browser-based code
 +
|  
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=455680 no-constant-condition]
!| consistent-this
+
| Error
| Ignore
+
|style="text-align:center;"| 8.0
| -
+
|Constant as conditional expression
| &nbsp;
+
| ''...'' is constant.
| &nbsp;
+
| Flags the use of a constant as a conditional expression
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=455680 no-const-assign]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=429722 curly]</del>
+
| Error
| Ignore
+
|style="text-align:center;"| 13.0
| 6.0
+
| Disallow modifying variables that are declared using const
| ''Statements should be enclosed in braces.''
+
| ''Discouraged use of constant as a conditional expression.''
| &nbsp;
+
| Flags the assignment to a constant variable
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-control-regex]
!| dot-notation
+
| Error
 +
|style="text-align:center;"| 11.0
 +
|Disallow control characters in regular expressions
 +
| ''Unexpected control character in regular expression''
 +
| Control characters are special, invisible characters in the ASCII range 0-31. These characters are rarely used in JavaScript strings so a regular expression containing these characters is most likely a mistake.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 +
|-
 +
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429690 no-debugger]
 
| Warning
 
| Warning
| -
+
|style="text-align:center;"| 6.0
| ''{a} is better written in dot notation.''
+
|Discouraged 'debugger' statement use
| &nbsp;
+
| ''debugger' statement use is discouraged.''
 +
| Warns when the <code>debugger</code> keyword is used
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=485767 ✔]
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=485767 ✔]
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428430 no-dupe-keys]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 eqeqeq]</del>
+
| Error
| Warning
+
|style="text-align:center;"| 6.0
| 5.0
+
|Duplicate object keys
 +
| ''Duplicate object key '{key}'.''
 +
| Flags object literals that contain the same key more than once.
 +
| style="text-align:center;" |[https://bugs.eclipse.org/bugs/show_bug.cgi?id=485953 ✔]
 
|
 
|
* ''Expected '===' and saw '=='.''
 
* ''Expected '!==' and saw '!='.''
 
| &nbsp;
 
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-duplicate-case]
!| guard-for-in
+
| Error
| Ignore
+
|style="text-align:center;"| 11.0
| -
+
|Duplicate case
| ''The body of a <code>for in</code> should be wrapped in an <code>if</code> statement to filter unwanted properties from the prototype.''
+
| ''Duplicate case label.''
| &nbsp;
+
| A switch statements with duplicate case labels is normally an indication of a programmer error.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=439366 no-empty-block]
!| max-depth
+
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;"| 7.0
| &nbsp;
+
|Undocumented empty block
| Enforces max depth of nested blocks within a function.
+
| ''Empty block should be removed or commented.''
 +
| Flags an empty block like <code>if (something) { }</code>.
 +
| style="text-align:center;" | ✔
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-empty-character-class]
!| max-len
+
| Error
| Ignore
+
|style="text-align:center;"| 11.0
| -
+
|Disallow empty character classes
| ''Line is too long.''
+
| ''Empty class.''
| Enforces a maximum line length.
+
| Empty character classes in regular expressions do not match anything and can result in code that may not work as intended.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-extra-boolean-cast]
!| max-params
+
| Error
| Ignore
+
|style="text-align:center;"| 11.0
| -
+
|Discourage redundant double negation
| &nbsp;
+
| Redundant double negation in ...
| &nbsp;
+
| In contexts such as an if statement's test where the result of the expression will already be coerced to a Boolean, casting to a Boolean via double negation (!!) is unnecessary.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-extra-parens]
!| max-statements
+
| Warning
| Ignore
+
|style="text-align:center;"| 11.0
| -
+
| Discourage redundant parentheses
| &nbsp;
+
| ''Gratuitous parentheses around expression.''
| &nbsp;
+
| This rule restricts the use of parentheses to only where they are necessary. It may be restricted to report only function expressions.
 +
|style="text-align:center;" | ✔
 +
|style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428040 no-extra-semi]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=424128 missing-doc]</del>
+
| Warning
| Ignore
+
|style="text-align:center;"| 5.0
| 5.0
+
|Unnecessary semicolons
| "Missing documentation for function '{name}.'"
+
| ''Unnecessary semicolon.''
| Flags missing documentation nodes on function declarations and function expressions when they appear as object properties
+
| Warns when a semicolon is found where it is not needed
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429815 no-fallthrough]
!| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=424204 missing-doc-items]
+
| Error
| Ignore
+
|style="text-align:center;" | 6.0
| -
+
|Switch case fall-through
|&nbsp;
+
| ''Switch case may be entered by falling through previous case. If intended, add a new comment //$FALL-THROUGH$ on the line above''
| Flags missing documentation for parameters, returns, throws, etc on function declarations and function expressions when they appear as object properties
+
| Flags a fallthrough case within a <code>switch</code> statement, unless it is explicitly commented.
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-invalid-regexp]
!| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428429 missing-nls]
+
| Error
 +
|style="text-align:center;"| 11.0
 +
|Invalid regular expressions
 +
| ''Invalid flags supplied to RegExp constructor '{${0}}'.'' or the error message from calling the constructor with the regex
 +
| This rule validates string arguments passed to the RegExp constructor.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 +
|-
 +
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=482616 no-irregular-whitespace]  
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;"| 11.0
| &nbsp;
+
| Report irregular whitespace
| Flags String literals that are not properly NLS'd
+
| '''Irregular whitespace not allowed''
 +
| This rule validates all whitespaces
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-negated-in-lhs]
!| new-cap
+
| Error
| Warning
+
|style="text-align:center;"| 11.0
| -
+
|Disallow negated left operand of in operator
| ''A constructor name should start with an uppercase letter.''
+
| ''The 'in' expression's left operand is negated.''
| &nbsp;
+
| Disallow negated left operand of in operator
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-obj-calls]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=429801 new-parens]</del>
+
 
| Error
 
| Error
| -
+
|style="text-align:center;"| 11.0
| ''Missing parentheses invoking constructor.''
+
|Disallow global object as function calls
| Flags <code>new Whatever</code>
+
| '' '{${0}}' is not a function.''
 +
| ECMAScript provides several global objects that are intended to be used as-is. Some of these objects look as if they could be constructors due their capitalization (such as Math and JSON) but will throw an error if you try to execute them as functions.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 +
|-
 +
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=455391 no-regex-spaces]
 +
| Error
 +
|style="text-align:center;"| 8.0
 +
|Multiple spaces in regular expressions
 +
| ''Avoid using multiple spaces in regular expressions. Use ' {${0}}' instead.''
 +
| Flags regular expressions that have two or more subsequent spaces.
 +
| style="text-align:center;" |
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=455354 no-reserved-keys]
!| no-alert
+
 
| Ignore
 
| Ignore
| -  
+
|style="text-align:center;"| 8.0
| '''{alert, confirm, prompt}' is not defined.''
+
|Reserved words used as property keys
| &nbsp;
+
| ''Reserved words should not be used as property keys.''
 +
| Checks to see if a JavaScript reserved word is being used as a property key
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=485980 ✔]
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=426723 no-sparse-arrays]
!| no-bitwise
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;"| 8.0
| ''Unexpected use of '{operator}'.''
+
|Sparse array declarations
| JSLint disallows bitwise ops by default.
+
| ''Sparse array declarations should be avoided.''
 +
| Flags sparse arrays with null elements like <code>var arr = [1, ,2]</code>
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=436986 no-unreachable]
!| no-caller
+
| Ignore
+
| -
+
| &nbsp;
+
| Flags references to <code>arguments.callee</code> and <code>arguments.caller</code>.
+
|-
+
 
+
!| no-catch-shadow
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;"| 6.0
| '''{a}' is already defined.''
+
|Unreachable code
 +
| ''Unreachable code.''
 +
| Flags statements that occur after a <code>return</code>, <code>throw</code>, etc.
 +
| style="text-align:center;" | ✔
 
|
 
|
* Flags a <code>catch</code> clause's variable that shadows a variable declared in an outer scope. (In IE8 this [http://weblog.bocoup.com/the-catch-with-try-catch/ causes the outer variable to be overwritten]).
 
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=425200 type-checked-consistent-return]
!| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=426723 no-comma-dangle]
+
| Warning
+
| -
+
| ''Unexpected comma.''
+
| Flags trailing commas in object literals and array declarations.
+
|-
+
 
+
!| no-cond-assign
+
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;"| 11.0
| &nbsp;
+
|Discouraged inconsistent returns
| Flags assignment in an <code>if/while/do..while/for</code> condition.
+
| ''Inconsistent return types: (type1) (type2)''
 +
| Warns when a function returns two values with different types.
 +
| style="text-align:center;" |
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429711 use-isnan]
!| no-console
+
| Error
| Ignore
+
|style="text-align:center;"| 6.0
| -
+
|NaN not compared with isNaN()
| &nbsp;
+
| ''Use the isNaN function to compare with NaN.''
| &nbsp;
+
| Warns when a comparison is done against NaN without using the <code>isNaN</code> function
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=470189 ✔]
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=485977 ✔]
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=447189 valid-typeof]
!| no-control-regex
+
| Error
| Ignore
+
|style="text-align:center;"| 7.0
| -
+
|Invalid 'typeof' comparison
| &nbsp;
+
| ''Invalid typeof comparison.''
| Flags control characters (U+0000–U+001F and U+007F) within the source argument to the RegExp constructor.
+
| Warns when a typeof comparison uses an invalid type.
 +
|
 +
|
 
|-
 
|-
 +
|}
  
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=429690 no-debugger]</del>
+
=== Best Practices ===
| Warning
+
These rules are not necessarily problem with your code, but are warnings that you might be doing something
| 6.0
+
you probably should not be.
| '''debugger' statement use is discouraged.''
+
 
| &nbsp;
+
{| class="wikitable sortable" border="1" cellpadding="5" cellspacing="0" style="width: 100%;"
 +
! width=13% | Rule
 +
! width=5% | Default Severity
 +
! width=3% | Available Since
 +
! width=24% | Setting Message
 +
! width=24%| Problem Message
 +
! width=24% | Details
 +
! width=3% | Quick Fix?
 +
! width=3% | Fix All?
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 accessor-pairs]
!| no-delete-var
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;"| 11.0
| ''Expected '.' and instead saw ';'.''
+
|Getter and setter accessors not in pairs
| Flags an attempt to <code>delete</code> a local variable.
+
| ''Getter is not present'' or ''Setter is not present''
 +
| It's a common mistake in JavaScript to create an object with just a setter for a property but never have a corresponding getter defined for it. Without a getter, you cannot read the property, so it ends up not being used.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=490332 check-tern-plugin]
!| no-div-regex
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 12.0
| ''A regular expression literal can be confused with '/='.''
+
|Missing .tern-project plugins entry for environment directive
| Flags a regex literal starting with <code>/=</code>
+
| ''To work in the 'foo' environment, the 'bar' plugin must be running.''
 +
| Warn when the an eslint-env directive specifies a library Orion provides tooling support for, but the library plugin has been disabled in the .tern-project file.
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=490332 ✔]
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=487279 curly]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=428430 no-dupe-keys]</del>
+
| Ignore
| Error
+
|style="text-align:center;" | 6.0
| 6.0
+
|Statements not enclosed in braces
| ''Duplicate object key '{key}'.''
+
| ''Statements should be enclosed in braces.''
| Flags object literals that contain the same key more than once.
+
| Warns when statements should be enclosed in braces, for example <code>if(something) foo();</code>
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=454641 ✔]
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 eqeqeq]
!| no-else-return
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 5.0
| &nbsp;
+
|Discouraged '==' use
| Flags an <code>else</code> appearing after an <code>if</code> that contains a <code>return</code>.
+
|
 +
* ''Expected '===' and saw '=='.''
 +
* ''Expected '!==' and saw '!='.''
 +
| Warns when <code>==</code> or <code>!=</code> is used
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=493019 missing-requirejs]
!| no-empty-class
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 12.0
| ''Empty class.''
+
|'requirejs' plugin missing in AMD environment
| Flags an empty character class <code>[]</code> within a regular expression.
+
| To use AMD, the 'requirejs' plug-in needs to be running.
 +
| Flags references to function calls from AMD when the Tern 'requirejs' plugin is not running
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=493019 ✔]
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=460976 no-caller]
!| no-empty-label
+
| Error
| Warning
+
|style="text-align:center;" | 9.0
| -
+
|Discouraged 'arguments.caller' or 'arguments.callee' use
| ''Label '{a}' is not allowed on this statement.''
+
| ''arguments.{callee, caller} is deprecated.''
| Flags a labeled statement that is not a <code>switch</code>, <code>for</code>, or <code>while</code>.
+
| Flags references to <code>arguments.callee</code> and <code>arguments.caller</code>.
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=459934 Future]
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-else-return]
!| no-empty
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;"| 11.0
| &nbsp;
+
|Unnecessary else after return
| Flags an empty block like <code>if (something) { }</code>.
+
| ''Unexpected 'else' after 'return'.''
 +
| If an if block contains a return statement, the else block becomes unnecessary. Its contents can be placed outside of the block.
 +
| style="text-align:center;" | ✔
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-empty-label]
!| no-eq-null
+
 
| Error
 
| Error
| -
+
|style="text-align:center;"| 11.0
| ''Use '===' to compare with 'null'.''
+
|No empty labels
| &nbsp;
+
| ''Unexpected label "{${0}}"''
 +
| Labeled statements are only used in conjunction with labeled break and continue statements. ECMAScript has no goto statement.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=467903 no-eq-null]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=429702 no-eval]</del>
+
| Error
| Ignore
+
|style="text-align:center;"| 11.0
| 6.0
+
|Disallow null comparisons
| '''eval' function calls are discouraged.''
+
| ''Use ‘===’ to compare with ‘null’.'' or ''Use ‘!==’ to compare with ‘null’.''
| &nbsp;
+
| Comparing to null without a type-checking operator (== or !=), can have unintended results as the comparison will evaluate to true when comparing to not just a null, but also an undefined value.
 +
|style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=485171 ✔]
 +
|style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=485171 ✔]
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486766 no-extend-native]
!| no-ex-assign
+
| Error
| Warning
+
|style="text-align:center;"| 13.0
| -
+
| Disallow extending of native objects
| ''Do not assign to the exception parameter.''
+
| '..... prototype is read only, properties should not be added.'
| &nbsp;
+
| Disallows directly modifying the prototype of builtin objects.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486765 no-extra-bind]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=428040 no-extra-semi]</del>
+
 
| Warning
 
| Warning
| 5.0
+
|style="text-align:center;" | 13.0
| ''Unnecessary semicolon.''
+
|Unnecessary 'bind()' use
| &nbsp;
+
| ''The function binding is unnecessary.''
 +
| Warns about unnecessary use of bind()
 +
|style="text-align:center;" | ✔
 +
|style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429702 no-eval]
!| no-fallthrough
+
| Ignore
| Warning
+
|style="text-align:center;" | 6.0
| -
+
|Discouraged 'eval()' use
| &nbsp;
+
| '''eval' function calls are discouraged.''
| Flags a fallthrough case within a <code>switch</code> statement, unless it is explicitly commented.
+
| Warns when the <code>eval()</code> function is used
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486764 no-implicit-coercion]
!| no-floating-decimal
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 13.0
| ''A {leading, trailing} decimal point can be confused with a dot: '{n}'.''
+
|Disallow the type conversion with shorter notations.
| Flags numeric literals that have a leading or trailing decimal point.
+
| ''use `Boolean(..)` instead.'', ''use `...indexOf(".") !== -1` instead.'', ''use `Number(..)` instead.'', ''use `String(foo)` instead.''
 +
| This rule is aimed to flag shorter notations for the type conversion, then suggest a more self-explanatory notation.
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461929 no-implied-eval]
!| no-func-assign
+
| Warning
+
| -
+
| &nbsp;
+
| Flags assignment to a variable that's already bound to a <code>FunctionExpression</code>.
+
|-
+
 
+
!| no-global-strict
+
| Warning
+
| -
+
| &nbsp;
+
| Flags <code>"use strict"</code> applied to the entire Program.
+
|-
+
 
+
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=429707 no-implied-eval]</del>
+
 
| Ignore
 
| Ignore
| 6.0
+
|style="text-align:center;" | 6.0
 +
|Discouraged implied 'eval()' use
 
| ''Implicit 'eval' function calls are discouraged.''
 
| ''Implicit 'eval' function calls are discouraged.''
 
| Flags calls to the string-argument form of <code>setTimeout</code> and <code>setInterval</code>, which implicitly perform <code>eval</code>. This rule logic was merged to be part of the <b>no-eval</b> rule.
 
| Flags calls to the string-argument form of <code>setTimeout</code> and <code>setInterval</code>, which implicitly perform <code>eval</code>. This rule logic was merged to be part of the <b>no-eval</b> rule.
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486763 no-invalid-this]
!| no-iterator
+
| Warning
| Error
+
|style="text-align:center;" | 13.0
| -
+
|Discouraged 'this' use outside of classes or class-like objects
| ''Reserved name '__iterator__'.''
+
| ''Unexpected 'this'''
| Flags use of __iterator__ as an identifier name or property key.
+
| This rule aims to flag usage of 'this' keywords outside of classes or class-like objects
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=455643 no-iterator]
!| no-label-var
+
 
| Error
 
| Error
| -
+
|style="text-align:center;" | 8.0
| '''{label}' is already defined.''
+
|Discouraged __iterator__ property use
| Flags labels that collide with an identifier.
+
| ''Discouraged __iterator__ property use.''
 +
| Flags use of <code>__iterator__</code> as an identifier name or property key.
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486761 no-lone-blocks]
!| no-loop-func
+
| Error
+
| -
+
| ''Don't make functions within a loop.''
+
| &nbsp;
+
|-
+
 
+
!| no-mixed-requires
+
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;" | 13.0
| &nbsp;
+
|Discouraged lone block use
| Flags Node.js <code>require()</code>s that mix different types of requires (core, module, file, computed).
+
| ''Block is redundant.'' or ''Nested block is redundant.''
 +
| Flags use of unnecessary and potentially confusing blocks at the top level of a script or within other blocks.
 +
| style="text-align:center;" |
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486760 no-native-reassign]
!| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=425200 no-mixed-returns]
+
 
| Error
 
| Error
| -
+
|style="text-align:center;" | 13.0
| &nbsp;
+
| Disallow reassignment of native objects
| Flags functions that return more than one kind of item, for example returning String and Object
+
| ''... is a read-only native object.''
|-
+
| This rule flags modifications to read-only global variables
 
+
|  
!| no-multi-str
+
| Warning
+
| -
+
| &nbsp;
+
| Flags use of ES5 multiline string literals.
+
|-
+
 
+
!| no-native-reassign
+
| Warning
+
| -
+
 
|
 
|
* ''Read only.''
 
* ''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.
 
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429817 no-new-array]
!| no-negated-in-lhs
+
| Warning
+
| -
+
| &nbsp;
+
|
+
* Flags a unary <code>!</code> operator applied to the LHS of an in statement, which negates the LHS, not the <code>in</code>.  
+
* Eg. <code>(!"key" in {key: 1})</code> (which always evaluates to false), will be flagged.
+
|-
+
 
+
!| no-new-array
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 6.0
 +
|Discouraged 'new Array()'
 
| ''Use the array literal notation [].''
 
| ''Use the array literal notation [].''
| Flags <code>new Array()</code>.
+
| Flags <code>new Array()</code>. ESLint calls this rule <code>no-array-constructor</code>
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429817 no-new-func]
!| no-new-func
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 6.0
 +
|Discouraged 'new Function()'
 
| ''The Function constructor is eval.''
 
| ''The Function constructor is eval.''
 
| Flags <code>new Function()</code>.
 
| Flags <code>new Function()</code>.
 +
| style="text-align:center;" |
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429817 no-new-object]
!| no-new-object
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 6.0
 +
|Discouraged 'new Object()'
 
| ''Use the object literal notation {}.''
 
| ''Use the object literal notation {}.''
 
| Flags <code>new Object()</code>.
 
| Flags <code>new Object()</code>.
 +
| style="text-align:center;" |
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429817 no-new-wrappers]
!| no-new-wrappers
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 6.0
 +
|Discouraged wrapper objects
 
| ''Do not use {String, Number, Boolean, Math, JSON} as a constructor.''
 
| ''Do not use {String, Number, Boolean, Math, JSON} as a constructor.''
 
| Flags <code>new</code> applied to any of those.
 
| Flags <code>new</code> applied to any of those.
 +
| style="text-align:center;" |[https://bugs.eclipse.org/bugs/show_bug.cgi?id=485877 ✔]
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486758 no-param-reassign]
!| no-new
+
| Ignore
| Error
+
|style="text-align:center;" | 13.0
| -
+
| Disallow Reassignment of Function Parameters
| ''Do not use 'new' for side effects.''
+
| Flags uses of <code>new</code> operator in an expression that is not assigned to anything.
+
|-
+
 
+
!| no-obj-calls
+
| Warning
+
| -
+
| ''Math is not a function..''
+
 
|
 
|
* Flags attempts to call object properties of the global object (<code>Math</code>, <code>JSON</code>) as a function, like <code>Math()</code>.
+
* ''Assignment to function parameter 'bar'.''
|-
+
* ''Assignment to property of function parameter 'bar'.''
 
+
| Report parameter reassignment inside functions. Can also report reassignment of parameter's properties.
!| no-octal-escape
+
| Warning
+
| -
+
| ''Bad escapement.''
+
| Flags octal escapes in strings, for example <code>var x = "Copyright \251";</code>
+
|-
+
 
+
!| no-octal
+
| Warning
+
| -
+
| ''Don't use extra leading zeros '{n}'.''
+
| Flags number literals that begin with leading 0s, which indicate a (probably accidental) octal literal.
+
|-
+
 
+
!| no-plusplus
+
| Warning
+
| -
+
 
|  
 
|  
* ''Unexpected use of '++'''
+
|
* ''Unexpected use of '--'''
+
| &nbsp;
+
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461848 no-proto]
!| no-proto
+
 
| Error
 
| Error
| -
+
|style="text-align:center;" | 9.0
 +
|Discouraged __proto__ property use
 +
|
 +
* ''Reserved name '__proto__' should not be assigned.''
 +
* ''Reserved name '__proto__' should not be used as a key.''
 +
| Flags use of the property <code>__proto__</code> as object keys or in assignments
 +
|
 
|
 
|
* ''Reserved name '__proto__' should not be assigned."
 
* 'Reserved name '__proto__' should not be used as a key."
 
| &nbsp;
 
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-redeclare]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-redeclare]</del>
+
 
| Warning
 
| Warning
| 5.0
+
|style="text-align:center;" | 5.0
 +
|Variable re-declarations
 
| '''{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>.
|-
+
| style="text-align:center;" |
 
+
!| no-return-assign
+
| Warning
+
| -
+
| &nbsp;
+
 
|
 
|
* Prevents assignment in a <code>return</code> statement.
 
* Unsupported by JSLint, although JSLint does require parens around a return-assignment, eg: <code>return (x = 2);</code>
 
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=463490 no-self-assign]
!| no-script-url
+
| Error
| Warning
+
|style="text-align:center;" | 11.0
| -
+
|Disallow self assignment
| &nbsp;
+
| '''{a}' is assigned to itself.''
|  
+
| Warns when a variable is being assigned to itself
* Flags string literals beginning with <code>javascript:</code>. (Script URLs are a form of <code>eval</code>.)
+
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486124 ✔]
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486124 ✔]
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461850 no-self-compare]
!| no-self-compare
+
 
| Error
 
| Error
| -
+
|style="text-align:center;"| 11.0
| &nbsp;
+
|Disallow self compare
| Flags comparisons where the left- and right-hand sides are the same.
+
| ''Comparing to itself is potentially pointless.''
 +
| Comparing a variable against itself is usually an error, either an typo or refactoring error. It is confusing to the reader and may potentially introduce a runtime error.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=438319 no-shadow]
!!| no-shadow
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 8.0
| &nbsp;
+
|Variable shadowing
| Flags variables that have the same name as a variable declared in an outer scope.
+
| '''{a}' is already declared in the upper scope.''
 +
| Flags variables that have the same name as a variable declared in an upper scope.
 +
| style="text-align:center;" | ✔
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461321 no-shadow-global]
!| no-spaced-func
+
| Warning
| Ignore
+
|style="text-align:center;" | 9.0
| -
+
|Global shadowing
| ''Unnecessary space in function call.''
+
| '''{a}' shadows a global member.''
| Report on excess space in a function call, for example <code>myFunc ();</code> or <code>new MyObj ();</code>
+
| Flags variables that have the same name as a variable declared in the global scope or specified environments.
|-
+
| style="text-align:center;" | ✔
 
+
!| no-sync
+
| Ignore
+
| -
+
| ''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).
 
 
|-
 
|-
 
+
!style="text-align:left;"| [http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=6e517847ef0742b090130748fb9a0329d33e16bf no-throw-literal]
!| no-ternary
+
| Ignore
+
| -
+
| &nbsp;
+
| Flags any use of the ternary operator <code>cond ? thenExpr : elseExpr</code>
+
|-
+
 
+
!| no-undef-init
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 9.0
| ''It is not necessary to initialize '{variable}' to 'undefined'.''
+
|Literal used in 'throw'
| &nbsp;
+
| ''Throw an Error instead.''
 +
| Flags code that throws a literal, eg. <code>throw "a problem occurred";</code>
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-undef]
!| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=427310 no-unused-params]
+
| Error
+
| -
+
| "Parameter '{param}' is not used."
+
| Flags parameters in function declarations / expressions if they are not being used
+
|-
+
 
+
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-undef]</del>
+
 
| Error
 
| Error
| 5.0
+
|style="text-align:center;" | 5.0
 +
|Undeclared global reference
 
| '''{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 <tt>/*global*/</tt> or <tt>/*globals*/</tt> block.
* Predefined environments (eg. '''node''', '''browser''') can be set in the /*jslint */ block.
+
* Predefined environments (eg. '''node''', '''browser''', '''amd''') can be set in a <tt>/*eslint-env*/</tt> block.
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461852 no-undef-expression]
!| no-underscore-dangle
+
| Warning
| Ignore
+
|style="text-align:center;" | 12.0
| -
+
|Undeclared function reference
| ''Dangling '_'''
+
| '''{member}' is undefined for '{object}' in {file}.''
| &nbsp;
+
| Flags references to a function that is not known to be a property of an object. Will only warn if the object has known properties.
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461852 no-undef-init]
!| no-unreachable
+
| Warning
| Error
+
|style="text-align:center;" | 9.0
| -
+
| Undeclared function reference
| ''Unreachable '{statement}' after '{control flow statement}'.''
+
| ''Avoid explicitly initializing variables to 'undefined'.''
| Flags statements that occur after a <code>return</code>, <code>throw</code>, etc.
+
| Avoid initializing variables to undefined.
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486757 no-unused-expressions]
!| no-unused-expressions
+
| Ignore
| Warning
+
|style="text-align:center;" | 13.0
| -
+
| 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 have no effect on the running code
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=427310 no-unused-params]
!| <deL>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-unused-vars]</del>
+
 
| Warning
 
| Warning
| 5.0
+
|style="text-align:center;" | 6.0
| ''Function declares unused variable '{a}'.''
+
|Unused parameters
| &nbsp;
+
| ''Parameter '{param}' is not used.''
 +
| Flags parameters in function declarations / expressions if they are not being used
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-unused-vars]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-use-before-define]</del>
+
 
| Warning
 
| Warning
| 5.0
+
|style="text-align:center;" | 5.0
 +
| Unused variables
 +
|
 +
*'''{a}' is unread.''
 +
*'''{a}' is read-only.''
 +
*'''{a}' is unused.''
 +
* ''Function '{a}' is unused''
 +
| Warns when a variable is created and not used (read) or a variable that is read-only is assigned to.
 +
Warns when a function is not used.
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 +
|-
 +
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-use-before-define]
 +
| Warning
 +
|style="text-align:center;" | 5.0
 +
|Member used before definition
 
| '''{a}' was used before it was defined.''
 
| '''{a}' was used before it was defined.''
| &nbsp;
+
| Warns when a variable, function or class is used before it is defined
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486755 no-void]
!| no-with
+
| Ignore
 +
|style="text-align:center;"| 13.0
 +
| Disallow use of the void operator.
 +
| Expected 'undefined' and instead saw 'void'.
 +
| Discourage the usage of the void operator.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 +
|-
 +
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461854 no-with]
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 9.0
 +
|Discouraged 'with' statement use
 
| ''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.
 +
|
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=f61bdaf06ac2f40eaca4daed39520cd60c41f5f3 radix]
!| no-wrap-func
+
| Warning
 +
|style="text-align:center;" | 8.0
 +
|Missing radix parameter to parseInt()
 +
| ''Missing radix parameter.''
 +
| Warns when parseInt() called without the 2nd parameter (radix).
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=487695 ✔]
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=487695 ✔]
 +
|-
 +
!style="text-align:left;"| unknown-require
 +
| Warning
 +
|style="text-align:center;" | 12.0
 +
| Validation of the tern settings
 +
| ''This library could not be found, type information for it will be incomplete.''
 +
| Validation of the tern settings for libraries.
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" |
 +
|-
 +
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486754 yoda]
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;" | 13.0
| ''Do not wrap function literals in parens unless they are to be immediately invoked.''
+
| Require or disallow Yoda Conditions
| Flags a parenthesized function literal that is not immediately invoked, eg. <code>(function fun(){})</code>
+
|
 +
* ''Expected literal to be on the right side of ...''
 +
* ''Expected literal to be on the left side of ...''
 +
| Enforce consistent style of conditions which compare a variable to a literal value.
 +
|
 +
|
 
|-
 
|-
 +
|}
  
!| object-prototype-external
+
=== Code Style ===
| Warning
+
These rules are not problems in any way but will warn based on certain accepted styles for coding.
| -
+
| &nbsp;
+
| Flags calls to methods of <code>Object.prototype</code> that rely on the prototype chain. For example this code should be flagged:
+
<source lang="javascript" line="line">
+
foo.hasOwnProperty("bar")
+
</source>
+
  
Example (1) is [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FObject%2FhasOwnProperty#hasOwnProperty_as_a_property unsafe], as <code>foo</code> may have a property named <code>hasOwnProperty</code>, or have been constructed via <code>Object.create(null)</code>.
+
{| class="wikitable sortable" border="1" cellpadding="5" cellspacing="0" style="width: 100%;"
 
+
! width=13% | Rule
As for this:
+
! width=5% | Default Severity
 
+
! width=3% | Available Since
<source lang="javascript" line="line" start="2">
+
! width=24% | Setting Message
Object.hasOwnProperty.call(foo, "bar")
+
! width=24%| Problem Message
</source>
+
! width=24% | Details
 
+
! width=3% | Quick Fix?
Example (2) technically relies on the prototype chain as well: the hasOwnProperty method is defined on Object.prototype, not Object. Object inherits the methods of Object.prototype [http://stackoverflow.com/questions/14817826/difference-between-an-object-and-its-prototype/14817913#14817913 through its prototype chain]. However (2) is unlikely to fail, as sane JavaScript programs will not modify the global objects' prototypes. If we choose to flag (2), it should only be for style.
+
! width=3% | Fix All?
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=424128 missing-doc]
!| one-var
+
| Ignore
| Warning
+
|style="text-align:center;" | 5.0
| -
+
|Missing JSDoc
| ''Too many var statements.''
+
| ''Missing documentation for function '{name}'.''
| Allows only 1 <code>var</code> statement per function.
+
| Flags missing documentation nodes on function declarations and function expressions when they appear as object properties
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486125 ✔]
 +
| style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428429 missing-nls]
!| quote-props
+
| Ignore
| Warning
+
|style="text-align:center;" | 9.0
| -
+
|Non-externalized string literals (missing $NON-NLS$ tag)
| &nbsp;
+
| ''Non-externalized string literal '{a}'.''
| Requires object literal keys to be quoted with " or '.
+
| Flags String literals that are not properly NLS'd
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486126 ✔]
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429801 new-parens]
!| quotes
+
| Error
 +
|style="text-align:center;" | 6.0
 +
|Missing parentheses in constructor call
 +
| ''Missing parentheses invoking constructor.''
 +
| Flags <code>new Whatever</code>
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=486127 ✔]
 +
|
 +
|-
 +
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=482616 no-mixed-spaces-and-tabs]
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;"| 11.0
| &nbsp;
+
|Mixed spaces and tabs
| Flags any use of single or double quote marks, depending on setting.
+
| ''Irregular whitespace not allowed.''
 +
| Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code harder to debug in a similar nature to mixed tabs and spaces.
 +
|style="text-align:center;" |
 +
|style="text-align:center;" |
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=438095 no-jslint]
!| radix
+
 
| Warning
 
| Warning
| -
+
|style="text-align:center;" | 7.0
| ''Missing radix parameter.''
+
|Unsupported environment directive
| Affects parseInt().
+
| ''The 'jslint' directive is unsupported, please use eslint-env.''
 +
| Flags use of the /* jslint */ directive
 +
| style="text-align:center;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=453322 Future]
 +
|
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=500436 no-trailing-spaces]
!| regex-spaces
+
| Ignore
| Warning
+
|style="text-align:center;" | 13.0
| -
+
| Unsupported environment directive
| ''Spaces are hard to count. Use {n}.''
+
| ''Trailing spaces not allowed.''
| &nbsp;
+
| Flags any trailing spaces
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=482619 quotes]
!| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=427930 semi]</del>
+
| Ignore
 +
|style="text-align:center;" | 13.0
 +
| Validate which quotes should be used (either single, double or backtick (es6 only))
 +
| ''Strings must use doublequote.'', ''Strings must use singlequote.'', ''Strings must use backtick.''
 +
| Warns when a quote is not the expected one
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | ✔
 +
|-
 +
!style="text-align:left;" | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=427930 semi]
 
| Warning
 
| Warning
| 5.0
+
|style="text-align:center;" | 5.0
 +
|Missing semicolons
 
| ''Missing semicolon.''
 
| ''Missing semicolon.''
| &nbsp;
+
| Warns when a semicolon should be used but is not
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | ✔
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=483010 unnecessary-nls]
!| strict
+
| Ignore
| 'Ignore
+
|style="text-align:center;" | 11.0
| -
+
|Unnecessary $NON-NLS$ tags
| &nbsp;
+
| ''Unnecessary $NON-NLS$ tag.''
| Flags any code that lacks the <code>"use strict"</code> pragma.
+
| Flags $NON-NLS$ comments that are not needed to exclude a string literal
 +
| style="text-align:center;" | ✔
 +
| style="text-align:center;" | ✔
 
|-
 
|-
 +
|}
  
!| unnecessary-strict
+
=== Future Implementations ===
| Warning
+
| -
+
| &nbsp;
+
| Flags <code>"use strict"</code> on a function when the entire Program is already in strict mode.
+
|-
+
  
!| use-isnan
+
Rules that are being considered for inclusion or were implemented but removed.
| Warning
+
 
| -
+
{| class="wikitable sortable" border="1" cellpadding="5" cellspacing="0" style="width: 100%;"
| ''Use the isNaN function to compare with NaN.''
+
! width=13% | Rule
| &nbsp;
+
! width=5% | Default Severity
 +
! width=3% | Available Since
 +
! width=24% | Setting Message
 +
! width=24%| Problem Message
 +
! width=24% | Details
 +
! width=3% | Quick Fix?
 +
! width=3% | Fix All?
 
|-
 
|-
 
+
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428433 block-scoped-var]
!| wrap-iife
+
| Error
 +
|style="text-align:center;" | -
 +
|
 +
| '''{variable}' used outside of binding context.''
 +
|
 +
Occurs when a function-scoped variable (<tt>var</tt>) is treated as if it was block scoped.
 +
|
 +
|
 +
|-
 +
!style="text-align:left;"| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=424204 missing-doc-items]
 
| Ignore
 
| Ignore
| -
+
|style="text-align:center;" | -
 +
|
 +
| ''Missing '{a}' tag for '{b}'.''
 +
| Flags missing documentation for parameters, returns, throws, etc on function declarations and function expressions when they appear as object properties
 +
|
 
|
 
|
* ''Wrap the entire immediate function invocation in parens.''
 
* ''Move the invocation into the parens that contain the function.''
 
| Flags missing parens on immediately-invoked functions, eg. <code>function(){ console.log('hi'); }();</code>
 
 
|-
 
|-
 
!| wrap-regex
 
| Warning
 
| -
 
| ''Wrap the /regexp/ literal in parens to disambiguate the slash operator.''
 
| &nbsp;
 
|-
 
 
 
 
|}
 
|}
  
== Tests ==
+
== Implementing a new rule ==
* Every rule needs extensive unit tests
+
''This section explains how to implement a new linting rule. For brevity, all paths are given relative to <tt>bundles/org.eclipse.orion.client.javascript/web/</tt> in the client repo.''
* Unit tests should use Mocha
+
  
Currently the tests are run from Node.js. They do not run in the browser (yet).
+
First, create the tests and rule:
 +
# Create a new <tt>describe("{rule-name}")</tt> block in: <tt>/js-tests/javascript/eslintRuleTests.js</tt>. Add several tests to it.
 +
# [[#Running the tests|Run the JS bundle tests]] and ensure that your new tests fail.
 +
# Implement the actual logic for your rule in <tt>/eslint/lib/load-rules-async.js</tt>.
 +
# Run the tests again. This time they should all pass.
  
=== Test requirements ===
+
To get your rule running in the Orion product's validator, there are additional steps:
First install [http://nodejs.org/ Node.js]. Then open a console and install Mocha globally:
+
# Create strings for the validation message(s) generated by your rule in <tt>/javascript/nls/root/problems.js</tt>.
 +
# Create a short string describing what your rule does in <tt>/javascript/nls/root/messages.js</tt>.
 +
# Add an entry to the <tt>orion.core.setting</tt> declaration in <tt>/javascript/plugins/javascriptPlugin.js</tt>. This allows your rule to be configured from the JS validator settings page. Make sure it references the same <tt>nameKey</tt> used in <tt>messages.js</tt>.
 +
# Add a config entry for your rule to <tt>/javascript/ruleData.js</tt>.
 +
# Add your rule to the #updated() handler in <tt>/javascript/validator.js</tt>.
  
$ npm install mocha -g
+
Reload the JS plugin, and your rule should now be configurable from the Settings page, and properly set up for translation too.
  
Then from your Orion client repository, run these commands to install eslint's dependencies:
+
== Tests ==
 
+
* Every rule needs extensive unit tests.
$ cd bundles/org.eclipse.orion.client.javascript/web/eslint/
+
* Unit tests should use [http://mochajs.org Mocha].
$ npm install
+
  
 
=== Running the tests ===
 
=== Running the tests ===
From the <code>bundles/org.eclipse.orion.client.javascript/web/eslint/</code> directory, simply run <code>npm test</code>:
+
* To run the ESLint tests as part of the main JavaScript tests suite load <tt>{orion-server-url}/javascript/js-tests/JsMochaSuite.html</tt> in your web browser.
 
+
** Click [https://orionhub.org/js-tests/javascript/JsMochaSuite.html here] to see the suite running on [https://orionhub.org orionhub].
$ npm test
+
* To run just the ESLint rule tests, load <tt>{orion-server-url}/js-tests/javascript/JsMochaSuite.html?grep=ESLint%20Rule%20Tests</tt> in your browser.
+
** Click [https://orionhub.org/js-tests/javascript/JsMochaSuite.html?grep=ESLint%20Rule%20Tests here] to see the suite running on [https://orionhub.org orionhub].
> eslint@0.2.0-dev test c:\Users\mamacdon\code\orion\client\bundles\org.eclipse.orion.client.javascript\web\eslint
+
* To run just the ESLint core tests, load <tt>{orion-server-url}/js-tests/javascript/JsMochaSuite.html?grep=ESLint%20Core%20Tests</tt> in your browser.
> bash scripts/test.sh
+
** Click [https://orionhub.org/js-tests/javascript/JsMochaSuite.html?grep=ESLint%20Core%20Tests here] to see the suite running on [https://orionhub.org orionhub].
+
* To run only a subset of the tests, add <tt>?grep=ESLint%20Rule%20Tests</tt> onto the test page URL.  
+
  ......................................................................
+
  ...............
+
+
  85 passing (106ms)
+
 
+
To run only a subset of the tests, launch mocha from the command line, passing the test file:
+
 
+
$ mocha tests/lib/rules/semi.js
+
+
  ............
+
+
  12 passing (17ms)
+
 
+
You can also pass an entire directory:
+
 
+
$ mocha tests/lib/rules
+
+
  ......................................................................
+
  ..........
+
+
  80 passing (104ms)
+
 
+
To run only some tests from a file, use the --grep option:
+
 
+
$ mocha tests/lib/rules/semi.js --grep VariableDeclaration
+
+
  .
+
+
  1 passing (5ms)
+
  
See [http://visionmedia.github.io/mocha/#usage Mocha usage options] for more.
+
See [http://mochajs.org/#grep-query Mocha usage options] for more options.
  
 
== User interface ==
 
== User interface ==
 
* <del>Should we have a UI for configuring what rules are active?</del> [https://bugs.eclipse.org/bugs/show_bug.cgi?id=424268 bug 424268].
 
* <del>Should we have a UI for configuring what rules are active?</del> [https://bugs.eclipse.org/bugs/show_bug.cgi?id=424268 bug 424268].
* Should we try to support <code>.eslintrc</code>? This would be an ideal project-scope setting.
+
* Should we try to support <code>.eslintrc</code>? This would be an ideal project-scope setting, and is being tracked in [https://bugs.eclipse.org/bugs/show_bug.cgi?id=461228 bug 461228].
* Should we try to honor equivalent JSLint/JSHint flags when possible? For example <code>/*jslint eqeqeq:false */</code> could disable the eqeqeq rule on a per-file basis.
+
* <del>Should we try to honor equivalent JSLint/JSHint flags when possible? For example <code>/*jslint eqeqeq:false */</code> could disable the eqeqeq rule on a per-file basis.</del>
** This would give compatibility with Orion codebase which uses these flags.
+
** ESLint now has its own syntax for this: <code>/*eslint ..*/</code>, which we are using instead.
** OTOH, eslint now has its own syntax for this: <code>/*eslint ..*/</code>, which we should perhaps use instead.
+
  
 
== i18n ==
 
== i18n ==
We need to support i18n. Pre-req is {{bug|422278}} (orion.edit.validator support for i18n).
+
<del>We need to support i18n. Pre-req is {{bug|422278}} (orion.edit.validator support for i18n).</del>
  
 
[[Category:Orion]]
 
[[Category:Orion]]
 +
[[Category:JavaScript]]

Latest revision as of 17:38, 8 December 2016

Orion 5.0 introduced ESLint as the validator that ships with Orion. This page captures ongoing issues.

Rules

The following sections describe all of the rules currently available in Orion and ones that we plan to add in the future.

To view this table in the same order as the Orion Settings page, hover over the Setting Message column title and press the down arrow to sort.

Potential Programming Problems

These rules report about problems with your code that might have undesired or incorrect results. Warnings from these rules should be addressed.

Rule Default Severity Available Since Setting Message Problem Message Details Quick Fix? Fix All?
no-comma-dangle Ignore 8.0 Trailing commas in object expressions Trailing commas in object expressions are discouraged. Flags trailing commas in object expressions.
no-cond-assign Error 8.0 Assignments in conditional expressions Expected a conditional expression and instead saw an assignment. Flags assignment in an if/while/do..while/for condition.
no-console Ignore 8.0 Discouraged console use in browser code Discouraged use of console in browser-based code. Flags the use of console in browser-based code
no-constant-condition Error 8.0 Constant as conditional expression ... is constant. Flags the use of a constant as a conditional expression
no-const-assign Error 13.0 Disallow modifying variables that are declared using const Discouraged use of constant as a conditional expression. Flags the assignment to a constant variable
no-control-regex Error 11.0 Disallow control characters in regular expressions Unexpected control character in regular expression Control characters are special, invisible characters in the ASCII range 0-31. These characters are rarely used in JavaScript strings so a regular expression containing these characters is most likely a mistake.
no-debugger Warning 6.0 Discouraged 'debugger' statement use debugger' statement use is discouraged. Warns when the debugger keyword is used
no-dupe-keys Error 6.0 Duplicate object keys Duplicate object key '{key}'. Flags object literals that contain the same key more than once.
no-duplicate-case Error 11.0 Duplicate case Duplicate case label. A switch statements with duplicate case labels is normally an indication of a programmer error.
no-empty-block Ignore 7.0 Undocumented empty block Empty block should be removed or commented. Flags an empty block like if (something) { }.
no-empty-character-class Error 11.0 Disallow empty character classes Empty class. Empty character classes in regular expressions do not match anything and can result in code that may not work as intended.
no-extra-boolean-cast Error 11.0 Discourage redundant double negation Redundant double negation in ... In contexts such as an if statement's test where the result of the expression will already be coerced to a Boolean, casting to a Boolean via double negation (!!) is unnecessary.
no-extra-parens Warning 11.0 Discourage redundant parentheses Gratuitous parentheses around expression. This rule restricts the use of parentheses to only where they are necessary. It may be restricted to report only function expressions.
no-extra-semi Warning 5.0 Unnecessary semicolons Unnecessary semicolon. Warns when a semicolon is found where it is not needed
no-fallthrough Error 6.0 Switch case fall-through Switch case may be entered by falling through previous case. If intended, add a new comment //$FALL-THROUGH$ on the line above Flags a fallthrough case within a switch statement, unless it is explicitly commented.
no-invalid-regexp Error 11.0 Invalid regular expressions Invalid flags supplied to RegExp constructor '{${0}}'. or the error message from calling the constructor with the regex This rule validates string arguments passed to the RegExp constructor.
no-irregular-whitespace Ignore 11.0 Report irregular whitespace 'Irregular whitespace not allowed This rule validates all whitespaces
no-negated-in-lhs Error 11.0 Disallow negated left operand of in operator The 'in' expression's left operand is negated. Disallow negated left operand of in operator
no-obj-calls Error 11.0 Disallow global object as function calls '{${0}}' is not a function. ECMAScript provides several global objects that are intended to be used as-is. Some of these objects look as if they could be constructors due their capitalization (such as Math and JSON) but will throw an error if you try to execute them as functions.
no-regex-spaces Error 8.0 Multiple spaces in regular expressions Avoid using multiple spaces in regular expressions. Use ' {${0}}' instead. Flags regular expressions that have two or more subsequent spaces.
no-reserved-keys Ignore 8.0 Reserved words used as property keys Reserved words should not be used as property keys. Checks to see if a JavaScript reserved word is being used as a property key
no-sparse-arrays Warning 8.0 Sparse array declarations Sparse array declarations should be avoided. Flags sparse arrays with null elements like var arr = [1, ,2]
no-unreachable Warning 6.0 Unreachable code Unreachable code. Flags statements that occur after a return, throw, etc.
type-checked-consistent-return Ignore 11.0 Discouraged inconsistent returns Inconsistent return types: (type1) (type2) Warns when a function returns two values with different types.
use-isnan Error 6.0 NaN not compared with isNaN() Use the isNaN function to compare with NaN. Warns when a comparison is done against NaN without using the isNaN function
valid-typeof Error 7.0 Invalid 'typeof' comparison Invalid typeof comparison. Warns when a typeof comparison uses an invalid type.

Best Practices

These rules are not necessarily problem with your code, but are warnings that you might be doing something you probably should not be.

Rule Default Severity Available Since Setting Message Problem Message Details Quick Fix? Fix All?
accessor-pairs Warning 11.0 Getter and setter accessors not in pairs Getter is not present or Setter is not present It's a common mistake in JavaScript to create an object with just a setter for a property but never have a corresponding getter defined for it. Without a getter, you cannot read the property, so it ends up not being used.
check-tern-plugin Warning 12.0 Missing .tern-project plugins entry for environment directive To work in the 'foo' environment, the 'bar' plugin must be running. Warn when the an eslint-env directive specifies a library Orion provides tooling support for, but the library plugin has been disabled in the .tern-project file.
curly Ignore 6.0 Statements not enclosed in braces Statements should be enclosed in braces. Warns when statements should be enclosed in braces, for example if(something) foo();
eqeqeq Warning 5.0 Discouraged '==' use
  • Expected '===' and saw '=='.
  • Expected '!==' and saw '!='.
Warns when == or != is used
missing-requirejs Warning 12.0 'requirejs' plugin missing in AMD environment To use AMD, the 'requirejs' plug-in needs to be running. Flags references to function calls from AMD when the Tern 'requirejs' plugin is not running
no-caller Error 9.0 Discouraged 'arguments.caller' or 'arguments.callee' use arguments.{callee, caller} is deprecated. Flags references to arguments.callee and arguments.caller. Future
no-else-return Warning 11.0 Unnecessary else after return Unexpected 'else' after 'return'. If an if block contains a return statement, the else block becomes unnecessary. Its contents can be placed outside of the block.
no-empty-label Error 11.0 No empty labels Unexpected label "{${0}}" Labeled statements are only used in conjunction with labeled break and continue statements. ECMAScript has no goto statement.
no-eq-null Error 11.0 Disallow null comparisons Use ‘===’ to compare with ‘null’. or Use ‘!==’ to compare with ‘null’. Comparing to null without a type-checking operator (== or !=), can have unintended results as the comparison will evaluate to true when comparing to not just a null, but also an undefined value.
no-extend-native Error 13.0 Disallow extending of native objects '..... prototype is read only, properties should not be added.' Disallows directly modifying the prototype of builtin objects.
no-extra-bind Warning 13.0 Unnecessary 'bind()' use The function binding is unnecessary. Warns about unnecessary use of bind()
no-eval Ignore 6.0 Discouraged 'eval()' use 'eval' function calls are discouraged. Warns when the eval() function is used
no-implicit-coercion Warning 13.0 Disallow the type conversion with shorter notations. use `Boolean(..)` instead., use `...indexOf(".") !== -1` instead., use `Number(..)` instead., use `String(foo)` instead. This rule is aimed to flag shorter notations for the type conversion, then suggest a more self-explanatory notation.
no-implied-eval Ignore 6.0 Discouraged implied 'eval()' use Implicit 'eval' function calls are discouraged. Flags calls to the string-argument form of setTimeout and setInterval, which implicitly perform eval. This rule logic was merged to be part of the no-eval rule.
no-invalid-this Warning 13.0 Discouraged 'this' use outside of classes or class-like objects Unexpected 'this' This rule aims to flag usage of 'this' keywords outside of classes or class-like objects
no-iterator Error 8.0 Discouraged __iterator__ property use Discouraged __iterator__ property use. Flags use of __iterator__ as an identifier name or property key.
no-lone-blocks Ignore 13.0 Discouraged lone block use Block is redundant. or Nested block is redundant. Flags use of unnecessary and potentially confusing blocks at the top level of a script or within other blocks.
no-native-reassign Error 13.0 Disallow reassignment of native objects ... is a read-only native object. This rule flags modifications to read-only global variables
no-new-array Warning 6.0 Discouraged 'new Array()' Use the array literal notation []. Flags new Array(). ESLint calls this rule no-array-constructor
no-new-func Warning 6.0 Discouraged 'new Function()' The Function constructor is eval. Flags new Function().
no-new-object Warning 6.0 Discouraged 'new Object()' Use the object literal notation {}. Flags new Object().
no-new-wrappers Warning 6.0 Discouraged wrapper objects Do not use {String, Number, Boolean, Math, JSON} as a constructor. Flags new applied to any of those.
no-param-reassign Ignore 13.0 Disallow Reassignment of Function Parameters
  • Assignment to function parameter 'bar'.
  • Assignment to property of function parameter 'bar'.
Report parameter reassignment inside functions. Can also report reassignment of parameter's properties.
no-proto Error 9.0 Discouraged __proto__ property use
  • Reserved name '__proto__' should not be assigned.
  • Reserved name '__proto__' should not be used as a key.
Flags use of the property __proto__ as object keys or in assignments
no-redeclare Warning 5.0 Variable re-declarations '{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-self-assign Error 11.0 Disallow self assignment '{a}' is assigned to itself. Warns when a variable is being assigned to itself
no-self-compare Error 11.0 Disallow self compare Comparing to itself is potentially pointless. Comparing a variable against itself is usually an error, either an typo or refactoring error. It is confusing to the reader and may potentially introduce a runtime error.
no-shadow Warning 8.0 Variable shadowing '{a}' is already declared in the upper scope. Flags variables that have the same name as a variable declared in an upper scope.
no-shadow-global Warning 9.0 Global shadowing '{a}' shadows a global member. Flags variables that have the same name as a variable declared in the global scope or specified environments.
no-throw-literal Warning 9.0 Literal used in 'throw' Throw an Error instead. Flags code that throws a literal, eg. throw "a problem occurred";
no-undef Error 5.0 Undeclared global reference '{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, amd) can be set in a /*eslint-env*/ block.
no-undef-expression Warning 12.0 Undeclared function reference '{member}' is undefined for '{object}' in {file}. Flags references to a function that is not known to be a property of an object. Will only warn if the object has known properties.
no-undef-init Warning 9.0 Undeclared function reference Avoid explicitly initializing variables to 'undefined'. Avoid initializing variables to undefined.
no-unused-expressions Ignore 13.0 Unused expressions Expected an assignment or function call and instead saw an expression. Flags expressions that have no effect on the running code
no-unused-params Warning 6.0 Unused parameters Parameter '{param}' is not used. Flags parameters in function declarations / expressions if they are not being used
no-unused-vars Warning 5.0 Unused variables
  • '{a}' is unread.
  • '{a}' is read-only.
  • '{a}' is unused.
  • Function '{a}' is unused
Warns when a variable is created and not used (read) or a variable that is read-only is assigned to.

Warns when a function is not used.

no-use-before-define Warning 5.0 Member used before definition '{a}' was used before it was defined. Warns when a variable, function or class is used before it is defined
no-void Ignore 13.0 Disallow use of the void operator. Expected 'undefined' and instead saw 'void'. Discourage the usage of the void operator.
no-with Warning 9.0 Discouraged 'with' statement use Expected an identifier and instead saw 'with'. Treated as fatal parse error in JSLint.
radix Warning 8.0 Missing radix parameter to parseInt() Missing radix parameter. Warns when parseInt() called without the 2nd parameter (radix).
unknown-require Warning 12.0 Validation of the tern settings This library could not be found, type information for it will be incomplete. Validation of the tern settings for libraries.
yoda Ignore 13.0 Require or disallow Yoda Conditions
  • Expected literal to be on the right side of ...
  • Expected literal to be on the left side of ...
Enforce consistent style of conditions which compare a variable to a literal value.

Code Style

These rules are not problems in any way but will warn based on certain accepted styles for coding.

Rule Default Severity Available Since Setting Message Problem Message Details Quick Fix? Fix All?
missing-doc Ignore 5.0 Missing JSDoc Missing documentation for function '{name}'. Flags missing documentation nodes on function declarations and function expressions when they appear as object properties
missing-nls Ignore 9.0 Non-externalized string literals (missing $NON-NLS$ tag) Non-externalized string literal '{a}'. Flags String literals that are not properly NLS'd
new-parens Error 6.0 Missing parentheses in constructor call Missing parentheses invoking constructor. Flags new Whatever
no-mixed-spaces-and-tabs Ignore 11.0 Mixed spaces and tabs Irregular whitespace not allowed. Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code harder to debug in a similar nature to mixed tabs and spaces.
no-jslint Warning 7.0 Unsupported environment directive The 'jslint' directive is unsupported, please use eslint-env. Flags use of the /* jslint */ directive Future
no-trailing-spaces Ignore 13.0 Unsupported environment directive Trailing spaces not allowed. Flags any trailing spaces
quotes Ignore 13.0 Validate which quotes should be used (either single, double or backtick (es6 only)) Strings must use doublequote., Strings must use singlequote., Strings must use backtick. Warns when a quote is not the expected one
semi Warning 5.0 Missing semicolons Missing semicolon. Warns when a semicolon should be used but is not
unnecessary-nls Ignore 11.0 Unnecessary $NON-NLS$ tags Unnecessary $NON-NLS$ tag. Flags $NON-NLS$ comments that are not needed to exclude a string literal

Future Implementations

Rules that are being considered for inclusion or were implemented but removed.

Rule Default Severity Available Since Setting Message Problem Message Details Quick Fix? Fix All?
block-scoped-var Error - '{variable}' used outside of binding context.

Occurs when a function-scoped variable (var) is treated as if it was block scoped.

missing-doc-items Ignore - Missing '{a}' tag for '{b}'. Flags missing documentation for parameters, returns, throws, etc on function declarations and function expressions when they appear as object properties

Implementing a new rule

This section explains how to implement a new linting rule. For brevity, all paths are given relative to bundles/org.eclipse.orion.client.javascript/web/ in the client repo.

First, create the tests and rule:

  1. Create a new describe("{rule-name}") block in: /js-tests/javascript/eslintRuleTests.js. Add several tests to it.
  2. Run the JS bundle tests and ensure that your new tests fail.
  3. Implement the actual logic for your rule in /eslint/lib/load-rules-async.js.
  4. Run the tests again. This time they should all pass.

To get your rule running in the Orion product's validator, there are additional steps:

  1. Create strings for the validation message(s) generated by your rule in /javascript/nls/root/problems.js.
  2. Create a short string describing what your rule does in /javascript/nls/root/messages.js.
  3. Add an entry to the orion.core.setting declaration in /javascript/plugins/javascriptPlugin.js. This allows your rule to be configured from the JS validator settings page. Make sure it references the same nameKey used in messages.js.
  4. Add a config entry for your rule to /javascript/ruleData.js.
  5. Add your rule to the #updated() handler in /javascript/validator.js.

Reload the JS plugin, and your rule should now be configurable from the Settings page, and properly set up for translation too.

Tests

  • Every rule needs extensive unit tests.
  • Unit tests should use Mocha.

Running the tests

  • To run the ESLint tests as part of the main JavaScript tests suite load {orion-server-url}/javascript/js-tests/JsMochaSuite.html in your web browser.
  • To run just the ESLint rule tests, load {orion-server-url}/js-tests/javascript/JsMochaSuite.html?grep=ESLint%20Rule%20Tests in your browser.
  • To run just the ESLint core tests, load {orion-server-url}/js-tests/javascript/JsMochaSuite.html?grep=ESLint%20Core%20Tests in your browser.
  • To run only a subset of the tests, add ?grep=ESLint%20Rule%20Tests onto the test page URL.

See Mocha usage options for more options.

User interface

  • Should we have a UI for configuring what rules are active? bug 424268.
  • Should we try to support .eslintrc? This would be an ideal project-scope setting, and is being tracked in bug 461228.
  • Should we try to honor equivalent JSLint/JSHint flags when possible? For example /*jslint eqeqeq:false */ could disable the eqeqeq rule on a per-file basis.
    • ESLint now has its own syntax for this: /*eslint ..*/, which we are using instead.

i18n

We need to support i18n. Pre-req is bug 422278 (orion.edit.validator support for i18n).

Back to the top