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"
(→New rules) |
(→Rule parity) |
||
Line 5: | Line 5: | ||
{| class="wikitable" border="1" style="width: 100%;" | {| class="wikitable" border="1" style="width: 100%;" | ||
− | ! ESLint rule | + | ! style="background:#efefef;" | ESLint rule |
− | ! JSLint option | + | ! style="background:#efefef;" | JSLint option |
− | ! JSLint message | + | ! style="background:#efefef;" | JSLint message |
− | ! Details | + | ! style="background:#efefef;" | Details |
|- | |- | ||
− | | block-scoped-var | + | !| block-scoped-var |
| Always on | | Always on | ||
| '''{variable}' is already defined.'' | | '''{variable}' is already defined.'' | ||
Line 19: | Line 19: | ||
|- | |- | ||
− | | brace-style | + | !| brace-style |
| Unsupported | | Unsupported | ||
| | | | ||
Line 25: | Line 25: | ||
|- | |- | ||
− | | camelcase | + | !| camelcase |
| Unsupported | | Unsupported | ||
| | | | ||
Line 31: | Line 31: | ||
|- | |- | ||
− | | complexity | + | !| complexity |
| Unsupported | | Unsupported | ||
| | | | ||
Line 37: | Line 37: | ||
|- | |- | ||
− | | consistent-this | + | !| consistent-this |
| Unsupported | | Unsupported | ||
| | | | ||
Line 43: | Line 43: | ||
|- | |- | ||
− | | curly | + | !| curly |
| Always on | | Always on | ||
| | | | ||
Line 51: | Line 51: | ||
|- | |- | ||
− | | dot-notation | + | !| dot-notation |
| '''sub''' | | '''sub''' | ||
| ''{a} is better written in dot notation.'' | | ''{a} is better written in dot notation.'' | ||
Line 57: | Line 57: | ||
|- | |- | ||
− | | eqeqeq | + | !| eqeqeq |
| '''eqeqeq''' or '''eqeq''' | | '''eqeqeq''' or '''eqeq''' | ||
| | | | ||
Line 67: | Line 67: | ||
|- | |- | ||
− | | guard-for-in | + | !| guard-for-in |
| '''forin''' | | '''forin''' | ||
| ''The body of a <code>for in</code> should be wrapped in an <code>if</code> statement to filter unwanted properties from the prototype.'' | | ''The body of a <code>for in</code> should be wrapped in an <code>if</code> statement to filter unwanted properties from the prototype.'' | ||
|- | |- | ||
− | | max-depth | + | !| max-depth |
| Unsupported | | Unsupported | ||
| | | | ||
Line 78: | Line 78: | ||
|- | |- | ||
− | | max-len | + | !| max-len |
| '''maxlen''' | | '''maxlen''' | ||
| ''Line too long.'' | | ''Line too long.'' | ||
Line 84: | Line 84: | ||
|- | |- | ||
− | | max-params | + | !| max-params |
| Unsupported | | Unsupported | ||
| | | | ||
|- | |- | ||
− | | max-statements | + | !| max-statements |
| Unsupported | | Unsupported | ||
| | | | ||
|- | |- | ||
− | | new-cap | + | !| new-cap |
| '''newcap''' | | '''newcap''' | ||
| ''A constructor name should start with an uppercase letter.'' | | ''A constructor name should start with an uppercase letter.'' | ||
|- | |- | ||
− | | new-parens | + | !| new-parens |
| Always on | | Always on | ||
| ''Missing '()' invoking a constructor.'' | | ''Missing '()' invoking a constructor.'' | ||
Line 105: | Line 105: | ||
|- | |- | ||
− | | no-alert | + | !| no-alert |
| '''devel''' | | '''devel''' | ||
| '''{alert, confirm, prompt}' is not defined.'' | | '''{alert, confirm, prompt}' is not defined.'' | ||
Line 111: | Line 111: | ||
|- | |- | ||
− | | no-bitwise | + | !| no-bitwise |
| '''bitwise''' | | '''bitwise''' | ||
| ''Unexpected use of '{operator}'.'' | | ''Unexpected use of '{operator}'.'' | ||
Line 117: | Line 117: | ||
|- | |- | ||
− | | no-caller | + | !| no-caller |
| Unsupported | | Unsupported | ||
| | | | ||
Line 123: | Line 123: | ||
|- | |- | ||
− | | no-catch-shadow | + | !| no-catch-shadow |
| Always on | | Always on | ||
| '''{a}' is already defined.'' | | '''{a}' is already defined.'' | ||
Line 130: | Line 130: | ||
|- | |- | ||
− | | no-comma-dangle | + | !| no-comma-dangle |
| Always on | | Always on | ||
| ''Unexpected comma.'' | | ''Unexpected comma.'' | ||
Line 136: | Line 136: | ||
|- | |- | ||
− | | no-cond-assign | + | !| no-cond-assign |
| Unsupported | | Unsupported | ||
| | | | ||
Line 142: | Line 142: | ||
|- | |- | ||
− | | no-console | + | !| no-console |
| '''devel''' | | '''devel''' | ||
| | | | ||
Line 148: | Line 148: | ||
|- | |- | ||
− | | no-control-regex | + | !| no-control-regex |
| Unsupported | | Unsupported | ||
| | | | ||
Line 154: | Line 154: | ||
|- | |- | ||
− | | no-debugger | + | !| no-debugger |
| '''debug''' | | '''debug''' | ||
| ''All 'debugger' statements should be removed.'' | | ''All 'debugger' statements should be removed.'' | ||
Line 160: | Line 160: | ||
|- | |- | ||
− | | no-delete-var | + | !| no-delete-var |
| Always on | | Always on | ||
| ''Expected '.' and instead saw ';'.'' | | ''Expected '.' and instead saw ';'.'' | ||
Line 166: | Line 166: | ||
|- | |- | ||
− | | no-div-regex | + | !| no-div-regex |
| Always on | | Always on | ||
| ''A regular expression literal can be confused with '/='.'' | | ''A regular expression literal can be confused with '/='.'' | ||
Line 172: | Line 172: | ||
|- | |- | ||
− | | no-dupe-keys | + | !| no-dupe-keys |
| Always on | | Always on | ||
| ''Duplicate key '{a}'.'' | | ''Duplicate key '{a}'.'' | ||
Line 178: | Line 178: | ||
|- | |- | ||
− | | no-else-return | + | !| no-else-return |
| Unsupported | | Unsupported | ||
| | | | ||
Line 184: | Line 184: | ||
|- | |- | ||
− | | no-empty-class | + | !| no-empty-class |
| Always on | | Always on | ||
| ''Empty class.'' | | ''Empty class.'' | ||
Line 190: | Line 190: | ||
|- | |- | ||
− | | no-empty-label | + | !| no-empty-label |
| Always on | | Always on | ||
| ''Label '{a}' on statement.'' | | ''Label '{a}' on statement.'' | ||
Line 196: | Line 196: | ||
|- | |- | ||
− | | no-empty | + | !| no-empty |
| Unsupported | | Unsupported | ||
| | | | ||
Line 202: | Line 202: | ||
|- | |- | ||
− | | no-eq-null | + | !| no-eq-null |
| Always on | | Always on | ||
| ''Use '===' to compare with 'null'.'' | | ''Use '===' to compare with 'null'.'' | ||
Line 208: | Line 208: | ||
|- | |- | ||
− | | no-eval | + | !| no-eval |
| '''evil''' | | '''evil''' | ||
| ''eval is evil.'' | | ''eval is evil.'' | ||
|- | |- | ||
− | | no-ex-assign | + | !| no-ex-assign |
| Always on | | Always on | ||
| ''Do not assign to the exception parameter.'' | | ''Do not assign to the exception parameter.'' | ||
|- | |- | ||
− | | no-extra-semi | + | !| no-extra-semi |
| Always on | | Always on | ||
| ''Unnecessary semicolon.'' | | ''Unnecessary semicolon.'' | ||
|- | |- | ||
− | | no-fallthrough | + | !| no-fallthrough |
| Unsupported | | Unsupported | ||
| | | | ||
Line 229: | Line 229: | ||
|- | |- | ||
− | | no-floating-decimal | + | !| no-floating-decimal |
| Always on | | Always on | ||
| ''A {leading, trailing} decimal point can be confused with a dot: '{n}'.'' | | ''A {leading, trailing} decimal point can be confused with a dot: '{n}'.'' | ||
Line 235: | Line 235: | ||
|- | |- | ||
− | | no-func-assign | + | !| no-func-assign |
| Unsupported | | Unsupported | ||
| | | | ||
Line 241: | Line 241: | ||
|- | |- | ||
− | | no-global-strict | + | !| no-global-strict |
| Unsupported | | Unsupported | ||
| | | | ||
Line 247: | Line 247: | ||
|- | |- | ||
− | | no-implied-eval | + | !| no-implied-eval |
| Always on | | Always on | ||
| ''Implied eval is evil. Pass a function instead of a string.'' | | ''Implied eval is evil. Pass a function instead of a string.'' | ||
Line 253: | Line 253: | ||
|- | |- | ||
− | | no-iterator | + | !| no-iterator |
| Always on | | Always on | ||
| ''Reserved name '__iterator__'.'' | | ''Reserved name '__iterator__'.'' | ||
Line 259: | Line 259: | ||
|- | |- | ||
− | | no-label-var | + | !| no-label-var |
| Always on | | Always on | ||
| '''{label}' is already defined.'' | | '''{label}' is already defined.'' | ||
Line 265: | Line 265: | ||
|- | |- | ||
− | | no-loop-func | + | !| no-loop-func |
| Always on | | Always on | ||
| ''Don't make functions within a loop.'' | | ''Don't make functions within a loop.'' | ||
Line 271: | Line 271: | ||
|- | |- | ||
− | | no-mixed-requires | + | !| no-mixed-requires |
| | | | ||
| | | | ||
Line 277: | Line 277: | ||
|- | |- | ||
− | | no-multi-str | + | !| no-multi-str |
| | | | ||
| | | | ||
Line 283: | Line 283: | ||
|- | |- | ||
− | | no-native-reassign | + | !| no-native-reassign |
| Always on | | Always on | ||
| | | | ||
Line 291: | Line 291: | ||
|- | |- | ||
− | | no-negated-in-lhs | + | !| no-negated-in-lhs |
| Unsupported | | Unsupported | ||
| | | | ||
Line 299: | Line 299: | ||
|- | |- | ||
− | | no-new-array | + | !| no-new-array |
| Always on | | Always on | ||
| ''Use the array literal notation [].'' | | ''Use the array literal notation [].'' | ||
Line 305: | Line 305: | ||
|- | |- | ||
− | | no-new-func | + | !| no-new-func |
| Always on | | Always on | ||
| ''The Function constructor is eval.'' | | ''The Function constructor is eval.'' | ||
Line 311: | Line 311: | ||
|- | |- | ||
− | | no-new-object | + | !| no-new-object |
| Always on | | Always on | ||
| ''Use the object literal notation {}.'' | | ''Use the object literal notation {}.'' | ||
Line 317: | Line 317: | ||
|- | |- | ||
− | | 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 323: | Line 323: | ||
|- | |- | ||
− | | no-new | + | !| no-new |
| Always on | | Always on | ||
| ''Do not use 'new' for side effects.'' | | ''Do not use 'new' for side effects.'' | ||
Line 329: | Line 329: | ||
|- | |- | ||
− | | no-obj-calls | + | !| no-obj-calls |
| Partial support | | Partial support | ||
| ''Math is not a function..'' | | ''Math is not a function..'' | ||
Line 337: | Line 337: | ||
|- | |- | ||
− | | no-octal-escape | + | !| no-octal-escape |
| Always on | | Always on | ||
| ''Bad escapement.'' | | ''Bad escapement.'' | ||
Line 343: | Line 343: | ||
|- | |- | ||
− | | no-octal | + | !| no-octal |
| Always on | | Always on | ||
| ''Don't use extra leading zeros '{n}'.'' | | ''Don't use extra leading zeros '{n}'.'' | ||
Line 349: | Line 349: | ||
|- | |- | ||
− | | no-plusplus | + | !| no-plusplus |
| '''plusplus''' | | '''plusplus''' | ||
| | | | ||
Line 356: | Line 356: | ||
|- | |- | ||
− | | no-proto | + | !| no-proto |
| Always on | | Always on | ||
| | | | ||
Line 364: | Line 364: | ||
|- | |- | ||
− | | no-redeclare | + | !| no-redeclare |
| Always on | | Always on | ||
| '''{a}' is already defined.'' | | '''{a}' is already defined.'' | ||
Line 370: | Line 370: | ||
|- | |- | ||
− | | no-return-assign | + | !| no-return-assign |
| Unsupported | | Unsupported | ||
| | | | ||
Line 378: | Line 378: | ||
|- | |- | ||
− | | no-script-url | + | !| no-script-url |
| Always on | | Always on | ||
| ''Script URL.'' | | ''Script URL.'' | ||
Line 386: | Line 386: | ||
|- | |- | ||
− | | no-self-compare | + | !| no-self-compare |
| Unsupported | | Unsupported | ||
| | | | ||
Line 392: | Line 392: | ||
|- | |- | ||
− | | no-shadow | + | !!| no-shadow |
| Unsupported | | Unsupported | ||
| | | | ||
Line 398: | Line 398: | ||
|- | |- | ||
− | | no-spaced-func | + | !| no-spaced-func |
| | | | ||
| | | | ||
|- | |- | ||
− | | no-sync | + | !| no-sync |
| '''stupid''' | | '''stupid''' | ||
| ''Unexpected sync method: '{a}'.'' | | ''Unexpected sync method: '{a}'.'' | ||
Line 411: | Line 411: | ||
|- | |- | ||
− | | no-ternary | + | !| no-ternary |
| Unsupported | | Unsupported | ||
| | | | ||
Line 417: | Line 417: | ||
|- | |- | ||
− | | no-undef-init | + | !| no-undef-init |
| Always on | | Always on | ||
| ''It is not necessary to initialize '{variable}' to 'undefined'.'' | | ''It is not necessary to initialize '{variable}' to 'undefined'.'' | ||
Line 423: | Line 423: | ||
|- | |- | ||
− | | no-undef | + | !| no-undef |
| '''undef''' | | '''undef''' | ||
| '''{variable}' is not defined.'' | | '''{variable}' is not defined.'' | ||
Line 431: | Line 431: | ||
|- | |- | ||
− | | no-underscore-dangle | + | !| no-underscore-dangle |
| '''nomen''' | | '''nomen''' | ||
| ''Dangling '_''' | | ''Dangling '_''' | ||
|- | |- | ||
− | | no-unreachable | + | !| no-unreachable |
| Always on | | Always on | ||
| ''Unreachable '{statement}' after '{control flow statement}'.'' | | ''Unreachable '{statement}' after '{control flow statement}'.'' | ||
Line 442: | Line 442: | ||
|- | |- | ||
− | | no-unused-expressions | + | !| no-unused-expressions |
| Always on | | Always on | ||
| ''Expected an assignment or function call and instead saw an expression.'' | | ''Expected an assignment or function call and instead saw an expression.'' | ||
Line 448: | Line 448: | ||
|- | |- | ||
− | | no-unused-vars | + | !| no-unused-vars |
| Always on | | Always on | ||
| ''Function declares unused variable '{a}'.'' (Orion) | | ''Function declares unused variable '{a}'.'' (Orion) | ||
Line 454: | Line 454: | ||
|- | |- | ||
− | | no-use-before-define | + | !| no-use-before-define |
| Always on | | Always on | ||
| '''{a}' was used before it was defined.'' | | '''{a}' was used before it was defined.'' | ||
|- | |- | ||
− | | no-with | + | !| no-with |
| Always on | | Always on | ||
| ''Expected an identifier and instead saw 'with'.'' | | ''Expected an identifier and instead saw 'with'.'' | ||
Line 465: | Line 465: | ||
|- | |- | ||
− | | no-wrap-func | + | !| no-wrap-func |
| Always on | | Always on | ||
| ''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.'' | ||
Line 471: | Line 471: | ||
|- | |- | ||
− | | one-var | + | !| one-var |
| '''onevar''' | | '''onevar''' | ||
| ''Too many var statements.'' | | ''Too many var statements.'' | ||
Line 477: | Line 477: | ||
|- | |- | ||
− | | quote-props | + | !| quote-props |
| Unsupported | | Unsupported | ||
| | | | ||
Line 483: | Line 483: | ||
|- | |- | ||
− | | quotes | + | !| quotes |
| Unsupported | | Unsupported | ||
| | | | ||
Line 489: | Line 489: | ||
|- | |- | ||
− | | radix | + | !| radix |
| Always on | | Always on | ||
| ''Missing radix parameter.'' | | ''Missing radix parameter.'' | ||
Line 495: | Line 495: | ||
|- | |- | ||
− | | regex-spaces | + | !| regex-spaces |
| Always on | | Always on | ||
| ''Spaces are hard to count. Use {n}.'' | | ''Spaces are hard to count. Use {n}.'' | ||
|- | |- | ||
− | | semi | + | !| semi |
| Always on | | Always on | ||
| ''Missing semicolon.'' | | ''Missing semicolon.'' | ||
Line 506: | Line 506: | ||
|- | |- | ||
− | | strict | + | !| strict |
| '''strict''' | | '''strict''' | ||
| | | | ||
Line 512: | Line 512: | ||
|- | |- | ||
− | | unnecessary-strict | + | !| unnecessary-strict |
| Unsupported | | Unsupported | ||
| | | | ||
Line 518: | Line 518: | ||
|- | |- | ||
− | | use-isnan | + | !| use-isnan |
| Always on | | Always on | ||
| ''Use the isNaN function to compare with NaN.'' | | ''Use the isNaN function to compare with NaN.'' | ||
Line 524: | Line 524: | ||
|- | |- | ||
− | | wrap-iife | + | !| wrap-iife |
| '''immed''' | | '''immed''' | ||
| | | | ||
Line 532: | Line 532: | ||
|- | |- | ||
− | | wrap-regex | + | !| wrap-regex |
| Always on | | Always on | ||
| ''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 11:57, 6 February 2014
Orion 5.0 will replace our current JSLint validator with ESLint. This page captures ongoing issues.
Contents
Rule parity
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 | Always on | '{a}' is already defined. |
|
no-comma-dangle | Always on | Unexpected comma. | Flags trailing commas in object literals. |
no-cond-assign | Unsupported | Flags assignment in an if/while/do..while/for condition.
| |
no-console | devel | ||
no-control-regex | Unsupported | Flags control characters (U+0000–U+001F and U+007F) within the source argument to the RegExp constructor. | |
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 | Unsupported | Flags an else appearing after an if that contains a return .
| |
no-empty-class | Always on | Empty class. | Flags an empty character class [] within a regular expression.
|
no-empty-label | Always on | Label '{a}' on statement. | Flags a labeled statement that is not a switch , for , or while .
|
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 | Unsupported | Flags a fallthrough case within a switch statement, unless it is explicitly commented.
| |
no-floating-decimal | Always on | 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 | Unsupported | Flags assignment to a variable that's already bound to a FunctionExpression .
| |
no-global-strict | Unsupported | Flags "use strict" applied to the entire Program.
| |
no-implied-eval | Always on | 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 | Always on | Reserved name '__iterator__'. | Flags use of __iterator__ as an identifier name or property key. |
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 | Flags Node.js require() s that mix different types of requires (core, module, file, computed).
| ||
no-multi-str | Flags use of ES5 multiline string literals. | ||
no-native-reassign | Always on |
|
Flags an attempt to reassign a native object like Math , Array, undefined , etc.
|
no-negated-in-lhs | Unsupported |
| |
no-new-array | Always on | Use the array literal notation []. | Flags new Array() .
|
no-new-func | Always on | The Function constructor is eval. | |
no-new-object | Always on | Use the object literal notation {}. | Flags new Object() .
|
no-new-wrappers | Do not use {String, Number, Boolean, Math, JSON} as a constructor. | Flags new applied to any of those.
| |
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 | Partial support | Math is not a function.. |
|
no-octal-escape | Always on | Bad escapement. | Flags octal escapes in strings, for example var x = "Copyright \251";
|
no-octal | Always on | Don't use extra leading zeros '{n}'. | Flags number literals that begin with leading 0s, which indicate a (probably accidental) octal literal. |
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 |
| |
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 | Always on | 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 | onevar | Too many var statements. | Allows only 1 var statement per function.
|
quote-props | Unsupported | Requires object literal keys to be quoted with " or '. | |
quotes | Unsupported | Flags any use of single or double quote marks, depending on setting. | |
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 | Unsupported | Flags "use strict" on a function when the entire Program is already in strict mode.
| |
use-isnan | Always on | Use the isNaN function to compare with NaN. | |
wrap-iife | immed |
|
Flags missing parens on immediately-invoked functions, eg. function(){ console.log('hi'); }();
|
wrap-regex | Always on | 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 |
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 - 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?Implemented. - 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).