Skip to content

Add allow rule option to vue/no-template-shadow #2317

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
stefanobartoletti opened this issue Nov 17, 2023 · 4 comments · Fixed by #2323
Closed

Add allow rule option to vue/no-template-shadow #2317

stefanobartoletti opened this issue Nov 17, 2023 · 4 comments · Fixed by #2323

Comments

@stefanobartoletti
Copy link

What rule do you want to change?
vue/no-template-shadow

Does this change cause the rule to produce more or fewer warnings?
Slightly few warnings, in selected occurrences

How will the change be implemented? (New option, new default behavior, etc.)?
Probably the best way is to set a new option to the existing rule, something like this:

"vue/no-template-shadow": ['error', {
    whitelist: ['allowed', 'variable', 'names'],
}],

I think it can be useful to have the ability to set a whitelist for well known variable names that are allowed to be shadowed, while still being able to throw errors or warnings in all other cases.

It could be possible to have certain selected variable names that have to remain the same (maybe for third party libraries constraints, or for some coding convention), while also wanting to prevent this behavior globally.

@FloEdelmann
Copy link
Member

FloEdelmann commented Nov 20, 2023

To match the no-shadow core ESLint rule, we should call that rule option allow: https://eslint.org/docs/latest/rules/no-shadow#allow

A PR to implement this is welcome 🙂

@stefanobartoletti
Copy link
Author

stefanobartoletti commented Nov 20, 2023

Thanks for your reply, I did not even notice that he core rule already had this feature :D

I'm not so sure if I am able to contribute with a PR, but maybe I can try to have a look in the next few days if I can free some time and maybe share some insights (not sure if I can properly contribute with code)

@FloEdelmann FloEdelmann changed the title Add ability to whitelist variable names when setting vue/no-template-shadow to error or warning Add allow rule option to vue/no-template-shadow Nov 20, 2023
@mussinbenarbia
Copy link
Contributor

@stefanobartoletti @FloEdelmann Hello! I had some free time today and took a stab at it, I hope it's ok 🙏 #2323

@stefanobartoletti
Copy link
Author

@mussinbenarbia thanks for taking care of this!

@FloEdelmann FloEdelmann linked a pull request Nov 29, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants