Skip to content

Commit 32bbf59

Browse files
committed
Support MemberExpressions in no-mutating-methods allowedObjects
1 parent 205861e commit 32bbf59

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

rules/no-mutating-methods.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ const create = function (context) {
4545
return;
4646
}
4747

48+
if (node.callee.object.type === 'MemberExpression' && allowedObjects.indexOf(node.callee.object.property.name) !== -1) {
49+
return;
50+
}
51+
4852
if (node.callee.object.name === 'Object') {
4953
if (mutatingObjectMethods.indexOf(node.callee.property.name) !== -1) {
5054
context.report({

test/no-mutating-methods.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ ruleTester.run('no-mutating-methods', rule, {
5151
allowedObjects: ['R']
5252
}]
5353
},
54+
{
55+
code: 'this.$router.push(a)',
56+
options: [{
57+
allowedObjects: ['$router']
58+
}]
59+
},
5460
'Object.keys(a)',
5561
'Object.values(a)'
5662
],

0 commit comments

Comments
 (0)