Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Orion/ESLint"
(→Rule parity) |
(→Rules) |
||
Line 167: | Line 167: | ||
!| no-console | !| no-console | ||
− | | | + | | Ignore |
− | | | + | | - |
− | | | + | | |
+ | | | ||
|- | |- | ||
!| no-control-regex | !| no-control-regex | ||
− | | | + | | Ignore |
− | | | + | | - |
+ | | | ||
| Flags control characters (U+0000–U+001F and U+007F) within the source argument to the RegExp constructor. | | Flags control characters (U+0000–U+001F and U+007F) within the source argument to the RegExp constructor. | ||
|- | |- | ||
− | !| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=429690 no-debugger] | + | !| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=429690 no-debugger]</del> |
− | | | + | | Warning |
− | | '' | + | | 6.0 |
− | | | + | | '''debugger' statement use is discouraged.'' |
+ | | | ||
|- | |- | ||
!| no-delete-var | !| no-delete-var | ||
− | | | + | | Warning |
+ | | - | ||
| ''Expected '.' and instead saw ';'.'' | | ''Expected '.' and instead saw ';'.'' | ||
| Flags an attempt to <code>delete</code> a local variable. | | Flags an attempt to <code>delete</code> a local variable. | ||
Line 191: | Line 195: | ||
!| no-div-regex | !| no-div-regex | ||
− | | | + | | Warning |
+ | | - | ||
| ''A regular expression literal can be confused with '/='.'' | | ''A regular expression literal can be confused with '/='.'' | ||
| Flags a regex literal starting with <code>/=</code> | | Flags a regex literal starting with <code>/=</code> | ||
Line 197: | Line 202: | ||
!| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428429 no-dupe-keys] | !| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428429 no-dupe-keys] | ||
− | | | + | | Error |
+ | | - | ||
| ''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 203: | Line 209: | ||
!| no-else-return | !| no-else-return | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Flags an <code>else</code> appearing after an <code>if</code> that contains a <code>return</code>. | | Flags an <code>else</code> appearing after an <code>if</code> that contains a <code>return</code>. | ||
|- | |- | ||
!| no-empty-class | !| no-empty-class | ||
− | | | + | | Warning |
+ | | - | ||
| ''Empty class.'' | | ''Empty class.'' | ||
| Flags an empty character class <code>[]</code> within a regular expression. | | Flags an empty character class <code>[]</code> within a regular expression. | ||
Line 215: | Line 223: | ||
!| no-empty-label | !| no-empty-label | ||
− | | | + | | Warning |
− | | ''Label '{a}' on statement.'' | + | | - |
+ | | ''Label '{a}' is not allowed on this statement.'' | ||
| Flags a labeled statement that is not a <code>switch</code>, <code>for</code>, or <code>while</code>. | | Flags a labeled statement that is not a <code>switch</code>, <code>for</code>, or <code>while</code>. | ||
|- | |- | ||
!| no-empty | !| no-empty | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Flags an empty block like <code>if (something) { }</code>. | | Flags an empty block like <code>if (something) { }</code>. | ||
|- | |- | ||
!| no-eq-null | !| no-eq-null | ||
− | | | + | | Error |
+ | | - | ||
| ''Use '===' to compare with 'null'.'' | | ''Use '===' to compare with 'null'.'' | ||
− | | | + | | |
|- | |- | ||
!| no-eval | !| no-eval | ||
− | | | + | | Ignore |
− | | ''eval | + | | - |
+ | | '''eval' should not be called.'' | ||
+ | | | ||
|- | |- | ||
!| no-ex-assign | !| no-ex-assign | ||
− | | | + | | Warning |
+ | | - | ||
| ''Do not assign to the exception parameter.'' | | ''Do not assign to the exception parameter.'' | ||
+ | | | ||
|- | |- | ||
− | !| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=428040 no-extra-semi] | + | !| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=428040 no-extra-semi]</del> |
− | | | + | | Warning |
+ | | 5.0 | ||
| ''Unnecessary semicolon.'' | | ''Unnecessary semicolon.'' | ||
+ | | | ||
|- | |- | ||
!| no-fallthrough | !| no-fallthrough | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Flags a fallthrough case within a <code>switch</code> statement, unless it is explicitly commented. | | Flags a fallthrough case within a <code>switch</code> statement, unless it is explicitly commented. | ||
|- | |- | ||
!| no-floating-decimal | !| no-floating-decimal | ||
− | | | + | | Warning |
+ | | - | ||
| ''A {leading, trailing} decimal point can be confused with a dot: '{n}'.'' | | ''A {leading, trailing} decimal point can be confused with a dot: '{n}'.'' | ||
| Flags numeric literals that have a leading or trailing decimal point. | | Flags numeric literals that have a leading or trailing decimal point. | ||
Line 260: | Line 279: | ||
!| no-func-assign | !| no-func-assign | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Flags assignment to a variable that's already bound to a <code>FunctionExpression</code>. | | Flags assignment to a variable that's already bound to a <code>FunctionExpression</code>. | ||
|- | |- | ||
!| no-global-strict | !| no-global-strict | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Flags <code>"use strict"</code> applied to the entire Program. | | Flags <code>"use strict"</code> applied to the entire Program. | ||
|- | |- | ||
!| no-implied-eval | !| no-implied-eval | ||
− | | | + | | Ignore |
+ | | - | ||
| ''Implied eval is evil. Pass a function instead of a string.'' | | ''Implied eval is evil. Pass a function instead of a string.'' | ||
| Flags calls to the string-argument form of <code>setTimeout</code> and <code>setInterval</code>, which implicitly perform <code>eval</code>. | | Flags calls to the string-argument form of <code>setTimeout</code> and <code>setInterval</code>, which implicitly perform <code>eval</code>. | ||
Line 278: | Line 300: | ||
!| no-iterator | !| no-iterator | ||
− | | | + | | Error |
+ | | - | ||
| ''Reserved name '__iterator__'.'' | | ''Reserved name '__iterator__'.'' | ||
| Flags use of __iterator__ as an identifier name or property key. | | Flags use of __iterator__ as an identifier name or property key. | ||
Line 284: | Line 307: | ||
!| no-label-var | !| no-label-var | ||
− | | | + | | Error |
+ | | - | ||
| '''{label}' is already defined.'' | | '''{label}' is already defined.'' | ||
| Flags labels that collide with an identifier. | | Flags labels that collide with an identifier. | ||
Line 290: | Line 314: | ||
!| no-loop-func | !| no-loop-func | ||
− | | | + | | Error |
+ | | - | ||
| ''Don't make functions within a loop.'' | | ''Don't make functions within a loop.'' | ||
− | | | + | | |
|- | |- | ||
!| no-mixed-requires | !| no-mixed-requires | ||
− | | | + | | Ignore |
− | | | + | | - |
+ | | | ||
| Flags Node.js <code>require()</code>s that mix different types of requires (core, module, file, computed). | | Flags Node.js <code>require()</code>s that mix different types of requires (core, module, file, computed). | ||
|- | |- | ||
!| no-multi-str | !| no-multi-str | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Flags use of ES5 multiline string literals. | | Flags use of ES5 multiline string literals. | ||
|- | |- | ||
!| no-native-reassign | !| no-native-reassign | ||
− | | | + | | Warning |
+ | | - | ||
| | | | ||
* ''Read only.'' | * ''Read only.'' | ||
Line 316: | Line 344: | ||
!| no-negated-in-lhs | !| no-negated-in-lhs | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| | | | ||
* Flags a unary <code>!</code> operator applied to the LHS of an in statement, which negates the LHS, not the <code>in</code>. | * Flags a unary <code>!</code> operator applied to the LHS of an in statement, which negates the LHS, not the <code>in</code>. | ||
Line 324: | Line 353: | ||
!| no-new-array | !| no-new-array | ||
− | | | + | | Warning |
+ | | - | ||
| ''Use the array literal notation [].'' | | ''Use the array literal notation [].'' | ||
| Flags <code>new Array()</code>. | | Flags <code>new Array()</code>. | ||
Line 330: | Line 360: | ||
!| no-new-func | !| no-new-func | ||
− | | | + | | Warning |
+ | | - | ||
| ''The Function constructor is eval.'' | | ''The Function constructor is eval.'' | ||
− | | | + | | Flags <code>new Function()</code>. |
|- | |- | ||
!| no-new-object | !| no-new-object | ||
− | | | + | | Warning |
+ | | - | ||
| ''Use the object literal notation {}.'' | | ''Use the object literal notation {}.'' | ||
| Flags <code>new Object()</code>. | | Flags <code>new Object()</code>. | ||
Line 342: | Line 374: | ||
!| no-new-wrappers | !| no-new-wrappers | ||
− | | | + | | Warning |
+ | | - | ||
| ''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. | ||
Line 348: | Line 381: | ||
!| no-new | !| no-new | ||
− | | | + | | Error |
+ | | - | ||
| ''Do not use 'new' for side effects.'' | | ''Do not use 'new' for side effects.'' | ||
| Flags uses of <code>new</code> operator in an expression that is not assigned to anything. | | Flags uses of <code>new</code> operator in an expression that is not assigned to anything. | ||
Line 354: | Line 388: | ||
!| no-obj-calls | !| no-obj-calls | ||
− | | | + | | Warning |
+ | | - | ||
| ''Math is not a function..'' | | ''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>. | * Flags attempts to call object properties of the global object (<code>Math</code>, <code>JSON</code>) as a function, like <code>Math()</code>. | ||
− | |||
|- | |- | ||
!| no-octal-escape | !| no-octal-escape | ||
− | | | + | | Warning |
+ | | - | ||
| ''Bad escapement.'' | | ''Bad escapement.'' | ||
| Flags octal escapes in strings, for example <code>var x = "Copyright \251";</code> | | Flags octal escapes in strings, for example <code>var x = "Copyright \251";</code> | ||
Line 368: | Line 403: | ||
!| no-octal | !| no-octal | ||
− | | | + | | Warning |
+ | | - | ||
| ''Don't use extra leading zeros '{n}'.'' | | ''Don't use extra leading zeros '{n}'.'' | ||
| Flags number literals that begin with leading 0s, which indicate a (probably accidental) octal literal. | | Flags number literals that begin with leading 0s, which indicate a (probably accidental) octal literal. | ||
Line 374: | Line 410: | ||
!| no-plusplus | !| no-plusplus | ||
− | | | + | | Warning |
+ | | - | ||
| | | | ||
* ''Unexpected use of '++''' | * ''Unexpected use of '++''' | ||
* ''Unexpected use of '--''' | * ''Unexpected use of '--''' | ||
+ | | | ||
|- | |- | ||
!| no-proto | !| no-proto | ||
− | | | + | | Error |
+ | | - | ||
| | | | ||
− | * ''Reserved name '__proto__'. | + | * ''Reserved name '__proto__' should not be assigned." |
− | * '' | + | * 'Reserved name '__proto__' should not be used as a key." |
− | | | + | | |
|- | |- | ||
− | !| no-redeclare | + | !| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-redeclare]</del> |
− | | | + | | Warning |
+ | | 5.0 | ||
| '''{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 395: | Line 435: | ||
!| no-return-assign | !| no-return-assign | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| | | | ||
* Prevents assignment in a <code>return</code> statement. | * Prevents assignment in a <code>return</code> statement. | ||
Line 403: | Line 444: | ||
!| no-script-url | !| no-script-url | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| | | | ||
* Flags string literals beginning with <code>javascript:</code>. (Script URLs are a form of <code>eval</code>.) | * Flags string literals beginning with <code>javascript:</code>. (Script URLs are a form of <code>eval</code>.) | ||
− | |||
|- | |- | ||
!| no-self-compare | !| no-self-compare | ||
− | | | + | | Error |
− | | | + | | - |
+ | | | ||
| Flags comparisons where the left- and right-hand sides are the same. | | Flags comparisons where the left- and right-hand sides are the same. | ||
|- | |- | ||
!!| no-shadow | !!| no-shadow | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Flags variables that have the same name as a variable declared in an outer scope. | | Flags variables that have the same name as a variable declared in an outer scope. | ||
|- | |- | ||
Line 428: | Line 471: | ||
!| no-sync | !| no-sync | ||
− | | | + | | Ignore |
+ | | - | ||
| ''Unexpected sync method: '{a}'.'' | | ''Unexpected sync method: '{a}'.'' | ||
| | | | ||
Line 436: | Line 480: | ||
!| no-ternary | !| no-ternary | ||
− | | | + | | Ignore |
− | | | + | | - |
+ | | | ||
| Flags any use of the ternary operator <code>cond ? thenExpr : elseExpr</code> | | Flags any use of the ternary operator <code>cond ? thenExpr : elseExpr</code> | ||
|- | |- | ||
!| no-undef-init | !| no-undef-init | ||
− | | | + | | Warning |
+ | | - | ||
| ''It is not necessary to initialize '{variable}' to 'undefined'.'' | | ''It is not necessary to initialize '{variable}' to 'undefined'.'' | ||
− | | | + | | |
|- | |- | ||
− | !| no-undef | + | !| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-undef]</del> |
− | | | + | | Error |
+ | | 5.0 | ||
| '''{variable}' is not defined.'' | | '''{variable}' is not defined.'' | ||
| | | | ||
Line 456: | Line 503: | ||
!| no-underscore-dangle | !| no-underscore-dangle | ||
− | | | + | | Ignore |
+ | | - | ||
| ''Dangling '_''' | | ''Dangling '_''' | ||
+ | | | ||
|- | |- | ||
!| no-unreachable | !| no-unreachable | ||
− | | | + | | Error |
+ | | - | ||
| ''Unreachable '{statement}' after '{control flow statement}'.'' | | ''Unreachable '{statement}' after '{control flow statement}'.'' | ||
| Flags statements that occur after a <code>return</code>, <code>throw</code>, etc. | | Flags statements that occur after a <code>return</code>, <code>throw</code>, etc. | ||
Line 467: | Line 517: | ||
!| no-unused-expressions | !| no-unused-expressions | ||
− | | | + | | Warning |
+ | | - | ||
| ''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. | ||
|- | |- | ||
− | !| no-unused-vars | + | !| <deL>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-unused-vars]</del> |
− | | | + | | Warning |
− | | ''Function declares unused variable '{a}'.'' | + | | 5.0 |
− | | | + | | ''Function declares unused variable '{a}'.'' |
+ | | | ||
|- | |- | ||
− | !| no-use-before-define | + | !| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=414779 no-use-before-define]</del> |
− | | | + | | Warning |
+ | | 5.0 | ||
| '''{a}' was used before it was defined.'' | | '''{a}' was used before it was defined.'' | ||
+ | | | ||
|- | |- | ||
!| no-with | !| no-with | ||
− | | | + | | Warning |
+ | | - | ||
| ''Expected an identifier and instead saw 'with'.'' | | ''Expected an identifier and instead saw 'with'.'' | ||
| Treated as fatal parse error in JSLint. | | Treated as fatal parse error in JSLint. | ||
Line 490: | Line 545: | ||
!| no-wrap-func | !| no-wrap-func | ||
− | | | + | | Ignore |
+ | | - | ||
| ''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.'' | ||
| Flags a parenthesized function literal that is not immediately invoked, eg. <code>(function fun(){})</code> | | Flags a parenthesized function literal that is not immediately invoked, eg. <code>(function fun(){})</code> | ||
Line 496: | Line 552: | ||
!| one-var | !| one-var | ||
− | | | + | | Warning |
+ | | - | ||
| ''Too many var statements.'' | | ''Too many var statements.'' | ||
| Allows only 1 <code>var</code> statement per function. | | Allows only 1 <code>var</code> statement per function. | ||
Line 502: | Line 559: | ||
!| quote-props | !| quote-props | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Requires object literal keys to be quoted with " or '. | | Requires object literal keys to be quoted with " or '. | ||
|- | |- | ||
!| quotes | !| quotes | ||
− | | | + | | Ignore |
− | | | + | | - |
+ | | | ||
| Flags any use of single or double quote marks, depending on setting. | | Flags any use of single or double quote marks, depending on setting. | ||
|- | |- | ||
!| radix | !| radix | ||
− | | | + | | Warning |
+ | | - | ||
| ''Missing radix parameter.'' | | ''Missing radix parameter.'' | ||
| Affects parseInt(). | | Affects parseInt(). | ||
Line 520: | Line 580: | ||
!| regex-spaces | !| regex-spaces | ||
− | | | + | | Warning |
+ | | - | ||
| ''Spaces are hard to count. Use {n}.'' | | ''Spaces are hard to count. Use {n}.'' | ||
+ | | | ||
|- | |- | ||
− | !| [https://bugs.eclipse.org/bugs/show_bug.cgi?id=427930 semi] | + | !| <del>[https://bugs.eclipse.org/bugs/show_bug.cgi?id=427930 semi]</del> |
− | | | + | | Warning |
+ | | 5.0 | ||
| ''Missing semicolon.'' | | ''Missing semicolon.'' | ||
− | | | + | | |
|- | |- | ||
!| strict | !| strict | ||
− | | ' | + | | 'Ignore |
− | | | + | | - |
+ | | | ||
| Flags any code that lacks the <code>"use strict"</code> pragma. | | Flags any code that lacks the <code>"use strict"</code> pragma. | ||
|- | |- | ||
!| unnecessary-strict | !| unnecessary-strict | ||
− | | | + | | Warning |
− | | | + | | - |
+ | | | ||
| Flags <code>"use strict"</code> on a function when the entire Program is already in strict mode. | | Flags <code>"use strict"</code> on a function when the entire Program is already in strict mode. | ||
|- | |- | ||
!| use-isnan | !| use-isnan | ||
− | | | + | | Warning |
+ | | - | ||
| ''Use the isNaN function to compare with NaN.'' | | ''Use the isNaN function to compare with NaN.'' | ||
− | | | + | | |
|- | |- | ||
!| wrap-iife | !| wrap-iife | ||
− | | | + | | Ignore |
+ | | - | ||
| | | | ||
* ''Wrap the entire immediate function invocation in parens.'' | * ''Wrap the entire immediate function invocation in parens.'' | ||
Line 557: | Line 624: | ||
!| wrap-regex | !| wrap-regex | ||
− | | | + | | Warning |
+ | | - | ||
| ''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 14:12, 5 March 2014
Orion 5.0 moved to ESLint as the validator that ships with Orion. This page captures ongoing issues.
Contents
Rules
The following table describes all of the rules currently available in Orion and ones that we plan to add in the future.
Rules that are currently available are struck out.
Rule | Default Severity | Available Since | Problem Message | Details |
---|---|---|---|---|
block-scoped-var | Error | - | '{variable}' is already defined. |
|
brace-style | Ignore | - | ||
camelcase | Ignore | - | ||
complexity | Ignore | - | ||
consistent-this | Ignore | - | ||
curly | Warning | - | Statement body should be inside '{ }' braces. (Orion) | |
dot-notation | Warning | - | {a} is better written in dot notation. | |
|
Warning | 5.0 |
|
|
guard-for-in | Ignore | - | The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
|
|
max-depth | Ignore | - | Enforces max depth of nested blocks within a function. | |
max-len | Ignore | - | Line is too long. | Enforces a maximum line length. |
max-params | Ignore | - | ||
max-statements | Ignore | - | ||
new-cap | Warning | - | A constructor name should start with an uppercase letter. | |
new-parens | Error | - | Missing '()' invoking a constructor. | Flags new Whatever
|
no-alert | Ignore | - | '{alert, confirm, prompt}' is not defined. | |
no-bitwise | Warning | - | Unexpected use of '{operator}'. | JSLint disallows bitwise ops by default. |
no-caller | Ignore | - | Flags references to arguments.callee and arguments.caller .
| |
no-catch-shadow | Warning | - | '{a}' is already defined. |
|
no-comma-dangle | Warning | - | Unexpected comma. | Flags trailing commas in object literals and array declarations. |
no-cond-assign | Ignore | - | Flags assignment in an if/while/do..while/for condition.
| |
no-console | Ignore | - | ||
no-control-regex | Ignore | - | Flags control characters (U+0000–U+001F and U+007F) within the source argument to the RegExp constructor. | |
|
Warning | 6.0 | 'debugger' statement use is discouraged. | |
no-delete-var | Warning | - | Expected '.' and instead saw ';'. | Flags an attempt to delete a local variable.
|
no-div-regex | Warning | - | A regular expression literal can be confused with '/='. | Flags a regex literal starting with /=
|
no-dupe-keys | Error | - | Duplicate key '{a}'. | Flags object literals that contain the same key more than once. |
no-else-return | Warning | - | Flags an else appearing after an if that contains a return .
| |
no-empty-class | Warning | - | Empty class. | Flags an empty character class [] within a regular expression.
|
no-empty-label | Warning | - | Label '{a}' is not allowed on this statement. | Flags a labeled statement that is not a switch , for , or while .
|
no-empty | Warning | - | Flags an empty block like if (something) { } .
| |
no-eq-null | Error | - | Use '===' to compare with 'null'. | |
no-eval | Ignore | - | 'eval' should not be called. | |
no-ex-assign | Warning | - | Do not assign to the exception parameter. | |
|
Warning | 5.0 | Unnecessary semicolon. | |
no-fallthrough | Warning | - | Flags a fallthrough case within a switch statement, unless it is explicitly commented.
| |
no-floating-decimal | Warning | - | A {leading, trailing} decimal point can be confused with a dot: '{n}'. | Flags numeric literals that have a leading or trailing decimal point. |
no-func-assign | Warning | - | Flags assignment to a variable that's already bound to a FunctionExpression .
| |
no-global-strict | Warning | - | Flags "use strict" applied to the entire Program.
| |
no-implied-eval | Ignore | - | Implied eval is evil. Pass a function instead of a string. | Flags calls to the string-argument form of setTimeout and setInterval , which implicitly perform eval .
|
no-iterator | Error | - | Reserved name '__iterator__'. | Flags use of __iterator__ as an identifier name or property key. |
no-label-var | Error | - | '{label}' is already defined. | Flags labels that collide with an identifier. |
no-loop-func | Error | - | Don't make functions within a loop. | |
no-mixed-requires | Ignore | - | Flags Node.js require() s that mix different types of requires (core, module, file, computed).
| |
no-multi-str | Warning | - | Flags use of ES5 multiline string literals. | |
no-native-reassign | Warning | - |
|
Flags an attempt to reassign a native object like Math , Array, undefined , etc.
|
no-negated-in-lhs | Warning | - |
| |
no-new-array | Warning | - | Use the array literal notation []. | Flags new Array() .
|
no-new-func | Warning | - | The Function constructor is eval. | Flags new Function() .
|
no-new-object | Warning | - | Use the object literal notation {}. | Flags new Object() .
|
no-new-wrappers | Warning | - | Do not use {String, Number, Boolean, Math, JSON} as a constructor. | Flags new applied to any of those.
|
no-new | Error | - | Do not use 'new' for side effects. | Flags uses of new operator in an expression that is not assigned to anything.
|
no-obj-calls | Warning | - | Math is not a function.. |
|
no-octal-escape | Warning | - | Bad escapement. | Flags octal escapes in strings, for example var x = "Copyright \251";
|
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 | - |
|
|
no-proto | Error | - |
|
|
|
Warning | 5.0 | '{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 | Warning | - |
| |
no-script-url | Warning | - |
| |
no-self-compare | Error | - | Flags comparisons where the left- and right-hand sides are the same. | |
no-shadow | Warning | - | Flags variables that have the same name as a variable declared in an outer scope. | |
no-spaced-func | ||||
no-sync | Ignore | - | Unexpected sync method: '{a}'. |
|
no-ternary | Ignore | - | Flags any use of the ternary operator cond ? thenExpr : elseExpr
| |
no-undef-init | Warning | - | It is not necessary to initialize '{variable}' to 'undefined'. | |
|
Error | 5.0 | '{variable}' is not defined. |
|
no-underscore-dangle | Ignore | - | Dangling '_' | |
no-unreachable | Error | - | Unreachable '{statement}' after '{control flow statement}'. | Flags statements that occur after a return , throw , etc.
|
no-unused-expressions | Warning | - | 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. |
|
Warning | 5.0 | Function declares unused variable '{a}'. | |
|
Warning | 5.0 | '{a}' was used before it was defined. | |
no-with | Warning | - | Expected an identifier and instead saw 'with'. | Treated as fatal parse error in JSLint. |
no-wrap-func | Ignore | - | Do not wrap function literals in parens unless they are to be immediately invoked. | Flags a parenthesized function literal that is not immediately invoked, eg. (function fun(){})
|
one-var | Warning | - | Too many var statements. | Allows only 1 var statement per function.
|
quote-props | Warning | - | Requires object literal keys to be quoted with " or '. | |
quotes | Ignore | - | Flags any use of single or double quote marks, depending on setting. | |
radix | Warning | - | Missing radix parameter. | Affects parseInt(). |
regex-spaces | Warning | - | Spaces are hard to count. Use {n}. | |
|
Warning | 5.0 | Missing semicolon. | |
strict | 'Ignore | - | Flags any code that lacks the "use strict" pragma.
| |
unnecessary-strict | Warning | - | Flags "use strict" on a function when the entire Program is already in strict mode.
| |
use-isnan | Warning | - | Use the isNaN function to compare with NaN. | |
wrap-iife | Ignore | - |
|
Flags missing parens on immediately-invoked functions, eg. function(){ console.log('hi'); }();
|
wrap-regex | Warning | - | Wrap the /regexp/ literal in parens to disambiguate the slash operator. |
New rules
Ideas for new linting rules that we should write.
Name | Severity | Description |
---|---|---|
object-prototype-external | Warning | Flags calls to methods of Object.prototype that rely on the prototype chain. For example this code should be flagged:
Example (1) is unsafe, as As for this:
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 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. |
|
Ignore | Flags missing documentation nodes on function declarations and function expressions when they appear as object properties |
missing-doc-items | Ignore | Flags missing documentation for parameters, returns, throws, etc on function declarations and function expressions when they appear as object properties |
unused-parameters | Error | Flags parameters in function declarations / expressions if they are not being used |
no-mixed-returns | Error | Flags functions that return more than one kind of item, for example returning String and Object |
missing-nls | Ignore | Flags String literals that are not properly NLS'd |
Rule priority
Here are the rules we want to support, grouped by priority. Implemented rules are struck out.
Critical
- block-scoped-var
-
eqeqeq -
no-undef -
no-redeclare -
no-unused-vars -
no-use-before-define
Important
- guard-for-in
- no-dupe-keys
- no-octal
- no-with
- radix
-
semi -
no-extra-semi - wrap-iife
Nice to have
- dot-notation
- new-cap
- new-parens
- no-caller
- no-comma-dangle
- no-implied-eval
- no-new-array
- no-new-object
- no-undef-init
- no-unused-expressions
- no-wrap-func
- use-isnan
Tests
- Every rule needs extensive unit tests
- Unit tests should use Mocha
Currently the tests are run from Node.js. They do not run in the browser (yet).
Test requirements
First install Node.js. Then open a console and install Mocha globally:
$ npm install mocha -g
Then from your Orion client repository, run these commands to install eslint's dependencies:
$ cd bundles/org.eclipse.orion.client.javascript/web/eslint/ $ npm install
Running the tests
From the bundles/org.eclipse.orion.client.javascript/web/eslint/
directory, simply run npm test
:
$ npm test > eslint@0.2.0-dev test c:\Users\mamacdon\code\orion\client\bundles\org.eclipse.orion.client.javascript\web\eslint > bash scripts/test.sh ...................................................................... ............... 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 Mocha usage options for more.
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. - 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.- This would give compatibility with Orion codebase which uses these flags.
- OTOH, eslint now has its own syntax for this:
/*eslint ..*/
, which we should perhaps use instead.
i18n
We need to support i18n. Pre-req is bug 422278 (orion.edit.validator support for i18n).