Skip to content

Commit

Permalink
prevent-abbreviations: Skip fix for variables used in Vue template (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Dec 12, 2022
1 parent 6aa742d commit 8cd1ded
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rules/prevent-abbreviations.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,12 @@ const create = context => {
node: definition.name,
};

if (variableReplacements.total === 1 && shouldFix(variable) && variableReplacements.samples[0]) {
if (
variableReplacements.total === 1
&& shouldFix(variable)
&& variableReplacements.samples[0]
&& !variable.references.some(reference => reference.vueUsedInTemplate)
) {
const [replacement] = variableReplacements.samples;

for (const scope of scopes) {
Expand Down
31 changes: 31 additions & 0 deletions test/prevent-abbreviations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2002,5 +2002,36 @@ test({
],
},
],
});

test.vue({
valid: [],
invalid: [
{
code: outdent`
<template>
<button @click="goToPrev"/>
</template>
<script setup>
const goToPrev = () => {}
</script>
`,
errors: 1,
},
{
code: outdent`
<template><button/></template>
<script setup>
const goToPrev = () => {}
</script>
`,
output: outdent`
<template><button/></template>
<script setup>
const goToPrevious = () => {}
</script>
`,
errors: 1,
},
],
});

0 comments on commit 8cd1ded

Please sign in to comment.