-
-
Notifications
You must be signed in to change notification settings - Fork 681
Disallow this
in template
#148
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
Comments
Thank you for this proposal! Good idea. This rule might be able to be generalized more. Vue.js disallows some keywords in templates. What do you think: |
Ah good catch. And I think some people may find it more readable for the |
@mysticatea, @hirokiosame maybe we should consider splinting this to 2 rules? |
I have posted a question in vue repo. |
I didn't realize the |
I think it either should be enabled or disabled @mysticatea without extra setting |
Oh, I still think this rule should be I think those should be:
For example: <template>
<div v-for="x in xs">
{{foo}} <!-- `foo` is reported in `always`. -->
{{this.foo}} <!-- `this.foo` is reported in `never`. -->
{{x}} <!-- `x` is not reported in both case. -->
{{this.x}} <!-- `x` is not reported in both case. -->
</div>
</template> |
@mysticatea i like your suggestion with i have question, which one should be set as default, for me Its nice that we can give option to specify how its should work. There is one more think, we should consider renaming it from |
Thank you, @armano2 !
I think the same, too.
Yes, I think the same. It's the reason that I suggested the option before the rule is added. |
@mysticatea I prepared new PR within requested changes and I renamed this rule to Sent from my Xiaomi Redmi 4A using FastHub |
* Add options to `no-this-in-template`. fixes #148 * Add few more advanced tests * Rename `no-this-in-template` to `this-in-template` * Add more edge cases * Do not remove `this.` when word is reserved * Add checks for *array like* accesed properties withc can't be converted to properties
Please describe what the rule should do:
Disallow
this
in the templateWhat category of rule is this? (place an "X" next to just one item)
[x] Enforces code style
[ ] Warns about a potential error
[ ] Suggests an alternate way of doing something
[ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
The text was updated successfully, but these errors were encountered: