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"
< Orion
(→Rules) |
|||
Line 2: | Line 2: | ||
== Rules == | == Rules == | ||
− | Here's a table showing the equivalent validation rules in JSLint and ESLint. Rules that JSLint does not support are marked as Unsupported | + | Here's a table showing the equivalent validation rules in JSLint and ESLint. Rules that JSLint does not support are marked as Unsupported. |
{| class="wikitable" border="1" style="width: 100%;" | {| class="wikitable" border="1" style="width: 100%;" | ||
Line 109: | Line 109: | ||
| no-bitwise | | no-bitwise | ||
| '''bitwise''' | | '''bitwise''' | ||
− | | Unexpected use of '{operator}'. | + | | ''Unexpected use of '{operator}'.'' |
| JSLint disallows bitwise ops by default. | | JSLint disallows bitwise ops by default. | ||
|- | |- | ||
Line 126: | Line 126: | ||
| no-comma-dangle | | no-comma-dangle | ||
| Always on | | Always on | ||
− | | Unexpected comma. | + | | ''Unexpected comma.'' |
| Flags trailing commas in object literals. | | Flags trailing commas in object literals. | ||
|- | |- | ||
Line 158: | Line 158: | ||
| no-div-regex | | no-div-regex | ||
− | | | + | | Always on |
− | | | + | | ''A regular expression literal can be confused with '/='.'' |
+ | | Flags a regex literal starting with <code>/=</code> | ||
|- | |- | ||
Line 293: | Line 294: | ||
| no-new-wrappers | | no-new-wrappers | ||
| | | | ||
− | | Do not use {String, Number, Boolean, Math, JSON} as a constructor. | + | | ''Do not use {String, Number, Boolean, Math, JSON} as a constructor.'' |
|- | |- | ||
Line 345: | Line 346: | ||
| no-script-url | | no-script-url | ||
+ | | Always on | ||
+ | | ''Script URL.'' | ||
| | | | ||
− | + | * Flags string literals beginning with <code>javascript:</code>. (Script URLs are a form of <code>eval</code>.) | |
+ | * Fatal parse error in JSLint. | ||
|- | |- | ||
| no-self-compare | | no-self-compare | ||
− | | | + | | Unsupported |
− | | | + | | |
+ | | Flags comparisons where the left- and right-hand sides are the same. | ||
|- | |- | ||
| no-shadow | | no-shadow | ||
+ | | Unsupported | ||
| | | | ||
− | | | + | | Flags variables that have the same name as a variable declared in an outer scope. |
|- | |- | ||
Line 373: | Line 379: | ||
| no-ternary | | no-ternary | ||
+ | | Unsupported | ||
| | | | ||
− | | | + | | Flags any use of the ternary operator <code>cond ? thenExpr : elseExpr</code> |
|- | |- | ||
Line 397: | Line 404: | ||
| no-unreachable | | no-unreachable | ||
− | | | + | | Always on |
− | | | + | | ''Unreachable '{statement}' after '{control flow statement}'.'' |
+ | | Flags statements that occur after a <code>return</code>, <code>throw</code>, etc. | ||
|- | |- | ||
Revision as of 10:21, 18 November 2013
Orion 5.0 will replace our current [JSLint validator with ESLint. This page captures ongoing issues.
Rules
Here's a table showing the equivalent validation rules in JSLint and ESLint. Rules that JSLint does not support are marked as Unsupported.
ESLint rule | JSLint option | JSLint message | Details |
---|---|---|---|
block-scoped-var | Always on | '{variable}' is already defined. |
|
brace-style | Unsupported | ||
camelcase | Unsupported | ||
complexity | Unsupported | ||
consistent-this | Unsupported | ||
curly | Always on |
|
|
dot-notation | sub | {a} is better written in dot notation. | |
eqeqeq | eqeqeq or eqeq |
|
|
guard-for-in | forin | The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
| |
max-depth | Unsupported | Enforces max depth of nested blocks within a function. | |
max-len | maxlen | Line too long. | Enforces a maximum line length. |
max-params | Unsupported | ||
max-statements | Unsupported | ||
new-cap | newcap | A constructor name should start with an uppercase letter. | |
new-parens | Always on | Missing '()' invoking a constructor. | Flags new Whatever
|
no-alert | devel | '{alert, confirm, prompt}' is not defined. | |
no-bitwise | bitwise | Unexpected use of '{operator}'. | JSLint disallows bitwise ops by default. |
no-caller | Unsupported | Flags references to arguments.callee and arguments.caller .
| |
no-catch-shadow | |||
no-comma-dangle | Always on | Unexpected comma. | Flags trailing commas in object literals. |
no-cond-assign | |||
no-console | devel | ||
no-control-regex | |||
no-debugger | debug | All 'debugger' statements should be removed. | |
no-delete-var | Always on | Expected '.' and instead saw ';'. | Flags an attempt to delete a local variable.
|
no-div-regex | Always on | A regular expression literal can be confused with '/='. | Flags a regex literal starting with /=
|
no-dupe-keys | Always on | Duplicate key '{a}'. | Flags object literals that contain the same key more than once. |
no-else-return | |||
no-empty-class | |||
no-empty-label | |||
no-empty | Unsupported | Flags an empty block like if (something) { }
| |
no-eq-null | Always on | Use '===' to compare with 'null'. | JSLint produces a similar warning when comparing against undefined .
|
no-eval | evil | eval is evil. | |
no-ex-assign | Always on | Do not assign to the exception parameter. | |
no-extra-semi | Always on | Unnecessary semicolon. | |
no-fallthrough | |||
no-floating-decimal | |||
no-func-assign | |||
no-global-strict | |||
no-implied-eval | |||
no-iterator | |||
no-label-var | Always on | '{label}' is already defined. | Flags labels that collide with an identifier. |
no-loop-func | Always on | Don't make functions within a loop. | |
no-mixed-requires | |||
no-multi-str | |||
no-native-reassign | Always on |
|
Flags an attempt to reassign a native object like Math , Array, undefined , etc.
|
no-negated-in-lhs | |||
no-new-array | Always on | Use the array literal notation []. | Flags new Array()
|
no-new-func | |||
no-new-object | Always on | Use the object literal notation {}. | |
no-new-wrappers | Do not use {String, Number, Boolean, Math, JSON} as a constructor. | ||
no-new | Always on | Do not use 'new' for side effects. | Flags uses of new operator in an expression that is not assigned to anything.
|
no-obj-calls | |||
no-octal-escape | |||
no-octal | |||
no-plusplus | plusplus |
| |
no-proto | Always on |
|
Treated as a fatal parse error in JSLint. |
no-redeclare | Always on | '{a}' is already defined. | Usually results from having two for loops in the same function that share a loop variable declaration like var i=... .
|
no-return-assign | Unsupported | Prevents assignment in a return statement.
| |
no-script-url | Always on | Script URL. |
|
no-self-compare | Unsupported | Flags comparisons where the left- and right-hand sides are the same. | |
no-shadow | Unsupported | Flags variables that have the same name as a variable declared in an outer scope. | |
no-spaced-func | |||
no-sync | stupid | Unexpected sync method: '{a}'. |
|
no-ternary | Unsupported | Flags any use of the ternary operator cond ? thenExpr : elseExpr
| |
no-undef-init | Always on | It is not necessary to initialize '{variable}' to 'undefined'. | |
no-undef | undef | '{variable}' is not defined. |
|
no-underscore-dangle | nomen | Dangling '_' | |
no-unreachable | Always on | Unreachable '{statement}' after '{control flow statement}'. | Flags statements that occur after a return , throw , etc.
|
no-unused-expressions | Always on | Expected an assignment or function call and instead saw an expression. | Flags expressions that appear in a statement context and don't cause side effects. |
no-unused-vars | Always on | Function declares unused variable '{a}'. (Orion) | Newer JSlint versions have an unparam option which works similarly. |
no-use-before-define | Always on | '{a}' was used before it was defined. | |
no-with | Always on | Expected an identifier and instead saw 'with'. | Treated as fatal parse error in JSLint. |
no-wrap-func | |||
one-var | vars | ||
quote-props | |||
quotes | Unsupported | ||
radix | Always on | Missing radix parameter. | Affects parseInt(). |
regex-spaces | Always on | Spaces are hard to count. Use {n}. | |
semi | Always on | Missing semicolon. | |
strict | strict | Flags any code that lacks the "use strict" pragma.
| |
unnecessary-strict | |||
use-isnan | Always on | Use the isNaN function to compare with NaN. | |
wrap-iife | immed |
|
|
wrap-regex | Always on | Wrap the /regexp/ literal in parens to disambiguate the slash operator. |
Rule priority
Here are the rules we want, in order of priority:
- no-undef