diff --git a/docs/rules/define-props-declaration.md b/docs/rules/define-props-declaration.md index db23e13d2..51a2864e7 100644 --- a/docs/rules/define-props-declaration.md +++ b/docs/rules/define-props-declaration.md @@ -43,17 +43,13 @@ const props = defineProps({ ```json { "vue/define-props-declaration": ["error", - "type-based" | "runtime", - { - "autoFixToSeparateInterface": false - } + "type-based" | "runtime" ] } ``` - `type-based` (default) enforces type-based declaration - `runtime` enforces runtime declaration -- `autoFixToSeparateInterface` (`boolean`) define `interface Props` used for type-based declaration instead of providing types inline ### `"runtime"` diff --git a/lib/rules/define-props-declaration.js b/lib/rules/define-props-declaration.js index db4b0a1a2..22e4f751b 100644 --- a/lib/rules/define-props-declaration.js +++ b/lib/rules/define-props-declaration.js @@ -6,6 +6,10 @@ const utils = require('../utils') +/** + * @typedef {import('../utils').ComponentProp} ComponentProp + */ + const PROPS_SEPARATOR = ', ' /** @@ -53,8 +57,11 @@ function* fixTypeBased(fixer, node, props, context) { } return null } -const mapNativeType = (/** @type {string} */ nativeType) => { - switch (nativeType) { + /** + * @param {string} nativeType + * @returns {string} + */ +const mapNativeType = (nativeType) => {switch (nativeType) { case 'String': { return 'string' } @@ -125,7 +132,6 @@ function optionGetType(node, sourceCode) { case 'ArrayExpression': { return node.elements .map((element) => { - // TODO handle SpreadElement if (element === null || element.type === 'SpreadElement') { return sourceCode.getText(node) } @@ -175,7 +181,7 @@ function optionGetType(node, sourceCode) { /** * @param {Expression} node - * @returns {boolean | undefined } + * @returns {boolean} */ function optionGetRequired(node) { if (node.type === 'ObjectExpression') { @@ -195,7 +201,7 @@ function optionGetRequired(node) { /** * @param {Expression} node - * @returns {Expression | undefined } + * @returns {Expression | undefined} */ function optionGetDefault(node) { if (node.type === 'ObjectExpression') { @@ -211,10 +217,6 @@ function optionGetDefault(node) { return undefined } -/** - * @typedef {import('../utils').ComponentProp} ComponentProp - */ - module.exports = { meta: { type: 'suggestion',