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 14: | Line 14: | ||
| - | | - | ||
| '{variable}' is already defined. | | '{variable}' is already defined. | ||
− | | Occurs when a function-scoped variable is treated as if it was block scoped. | + | | |
+ | * Occurs when a function-scoped variable is treated as if it was block scoped. | ||
+ | * ESLint calls this error '{variable} used outside of binding context.' | ||
|- | |- | ||
Line 39: | Line 41: | ||
| curly | | curly | ||
| - | | - | ||
− | | Statement body should be inside '{ }' braces. (Orion) | + | | |
+ | * Statement body should be inside '{ }' braces. (Orion) | ||
+ | * Expected '{'. (Regular JSLint) | ||
| | | | ||
|- | |- | ||
Line 50: | Line 54: | ||
| eqeqeq | | eqeqeq | ||
− | | '''eqeqeq''' | + | | '''eqeqeq''' or '''eqeq''' |
− | | Expected '===' and saw '=='. | + | | |
− | | Newer versions of JSLint call this option '''eqeqeq'''. Orion's version calls it '''eqeq''', and inverts the flag's value. | + | * Expected '===' and saw '=='. |
+ | * Expected '!==' and saw '!='. | ||
+ | | | ||
+ | * Newer versions of JSLint call this option '''eqeqeq'''. | ||
+ | * Orion's version calls it '''eqeq''', and inverts the flag's value. | ||
|- | |- | ||
Line 253: | Line 261: | ||
| no-native-reassign | | no-native-reassign | ||
| - | | - | ||
− | | Read only. | + | | |
+ | * Read only. | ||
+ | * Bad assignment. | ||
| Flags an attempt to reassign a native object like <code>Math</code>, Array, <code>undefined</code>, etc. | | Flags an attempt to reassign a native object like <code>Math</code>, Array, <code>undefined</code>, etc. | ||
|- | |- | ||
Line 311: | Line 321: | ||
| no-proto | | no-proto | ||
| - | | - | ||
− | | | + | | |
+ | * Reserved name '__proto__'. (if used as an identifier) | ||
+ | * Stupid key '{a}' (if used as a key) | ||
| Treated as a fatal parse error in JSLint. | | Treated as a fatal parse error in JSLint. | ||
|- | |- | ||
Line 317: | Line 329: | ||
| no-redeclare | | no-redeclare | ||
| - | | - | ||
− | | | + | | '{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 350: | Line 362: | ||
| '''stupid''' | | '''stupid''' | ||
| Unexpected sync method: '{a}'. | | Unexpected sync method: '{a}'. | ||
− | | Flags Node.js's synchronous I/O methods. | + | | |
+ | * Flags Node.js's synchronous I/O methods. | ||
+ | * The '''stupid''' option is supported only in newer versions of JSLint (not Orion's). | ||
|- | |- | ||
Line 366: | Line 380: | ||
| '''undef''' | | '''undef''' | ||
| '{variable}' is not defined. | | '{variable}' is not defined. | ||
− | | Flags references to a global variable that is not listed in a /*global*/ or /*globals*/ block. | + | | |
+ | * Flags references to a global variable that is not listed in a /*global*/ or /*globals*/ block. | ||
+ | * Predefined environments (eg. '''node''', '''browser''') can be set in the /*jslint */ block. | ||
|- | |- | ||
Line 458: | Line 474: | ||
| wrap-iife | | wrap-iife | ||
| '''immed''' | | '''immed''' | ||
− | | Wrap the entire immediate function invocation in parens. | + | | |
+ | * Wrap the entire immediate function invocation in parens. | ||
+ | * Do not wrap function literals in parens unless they are to be immediately invoked. | ||
+ | * Move the invocation into the parens that contain the function. | ||
| | | | ||
|- | |- |
Revision as of 18:52, 15 November 2013
Orion 5.0 will replace our current JSLint validator with ESLint. This page captures ongoing issues.
Rules
Here's a table showing the equivalent validation rules in JSLint and ESLint. If a rule has no "JSLint option", then JSLint always enforces it and it cannot be disabled.
ESLint rule | JSLint option | JSLint message | Details |
---|---|---|---|
block-scoped-var | - | '{variable}' is already defined. |
|
brace-style | - | (Not supported) | |
camelcase | - | (Not supported) | |
complexity | - | (Not supported) | |
consistent-this | - | (Not supported) | |
curly | - |
|
|
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 | - | (Not supported) | Enforces max depth of nested blocks within a function. |
max-len | maxlen | Line too long. | Enforces a maximum line length. |
max-params | |||
max-statements | |||
new-cap | newcap | A constructor name should start with an uppercase letter. | |
new-parens | - | Missing '()' invoking a constructor. | Flags new Whatever
|
no-alert | |||
no-bitwise | bitwise | Unexpected use of '{operator}'. | JSLint disallows bitwise ops by default. |
no-caller | - | (Not supported) | Flags references to arguments.callee and arguments.caller .
|
no-catch-shadow | |||
no-comma-dangle | - | Unexpected comma. | Flags trailing commas in object literals. |
no-cond-assign | |||
no-console | |||
no-control-regex | |||
no-debugger | |||
no-delete-var | |||
no-div-regex | |||
no-dupe-keys | - | Duplicate key '{a}'. | Flags object literals that contain the same key more than once. |
no-else-return | |||
no-empty-class | |||
no-empty-label | |||
no-empty | - | (Not supported) | Flags an empty block like if (..) { } |
no-eq-null | - | Use '===' to compare with 'null'. | JSLint produces similar warnings when comparing against undefined .
|
no-eval | evil | eval is evil. | |
no-ex-assign | - | Do not assign to the exception parameter. | |
no-extra-semi | - | Unnecessary semicolon. | |
no-fallthrough | |||
no-floating-decimal | |||
no-func-assign | |||
no-global-strict | |||
no-implied-eval | |||
no-iterator | |||
no-label-var | - | '{label}' is already defined. | Flags labels that collide with an identifier. |
no-loop-func | - | Don't make functions within a loop. | |
no-mixed-requires | |||
no-multi-str | |||
no-native-reassign | - |
|
Flags an attempt to reassign a native object like Math , Array, undefined , etc.
|
no-negated-in-lhs | |||
no-new-array | - | Use the array literal notation []. | Flags new Array()
|
no-new-func | - | Do not use 'new' for side effects. | Flags uses of new operator in an expression that is not assigned to anything.
|
no-new-object | - | Use the object literal notation {}. | |
no-new-wrappers | Do not use {String, Number, Boolean, Math, JSON} as a constructor. | ||
no-new | |||
no-obj-calls | |||
no-octal-escape | |||
no-octal | |||
no-plusplus | plusplus | Unexpected use of '{++, --}' | |
no-proto | - |
|
Treated as a fatal parse error in JSLint. |
no-redeclare | - | '{a}' is already defined. | Usually results from having two for loops in the same function that share a loop variable declaration like var i=... .
|
no-return-assign | - | (Not supported) | Prevents assignment in a return statement.
|
no-script-url | |||
no-self-compare | |||
no-shadow | |||
no-spaced-func | |||
no-sync | stupid | Unexpected sync method: '{a}'. |
|
no-ternary | |||
no-undef-init | - | It is not necessary to initialize 'x' to 'undefined'. | |
no-undef | undef | '{variable}' is not defined. |
|
no-underscore-dangle | nomen | dangling '_' | |
no-unreachable | |||
no-unused-expressions | - | Expected an assignment or function call and instead saw an expression. | Flags expressions that appear in a statement context and don't cause side effects. |
no-unused-vars | - | Function declares unused variable '{a}'. (Orion) | Newer JSlint versions have an unparam option which works similarly. |
no-use-before-define | - | '{a}' was used before it was defined. | |
no-with | - | Expected an identifier and instead saw 'with'. | Treated as fatal parse error in JSLint. |
no-wrap-func | |||
one-var | vars | ||
quote-props | |||
quotes | - | (Not supported) | |
radix | - | Missing radix parameter. | Affects parseInt() |
regex-spaces | - | Spaces are hard to count. Use {n}. | |
semi | - | Missing semicolon. | |
strict | strict | Requires "use strict" pragma.
| |
unnecessary-strict | |||
use-isnan | - | Use the isNaN function to compare with NaN. | |
wrap-iife | immed |
|
|
wrap-regex | - | Wrap the /regexp/ literal in parens to disambiguate the slash operator. |
Rule priority
Here are the rules we want, in order of priority:
- no-undef