New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule Proposal: Prohibit calling computed properties like methods #928
Comments
If the computed item return function(imported from another file), I think ESLint can't realize whether it's a function. <template>
<div>
<button type="button" @click="judgeName">button</button>
</div>
</template>
<script>
import { func } from "./func";
export default {
computed: {
getAlert() {
return func; // this type is Identifier...
}
},
methods: {
judgeName() {
this.getAlert();
}
}
};
</script> export const func = () => {
alert('aaaaaaa')
} @ota-meshi |
May not be able to track whether it is a function as you say. Hmm.. this rule may cannot be implemented. |
Oh, right. I totally forgot the use case that computed props could be functions too when I was making my mind up about the rule. 🙈 Could we "limit" the detection then to computed properties without "external dependencies" somehow? |
Hi @manniL
Yes. It's probably possible. @ota-meshi
and more? |
@tyankatsu0105 I don't think you need to track |
@manniL |
Thanks a lot 👍 |
Please describe what the rule should do:
This rule should prohibit calling computed properties like methods. The only exception would be when a method is returned by that computed property. Not sure if this is actually "easily detectable" though.
What category should the rule belong to?
Provide 2-3 code examples that this rule should warn about:
The text was updated successfully, but these errors were encountered: