From fee8a116347442a0adedf2a4a9f805b13707bab1 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 28 Dec 2018 18:14:23 -0500 Subject: [PATCH] tools: remove custom buffer-constructor lint rule 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 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen --- lib/.eslintrc.yaml | 1 - .../test-eslint-buffer-constructor.js | 27 ------------------- test/root.status | 1 - tools/eslint-rules/buffer-constructor.js | 20 -------------- 4 files changed, 49 deletions(-) delete mode 100644 test/parallel/test-eslint-buffer-constructor.js delete mode 100644 tools/eslint-rules/buffer-constructor.js diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index e9b43e9bff5236..81a764f0f85b81 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -27,7 +27,6 @@ rules: message: "Use an error exported by the internal/errors module." # Custom rules in tools/eslint-rules node-core/require-globals: error - node-core/buffer-constructor: error node-core/no-let-in-for-declaration: error node-core/lowercase-name-for-primitive: error node-core/non-ascii-character: error diff --git a/test/parallel/test-eslint-buffer-constructor.js b/test/parallel/test-eslint-buffer-constructor.js deleted file mode 100644 index daa1a527673c1a..00000000000000 --- a/test/parallel/test-eslint-buffer-constructor.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -const common = require('../common'); -common.skipIfEslintMissing(); - -const RuleTester = require('../../tools/node_modules/eslint').RuleTester; -const rule = require('../../tools/eslint-rules/buffer-constructor'); - -const message = 'Use of the Buffer() constructor has been deprecated. ' + - 'Please use either Buffer.alloc(), Buffer.allocUnsafe(), ' + - 'or Buffer.from()'; - -new RuleTester().run('buffer-constructor', rule, { - valid: [ - 'Buffer.from(foo)' - ], - invalid: [ - { - code: 'Buffer(foo)', - errors: [{ message }] - }, - { - code: 'new Buffer(foo)', - errors: [{ message }] - } - ] -}); diff --git a/test/root.status b/test/root.status index 9c40512cb68051..e5dd389cae0424 100644 --- a/test/root.status +++ b/test/root.status @@ -31,7 +31,6 @@ parallel/test-domain-with-abort-on-uncaught-exception: SLOW parallel/test-env-var-no-warnings: SLOW parallel/test-error-reporting: SLOW parallel/test-eslint-alphabetize-errors: SLOW -parallel/test-eslint-buffer-constructor: SLOW parallel/test-eslint-crypto-check: SLOW parallel/test-eslint-documented-errors: SLOW parallel/test-eslint-duplicate-requires: SLOW diff --git a/tools/eslint-rules/buffer-constructor.js b/tools/eslint-rules/buffer-constructor.js deleted file mode 100644 index 412fdaa934664b..00000000000000 --- a/tools/eslint-rules/buffer-constructor.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @fileoverview Require use of new Buffer constructor methods in lib - * @author James M Snell - */ -'use strict'; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -const msg = 'Use of the Buffer() constructor has been deprecated. ' + - 'Please use either Buffer.alloc(), Buffer.allocUnsafe(), ' + - 'or Buffer.from()'; -const astSelector = 'NewExpression[callee.name="Buffer"],' + - 'CallExpression[callee.name="Buffer"]'; - -module.exports = function(context) { - return { - [astSelector]: (node) => context.report(node, msg) - }; -};