Skip to content

Commit 2a1c654

Browse files
committed
feature: remove autoFixToSeparateInterface option
1 parent bbdc134 commit 2a1c654

File tree

2 files changed

+1
-50
lines changed

2 files changed

+1
-50
lines changed

Diff for: lib/rules/define-props-declaration.js

+1-25
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ const PROPS_SEPARATOR = ', '
1616
*/
1717
function* fixTypeBased(fixer, node, props, context) {
1818
const sourceCode = context.getSourceCode()
19-
const autoFixToSeparateInterface =
20-
context.options[1]?.autoFixToSeparateInterface || false
2119

2220
const componentPropsData = props.map((prop) =>
2321
getComponentPropData(prop, sourceCode)
@@ -36,20 +34,7 @@ function* fixTypeBased(fixer, node, props, context) {
3634
yield fixer.replaceText(node.arguments[0], '')
3735

3836
// add type annotation
39-
if (autoFixToSeparateInterface) {
40-
const variableDeclarationNode = node.parent.parent
41-
if (!variableDeclarationNode) {
42-
return
43-
}
44-
45-
yield fixer.insertTextBefore(
46-
variableDeclarationNode,
47-
`interface Props ${componentPropsTypeCode.replace(/;/g, ',')}; `
48-
)
49-
yield fixer.insertTextAfter(node.callee, `<Props>`)
50-
} else {
51-
yield fixer.insertTextAfter(node.callee, `<${componentPropsTypeCode}>`)
52-
}
37+
yield fixer.insertTextAfter(node.callee, `<${componentPropsTypeCode}>`)
5338

5439
// add defaults if needed
5540
const propTypesDataWithDefaultValue = componentPropsData.filter(
@@ -242,15 +227,6 @@ module.exports = {
242227
schema: [
243228
{
244229
enum: ['type-based', 'runtime']
245-
},
246-
{
247-
type: 'object',
248-
properties: {
249-
autoFixToSeparateInterface: {
250-
type: 'boolean',
251-
default: false
252-
}
253-
}
254230
}
255231
],
256232
messages: {

Diff for: tests/lib/rules/define-props-declaration.js

-25
Original file line numberDiff line numberDiff line change
@@ -538,31 +538,6 @@ tester.run('define-props-declaration', rule, {
538538
}
539539
]
540540
},
541-
// separate interface
542-
{
543-
filename: 'test.vue',
544-
code: `
545-
<script setup lang="ts">
546-
const props = defineProps({
547-
kind: {
548-
type: Object as PropType<{ id: number; name: string }>
549-
}
550-
})
551-
</script>
552-
`,
553-
output: `
554-
<script setup lang="ts">
555-
interface Props { kind?: { id: number, name: string } }; const props = defineProps<Props>()
556-
</script>
557-
`,
558-
options: ['type-based', { autoFixToSeparateInterface: true }],
559-
errors: [
560-
{
561-
message: 'Use type-based declaration instead of runtime declaration.',
562-
line: 3
563-
}
564-
]
565-
},
566541
// Array of types
567542
{
568543
filename: 'test.vue',

0 commit comments

Comments
 (0)