jfmengels / eslint-plugin-fp

ESLint rules for functional programming
MIT License
970 stars 36 forks source link

Support MemberExpressions in no-mutating-methods allowedObjects #54

Open raineorshine opened 3 years ago

raineorshine commented 3 years ago

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.