vuetifyjs / eslint-plugin-vuetify

An eslint plugin for Vuetify
Other
120 stars 22 forks source link

[Bug] v-btn text prop wrongly converted to variant="text" #59

Open mtdvlpr opened 1 year ago

mtdvlpr commented 1 year ago

When I try to use the new text prop of v-btn (<v-btn text="Click me!" />) it gets converted to <v-btn variant="text" />.

The conversion should only occur for <v-btn text /> or <v-btn :text="true" />.

KaelWD commented 1 year ago

This plugin is only really intended to be used for migration from v2-v3, not for existing v3 projects.

mtdvlpr commented 1 year ago

Well, I find it useful to keep using it, so I can prevent accidentally using my old knowledge of Vuetify 2.

mtdvlpr commented 1 year ago

Suppose you started converting your code from v2 to v3 manually and only later discovered this plugin. You wouldn't want the plugin to suddenly remove your button texts.

KaelWD commented 1 year ago

:text="variable" is replaced with :variant="variable && 'text'" so it isn't really possible to have a rule that works for both

mtdvlpr commented 1 year ago

No easy way to distinguish boolean variables from string variables? If not, I'll figure something out. It's not a biggie.

KaelWD commented 1 year ago

Not variables. Static strings is possible, the way rules are defined internally though is just text: { name: 'variant', value: 'text' } which is also shared with other props so probably not easy to add an override just for this.

I could add a config like 'vuetify/no-deprecated-props': ['error', { ignore: { VBtn: ['text'] } }]

mtdvlpr commented 1 year ago

@KaelWD the ignore config would be great!

abea commented 1 year ago

One solution would be to make this a special case at the warn level. The rule description could highlight that the prop has changed and direct people to manually switch to the variant prop instead. As a separate rule it could be disabled individually once the project has made the conversions. I would guess there aren't too many cases like this where a v2 prop is deprecated but there's a new v3 prop that does a totally different thing.

The ignore config would also be helpful.

KaelWD commented 1 year ago

Another option would be something like settings.vuetify.migrationMode = false https://eslint.org/docs/latest/use/configure/configuration-files#adding-shared-settings