Skip to content

Commit e7ff982

Browse files
committed
add fix
1 parent 50b5b7d commit e7ff982

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/rules/require-shorthand-boolean-prop.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
recommended: false,
2020
url: 'https://eslint.vuejs.org/rules/require-shorthand-boolean-prop.html'
2121
},
22-
fixable: null, // or "code" or "whitespace"
22+
fixable: 'code',
2323
schema: [
2424
{
2525
enum: ['always', 'never']
@@ -38,7 +38,13 @@ module.exports = {
3838
context.report({
3939
node,
4040
loc: node.loc,
41-
message: 'Unexpected shorthand prop.'
41+
message: 'Unexpected shorthand prop.',
42+
fix (fixer) {
43+
const { rawName } = attr.key || {}
44+
return rawName
45+
? fixer.replaceTextRange(attr.range, `:${rawName}="true"`)
46+
: null
47+
}
4248
})
4349
}
4450
continue
@@ -49,7 +55,13 @@ module.exports = {
4955
context.report({
5056
node,
5157
loc: node.loc,
52-
message: "Unexpected 'true' value."
58+
message: "Unexpected 'true' value.",
59+
fix (fixer) {
60+
const { rawName } = (attr.key || {}).argument || {}
61+
return rawName
62+
? fixer.replaceTextRange(attr.range, rawName)
63+
: null
64+
}
5365
})
5466
}
5567
continue

0 commit comments

Comments
 (0)