Skip to content

Commit a577bd0

Browse files
committed
fix: replace conditional prop binding with ternary instead of &&
1 parent 2892491 commit a577bd0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/rules/no-deprecated-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ module.exports = {
722722
return [fixer.replaceText(propNameNode, replace.name), fixer.replaceText(attr.value, `"${value}"`)]
723723
} else {
724724
const expression = context.getSourceCode().getText(attr.value.expression)
725-
return [fixer.replaceText(propNameNode, replace.name), fixer.replaceText(attr.value, `"${expression} && '${value}'"`)]
725+
return [fixer.replaceText(propNameNode, replace.name), fixer.replaceText(attr.value, `"${expression} ? '${value}' : undefined"`)]
726726
}
727727
} else {
728728
return fixer.replaceText(attr, `${replace.bind ? ':' : ''}${replace.name}="${value}"`)

tests/rules/no-deprecated-props.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ tester.run('no-deprecated-props', rule, {
2323
},
2424
{
2525
code: '<template><v-btn :outline="false" /></template>',
26-
output: `<template><v-btn :variant="false && 'outlined'" /></template>`,
26+
output: `<template><v-btn :variant="false ? 'outlined' : undefined" /></template>`,
2727
errors: [{ messageId: 'replacedWith' }],
2828
},
2929
{
3030
code: '<template><v-btn v-bind:outline="false" /></template>',
31-
output: `<template><v-btn v-bind:variant="false && 'outlined'" /></template>`,
31+
output: `<template><v-btn v-bind:variant="false ? 'outlined' : undefined" /></template>`,
3232
errors: [{ messageId: 'replacedWith' }],
3333
},
3434
{
@@ -73,7 +73,7 @@ tester.run('no-deprecated-props', rule, {
7373
},
7474
{
7575
code: '<template><v-window :vertical="condition" /></template>',
76-
output: `<template><v-window :direction="condition && 'vertical'" /></template>`,
76+
output: `<template><v-window :direction="condition ? 'vertical' : undefined" /></template>`,
7777
errors: [{ messageId: 'replacedWith' }],
7878
},
7979
{

0 commit comments

Comments
 (0)