From 2506c808d1cffb3d0d749d1f4680854ac176f48f Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Mon, 12 Sep 2022 23:33:06 +0800
Subject: [PATCH 01/19] Add `vue/prefer-type-props-decl` rule
---
docs/rules/README.md | 1 +
docs/rules/prefer-type-props-decl.md | 53 +++++++++++++
lib/configs/no-layout-rules.js | 1 +
lib/index.js | 1 +
lib/rules/prefer-type-props-decl.js | 56 +++++++++++++
tests/lib/rules/prefer-type-props-decl.js | 96 +++++++++++++++++++++++
6 files changed, 208 insertions(+)
create mode 100644 docs/rules/prefer-type-props-decl.md
create mode 100644 lib/rules/prefer-type-props-decl.js
create mode 100644 tests/lib/rules/prefer-type-props-decl.js
diff --git a/docs/rules/README.md b/docs/rules/README.md
index de00e7e53..cfec04f94 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -252,6 +252,7 @@ For example:
| [vue/prefer-prop-type-boolean-first](./prefer-prop-type-boolean-first.md) | enforce `Boolean` comes first in component prop types | :bulb: | :warning: |
| [vue/prefer-separate-static-class](./prefer-separate-static-class.md) | require static class names in template to be in a separate `class` attribute | :wrench: | :hammer: |
| [vue/prefer-true-attribute-shorthand](./prefer-true-attribute-shorthand.md) | require shorthand form attribute when `v-bind` value is `true` | :bulb: | :hammer: |
+| [vue/prefer-type-props-decl](./prefer-type-props-decl.md) | enforce type-only `defineProps` | | :lipstick: |
| [vue/require-direct-export](./require-direct-export.md) | require the component to be directly exported | | :hammer: |
| [vue/require-emit-validator](./require-emit-validator.md) | require type definitions in emits | :bulb: | :hammer: |
| [vue/require-expose](./require-expose.md) | require declare public properties using `expose` | :bulb: | :hammer: |
diff --git a/docs/rules/prefer-type-props-decl.md b/docs/rules/prefer-type-props-decl.md
new file mode 100644
index 000000000..7f9252388
--- /dev/null
+++ b/docs/rules/prefer-type-props-decl.md
@@ -0,0 +1,53 @@
+---
+pageClass: rule-details
+sidebarDepth: 0
+title: vue/prefer-type-props-decl
+description: enforce type-based `defineProps`
+---
+
+# vue/prefer-type-props-decl
+
+> enforce type-based `defineProps`
+
+- :exclamation: **_This rule has not been released yet._**
+
+## :book: Rule Details
+
+This rule forces developers to use the type-based declaration of `defineProps` instead of runtime declaration.
+
+This rule only works in setup script and `lang="ts"`.
+
+
+
+```vue
+
+```
+
+
+
+
+
+```vue
+
+```
+
+
+
+## :wrench: Options
+
+Nothing.
+
+## :mag: Implementation
+
+- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/prefer-type-props-decl.js)
+- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/prefer-type-props-decl.js)
diff --git a/lib/configs/no-layout-rules.js b/lib/configs/no-layout-rules.js
index ab03684b5..ea8637402 100644
--- a/lib/configs/no-layout-rules.js
+++ b/lib/configs/no-layout-rules.js
@@ -41,6 +41,7 @@ module.exports = {
'vue/object-property-newline': 'off',
'vue/operator-linebreak': 'off',
'vue/padding-line-between-blocks': 'off',
+ 'vue/prefer-type-props-decl': 'off',
'vue/script-indent': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/space-in-parens': 'off',
diff --git a/lib/index.js b/lib/index.js
index ca3a93084..92f517643 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -162,6 +162,7 @@ module.exports = {
'prefer-separate-static-class': require('./rules/prefer-separate-static-class'),
'prefer-template': require('./rules/prefer-template'),
'prefer-true-attribute-shorthand': require('./rules/prefer-true-attribute-shorthand'),
+ 'prefer-type-props-decl': require('./rules/prefer-type-props-decl'),
'prop-name-casing': require('./rules/prop-name-casing'),
'quote-props': require('./rules/quote-props'),
'require-component-is': require('./rules/require-component-is'),
diff --git a/lib/rules/prefer-type-props-decl.js b/lib/rules/prefer-type-props-decl.js
new file mode 100644
index 000000000..e42ad5f93
--- /dev/null
+++ b/lib/rules/prefer-type-props-decl.js
@@ -0,0 +1,56 @@
+/**
+ * @author Amorites
+ * See LICENSE file in root directory for full license.
+ */
+'use strict'
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+const utils = require('../utils')
+
+// ------------------------------------------------------------------------------
+// Helpers
+// ------------------------------------------------------------------------------
+
+// ------------------------------------------------------------------------------
+// Rule Definition
+// ------------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ type: 'layout',
+ docs: {
+ description: 'enforce type-based `defineProps`',
+ categories: undefined,
+ url: 'https://eslint.vuejs.org/rules/prefer-type-props-decl.html'
+ },
+ fixable: null,
+ schema: [],
+ messages: {
+ hasArg: 'Use type-based declaration instead of runtime declaration.'
+ }
+ },
+ /** @param {RuleContext} context */
+ create(context) {
+ const scriptSetup = utils.getScriptSetupElement(context)
+ if (!scriptSetup) {
+ return {}
+ }
+ if (!utils.hasAttribute(scriptSetup, 'lang', 'ts')) {
+ return {}
+ }
+
+ return utils.defineScriptSetupVisitor(context, {
+ onDefinePropsEnter(node) {
+ if (node.arguments.length > 0) {
+ context.report({
+ node,
+ messageId: 'hasArg'
+ })
+ }
+ }
+ })
+ }
+}
diff --git a/tests/lib/rules/prefer-type-props-decl.js b/tests/lib/rules/prefer-type-props-decl.js
new file mode 100644
index 000000000..dc4a21092
--- /dev/null
+++ b/tests/lib/rules/prefer-type-props-decl.js
@@ -0,0 +1,96 @@
+/**
+ * @author Amorites
+ * See LICENSE file in root directory for full license.
+ */
+'use strict'
+
+const RuleTester = require('eslint').RuleTester
+const rule = require('../../../lib/rules/prefer-type-props-decl')
+
+const tester = new RuleTester({
+ parser: require.resolve('vue-eslint-parser'),
+ parserOptions: {
+ ecmaVersion: 2020,
+ sourceType: 'module'
+ }
+})
+
+tester.run('prefer-type-props-decl', rule, {
+ valid: [
+ {
+ filename: 'test.vue',
+ code: `
+
+ `
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+
+
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
+ }
+ ],
+ invalid: [
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ errors: [
+ {
+ message: 'Use type-based declaration instead of runtime declaration.',
+ line: 3
+ }
+ ]
+ }
+ ]
+})
From 5fa4d5c1ec624e0a5606f21aa04841ded3a21506 Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Tue, 13 Sep 2022 01:46:08 +0800
Subject: [PATCH 02/19] Add rule
---
docs/rules/README.md | 3 +-
docs/rules/prefer-type-emits-decl.md | 51 +++++++++++++
docs/rules/prefer-type-props-decl.md | 3 +-
lib/configs/no-layout-rules.js | 1 +
lib/index.js | 1 +
lib/rules/prefer-type-emits-decl.js | 56 ++++++++++++++
tests/lib/rules/prefer-type-emits-decl.js | 93 +++++++++++++++++++++++
7 files changed, 205 insertions(+), 3 deletions(-)
create mode 100644 docs/rules/prefer-type-emits-decl.md
create mode 100644 lib/rules/prefer-type-emits-decl.js
create mode 100644 tests/lib/rules/prefer-type-emits-decl.js
diff --git a/docs/rules/README.md b/docs/rules/README.md
index cfec04f94..e2c017a04 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -252,7 +252,8 @@ For example:
| [vue/prefer-prop-type-boolean-first](./prefer-prop-type-boolean-first.md) | enforce `Boolean` comes first in component prop types | :bulb: | :warning: |
| [vue/prefer-separate-static-class](./prefer-separate-static-class.md) | require static class names in template to be in a separate `class` attribute | :wrench: | :hammer: |
| [vue/prefer-true-attribute-shorthand](./prefer-true-attribute-shorthand.md) | require shorthand form attribute when `v-bind` value is `true` | :bulb: | :hammer: |
-| [vue/prefer-type-props-decl](./prefer-type-props-decl.md) | enforce type-only `defineProps` | | :lipstick: |
+| [vue/prefer-type-emits-decl](./prefer-type-emits-decl.md) | enforce type-based `defineEmits` | | :lipstick: |
+| [vue/prefer-type-props-decl](./prefer-type-props-decl.md) | enforce type-based `defineProps` | | :lipstick: |
| [vue/require-direct-export](./require-direct-export.md) | require the component to be directly exported | | :hammer: |
| [vue/require-emit-validator](./require-emit-validator.md) | require type definitions in emits | :bulb: | :hammer: |
| [vue/require-expose](./require-expose.md) | require declare public properties using `expose` | :bulb: | :hammer: |
diff --git a/docs/rules/prefer-type-emits-decl.md b/docs/rules/prefer-type-emits-decl.md
new file mode 100644
index 000000000..564fa4e41
--- /dev/null
+++ b/docs/rules/prefer-type-emits-decl.md
@@ -0,0 +1,51 @@
+---
+pageClass: rule-details
+sidebarDepth: 0
+title: vue/prefer-type-emits-decl
+description: enforce type-based `defineEmits`
+---
+# vue/prefer-type-emits-decl
+
+> enforce type-based `defineEmits`
+
+- :exclamation: ***This rule has not been released yet.***
+
+## :book: Rule Details
+
+This rule forces developers to use the type-based declaration of `defineEmits` instead of runtime declaration.
+
+This rule only works in setup script and `lang="ts"`.
+
+
+
+```vue
+
+```
+
+
+
+
+
+```vue
+
+```
+
+
+
+## :wrench: Options
+
+Nothing.
+
+## :mag: Implementation
+
+- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/prefer-type-emits-decl.js)
+- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/prefer-type-emits-decl.js)
diff --git a/docs/rules/prefer-type-props-decl.md b/docs/rules/prefer-type-props-decl.md
index 7f9252388..c6f42d347 100644
--- a/docs/rules/prefer-type-props-decl.md
+++ b/docs/rules/prefer-type-props-decl.md
@@ -4,12 +4,11 @@ sidebarDepth: 0
title: vue/prefer-type-props-decl
description: enforce type-based `defineProps`
---
-
# vue/prefer-type-props-decl
> enforce type-based `defineProps`
-- :exclamation: **_This rule has not been released yet._**
+- :exclamation: ***This rule has not been released yet.***
## :book: Rule Details
diff --git a/lib/configs/no-layout-rules.js b/lib/configs/no-layout-rules.js
index ea8637402..11fea318f 100644
--- a/lib/configs/no-layout-rules.js
+++ b/lib/configs/no-layout-rules.js
@@ -41,6 +41,7 @@ module.exports = {
'vue/object-property-newline': 'off',
'vue/operator-linebreak': 'off',
'vue/padding-line-between-blocks': 'off',
+ 'vue/prefer-type-emits-decl': 'off',
'vue/prefer-type-props-decl': 'off',
'vue/script-indent': 'off',
'vue/singleline-html-element-content-newline': 'off',
diff --git a/lib/index.js b/lib/index.js
index 92f517643..deeb90589 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -162,6 +162,7 @@ module.exports = {
'prefer-separate-static-class': require('./rules/prefer-separate-static-class'),
'prefer-template': require('./rules/prefer-template'),
'prefer-true-attribute-shorthand': require('./rules/prefer-true-attribute-shorthand'),
+ 'prefer-type-emits-decl': require('./rules/prefer-type-emits-decl'),
'prefer-type-props-decl': require('./rules/prefer-type-props-decl'),
'prop-name-casing': require('./rules/prop-name-casing'),
'quote-props': require('./rules/quote-props'),
diff --git a/lib/rules/prefer-type-emits-decl.js b/lib/rules/prefer-type-emits-decl.js
new file mode 100644
index 000000000..b95540ef9
--- /dev/null
+++ b/lib/rules/prefer-type-emits-decl.js
@@ -0,0 +1,56 @@
+/**
+ * @author Amorites
+ * See LICENSE file in root directory for full license.
+ */
+'use strict'
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+const utils = require('../utils')
+
+// ------------------------------------------------------------------------------
+// Helpers
+// ------------------------------------------------------------------------------
+
+// ------------------------------------------------------------------------------
+// Rule Definition
+// ------------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ type: 'layout',
+ docs: {
+ description: 'enforce type-based `defineEmits`',
+ categories: undefined,
+ url: 'https://eslint.vuejs.org/rules/prefer-type-emits-decl.html'
+ },
+ fixable: null,
+ schema: [],
+ messages: {
+ hasArg: 'Use type-based declaration instead of runtime declaration.'
+ }
+ },
+ /** @param {RuleContext} context */
+ create(context) {
+ const scriptSetup = utils.getScriptSetupElement(context)
+ if (!scriptSetup) {
+ return {}
+ }
+ if (!utils.hasAttribute(scriptSetup, 'lang', 'ts')) {
+ return {}
+ }
+
+ return utils.defineScriptSetupVisitor(context, {
+ onDefineEmitsEnter(node) {
+ if (node.arguments.length > 0) {
+ context.report({
+ node,
+ messageId: 'hasArg'
+ })
+ }
+ }
+ })
+ }
+}
diff --git a/tests/lib/rules/prefer-type-emits-decl.js b/tests/lib/rules/prefer-type-emits-decl.js
new file mode 100644
index 000000000..82e5c93aa
--- /dev/null
+++ b/tests/lib/rules/prefer-type-emits-decl.js
@@ -0,0 +1,93 @@
+/**
+ * @author Amorites
+ * See LICENSE file in root directory for full license.
+ */
+'use strict'
+
+const RuleTester = require('eslint').RuleTester
+const rule = require('../../../lib/rules/prefer-type-emits-decl')
+
+const tester = new RuleTester({
+ parser: require.resolve('vue-eslint-parser'),
+ parserOptions: {
+ ecmaVersion: 2020,
+ sourceType: 'module'
+ }
+})
+
+tester.run('prefer-type-props-decl', rule, {
+ valid: [
+ {
+ filename: 'test.vue',
+ code: `
+
+ `
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+
+
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
+ }
+ ],
+ invalid: [
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ errors: [
+ {
+ message: 'Use type-based declaration instead of runtime declaration.',
+ line: 3
+ }
+ ]
+ }
+ ]
+})
From dd6f19db4ea3927ee18e244831674e0897cbaddc Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Tue, 13 Sep 2022 02:01:58 +0800
Subject: [PATCH 03/19] chore: Related Rules
---
docs/rules/prefer-type-emits-decl.md | 9 +++-
docs/rules/prefer-type-props-decl.md | 5 +++
docs/rules/valid-define-props.md | 53 +++++++++++++----------
lib/rules/prefer-type-emits-decl.js | 5 +--
lib/rules/prefer-type-props-decl.js | 5 +--
tests/lib/rules/prefer-type-emits-decl.js | 3 --
tests/lib/rules/prefer-type-props-decl.js | 3 --
7 files changed, 43 insertions(+), 40 deletions(-)
diff --git a/docs/rules/prefer-type-emits-decl.md b/docs/rules/prefer-type-emits-decl.md
index 564fa4e41..cfa37f7d5 100644
--- a/docs/rules/prefer-type-emits-decl.md
+++ b/docs/rules/prefer-type-emits-decl.md
@@ -16,7 +16,7 @@ This rule forces developers to use the type-based declaration of `defineEmits` i
This rule only works in setup script and `lang="ts"`.
-
+
```vue
```
@@ -38,8 +38,8 @@ This rule reports `defineProps` compiler macros in the following cases:
```vue
```
@@ -47,8 +47,8 @@ This rule reports `defineProps` compiler macros in the following cases:
```vue
```
@@ -56,11 +56,11 @@ This rule reports `defineProps` compiler macros in the following cases:
```vue
```
@@ -70,9 +70,9 @@ This rule reports `defineProps` compiler macros in the following cases:
```vue
```
@@ -80,8 +80,8 @@ This rule reports `defineProps` compiler macros in the following cases:
```vue
```
@@ -89,9 +89,9 @@ This rule reports `defineProps` compiler macros in the following cases:
```vue
```
@@ -101,13 +101,13 @@ This rule reports `defineProps` compiler macros in the following cases:
```vue
```
@@ -117,8 +117,8 @@ This rule reports `defineProps` compiler macros in the following cases:
```vue
```
@@ -128,6 +128,11 @@ This rule reports `defineProps` compiler macros in the following cases:
Nothing.
+## :couple: Related Rules
+
+- [vue/prefer-type-props-decl](./prefer-type-props-decl.md)
+- [vue/prefer-type-emits-decl](./prefer-type-emits-decl.md)
+
## :rocket: Version
This rule was introduced in eslint-plugin-vue v7.13.0
diff --git a/lib/rules/prefer-type-emits-decl.js b/lib/rules/prefer-type-emits-decl.js
index b95540ef9..0d4182571 100644
--- a/lib/rules/prefer-type-emits-decl.js
+++ b/lib/rules/prefer-type-emits-decl.js
@@ -35,10 +35,7 @@ module.exports = {
/** @param {RuleContext} context */
create(context) {
const scriptSetup = utils.getScriptSetupElement(context)
- if (!scriptSetup) {
- return {}
- }
- if (!utils.hasAttribute(scriptSetup, 'lang', 'ts')) {
+ if (!scriptSetup || !utils.hasAttribute(scriptSetup, 'lang', 'ts')) {
return {}
}
diff --git a/lib/rules/prefer-type-props-decl.js b/lib/rules/prefer-type-props-decl.js
index e42ad5f93..24e2c0572 100644
--- a/lib/rules/prefer-type-props-decl.js
+++ b/lib/rules/prefer-type-props-decl.js
@@ -35,10 +35,7 @@ module.exports = {
/** @param {RuleContext} context */
create(context) {
const scriptSetup = utils.getScriptSetupElement(context)
- if (!scriptSetup) {
- return {}
- }
- if (!utils.hasAttribute(scriptSetup, 'lang', 'ts')) {
+ if (!scriptSetup || !utils.hasAttribute(scriptSetup, 'lang', 'ts')) {
return {}
}
diff --git a/tests/lib/rules/prefer-type-emits-decl.js b/tests/lib/rules/prefer-type-emits-decl.js
index 82e5c93aa..b4b430980 100644
--- a/tests/lib/rules/prefer-type-emits-decl.js
+++ b/tests/lib/rules/prefer-type-emits-decl.js
@@ -55,9 +55,6 @@ tester.run('prefer-type-props-decl', rule, {
{
filename: 'test.vue',
code: `
-
-
-
```
-
-
```vue
@@ -48,7 +44,7 @@ Nothing.
## :couple: Related Rules
- [vue/prefer-type-props-decl](./prefer-type-props-decl.md)
-- [vue/valid-define-props](./valid-define-props.md)
+- [vue/valid-define-emits](./valid-define-emits.md)
## :mag: Implementation
diff --git a/docs/rules/prefer-type-props-decl.md b/docs/rules/prefer-type-props-decl.md
index d92a40ff6..820bdfb1e 100644
--- a/docs/rules/prefer-type-props-decl.md
+++ b/docs/rules/prefer-type-props-decl.md
@@ -16,8 +16,6 @@ This rule forces developers to use the type-based declaration of `defineProps` i
This rule only works in setup script and `lang="ts"`.
-
-
```vue
```
-
-
```vue
diff --git a/docs/rules/valid-define-emits.md b/docs/rules/valid-define-emits.md
index 5718794ca..1162e70d8 100644
--- a/docs/rules/valid-define-emits.md
+++ b/docs/rules/valid-define-emits.md
@@ -27,8 +27,8 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -38,8 +38,8 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -47,8 +47,8 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -56,11 +56,11 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -70,9 +70,9 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -80,8 +80,8 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -89,9 +89,9 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -101,13 +101,13 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -117,8 +117,8 @@ This rule reports `defineEmits` compiler macros in the following cases:
```vue
```
@@ -128,6 +128,11 @@ This rule reports `defineEmits` compiler macros in the following cases:
Nothing.
+## :couple: Related Rules
+
+- [vue/prefer-type-emits-decl](./prefer-type-emits-decl.md)
+- [vue/valid-define-props](./valid-define-props.md)
+
## :rocket: Version
This rule was introduced in eslint-plugin-vue v7.13.0
diff --git a/docs/rules/valid-define-props.md b/docs/rules/valid-define-props.md
index 623472ed2..c36f7832a 100644
--- a/docs/rules/valid-define-props.md
+++ b/docs/rules/valid-define-props.md
@@ -131,7 +131,7 @@ Nothing.
## :couple: Related Rules
- [vue/prefer-type-props-decl](./prefer-type-props-decl.md)
-- [vue/prefer-type-emits-decl](./prefer-type-emits-decl.md)
+- [vue/valid-define-emits](./valid-define-emits.md)
## :rocket: Version
From 6545e85b2940b931d8ad7f96712ae7ac0b824848 Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Wed, 14 Sep 2022 20:04:30 +0800
Subject: [PATCH 07/19] Update lib/rules/prefer-type-emits-decl.js
Co-authored-by: Flo Edelmann
---
lib/rules/prefer-type-emits-decl.js | 4 ----
1 file changed, 4 deletions(-)
diff --git a/lib/rules/prefer-type-emits-decl.js b/lib/rules/prefer-type-emits-decl.js
index b76842011..c57ee9aca 100644
--- a/lib/rules/prefer-type-emits-decl.js
+++ b/lib/rules/prefer-type-emits-decl.js
@@ -10,10 +10,6 @@
const utils = require('../utils')
-// ------------------------------------------------------------------------------
-// Helpers
-// ------------------------------------------------------------------------------
-
// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
From 9dd43d8a5a4f4019868e947906dc578f0cacb99f Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Wed, 14 Sep 2022 20:07:08 +0800
Subject: [PATCH 08/19] Update tests/lib/rules/prefer-type-emits-decl.js
Co-authored-by: Flo Edelmann
---
tests/lib/rules/prefer-type-emits-decl.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/lib/rules/prefer-type-emits-decl.js b/tests/lib/rules/prefer-type-emits-decl.js
index b4b430980..229691cf1 100644
--- a/tests/lib/rules/prefer-type-emits-decl.js
+++ b/tests/lib/rules/prefer-type-emits-decl.js
@@ -15,7 +15,7 @@ const tester = new RuleTester({
}
})
-tester.run('prefer-type-props-decl', rule, {
+tester.run('prefer-type-emits-decl', rule, {
valid: [
{
filename: 'test.vue',
From 624396e387b2eedaea7d7eedcc1bf09e91bea0ab Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Wed, 14 Sep 2022 20:55:34 +0800
Subject: [PATCH 09/19] chore: rename rule name
---
docs/rules/README.md | 474 +++++++++---------
...ts-decl.md => define-emits-declaration.md} | 15 +-
...ps-decl.md => define-props-declaration.md} | 15 +-
docs/rules/valid-define-emits.md | 3 +-
docs/rules/valid-define-props.md | 3 +-
lib/configs/no-layout-rules.js | 4 +-
lib/index.js | 4 +-
...ts-decl.js => define-emits-declaration.js} | 2 +-
...ps-decl.js => define-props-declaration.js} | 2 +-
...ts-decl.js => define-emits-declaration.js} | 4 +-
...ps-decl.js => define-props-declaration.js} | 4 +-
11 files changed, 267 insertions(+), 263 deletions(-)
rename docs/rules/{prefer-type-emits-decl.md => define-emits-declaration.md} (70%)
rename docs/rules/{prefer-type-props-decl.md => define-props-declaration.md} (69%)
rename lib/rules/{prefer-type-emits-decl.js => define-emits-declaration.js} (94%)
rename lib/rules/{prefer-type-props-decl.js => define-props-declaration.js} (95%)
rename tests/lib/rules/{prefer-type-emits-decl.js => define-emits-declaration.js} (94%)
rename tests/lib/rules/{prefer-type-props-decl.js => define-props-declaration.js} (94%)
diff --git a/docs/rules/README.md b/docs/rules/README.md
index e2c017a04..d7e017537 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -8,9 +8,9 @@ pageClass: rule-list
::: tip Legend
- :wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems.
+:wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems.
- :bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
+:bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
:::
Mark indicating rule type:
@@ -25,10 +25,10 @@ Rules in this category are enabled for all presets provided by eslint-plugin-vue
-| Rule ID | Description | | |
-|:--------|:------------|:--:|:--:|
-| [vue/comment-directive](./comment-directive.md) | support comment-directives in `` | | :warning: |
-| [vue/jsx-uses-vars](./jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused | | :warning: |
+| Rule ID | Description | | |
+| :---------------------------------------------- | :--------------------------------------------------- | :-: | :-------: |
+| [vue/comment-directive](./comment-directive.md) | support comment-directives in `` | | :warning: |
+| [vue/jsx-uses-vars](./jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused | | :warning: |
@@ -39,95 +39,95 @@ Rules in this category are enabled for all presets provided by eslint-plugin-vue
-| Rule ID | Description | | |
-|:--------|:------------|:--:|:--:|
-| [vue/multi-word-component-names](./multi-word-component-names.md) | require component names to be always multi-word | | :three::two::hammer: |
-| [vue/no-arrow-functions-in-watch](./no-arrow-functions-in-watch.md) | disallow using arrow functions to define watcher | | :three::two::warning: |
-| [vue/no-async-in-computed-properties](./no-async-in-computed-properties.md) | disallow asynchronous actions in computed properties | | :three::two::warning: |
-| [vue/no-child-content](./no-child-content.md) | disallow element's child contents which would be overwritten by a directive like `v-html` or `v-text` | :bulb: | :three::two::warning: |
-| [vue/no-computed-properties-in-data](./no-computed-properties-in-data.md) | disallow accessing computed properties in `data`. | | :three::two::warning: |
-| [vue/no-custom-modifiers-on-v-model](./no-custom-modifiers-on-v-model.md) | disallow custom modifiers on v-model used on the component | | :two::warning: |
-| [vue/no-deprecated-data-object-declaration](./no-deprecated-data-object-declaration.md) | disallow using deprecated object declaration on data (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-destroyed-lifecycle](./no-deprecated-destroyed-lifecycle.md) | disallow using deprecated `destroyed` and `beforeDestroy` lifecycle hooks (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-dollar-listeners-api](./no-deprecated-dollar-listeners-api.md) | disallow using deprecated `$listeners` (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-dollar-scopedslots-api](./no-deprecated-dollar-scopedslots-api.md) | disallow using deprecated `$scopedSlots` (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-events-api](./no-deprecated-events-api.md) | disallow using deprecated events api (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-filter](./no-deprecated-filter.md) | disallow using deprecated filters syntax (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-functional-template](./no-deprecated-functional-template.md) | disallow using deprecated the `functional` template (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-html-element-is](./no-deprecated-html-element-is.md) | disallow using deprecated the `is` attribute on HTML elements (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-inline-template](./no-deprecated-inline-template.md) | disallow using deprecated `inline-template` attribute (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-props-default-this](./no-deprecated-props-default-this.md) | disallow deprecated `this` access in props default function (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-router-link-tag-prop](./no-deprecated-router-link-tag-prop.md) | disallow using deprecated `tag` property on `RouterLink` (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-scope-attribute](./no-deprecated-scope-attribute.md) | disallow deprecated `scope` attribute (in Vue.js 2.5.0+) | :wrench: | :three::hammer: |
-| [vue/no-deprecated-slot-attribute](./no-deprecated-slot-attribute.md) | disallow deprecated `slot` attribute (in Vue.js 2.6.0+) | :wrench: | :three::hammer: |
-| [vue/no-deprecated-slot-scope-attribute](./no-deprecated-slot-scope-attribute.md) | disallow deprecated `slot-scope` attribute (in Vue.js 2.6.0+) | :wrench: | :three::hammer: |
-| [vue/no-deprecated-v-bind-sync](./no-deprecated-v-bind-sync.md) | disallow use of deprecated `.sync` modifier on `v-bind` directive (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-v-is](./no-deprecated-v-is.md) | disallow deprecated `v-is` directive (in Vue.js 3.1.0+) | :wrench: | :three::hammer: |
-| [vue/no-deprecated-v-on-native-modifier](./no-deprecated-v-on-native-modifier.md) | disallow using deprecated `.native` modifiers (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-v-on-number-modifiers](./no-deprecated-v-on-number-modifiers.md) | disallow using deprecated number (keycode) modifiers (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-vue-config-keycodes](./no-deprecated-vue-config-keycodes.md) | disallow using deprecated `Vue.config.keyCodes` (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-dupe-keys](./no-dupe-keys.md) | disallow duplication of field names | | :three::two::warning: |
-| [vue/no-dupe-v-else-if](./no-dupe-v-else-if.md) | disallow duplicate conditions in `v-if` / `v-else-if` chains | | :three::two::warning: |
-| [vue/no-duplicate-attributes](./no-duplicate-attributes.md) | disallow duplication of attributes | | :three::two::warning: |
-| [vue/no-export-in-script-setup](./no-export-in-script-setup.md) | disallow `export` in `
```
-
+
```vue
```
-
+
```vue
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ },
+ options: ['type-based']
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ options: ['runtime']
+ },
+ {
+ filename: 'test.vue',
+ // ignore code without defineEmits
code: `
+ `,
+ errors: [
+ {
+ message: 'Use type-based declaration instead of runtime declaration.',
+ line: 3
+ }
+ ],
+ options: ['type-based']
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ },
+ errors: [
+ {
+ message: 'Use runtime declaration instead of type-based declaration.',
+ line: 3
+ }
+ ],
+ options: ['runtime']
}
]
})
diff --git a/tests/lib/rules/define-props-declaration.js b/tests/lib/rules/define-props-declaration.js
index 080e87ea2..67ea338ec 100644
--- a/tests/lib/rules/define-props-declaration.js
+++ b/tests/lib/rules/define-props-declaration.js
@@ -20,12 +20,15 @@ tester.run('define-props-declaration', rule, {
{
filename: 'test.vue',
code: `
-
- `
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
},
{
filename: 'test.vue',
@@ -38,7 +41,30 @@ tester.run('define-props-declaration', rule, {
`,
parserOptions: {
parser: require.resolve('@typescript-eslint/parser')
- }
+ },
+ options: ['type-based']
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ options: ['runtime']
+ },
+ {
+ filename: 'test.vue',
+ // ignore script without lang="ts"
+ code: `
+
+ `
},
{
filename: 'test.vue',
@@ -55,6 +81,7 @@ tester.run('define-props-declaration', rule, {
},
{
filename: 'test.vue',
+ // ignore non-setup script
code: `
+ `,
+ errors: [
+ {
+ message: 'Use type-based declaration instead of runtime declaration.',
+ line: 3
+ }
+ ],
+ options: ['type-based']
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ },
+ options: ['runtime'],
+ errors: [
+ {
+ message: 'Use runtime declaration instead of type-based declaration.',
+ line: 3
+ }
+ ]
}
]
})
From 46191133eace44093b2ba12c95d199461d93cbcb Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Thu, 15 Sep 2022 18:58:51 +0800
Subject: [PATCH 11/19] update rule docs
---
docs/rules/README.md | 474 ++++++++++++-------------
docs/rules/define-emits-declaration.md | 22 +-
docs/rules/define-props-declaration.md | 22 +-
docs/rules/valid-define-emits.md | 1 -
docs/rules/valid-define-props.md | 1 -
lib/configs/no-layout-rules.js | 2 -
lib/index.js | 4 +-
lib/rules/define-emits-declaration.js | 2 +-
lib/rules/define-props-declaration.js | 2 +-
9 files changed, 273 insertions(+), 257 deletions(-)
diff --git a/docs/rules/README.md b/docs/rules/README.md
index d7e017537..8ae175625 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -8,9 +8,9 @@ pageClass: rule-list
::: tip Legend
-:wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems.
+ :wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems.
-:bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
+ :bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
:::
Mark indicating rule type:
@@ -25,10 +25,10 @@ Rules in this category are enabled for all presets provided by eslint-plugin-vue
-| Rule ID | Description | | |
-| :---------------------------------------------- | :--------------------------------------------------- | :-: | :-------: |
-| [vue/comment-directive](./comment-directive.md) | support comment-directives in `` | | :warning: |
-| [vue/jsx-uses-vars](./jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused | | :warning: |
+| Rule ID | Description | | |
+|:--------|:------------|:--:|:--:|
+| [vue/comment-directive](./comment-directive.md) | support comment-directives in `` | | :warning: |
+| [vue/jsx-uses-vars](./jsx-uses-vars.md) | prevent variables used in JSX to be marked as unused | | :warning: |
@@ -39,95 +39,95 @@ Rules in this category are enabled for all presets provided by eslint-plugin-vue
-| Rule ID | Description | | |
-| :---------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------- | :------------: | :-------------------: |
-| [vue/multi-word-component-names](./multi-word-component-names.md) | require component names to be always multi-word | | :three::two::hammer: |
-| [vue/no-arrow-functions-in-watch](./no-arrow-functions-in-watch.md) | disallow using arrow functions to define watcher | | :three::two::warning: |
-| [vue/no-async-in-computed-properties](./no-async-in-computed-properties.md) | disallow asynchronous actions in computed properties | | :three::two::warning: |
-| [vue/no-child-content](./no-child-content.md) | disallow element's child contents which would be overwritten by a directive like `v-html` or `v-text` | :bulb: | :three::two::warning: |
-| [vue/no-computed-properties-in-data](./no-computed-properties-in-data.md) | disallow accessing computed properties in `data`. | | :three::two::warning: |
-| [vue/no-custom-modifiers-on-v-model](./no-custom-modifiers-on-v-model.md) | disallow custom modifiers on v-model used on the component | | :two::warning: |
-| [vue/no-deprecated-data-object-declaration](./no-deprecated-data-object-declaration.md) | disallow using deprecated object declaration on data (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-destroyed-lifecycle](./no-deprecated-destroyed-lifecycle.md) | disallow using deprecated `destroyed` and `beforeDestroy` lifecycle hooks (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-dollar-listeners-api](./no-deprecated-dollar-listeners-api.md) | disallow using deprecated `$listeners` (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-dollar-scopedslots-api](./no-deprecated-dollar-scopedslots-api.md) | disallow using deprecated `$scopedSlots` (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-events-api](./no-deprecated-events-api.md) | disallow using deprecated events api (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-filter](./no-deprecated-filter.md) | disallow using deprecated filters syntax (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-functional-template](./no-deprecated-functional-template.md) | disallow using deprecated the `functional` template (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-html-element-is](./no-deprecated-html-element-is.md) | disallow using deprecated the `is` attribute on HTML elements (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-inline-template](./no-deprecated-inline-template.md) | disallow using deprecated `inline-template` attribute (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-props-default-this](./no-deprecated-props-default-this.md) | disallow deprecated `this` access in props default function (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-router-link-tag-prop](./no-deprecated-router-link-tag-prop.md) | disallow using deprecated `tag` property on `RouterLink` (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-scope-attribute](./no-deprecated-scope-attribute.md) | disallow deprecated `scope` attribute (in Vue.js 2.5.0+) | :wrench: | :three::hammer: |
-| [vue/no-deprecated-slot-attribute](./no-deprecated-slot-attribute.md) | disallow deprecated `slot` attribute (in Vue.js 2.6.0+) | :wrench: | :three::hammer: |
-| [vue/no-deprecated-slot-scope-attribute](./no-deprecated-slot-scope-attribute.md) | disallow deprecated `slot-scope` attribute (in Vue.js 2.6.0+) | :wrench: | :three::hammer: |
-| [vue/no-deprecated-v-bind-sync](./no-deprecated-v-bind-sync.md) | disallow use of deprecated `.sync` modifier on `v-bind` directive (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-v-is](./no-deprecated-v-is.md) | disallow deprecated `v-is` directive (in Vue.js 3.1.0+) | :wrench: | :three::hammer: |
-| [vue/no-deprecated-v-on-native-modifier](./no-deprecated-v-on-native-modifier.md) | disallow using deprecated `.native` modifiers (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-deprecated-v-on-number-modifiers](./no-deprecated-v-on-number-modifiers.md) | disallow using deprecated number (keycode) modifiers (in Vue.js 3.0.0+) | :wrench: | :three::warning: |
-| [vue/no-deprecated-vue-config-keycodes](./no-deprecated-vue-config-keycodes.md) | disallow using deprecated `Vue.config.keyCodes` (in Vue.js 3.0.0+) | | :three::warning: |
-| [vue/no-dupe-keys](./no-dupe-keys.md) | disallow duplication of field names | | :three::two::warning: |
-| [vue/no-dupe-v-else-if](./no-dupe-v-else-if.md) | disallow duplicate conditions in `v-if` / `v-else-if` chains | | :three::two::warning: |
-| [vue/no-duplicate-attributes](./no-duplicate-attributes.md) | disallow duplication of attributes | | :three::two::warning: |
-| [vue/no-export-in-script-setup](./no-export-in-script-setup.md) | disallow `export` in `
```
+
+
```vue
diff --git a/docs/rules/define-props-declaration.md b/docs/rules/define-props-declaration.md
index 80cc818b3..473d83514 100644
--- a/docs/rules/define-props-declaration.md
+++ b/docs/rules/define-props-declaration.md
@@ -4,11 +4,12 @@ sidebarDepth: 0
title: vue/define-props-declaration
description: enforce declaration style of `defineProps`
---
+
# vue/define-props-declaration
> enforce declaration style of `defineProps`
-- :exclamation: ***This rule has not been released yet.***
+- :exclamation: **_This rule has not been released yet._**
## :book: Rule Details
@@ -16,6 +17,8 @@ This rule enforces `defineProps` typing style which you should use `type-based`
This rule only works in setup script and `lang="ts"`.
+
+
```vue
```
+
+
```vue
From 7ff9dedbecf2ce280a4a96dabddd8e58b76c8a24 Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Thu, 15 Sep 2022 19:07:08 +0800
Subject: [PATCH 13/19] fix lint issues
---
docs/rules/define-emits-declaration.md | 3 +--
docs/rules/define-props-declaration.md | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/docs/rules/define-emits-declaration.md b/docs/rules/define-emits-declaration.md
index 481220d17..1c6e5bb9c 100644
--- a/docs/rules/define-emits-declaration.md
+++ b/docs/rules/define-emits-declaration.md
@@ -4,12 +4,11 @@ sidebarDepth: 0
title: vue/define-emits-declaration
description: enforce declaration style of `defineEmits`
---
-
# vue/define-emits-declaration
> enforce declaration style of `defineEmits`
-- :exclamation: **_This rule has not been released yet._**
+- :exclamation: ***This rule has not been released yet.***
## :book: Rule Details
diff --git a/docs/rules/define-props-declaration.md b/docs/rules/define-props-declaration.md
index 473d83514..2e78a8d68 100644
--- a/docs/rules/define-props-declaration.md
+++ b/docs/rules/define-props-declaration.md
@@ -4,12 +4,11 @@ sidebarDepth: 0
title: vue/define-props-declaration
description: enforce declaration style of `defineProps`
---
-
# vue/define-props-declaration
> enforce declaration style of `defineProps`
-- :exclamation: **_This rule has not been released yet._**
+- :exclamation: ***This rule has not been released yet.***
## :book: Rule Details
From ee7238826bba72c48c9c4a063427a79c1c70e280 Mon Sep 17 00:00:00 2001
From: Amorites <751809522@qq.com>
Date: Thu, 15 Sep 2022 19:15:40 +0800
Subject: [PATCH 14/19] Update docs/rules/define-emits-declaration.md
Co-authored-by: Flo Edelmann
---
docs/rules/define-emits-declaration.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/rules/define-emits-declaration.md b/docs/rules/define-emits-declaration.md
index 1c6e5bb9c..22a53f34a 100644
--- a/docs/rules/define-emits-declaration.md
+++ b/docs/rules/define-emits-declaration.md
@@ -16,7 +16,7 @@ This rule enforces `defineEmits` typing style which you should use `type-based`
This rule only works in setup script and `lang="ts"`.
-
+
```vue
-```
-
-
-
-
-```vue
-
@@ -50,6 +42,25 @@ const emit = defineEmits(['change', 'update'])
"vue/define-emits-declaration": ["error", "type-based" | "runtime"]
```
+### `runtime`
+
+
+
+```vue
+
+```
+
+
+
## :couple: Related Rules
- [vue/define-props-declaration](./define-props-declaration.md)
diff --git a/docs/rules/define-props-declaration.md b/docs/rules/define-props-declaration.md
index 9147c6486..22ae7c14b 100644
--- a/docs/rules/define-props-declaration.md
+++ b/docs/rules/define-props-declaration.md
@@ -24,15 +24,7 @@ This rule only works in setup script and `lang="ts"`.
const props = defineProps<{
kind: string
}>()
-
-```
-
-
-
-
-```vue
-
+```
+
+
+
```json
"vue/define-props-declaration": ["error", "type-based" | "runtime"]
```
From 169ca72a172aa3ed1c3c859e61b7599e30a9fbcd Mon Sep 17 00:00:00 2001
From: Flo Edelmann
Date: Thu, 15 Sep 2022 15:28:05 +0200
Subject: [PATCH 19/19] Fix order in docs
---
docs/rules/define-emits-declaration.md | 6 +++---
docs/rules/define-props-declaration.md | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/docs/rules/define-emits-declaration.md b/docs/rules/define-emits-declaration.md
index 1c945ca12..50af9f951 100644
--- a/docs/rules/define-emits-declaration.md
+++ b/docs/rules/define-emits-declaration.md
@@ -35,13 +35,13 @@ const emit = defineEmits(['change', 'update'])
## :wrench: Options
-- `type-based` (default) enforces type-based declaration
-- `runtime` enforces runtime declaration
-
```json
"vue/define-emits-declaration": ["error", "type-based" | "runtime"]
```
+- `type-based` (default) enforces type-based declaration
+- `runtime` enforces runtime declaration
+
### `runtime`
diff --git a/docs/rules/define-props-declaration.md b/docs/rules/define-props-declaration.md
index 22ae7c14b..db68791fb 100644
--- a/docs/rules/define-props-declaration.md
+++ b/docs/rules/define-props-declaration.md
@@ -36,6 +36,10 @@ const props = defineProps({
## :wrench: Options
+```json
+ "vue/define-props-declaration": ["error", "type-based" | "runtime"]
+```
+
- `type-based` (default) enforces type-based declaration
- `runtime` enforces runtime declaration
@@ -58,10 +62,6 @@ const emit = defineEmits(['change', 'update'])
-```json
- "vue/define-props-declaration": ["error", "type-based" | "runtime"]
-```
-
## :couple: Related Rules
- [vue/define-emits-declaration](./define-emits-declaration.md)