0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
Commit Graph

59 Commits

Author SHA1 Message Date
Michaël Zasso
7c2dbd13b5 tools: enforce consistent operator linebreak style
Adds the `operator-linebreak` rule to our ESLint config.

PR-URL: https://github.com/nodejs/node/pull/10178
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-12-10 10:47:31 +01:00
Michaël Zasso
0ae1684396 tools: add ESLint rule for assert.throws arguments
The second argument to "assert.throws" is usually a validation RegExp or
function for the thrown error. However, the function also accepts a
string and in this case it is interpreted as a message for the
AssertionError and not used for validation. It is common for people to
forget this and pass a validation string by mistake.
This new rule checks that we never pass a string literal as a second argument
to "assert.throws". Additionally, there is an option to enforce the
function to be called with at least two arguments. It is currently off
because we have many tests that do not comply with this rule.

PR-URL: https://github.com/nodejs/node/pull/10089
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2016-12-05 16:01:12 +01:00
Prince J Wesley
5cf0157b82 tools: Add no useless regex char class rule
Eslint Rule:
Disallow useless escape in regex character class
with optional override characters option and auto
fixable with eslint --fix option.

Usage:
no-useless-regex-char-class-escape: [2, { override: ['[', ']'] }]

PR-URL: https://github.com/nodejs/node/pull/9591
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2016-11-23 22:06:37 -08:00
Rich Trott
7537718460 tools: enforce function name matching in linter
ESLint has a `func-name-matching` rule that requires that function names
match the variable or property to which they are being assigned.

The code base currently has 100% compliance with this rule.

Enable the rule to keep it that way.

PR-URL: https://github.com/nodejs/node/pull/9408
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
2016-11-03 19:45:00 -07:00
Michaël Zasso
6031d8e76e tools: enable ES2016 syntax support in ESLint
This allows us to use the exponentiation operator.

PR-URL: https://github.com/nodejs/node/pull/9218
Ref: https://github.com/nodejs/node/pull/9208#issuecomment-255309920
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-10-24 14:02:31 +02:00
Rich Trott
3dbf900e85 tools: replace custom lint rule for getter/setter
Replace custom `no-definegetter-definesetter` lint rule with ESLint's
built-in `no-restricted-properties`.

Refs: https://github.com/nodejs/node/pull/9112#pullrequestreview-4378536
PR-URL: https://github.com/nodejs/node/pull/9194
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-10-21 07:37:10 -07:00
Rich Trott
5e6ae830fe tools: disallow extra blank lines at EOF/BOF
Enabling linting to disallow extra blank lines at the start or end of
JavaScript files in our code base.

Fixes: https://github.com/nodejs/node/issues/8918
PR-URL: https://github.com/nodejs/node/pull/8920
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-10-05 21:11:09 -07:00
Rich Trott
b5ec47e941 test: clean up test-timers-immediate
Clean up test-timers-immediate. Use of `let` also requires a tweak to
ESLint rules (but it's one that we should do as timers is pretty much
the reason it exists).

PR-URL: https://github.com/nodejs/node/pull/8857
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-10-02 20:40:51 -07:00
Teddy Katz
b1b1978ec5
tools: add additional ESLint rules
PR-URL: https://github.com/nodejs/node/pull/8643
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@keybase.io>
2016-09-20 23:21:10 -04:00
Rich Trott
d4061a6314 tools: replace custom ESLint rule with built-in
ESLint 3.5.0 introduces a `no-restricted-properties` rule. Replace our
custom `no-deepEqual` rule with this rule.

PR-URL: https://github.com/nodejs/node/pull/8478
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-09-12 21:12:03 -07:00
Rich Trott
05b566a5ef tools: update ESLint to 3.3.0 and enable rules
Update ESLint 3.3.0 and update .eslintrc:

* replace deprecated no-negated-in-lhs rule with no-unsafe-negation
  * http://eslint.org/docs/rules/no-negated-in-lhs
  * http://eslint.org/docs/rules/no-unsafe-negation
* enable no-template-curly-in-string
  * http://eslint.org/docs/rules/no-template-curly-in-string
* enable no-global-assign
  * http://eslint.org/docs/rules/no-global-assign
* enable func-call-spacing
  * http://eslint.org/docs/rules/func-call-spacing

PR-URL: https://github.com/nodejs/node/pull/8097
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-08-16 15:16:10 -07:00
Rich Trott
cb2e83e573 tools: enable rest-spread-spacing
There are currently 17 instances of the spread operator and all of them
have no space between the operator and the subsequent argument. This
change enables a lint rule to enforce that same style on any future uses
of the spread operator.

Refs: 7a1b47f329 (r74479351)
PR-URL: https://github.com/nodejs/node/pull/8073
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-08-14 20:43:59 -07:00
Rich Trott
8726a1c318 tools: enable linting for chained properties
Refs: https://github.com/nodejs/node/pull/7920
PR-URL: https://github.com/nodejs/node/pull/7999
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-08-09 21:19:07 -07:00
silverwind
11b23068cd
tools: consistent .eslintrc formatting
All quotes in .eslintrc were unnecessary and inconsistently placed
across the file. Additionally, format the globals to be consistent
with the style of whitespace and sorted them alphabetically.

PR-URL: https://github.com/nodejs/node/pull/7691
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2016-07-13 22:10:20 +02:00
Rich Trott
863952ebad tools: enforce JS brace style with linting
Enable `brace-style` in ESLint.

Ref: https://github.com/nodejs/node/pull/7094#discussion_r70149215
PR-URL: https://github.com/nodejs/node/pull/7630
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2016-07-12 10:33:53 -07:00
Rich Trott
21b53fe012 tools: disallow deprecated define getter/setter
PR-URL: https://github.com/nodejs/node/pull/6774
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Refs: https://github.com/nodejs/node/pull/6768
2016-05-19 22:08:30 -07:00
Rich Trott
517b89209c tools: enforce linting for unix-style line endings
PR-URL: https://github.com/nodejs/node/pull/6685
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ben Noorhduis <info@bnoordhuis.nl>
2016-05-12 21:54:21 -07:00
Rich Trott
6979632020 tools: disallow multiple spaces except indentation
Except for indentation, disallow multiple whitespace around logical
expressions, conditional expressions, declarations, array elements,
object properties, sequences and function parameters.

PR-URL: https://github.com/nodejs/node/pull/6645
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-05-11 23:19:23 -07:00
Rich Trott
4e6dc00401 tools: lint for object literal spacing
There has been occasional nits for spacing in object literals in PRs but
the project does not lint for it and it is not always handled
consistently in the existing code, even on adjacent lines of a file.

This change enables a linting rule requiring no space between the key
and the colon, and requiring at least one space (but allowing for more
so property values can be lined up if desired) between the colon and the
value. This appears to be the most common style used in the current code
base.

Example code the complies with lint rule:

    myObj = { foo: 'bar' };

Examples that do not comply with the lint rule:

    myObj = { foo : 'bar' };
    myObj = { foo:'bar' };

PR-URL: https://github.com/nodejs/node/pull/6592
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-05-08 22:45:20 -07:00
Rich Trott
83aa1f7f3f tools: lint for use of space in template strings
There are over 70 files in the project using template strings and all of
them have followed the convention of no spaces in curly braces.

Good: `${foo}`

Not used: `${ foo }`

Since the project has adopted a convention, and ESLint has a rule to
enforce exactly this convention, enable the rule.

PR-URL: https://github.com/nodejs/node/pull/6591
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
2016-05-07 20:14:15 -07:00
Rich Trott
ded3aea449 tools: lint for function argument alignment
In function calls that span multiple lines, apply a custom lint rule to
enforce argument alignment.

With this rule, the following code will be flagged as an error by the
linter because the arguments on the second line start in a different
column than on the first line:

    myFunction(a, b,
      c, d);

The following code will not be flagged as an error by the linter:

    myFunction(a, b,
               c, d);

PR-URL: https://github.com/nodejs/node/pull/6390
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
2016-04-28 14:51:45 -07:00
Rich Trott
e84c69310f tools: enforce deepStrictEqual over deepEqual
Introduce a lint rule that enforces use of `assert.deepStrictEqual()`
over `assert.deepEqual()`.

PR-URL: https://github.com/nodejs/node/pull/6213
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-22 14:39:53 -07:00
Rich Trott
8ede3d5002 tools: lint rule for assert.fail()
`assert.fail()` is often mistakenly used with a single argument even in
Node.js core. (See fixes to previous instances in
b7f4b1ba4c,
28e9a022df. and
676e61872f54dd546e324599c7871c20b798386a.)

This commit adds a linting rule to identify instances of this issue.

PR-URL: https://github.com/nodejs/node/pull/6261
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-20 08:36:27 -07:00
Rich Trott
ca698330ac tools: lint for alignment of variable assignments
Enforce alignment/indentation on variable assignments that span multiple
lines.

PR-URL: https://github.com/nodejs/node/pull/6242
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-04-18 17:19:16 -07:00
Rich Trott
810aa9f6c3 tools: enable no-self-assign ESLint rule
Enabled no-self-assign rule in ESLint.

This required one change in a benchmark file. Changed a loop (that is
outside of the benchmark itself, so performance is not critical) from a
for loop that repeats a string to use String.prototype.repeat() instead.

While at it, took the opportunity to const-ify the benchmark file.

Also moved the "Strict" section in the .eslintrc to match where it is in
the ESLint documentation. Updated the link for Strict rules to point to
the ESLint website rather than the GitHub-hosted code.

PR-URL: https://github.com/nodejs/node/pull/5552
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-03-07 10:07:17 -08:00
Rich Trott
66ea32d6d1 tools: enable no-extra-parens in ESLint
Enable `no-extra-parens`. This rule restricts the use of parentheses to
only where they are necessary. It is set to be restricted to report only
function expressions.

PR-URL: https://github.com/nodejs/node/pull/5512
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-03 09:30:01 -08:00
Rich Trott
d26417f123 tools: apply custom buffer lint rule to /lib only
The lint rule is there to avoid a circular-dependency issue that only
applies to `/lib`. In preparation for linting `/benchmark`, apply that
rule to `/lib` only to avoid churn in `/benchmark`.

Refs: https://github.com/nodejs/node/issues/3983#issuecomment-158956113
PR-URL: https://github.com/nodejs/node/pull/5371
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-02-24 20:09:52 -08:00
Rich Trott
9534f6dfd5 tools: enable additional lint rules
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>
2016-02-24 14:54:29 -08:00
Rich Trott
db4e7528b0 tools: add Node.js-specific ESLint rules
Add these rules:

* no-restricted-modules: See
http://eslint.org/docs/rules/no-restricted-modules. It has been
configured to prohibit the use of the deprecated `sys` and `_linklist`
modules.
* no-new-require: See http://eslint.org/docs/rules/no-new-require
* no-mixed-requires: http://eslint.org/docs/rules/no-mixed-requires

PR-URL: https://github.com/nodejs/node/pull/5320
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-21 13:44:45 -08:00
Rich Trott
2ba7baac93 tools: replace obsolete ESLint rules
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>
2016-02-18 10:13:36 -08:00
Rich Trott
d3c3a928c3 tools: remove obsolete lint rules
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>
2016-02-18 10:13:03 -08:00
Rich Trott
57891c3cfe tools: add recommended ES6 lint rules
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>
2016-02-15 22:14:30 -08:00
Rich Trott
ffbc05af59 tools: add recommended linting rules
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>
2016-02-12 13:34:38 -08:00
Rich Trott
783a563d3a tools: remove excessive comments from .eslintrc
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>
2016-02-10 10:55:27 -08:00
Jackson Tian
cc195bf37b tools: enable no-proto rule for linter
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>
2016-02-10 08:40:23 -08:00
Rich Trott
a84bf2ce68 tools: disallow mixed spaces and tabs for indents
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>
2016-02-09 09:33:08 -08:00
Rich Trott
eea987f937 tools: alphabetize eslint stylistic issues section
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>
2016-02-09 09:33:08 -08:00
Rich Trott
478c68284f tools: lint for empty character classes in regex
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>
2016-02-07 13:20:45 -08:00
Rich Trott
7406cd3a59 tools: lint for spacing around unary operators
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>
2016-02-04 10:56:17 -08:00
Rich Trott
34f39670cf tools: enable no-redeclare rule for linter
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>
2016-02-04 09:52:17 -08:00
cjihrig
452928eb24 tools: add arrow function rules to eslint
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>
2016-01-28 11:31:14 -05:00
Roman Reiss
d4f31b5105 tools: enable assorted ESLint error rules
Enables assorted rules from the category of possible errors. These
should not get in the way in any form.

- http://eslint.org/docs/rules/no-control-regex
- http://eslint.org/docs/rules/no-extra-boolean-cast
- http://eslint.org/docs/rules/no-invalid-regexp
- http://eslint.org/docs/rules/no-irregular-whitespace
- http://eslint.org/docs/rules/no-unexpected-multiline

PR-URL: https://github.com/nodejs/node/pull/4864
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Klauke <romaaan.git@gmail.com>
2016-01-26 17:01:35 +01:00
Roman Reiss
6588a70463 tools: enable space-in-parens ESLint rule
Ref: http://eslint.org/docs/rules/space-in-parens.html
PR-URL: https://github.com/nodejs/node/pull/4753
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2016-01-19 04:08:58 +01:00
Michaël Zasso
162e16afdb tools: enable no-extra-semi rule in eslint
PR-URL: https://github.com/nodejs/node/pull/2205
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-01-16 19:52:46 +01:00
Michaël Zasso
4d5ee7a512 tools: update eslint config
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>
2016-01-13 23:15:58 +01:00
Rich Trott
775cfdcd46 tools: implement no-unused-vars for eslint
PR-URL: https://github.com/nodejs/node/pull/4536
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-01-05 09:00:09 -08:00
Rich Trott
25cd455407 tools: enforce throw new Error() with lint rule
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>
2015-11-10 21:01:53 -08:00
Sakthipriyan Vairamani
b0e7b362c2 tools: enable prefer-const eslint rule
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>
2015-10-27 23:02:43 +05:30
Sakthipriyan Vairamani
845acb4e1e tools: enable arrow functions in .eslintrc
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>
2015-09-15 10:27:20 +05:30
Brendan Ashworth
96a2b2d54d tools: enable space-after-keywords in eslint
Requires that you do:

  if (x) { ... }

Rather than:

  if(x) { ... }
2015-08-22 18:01:53 -07:00