summaryrefslogtreecommitdiff
path: root/tools/eslint-rules
AgeCommit message (Collapse)Author
2019-01-11tools: lint for use of internalBinding()cjihrig
Use of process.binding() has largely been replaced by internalBinding(). This commit updates the custom crypto check ESLint rule to check for both process.binding() and internalBinding(). Refs: https://github.com/nodejs/node/pull/24952 PR-URL: https://github.com/nodejs/node/pull/25395 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-01-11tools: update crypo check rulecjihrig
This commit updates the custom crypto-check ESLint rule to detect require() calls that come before any hasCrypto checks. PR-URL: https://github.com/nodejs/node/pull/25399 Refs: https://github.com/nodejs/node/pull/25388 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-12-30tools: remove custom buffer-constructor lint rulecjihrig
This rule is no longer needed. ESLint's built in no-buffer-constructor rule is enabled instead. PR-URL: https://github.com/nodejs/node/pull/25261 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-12-10tools: capitalize sentencesRuben Bridgewater
This adds the `capitalized-comments` eslint rule to verify that actual sentences use capital letters as starting letters. It ignores special words and all lines below 62 characters. PR-URL: https://github.com/nodejs/node/pull/24808 Reviewed-By: Sam Ruby <rubys@intertwingly.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-07-12tools: add no-duplicate-requires ruleGus Caplan
PR-URL: https://github.com/nodejs/node/pull/21712 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
2018-06-06test,tools: refactor custom ESLint for readabilityRich Trott
Refactor the test and the source for the `lowercase-name-for-primitive` custom ESLint rule for readability. PR-URL: https://github.com/nodejs/node/pull/21134 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-05-18tools: stricter eslint rule for globalsRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/20567 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2018-05-08tools: add eslint check for skipIfEslintMissingRichard Lau
Add a custom eslint rule to check for `common.skipIfEslintMissing()` to allow tests to run from source tarballs that do not include eslint. Fix up rule tests that were failing the new check. Refs: https://github.com/nodejs/node/issues/20336 PR-URL: https://github.com/nodejs/node/pull/20372 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-02lint: change require-buffer rule messageGus Caplan
PR-URL: https://github.com/nodejs/node/pull/19701 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-07benchmark,lib,test,tools: use consistent quotesRich Trott
In preparation for a linting rule, use consistent quotation for properties in objects. PR-URL: https://github.com/nodejs/node/pull/19156 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> 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: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Roman Reiss <me@silverwind.io>
2018-02-22tools: fix custom eslint rule errorsRuben Bridgewater
This fixes a few rules by making sure the input is actually ready to be checked. Otherwise those can throw TypeErrors or result in faulty error messages. PR-URL: https://github.com/nodejs/node/pull/18853 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-02-17tools: custom eslint autofix for inspector-check.jsShobhit Chittora
1. Adds fixer method 2. Extends test PR-URL: https://github.com/nodejs/node/pull/16646 Refs: https://github.com/nodejs/node/issues/16636 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-02-17tools: auto fix custom crypto-check eslint ruleShobhit Chittora
1. Fixer for crypto-check.js 2. Extends tests PR-URL: https://github.com/nodejs/node/pull/16647 Refs: https://github.com/nodejs/node/issues/16636 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-02-12tools: fix eslint isRequiredRuben Bridgewater
Currently the call can lead to a TypeError with the message: `Cannot read property 'value' of undefined`. This fixes it by first checking that the first argument is truthy. PR-URL: https://github.com/nodejs/node/pull/18729 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2018-02-07tools: add fixer for prefer-assert-iferror.jsShobhit Chittora
PR-URL: https://github.com/nodejs/node/pull/16648 Refs: https://github.com/nodejs/node/issues/16636 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-02-04tools: non-Ascii linter for /lib onlySarat Addepalli
Non-ASCII characters in /lib get compiled into the node binary, and may bloat the binary size unnecessarily. A linter rule may help prevent this. PR-URL: https://github.com/nodejs/node/pull/18043 Fixes: https://github.com/nodejs/node/issues/11209 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2018-02-01tools: auto fix custom eslint ruleShobhit Chittora
1. Extends tests 2. Refactors code 3. Adds fixer Refs: #16636 PR-URL: https://github.com/nodejs/node/pull/16652 Refs: https://github.com/nodejs/node/issues/16636 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-12-29tools: add check for using process.binding cryptoDaniel Bevenius
Currently, when configuring --without-ssl any tests that use process.binding('crypto') will not report a lint warning. This is because the eslint check only generates a warning when using require. This commit adds a check for using binding in addition to require. PR-URL: https://github.com/nodejs/node/pull/17867 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-26tools: autofixer for lowercase-name-for-primitiveShobhit Chittora
PR-URL: https://github.com/nodejs/node/pull/17715 Refs: https://github.com/nodejs/node/issues/16636 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Weijia Wang <starkwang@126.com>
2017-12-19tools: add number-isnan ruleJon Moss
PR-URL: https://github.com/nodejs/node/pull/17556 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-12-15tools: simplify lowercase-name-for-primitive rulecjihrig
PR-URL: https://github.com/nodejs/node/pull/17653 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2017-12-13tools: add lowercase-name-for-primitive eslint ruleWeijia Wang
Primitives should use lowercase in error message. Refs: https://github.com/nodejs/node/pull/16401 PR-URL: https://github.com/nodejs/node/pull/17568 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-12-11tools: simplify no-let-in-for-declaration rulecjihrig
PR-URL: https://github.com/nodejs/node/pull/17572 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2017-12-11tools: simplify buffer-constructor rulecjihrig
PR-URL: https://github.com/nodejs/node/pull/17572 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2017-12-11tools: simplify prefer-assert-methods rulecjihrig
PR-URL: https://github.com/nodejs/node/pull/17572 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2017-12-11tools: simplify prefer-common-mustnotcall rulecjihrig
PR-URL: https://github.com/nodejs/node/pull/17572 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2017-12-11tools: prefer common.expectsError in testsAnatoli Papirovski
Add lint rule to validate that common.expectsError(fn, err) is being used instead of assert.throws(fn, common.expectsError(err)); PR-URL: https://github.com/nodejs/node/pull/17557 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-30tools: add docs for prefer-util-format-errors ruleJon Moss
I had a little trouble understanding what the rule was trying to say, so am documenting what would pass/fail. PR-URL: https://github.com/nodejs/node/pull/17376 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-11-28tools: add lint fixer for `require-buffer`Bamieh
Adds `require-buffer` lint fixer. If the buffer module is not required while `Buffer` is used, require the `buffer` module. If the file has a `'use strict';` line, add the require after it on a separate line. If the file does not have any (currently impossible with the `strict` rule) add it after the first comment (before the real code starts). Fixes: https://github.com/nodejs/node/issues/16636 PR-URL: https://github.com/nodejs/node/pull/17144 Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-11-18errors: consistent format for error messageAnatoli Papirovski
Consistently use printf-style strings for error messages that do not need a custom argument order or processing of arguments. PR-URL: https://github.com/nodejs/node/pull/16904 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-11-13tools: remove unused trailing function argumentsRich Trott
Update tools/doc/html.js and tools/eslint-rules/crypto-check.js to remove unused trailing function arguments in preparation for enabling a lint rule to enforce that practice. PR-URL: https://github.com/nodejs/node/pull/16953 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2017-11-13tools: fix inspector-check reportingDaniel Bevenius
Currently the inspector-check rule does not store the node when the usage of a require('inspector') is done. This means that it is not possible to disable this rule. For example, if you add the following to a test that uses the inspector module: //common.skipIfInspectorDisabled(); /* eslint-disable inspector-check */ This will not disable the check and there will still be a lint error reported. This commit stores the node where the require statement is done which allows for the rule to also be disabled. PR-URL: https://github.com/nodejs/node/pull/16902 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-04tools: add fixer for no-let-in-for-declarationWeijia Wang
PR-URL: https://github.com/nodejs/node/pull/16642 Refs: https://github.com/nodejs/node/issues/16636 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-10-26tools: add eslint rule for documented errorsJames M Snell
PR-URL: https://github.com/nodejs/node/pull/16450 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2017-10-19tools: enable additional eslint rulesAnatoli Papirovski
Enable additional rules that node either already adheres to or it makes sense to do so going forward: for-direction, accessor-pairs, no-lonely-if and symbol-description. Fix all instances of no-lonely-if in lib & test and disable accessor-pairs in test-util-inspect. PR-URL: https://github.com/nodejs/node/pull/16243 Refs: https://eslint.org/docs/rules/for-direction Refs: https://eslint.org/docs/rules/accessor-pairs Refs: https://eslint.org/docs/rules/no-lonely-if Refs: https://eslint.org/docs/rules/symbol-description Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-09-28errors,tools: ASCIIbetical instead of alphabeticalRefael Ackermann
PR-URL: https://github.com/nodejs/node/pull/15578 Fixes: https://github.com/nodejs/node/issues/15576 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-09-07module: Allow runMain to be ESMBradley Farias
This follows the EPS an allows the node CLI to have ESM as an entry point. `node ./example.mjs`. A newer V8 is needed for `import()` so that is not included. `import.meta` is still in specification stage so that also is not included. PR-URL: https://github.com/nodejs/node/pull/14369 Author: Bradley Farias <bradley.meck@gmail.com> Author: Guy Bedford <guybedford@gmail.com> Author: Jan Krems <jan.krems@groupon.com> Author: Timothy Gu <timothygu99@gmail.com> Author: Michaël Zasso <targos@protonmail.com> Author: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-09-01errors,tools: alphabetize-errors lint ruleJon Moss
To make sure errors in lib/internal/errors.js (are defined via `E`) will stay in alphabetical order going forward. PR-URL: https://github.com/nodejs/node/pull/15083 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-08-30tools: add eslint rule for inspector checkingDaniel Bevenius
The motivation for this commit is to pick up early on missing checks for inspector support (when Node is built --without-inspector). PR-URL: https://github.com/nodejs/node/pull/13813 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2017-08-30tools: add eslint rule for hasCrypto checkingDaniel Bevenius
The motivation for this commit is to pick up early on missing checks for crypto support (when Node is built --without-ssl). There are currently usages of common.hasCrypto which are not just for detecting if crypto support is available and then skip the test in question. For these case we still want to have a lint error generated which can then be disabled using an ESLint comment. PR-URL: https://github.com/nodejs/node/pull/13813 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2017-08-03tools: simplify no-unescaped-regexp-dot ruleRich Trott
no-unescaped-regexp-dot ESLint custom rule contains feature detection that is not needed on master or the v6.x-staging branch. The rule does not exist in the v4.x-staging branch. Remove the unnecessary complexity. PR-URL: https://github.com/nodejs/node/pull/14561 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-08-02tools: replace assert-throw-arguments custom lintRich Trott
The functionality of ESLint custom rule assert-throws-arguments can be replaced with no-restricted-syntax entries. PR-URL: https://github.com/nodejs/node/pull/14547 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-21lib,src: fix consistent spacing inside bracesSebastiaan Deckers
PR-URL: https://github.com/nodejs/node/pull/14162 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-06tools: remove align-multiline-assignment lint ruleRich Trott
In preparation for stricter indentation linting, remove the align-multiline-assignment custom rule, as it may conflict with the ESLint stricter indentation linting. PR-URL: https://github.com/nodejs/node/pull/14079 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-07-02tools: change var to const in ./eslint-rulesRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/13732 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-06-28tools: remove comment in eslint ruleDaniel Bevenius
I noticed this comment while working on a different task and could not find any reason for it being there. Just bringing this up in case it was overlooked. PR-URL: https://github.com/nodejs/node/pull/13945 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-06-22tools: fix error in custom ESLint ruleRich Trott
Fix previously-unnoticed typo in `required-modules.js`. Refs: https://github.com/nodejs/node/pull/13758#discussion_r122582786 PR-URL: https://github.com/nodejs/node/pull/13758 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-06-22tools: fix indentation in required-modules.jsRich Trott
In preparation for applying the more strict indentation linting available in ESLint 4.0.0, correct minor indentation issues in tools/eslint-rules/required-modules.js. This is the only file with indentation that does not conform to the stricter checks. PR-URL: https://github.com/nodejs/node/pull/13758 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-04-12tools: replace custom assert.fail lint ruleRich Trott
Replace custom lint rule for `assert.fail()` function signature errors with a restricted-syntax rule. PR-URL: https://github.com/nodejs/node/pull/12287 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-08tools: replace custom new-with-error ruleRich Trott
Use no-restricted-syntax to implement the requirement that `Error` objects must be thrown with the `new` keyword. PR-URL: https://github.com/nodejs/node/pull/12249 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>