mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 11:12:55 +00:00

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/6768
33 lines
900 B
JavaScript
33 lines
900 B
JavaScript
/**
|
|
* @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.`);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
};
|