Browse Source

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>
v6.x
Rich Trott 8 years ago
committed by Myles Borins
parent
commit
9077f63dcf
  1. 7
      .eslintrc
  2. 32
      tools/eslint-rules/no-definegetter-definesetter.js

7
.eslintrc

@ -63,6 +63,12 @@ rules:
object: assert, object: assert,
property: deepEqual, property: deepEqual,
message: Please use assert.deepStrictEqual(). message: Please use assert.deepStrictEqual().
}, {
property: __defineGetter__,
message: __defineGetter__ is deprecated.
}, {
property: __defineSetter__,
message: __defineSetter__ is deprecated.
}] }]
# Stylistic Issues # Stylistic Issues
@ -112,7 +118,6 @@ rules:
align-multiline-assignment: 2 align-multiline-assignment: 2
assert-fail-single-argument: 2 assert-fail-single-argument: 2
new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError] new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError]
no-definegetter-definesetter: 2
# Global scoped method and vars # Global scoped method and vars
globals: globals:

32
tools/eslint-rules/no-definegetter-definesetter.js

@ -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.`);
}
}
}
};
}
};
Loading…
Cancel
Save