Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Orion/ESLint"
< Orion
(→Rules) |
(→Rules) |
||
Line 2: | Line 2: | ||
== Rules == | == Rules == | ||
− | Here's a table showing the equivalent validation rules in JSLint and ESLint. | + | 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. |
{| class="wikitable" border="1" style="width: 100%;" | {| class="wikitable" border="1" style="width: 100%;" | ||
Line 12: | Line 12: | ||
| block-scoped-var | | block-scoped-var | ||
− | | | + | | - |
− | | | + | | '{variable}' is already defined. |
+ | | Occurs when a function-scoped variable is treated as if it was block scoped.<br>ESLint calls this error '{variable} used outside of binding context.' | ||
|- | |- | ||
Line 299: | Line 300: | ||
| 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>. | ||
|- | |- | ||
Line 344: | Line 346: | ||
| no-undef | | no-undef | ||
− | | '''node''', '''browser''', '''require''' | + | | - |
− | + | | '{variable}' is not defined. | |
+ | | Any global variables must be listed in a /*global*/ or /*globals*/ block.<br>Predefined environments (eg. '''node''', '''browser''', '''require''') can be set in /*jslint */ options. | ||
|- | |- | ||
− | |||
| no-underscore-dangle | | no-underscore-dangle | ||
Line 370: | Line 372: | ||
| no-use-before-define | | no-use-before-define | ||
− | | | + | | - |
− | | | + | | '{a}' was used before it was defined. |
|- | |- | ||
| no-with | | no-with | ||
− | | | + | | - |
− | | | + | | Expected an identifier and instead saw 'with'. |
+ | | Treated as fatal parse error in JSLint. | ||
|- | |- | ||
Line 396: | Line 399: | ||
| quotes | | quotes | ||
| | | | ||
− | | | + | | Strings must use doublequote. |
+ | | Only if "jsonmode" | ||
|- | |- | ||
| radix | | radix | ||
− | | | + | | - |
− | | | + | | Missing radix parameter. |
+ | | Affects parseInt() | ||
|- | |- | ||
Line 416: | Line 421: | ||
| strict | | strict | ||
+ | | '''strict''' | ||
| | | | ||
− | | | + | | Requires <code>"use strict"</code> pragma. |
|- | |- | ||
Line 426: | Line 432: | ||
| use-isnan | | use-isnan | ||
− | | | + | | - |
− | | | + | | Use the isNaN function to compare with NaN. |
|- | |- | ||
| wrap-iife | | wrap-iife | ||
− | | | + | | '''immed''' |
| Wrap the entire immediate function invocation in parens.<br>Do not wrap function literals in parens unless they are to be immediately invoked.<br>Move the invocation into the parens that contain the function. | | Wrap the entire immediate function invocation in parens.<br>Do not wrap function literals in parens unless they are to be immediately invoked.<br>Move the invocation into the parens that contain the function. | ||
| | | |
Revision as of 12:18, 15 November 2013
Orion 5.0 will replace our current JSLint validator with ESLint. This page captures ongoing issues.
Rules
Here's a table showing the equivalent validation rules in JSLint and ESLint. If a rule has no "JSLint option", then JSLint always enforces it and it cannot be disabled.
ESLint rule | JSLint option | JSLint message | Details |
---|---|---|---|
block-scoped-var | - | '{variable}' is already defined. | Occurs when a function-scoped variable is treated as if it was block scoped. ESLint calls this error '{variable} used outside of binding context.' |
brace-style | |||
camelcase | |||
complexity | |||
consistent-this | |||
curly | |||
dot-notation | sub | {a} is better written in dot notation. | |
eqeqeq | eqeqeq eqeq |
Expected '===' and saw '=='. Expected '!==' and saw '!='. |
eqeq only appears in old versions of JSLint (like Orion's), has opposite on/off state to eqeqeq. |
guard-for-in | forin | The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype. | |
max-depth | |||
max-len | |||
max-params | |||
max-statements | |||
new-cap | - | A constructor name should start with an uppercase letter. | |
new-parens | |||
no-alert | |||
no-bitwise | |||
no-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 | |||
no-else-return | |||
no-empty-class | |||
no-empty-label | |||
no-empty | |||
no-eq-null | |||
no-eval | |||
no-ex-assign | |||
no-extra-semi | |||
no-fallthrough | |||
no-floating-decimal | |||
no-func-assign | |||
no-global-strict | |||
no-implied-eval | |||
no-iterator | |||
no-label-var | |||
no-loop-func | |||
no-mixed-requires | |||
no-multi-str | |||
no-native-reassign | |||
no-negated-in-lhs | |||
no-new-array | |||
no-new-func | |||
no-new-object | |||
no-new-wrappers | |||
no-new | |||
no-obj-calls | |||
no-octal-escape | |||
no-octal | |||
no-plusplus | |||
no-proto | |||
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 | |||
no-script-url | |||
no-self-compare | |||
no-shadow | |||
no-spaced-func | |||
no-sync | |||
no-ternary | |||
no-undef-init | |||
no-undef | - | '{variable}' is not defined. | Any global variables must be listed in a /*global*/ or /*globals*/ block. Predefined environments (eg. node, browser, require) can be set in /*jslint */ options. |
no-underscore-dangle | |||
no-unreachable | |||
no-unused-expressions | |||
no-unused-vars | |||
no-use-before-define | - | '{a}' was used before it was defined. | |
no-with | - | Expected an identifier and instead saw 'with'. | Treated as fatal parse error in JSLint. |
no-wrap-func | |||
one-var | |||
quote-props | |||
quotes | Strings must use doublequote. | Only if "jsonmode" | |
radix | - | Missing radix parameter. | Affects parseInt() |
regex-spaces | |||
semi | - | Missing semicolon. | |
strict | strict | Requires "use strict" pragma.
| |
unnecessary-strict | |||
use-isnan | - | Use the isNaN function to compare with NaN. | |
wrap-iife | immed | Wrap the entire immediate function invocation in parens. Do not wrap function literals in parens unless they are to be immediately invoked. Move the invocation into the parens that contain the function. |
|
wrap-regex | - | Wrap the /regexp/ literal in parens to disambiguate the slash operator. |
Rule priority
Here are the rules we want, in order of priority:
- no-undef