vuetifyjs / eslint-plugin-vuetify

An eslint plugin for Vuetify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mtdvlpr opened this issue · comments

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" />.

commented

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

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

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.

commented

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

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

commented

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'] } }]

@KaelWD the ignore config would be great!

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.

commented

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