Skip to content

Support MemberExpressions in no-mutating-methods allowedObjects#54

Open
raineorshine wants to merge 1 commit intojfmengels:masterfrom
raineorshine:allowedObjects
Open

Support MemberExpressions in no-mutating-methods allowedObjects#54
raineorshine wants to merge 1 commit intojfmengels:masterfrom
raineorshine:allowedObjects

Conversation

@raineorshine
Copy link
Copy Markdown

@raineorshine raineorshine commented Jan 1, 2021

In no-mutating-methods, the allowedObjects option currently only works on Identifier types, not MemberExpression types. This PR adds support for MemberExpression types.

For example, this currently reports an error:

/* eslint fp/no-mutating-methods: ["error", {"allowedObjects": ["two"]}] */
one.two.push(a)

Use Case

The standard way of navigating to a new route in vue-router is with this.$router.push(...). Setting "allowedObjects": ["$router"] does not work as expected. There is no way to get no-mutating-methods to ignore this with the current implementation.

Additional Nodes

This is a breaking change. I can add a different option to avoid breaking, but arguably the existing option should have always functioned this way.

raineorshine added a commit to a-thousand-worlds/a-thousand-worlds that referenced this pull request Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant