Skip to content

Commit 536c6a1

Browse files
committed
feature: rename autoFixToSeparateInterface option and describe it in the docs
1 parent f6c205f commit 536c6a1

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

docs/rules/define-props-declaration.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,19 @@ const props = defineProps({
4141
## :wrench: Options
4242

4343
```json
44-
"vue/define-props-declaration": ["error", "type-based" | "runtime"]
44+
{
45+
"vue/define-props-declaration": ["error",
46+
"type-based" | "runtime",
47+
{
48+
"autoFixToSeparateInterface": false
49+
}
50+
]
51+
}
4552
```
4653

4754
- `type-based` (default) enforces type-based declaration
4855
- `runtime` enforces runtime declaration
56+
- `autoFixToSeparateInterface` (`boolean`) define `interface Props` used for type-based declaration instead of providing types inline
4957

5058
### `"runtime"`
5159

lib/rules/define-props-declaration.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ module.exports = {
184184
{
185185
type: 'object',
186186
properties: {
187-
separateInterface: {
187+
autoFixToSeparateInterface: {
188188
type: 'boolean',
189189
default: false
190190
}
@@ -206,7 +206,7 @@ module.exports = {
206206
}
207207

208208
const defineType = context.options[0] || 'type-based'
209-
const separateInterface = context.options[1]?.separateInterface || false
209+
const autoFixToSeparateInterface = context.options[1]?.autoFixToSeparateInterface || false
210210

211211
return utils.defineScriptSetupVisitor(context, {
212212
onDefinePropsEnter(node, props) {
@@ -235,7 +235,7 @@ module.exports = {
235235
yield fixer.replaceText(node.arguments[0], '')
236236

237237
// add type annotation
238-
if (separateInterface) {
238+
if (autoFixToSeparateInterface) {
239239
const variableDeclarationNode = node.parent.parent
240240
if (!variableDeclarationNode) {
241241
return

tests/lib/rules/define-props-declaration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ tester.run('define-props-declaration', rule, {
555555
interface Props { kind?: { id: number, name: string } }; const props = defineProps<Props>()
556556
</script>
557557
`,
558-
options: ['type-based', { separateInterface: true }],
558+
options: ['type-based', { autoFixToSeparateInterface: true }],
559559
errors: [
560560
{
561561
message: 'Use type-based declaration instead of runtime declaration.',

0 commit comments

Comments
 (0)