mirror of https://github.com/nodejs/node.git
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/6768pull/6874/head
parent
37a5a1c497
commit
21b53fe012
|
@ -94,6 +94,7 @@ rules:
|
|||
assert-fail-single-argument: 2
|
||||
new-with-error: [2, "Error", "RangeError", "TypeError", "SyntaxError", "ReferenceError"]
|
||||
no-deepEqual: 2
|
||||
no-definegetter-definesetter: 2
|
||||
|
||||
# Global scoped method and vars
|
||||
globals:
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* @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…
Reference in New Issue