File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 */
77'use strict' ;
88
9+ // Cribbed from `eslint-module-utils/declaredScope`
10+ function declaredScope ( context , name ) {
11+ const references = context . getScope ( ) . references ;
12+ const reference = references . find ( ( x ) => x . identifier . name === name ) ;
13+ if ( ! reference ) return undefined ;
14+ return reference . resolved . scope . type ;
15+ }
16+
917//------------------------------------------------------------------------------
1018// Rule Definition
1119//------------------------------------------------------------------------------
@@ -19,8 +27,16 @@ module.exports = {
1927 } ,
2028 create ( context ) {
2129 return {
22- // eslint-disable-next-line max-len
23- 'CallExpression[callee.name="ObjectCreate"][arguments.0.type="Literal"][arguments.0.value=null][arguments.length=1]' ( node ) {
30+ /* eslint max-len: 0 */
31+ 'CallExpression[callee.type="Identifier"][callee.name="ObjectCreate"][arguments.0.type="Literal"][arguments.0.value=null][arguments.length=1],\
32+ CallExpression[callee.type="MemberExpression"][callee.object.name="Object"][callee.property.name="create"][arguments.0.type="Literal"][arguments.0.value=null][arguments.length=1]\
33+ ' ( node ) {
34+ if ( node . callee . type === 'MemberExpression' ) {
35+ const scope = declaredScope ( context , node . callee . object ) ;
36+ if ( scope !== 'module' && scope !== 'global' ) {
37+ return ;
38+ }
39+ }
2440 context . report ( {
2541 node,
2642 messageId : 'error' ,
You can’t perform that action at this time.
0 commit comments