Skip to content

Should prohibited keywords includes this? #6362

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

Closed
mysticatea opened this issue Aug 14, 2017 · 5 comments
Closed

Should prohibited keywords includes this? #6362

mysticatea opened this issue Aug 14, 2017 · 5 comments

Comments

@mysticatea
Copy link
Member

What problem does this feature solve?

From vuejs/eslint-plugin-vue#148.

Vue.js has prohibited keywords, but it does not include this (though it includes super).
My feeling is that the use of this causes confusing.

Are there reasons that the prohibited keywords don't include this?

What does the proposed API look like?

The prohibited keywords include this keyword.

@HerringtonDarkholme
Copy link
Member

Sounds reasonable. Especially when vue automatically prefix template identifiers with this.

@nickmessing
Copy link
Member

I actually sometimes use this for demonstration purposes for people coming from react background. I don't think it should be prohibited since it works perfectly fine. Rather it should be a part of eslint-plugin-vue and be "recommended" instead of "forbidden".

P.S. just though about this now, @HerringtonDarkholme do you think it's reasonable to remove do (and let) from prohibited keywords? Does it make sense to support do expression? (ex: @click="myMethod(do { let tmp = f(); tmp * tmp + 1 })")

@HerringtonDarkholme
Copy link
Member

@nickmessing For let and do, I don't think we should allow them since it can promote more inappropriate logic in template. Like the example you give, I would think it probably belong to a method on vm.

@mysticatea
Copy link
Member Author

I don't think it should be prohibited since it works perfectly fine.

Ah, I see. I didn't realize this. prefix works fine.

@yyx990803
Copy link
Member

Since some users actually use this inside templates, prohibiting it will be a breaking change. As @nickmessing suggested, I think it would be better to make this a rule in the eslint plugin instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants