-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: disallow deprecated define getter/setter
PR-URL: #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: #6768
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.`); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
}; |