Skip to content

Commit bc030be

Browse files
committed
feat: remove fix function from this rule
1 parent 5a9b764 commit bc030be

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

docs/rules/no-v-text.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ description: disallow use of v-text
88

99
> disallow use of v-text
1010
11-
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1211

1312
## :book: Rule Details
1413

1514
This rule reports all uses of `v-text` directive.
16-
When using selfClose to element with v-text like `<div v-text="foobar" />`, it can't be fixed.
1715

18-
<eslint-code-block fix :rules="{'vue/no-v-text': ['error']}">
16+
<eslint-code-block :rules="{'vue/no-v-text': ['error']}">
1917

2018
```vue
2119
<template>
@@ -24,8 +22,6 @@ When using selfClose to element with v-text like `<div v-text="foobar" />`, it c
2422
2523
<!-- ✗ BAD -->
2624
<div v-text="foobar"></div>
27-
<!-- Reported. However, Not fixable -->
28-
<div v-text="foobar" />
2925
</template>
3026
```
3127

lib/rules/no-v-text.js

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,18 @@ module.exports = {
1717
categories: undefined,
1818
url: 'https://eslint.vuejs.org/rules/no-v-text.html'
1919
},
20-
fixable: 'code',
20+
fixable: null,
2121
schema: []
2222
},
2323
/** @param {RuleContext} context */
2424
create(context) {
2525
return utils.defineTemplateBodyVisitor(context, {
26-
/** @param {VElement} node */
27-
"VElement:has(VAttribute[directive=true][key.name.name='text'])"(node) {
28-
const vText = utils.getDirective(node, 'text')
29-
30-
if (!vText) return
31-
32-
const vTextValue = vText.value.expression.name
33-
26+
/** @param {VDirective} node */
27+
"VAttribute[directive=true][key.name.name='text']"(node) {
3428
context.report({
35-
node: vText,
36-
loc: vText.loc,
37-
message: "Don't use 'v-text'.",
38-
fix(fixable) {
39-
if (node.startTag.selfClosing) return
40-
41-
return [
42-
fixable.remove(vText),
43-
fixable.insertTextAfterRange(
44-
node.startTag.range,
45-
`{{${vTextValue}}}`
46-
)
47-
]
48-
}
29+
node,
30+
loc: node.loc,
31+
message: "Don't use 'v-text'."
4932
})
5033
}
5134
})

0 commit comments

Comments
 (0)