Skip to content

Commit

Permalink
tools: disallow deprecated define getter/setter
Browse files Browse the repository at this point in the history
PR-URL: #6774
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
Refs: #6768
  • Loading branch information
Trott authored and Fishrock123 committed May 23, 2016
1 parent 0899ccd commit eeb0b9e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 32 additions & 0 deletions tools/eslint-rules/no-definegetter-definesetter.js
Original file line number Diff line number Diff line change
@@ -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.`);
}
}
}
};
}
};

0 comments on commit eeb0b9e

Please sign in to comment.