Skip to content

Commit 8cd1ded

Browse files
authored
prevent-abbreviations: Skip fix for variables used in Vue template (#2012)
1 parent 6aa742d commit 8cd1ded

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

rules/prevent-abbreviations.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,12 @@ const create = context => {
448448
node: definition.name,
449449
};
450450

451-
if (variableReplacements.total === 1 && shouldFix(variable) && variableReplacements.samples[0]) {
451+
if (
452+
variableReplacements.total === 1
453+
&& shouldFix(variable)
454+
&& variableReplacements.samples[0]
455+
&& !variable.references.some(reference => reference.vueUsedInTemplate)
456+
) {
452457
const [replacement] = variableReplacements.samples;
453458

454459
for (const scope of scopes) {

test/prevent-abbreviations.mjs

+31
Original file line numberDiff line numberDiff line change
@@ -2002,5 +2002,36 @@ test({
20022002
],
20032003
},
20042004
],
2005+
});
20052006

2007+
test.vue({
2008+
valid: [],
2009+
invalid: [
2010+
{
2011+
code: outdent`
2012+
<template>
2013+
<button @click="goToPrev"/>
2014+
</template>
2015+
<script setup>
2016+
const goToPrev = () => {}
2017+
</script>
2018+
`,
2019+
errors: 1,
2020+
},
2021+
{
2022+
code: outdent`
2023+
<template><button/></template>
2024+
<script setup>
2025+
const goToPrev = () => {}
2026+
</script>
2027+
`,
2028+
output: outdent`
2029+
<template><button/></template>
2030+
<script setup>
2031+
const goToPrevious = () => {}
2032+
</script>
2033+
`,
2034+
errors: 1,
2035+
},
2036+
],
20062037
});

0 commit comments

Comments
 (0)