From 9077f63dcfac622f7ecc1012e3a2e7a4d8bed854 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 19 Oct 2016 14:27:02 -0700 Subject: [PATCH] tools: replace custom lint rule for getter/setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Roman Reiss Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: Luigi Pinca Reviewed-By: Sakthipriyan Vairamani --- .eslintrc | 7 +++- .../no-definegetter-definesetter.js | 32 ------------------- 2 files changed, 6 insertions(+), 33 deletions(-) delete mode 100644 tools/eslint-rules/no-definegetter-definesetter.js diff --git a/.eslintrc b/.eslintrc index 6e483a13b7d6c5..262717980f3a48 100644 --- a/.eslintrc +++ b/.eslintrc @@ -63,6 +63,12 @@ rules: object: assert, property: deepEqual, message: Please use assert.deepStrictEqual(). + }, { + property: __defineGetter__, + message: __defineGetter__ is deprecated. + }, { + property: __defineSetter__, + message: __defineSetter__ is deprecated. }] # Stylistic Issues @@ -112,7 +118,6 @@ rules: align-multiline-assignment: 2 assert-fail-single-argument: 2 new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError] - no-definegetter-definesetter: 2 # Global scoped method and vars globals: diff --git a/tools/eslint-rules/no-definegetter-definesetter.js b/tools/eslint-rules/no-definegetter-definesetter.js deleted file mode 100644 index 3de010f47f203c..00000000000000 --- a/tools/eslint-rules/no-definegetter-definesetter.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @fileoverview Rule to flag usage of __defineGetter__ and __defineSetter__ - * @author Rich Trott - */ - -'use strict'; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -module.exports = { - create: function(context) { - const disallowed = ['__defineGetter__', '__defineSetter__']; - - return { - MemberExpression: function(node) { - var prop; - if (node.property) { - if (node.property.type === 'Identifier' && !node.computed) { - prop = node.property.name; - } else if (node.property.type === 'Literal') { - prop = node.property.value; - } - if (disallowed.includes(prop)) { - context.report(node, `The ${prop} property is deprecated.`); - } - } - } - }; - } -};