Enable additional likely-uncontroversial lint rules:
* `comma-dangle` set to prohibit dangling commas on objects and arrays
that are defined on a single line. Multi-line definitions can use or
omit a trailing comma.
* `no-unused-labels` Prohibits defining a label that is not used.
* `no-path-concat` Prohibits string-concatenation using i`__dirname` and
`__filename`. Use `path.join()`, `path.resolve()`, or template strings
instead.
* `no-new-symbol` disallow use of `new` operator with `Symbol` object.
Violating this rule would result in a `TypeError` at runtime.`
PR-URL: https://github.com/nodejs/node/pull/5357
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Now that we are using ESLint 2, replace ESLint 1 rules with their ESLint
2 equivalents.
PR-URL: https://github.com/nodejs/node/pull/5214
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: jbergstroem - Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
We are about to upgrade from ESlint 1 to ESLint 2. Remove lint rules
that will not exist in ESLint 2.
PR-URL: https://github.com/nodejs/node/pull/5214
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: jbergstroem - Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Add the following (seemingly non-controversial) ESLint rules:
* `constructor-super`: Verify calls of `super()` in constructors. Flags
situations that will result in runtime errors. Since we do not have 100%
code coverage in tests, linting for runtime errors is useful.
* `no-class-assign`: Flags cases where a class declaration is
overwritten via variable assignment later. It is difficult to think of a
situation where this is not an error, and easy to think of situations
(particularly in lengthy test files) where it could come up.
* `no-const-assign`: Assigning to a const after declaration is a runtime
error.
* `no-dupe-class-members`: Declare a class member twice, then only the
second one counts. This is analogous to redeclaring a variable.
* `no-this-before-super`: Using `this` or `super` in a derived class
before a call to `super()` is a `ReferenceError`
PR-URL: https://github.com/nodejs/node/pull/5210
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Rod Vagg <rod@vagg.org>
This change adds ESLint rules that meet two criteria:
* recommended by ESLint
* require no code changes
These rules are:
* `no-func-assign`: Disallow overwriting a function that was written
as a function declaration.
* `no-negated-in-lhs`: Disallow negated left operand of `in` operator.
It prevents `if(!a in b)` when `if(!(a in b))` is intended.
* `no-obj-calls`: Disallow global object function calls. It prevents
errors like `JSON()` and `Math()`.
to exercise the code in tests or whatever, it can sneak in.
* `use-isnan`: Prevents errors like `if (foo == NaN)`
* `no-octal`: Disallows confusing constructs like `var num = 071;`
* `no-delete-var`: Delete works on properties, not variables. Disallows
`delete foo`.
PR-URL: https://github.com/nodejs/node/pull/5188
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
The comments make the config hard to scan. They do not provide any
information that isn't in the documentation links referred to in
comments (that are not being removed here).
Additionally, all rule config sections are alphabetically ordered for
easier scanning etc.
PR-URL: https://github.com/nodejs/node/pull/5151
Reviewed-By: Roman Reiss <me@silverwind.io>
Enable `no-proto` in `.eslintrc`.
Use `Object.setPrototypeOf()` and `Object.getPrototypeOf()`
instead of.
PR-URL: https://github.com/nodejs/node/pull/5140
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Enable eslint rule disallowing mixing tabs and spaces for indentation.
Modify the one file that had been mixing tabs and spaces.
PR-URL: https://github.com/nodejs/node/pull/5135
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Rearrange the style rules in .eslintrc to be in alphabetical order.
This has two benefits:
It means the rules appear in the same order as they do in the ESLint
documentation, easing cross-referencing.
It also means that it is much easier to determine with visual inspection
if a rule is set or not.
https://github.com/nodejs/node/pull/5135
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Enable linting rule to forbid empty character classes in regular
expressions. See http://eslint.org/docs/rules/no-empty-character-class
Organize "Possible Error" rules in .eslintrc in alphabetical order to
match eslint documentation.
PR-URL: https://github.com/nodejs/node/pull/5115
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Enable `space-unary-ops` in `.eslintrc`. This prohibits things like:
i ++ // use `i++` instead
typeof(foo) // use `typeof foo` or `typeof (foo)` instead
Ref: https://github.com/nodejs/node/pull/4772#discussion_r51732299
PR-URL: https://github.com/nodejs/node/pull/5063
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/5047
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit enables the following rules:
* arrow-parens - requires parens around arrow function arguments
* arrow-spacing - ensures a space on each side of the =>
* no-arrow-condition - prevents accidental use of => in cases
where the user really intends to use <=
PR-URL: https://github.com/nodejs/node/pull/4813
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
The no-reserved-keys rule doesn't exist anymore and we don't need ES3
compatibility.
escape and unescape are now known by eslint.
--reset flag was removed and it is now the default behavior.
PR-URL: https://github.com/nodejs/io.js/pull/2286
Reviewed-By: Roman Reiss <me@silverwind.io>
Add linting rule requiring `throw new Error()` over `throw Error()`.
PR-URL: https://github.com/nodejs/node/pull/3714
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Description from: http://eslint.org/docs/rules/prefer-const.html
If a variable is never modified, using the `const` declaration is
better. `const` declaration tells readers, "this variable is never
modified," reducing cognitive load and improving maintainability.
Refer: https://github.com/nodejs/node/issues/3118
PR-URL: https://github.com/nodejs/node/pull/3152
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
As of v8 4.5, arrow functions are rolled out. This patch allows eslint
to accept arrow functions as well.
PR-URL: #2840
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The rule was disabled because of an eslint bug which is now resolved.
All code in lib was already conforming and only test code needed a few
changes to make the linter happy with this rule enabled.
Ref: https://github.com/eslint/eslint/issues/2408
PR-URL: https://github.com/nodejs/io.js/pull/2072
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
Reviewed-by: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alex Kocharin <alex@kocharin.ru>
Enables rules for trailing whitespace, final newline and maximum
consecutive empty lines.
PR-URL: https://github.com/nodejs/io.js/pull/1971
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Enables the following rules:
- no-undef: Valuable rule to error on usage of undefined variables
- require-buffer: Custom rule that forbids usage of the global Buffer
inside lib/ because of REPL issues.
PR-URL: https://github.com/nodejs/io.js/pull/1794
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Required to make linting pass for using object literal
shorthand properties.
PR-URL: https://github.com/nodejs/io.js/pull/1760
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Enable linting for the test directory. A number of changes was made so
all tests conform the current rules used by lib and src directories. The
only exception for tests is that unreachable (dead) code is allowed.
test-fs-non-number-arguments-throw had to be excluded from the changes
because of a weird issue on Windows CI.
PR-URL: https://github.com/nodejs/io.js/pull/1721
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Certain cases with comments inside arrays or object literals fail to
pass eslint's comma-spacing rule. This change sets the comma-spacing
rule to the 'warn' level.
Once https://github.com/eslint/eslint/issues/2408 is resolved and
released, this rule should be set back to 'error' level.
PR-URL: https://github.com/iojs/io.js/pull/1672
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
In certain environments escape sequences could be splitted into
multiple chunks. For example, when user presses left arrow,
`\x1b[D` sequence could appear as two keypresses (`\x1b` + `[D`).
PR-URL: https://github.com/iojs/io.js/pull/1601
Fixes: https://github.com/iojs/io.js/issues/1403
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>