From 641a48344aafe30921e06e054d81412ab612c57f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Wed, 28 Sep 2022 14:18:27 +0800
Subject: [PATCH 01/22] require-prop-comment
---
docs/rules/README.md | 1 +
docs/rules/require-prop-comment.md | 68 ++++++++
lib/index.js | 1 +
lib/rules/require-prop-comment.js | 92 +++++++++++
tests/lib/rules/require-prop-comment.js | 200 ++++++++++++++++++++++++
5 files changed, 362 insertions(+)
create mode 100644 docs/rules/require-prop-comment.md
create mode 100644 lib/rules/require-prop-comment.js
create mode 100644 tests/lib/rules/require-prop-comment.js
diff --git a/docs/rules/README.md b/docs/rules/README.md
index 780b10cbe..b35c2b8ff 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -260,6 +260,7 @@ For example:
| [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: |
| [vue/require-name-property](./require-name-property.md) | require a name property in Vue components | | :hammer: |
+| [vue/require-prop-comment](./require-prop-comment.md) | require prop should have a comment | | :warning: |
| [vue/script-indent](./script-indent.md) | enforce consistent indentation in `
+```
+
+
+
+
+
+```vue
+
+
+ 1
+
+
+```
+
+
+
+## :wrench: Options
+
+Nothing.
+
+## :mag: Implementation
+
+- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/require-prop-comment.js)
+- [Test source](https://github.com/vuejs/eslint-plugin-vue/blob/master/tests/lib/rules/require-prop-comment.js)
diff --git a/lib/index.js b/lib/index.js
index e7dcd5bec..7578f7740 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -175,6 +175,7 @@ module.exports = {
'require-explicit-emits': require('./rules/require-explicit-emits'),
'require-expose': require('./rules/require-expose'),
'require-name-property': require('./rules/require-name-property'),
+ 'require-prop-comment': require('./rules/require-prop-comment'),
'require-prop-type-constructor': require('./rules/require-prop-type-constructor'),
'require-prop-types': require('./rules/require-prop-types'),
'require-render-return': require('./rules/require-render-return'),
diff --git a/lib/rules/require-prop-comment.js b/lib/rules/require-prop-comment.js
new file mode 100644
index 000000000..cfb5b3cdb
--- /dev/null
+++ b/lib/rules/require-prop-comment.js
@@ -0,0 +1,92 @@
+/**
+ * @author *****your name*****
+ * See LICENSE file in root directory for full license.
+ */
+'use strict'
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+const utils = require('../utils')
+
+// ------------------------------------------------------------------------------
+// Helpers
+// ------------------------------------------------------------------------------
+
+// ...
+
+// ------------------------------------------------------------------------------
+// Rule Definition
+// ------------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ type: 'problem',
+ docs: {
+ description: 'require prop should have a comment',
+ categories: undefined,
+ url: 'https://eslint.vuejs.org/rules/require-prop-comment.html'
+ },
+ fixable: null,
+ schema: [],
+ messages: {
+ // ...
+ }
+ },
+ /** @param {RuleContext} context */
+ create(context) {
+ const sourceCode = context.getSourceCode()
+
+ /**
+ * @param {import('../utils').ComponentProp[]} props
+ */
+ function verifyProps(props) {
+ for (const prop of props) {
+ if (!prop.propName) {
+ continue
+ }
+ const beforeComments = sourceCode.getCommentsBefore(prop.node)
+
+ if (beforeComments.length > 0) continue
+ context.report({
+ node: prop.node,
+ message: 'The "{{name}}" property should have a comment.',
+ data: {
+ name: prop.propName
+ }
+ })
+ }
+ }
+ // 合成选择器
+ return utils.compositingVisitors(
+ // 遍历
+ `
+ },
+ {
+ code: `
+
+ 1
+
+
+ `
+ },
+ {
+ code: `
+ import { defineComponent } from '@vue/composition-api'
+ export const ComponentName = defineComponent({
+ props: {
+ /**
+ * a comment
+ */
+ a: Number
+ },
+ render() {
+ return
1
+ }
+ })
+ `
+ }
+ ],
+ invalid: [
+ {
+ code: `
+
+ 1
+
+
+ `,
+ errors: [
+ {
+ line: 10
+ }
+ ]
+ },
+ {
+ code: `
+
+ 1
+
+
+ `,
+ errors: [
+ {
+ line: 14
+ }
+ ]
+ },
+ {
+ code: `
+
+ 1
+
+
+ `,
+ errors: [
+ {
+ line: 7
+ }
+ ]
+ },
+ {
+ code: `
+
+ 1
+
+
+ `,
+ errors: [
+ {
+ line: 7
+ }
+ ]
+ },
+ {
+ code: `
+ import { defineComponent } from '@vue/composition-api'
+ export const ComponentName = defineComponent({
+ props: {
+ a: Number
+ },
+ render() {
+ return 1
+ }
+ })
+ `,
+ errors: [
+ {
+ line: 5
+ }
+ ]
+ },
+ {
+ code: `
+ import Vue from 'vue'
+ new Vue({
+ props: {
+ a: Number
+ }
+ })
+ `,
+ errors: [
+ {
+ line: 5
+ }
+ ]
+ }
+ ]
+})
From 3e8d0e1e16c5d14d72af31ce4b27e90459647e33 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Wed, 19 Oct 2022 16:26:10 +0800
Subject: [PATCH 02/22] add type arg
---
docs/rules/README.md | 2 +-
docs/rules/require-prop-comment.md | 121 +++++++++++++++++++++++-
lib/rules/require-prop-comment.js | 77 ++++++++++-----
tests/lib/rules/require-prop-comment.js | 95 +++++++++++--------
4 files changed, 225 insertions(+), 70 deletions(-)
diff --git a/docs/rules/README.md b/docs/rules/README.md
index b35c2b8ff..269e9c1fa 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -260,7 +260,7 @@ For example:
| [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: |
| [vue/require-name-property](./require-name-property.md) | require a name property in Vue components | | :hammer: |
-| [vue/require-prop-comment](./require-prop-comment.md) | require prop should have a comment | | :warning: |
+| [vue/require-prop-comment](./require-prop-comment.md) | require that props have a comment | | :warning: |
| [vue/script-indent](./script-indent.md) | enforce consistent indentation in `
```
@@ -60,7 +60,118 @@ const props = defineProps({
## :wrench: Options
-Nothing.
+```json
+{
+ "vue/require-prop-comment": ["error", {
+ "type": "block"
+ }]
+}
+```
+- `type` ... Type of comment.Default is `"block"`
+ - `"line"` ... Only line comment are allowed,one or more.
+ - `"block"` ... Only block comment are allowed,one is allowed.
+ - `"unlimited"` ... There is no limit to the number and type.
+
+### `"type":"block"`
+
+
+
+
+
+
+
+
+
+
+
+
+
+### `"type":"line"`
+
+
+
+
+
+
+
+
+
+
+
+
+
+### `"type":"unlimited"`
+
+
+
+
+
+
+
+
+
+
+
+
## :mag: Implementation
diff --git a/lib/rules/require-prop-comment.js b/lib/rules/require-prop-comment.js
index cfb5b3cdb..8c5c32568 100644
--- a/lib/rules/require-prop-comment.js
+++ b/lib/rules/require-prop-comment.js
@@ -24,69 +24,96 @@ module.exports = {
meta: {
type: 'problem',
docs: {
- description: 'require prop should have a comment',
+ description: 'require that props have a comment',
categories: undefined,
url: 'https://eslint.vuejs.org/rules/require-prop-comment.html'
},
fixable: null,
- schema: [],
+ schema: [
+ {
+ type: 'object',
+ properties: {
+ type: { enum: ['line', 'block', 'unlimited'] }
+ },
+ additionalProperties: false
+ }
+ ],
messages: {
// ...
}
},
/** @param {RuleContext} context */
create(context) {
+ /** @type {{type: "line" | "block" | "unlimited"}|undefined} */
+ const schema = context.options[0]
+
+ /** @type {"line" | "block" | "unlimited"} */
+ const type = schema ? schema.type : 'block'
+
const sourceCode = context.getSourceCode()
+ /** @type {{(comments:Comment[]):string}} */
+ const verifyBlock = (comments) => {
+ if (comments.length === 1 && comments[0].type === 'Block') return ''
+ return 'The "{{name}}" property should have one block comment.'
+ }
+ /** @type {{(comments:Comment[]):string}} */
+ const verifyLine = (comments) => {
+ if (comments.length > 0 && comments.every((c) => c.type === 'Line')) {
+ return ''
+ }
+ return 'The "{{name}}" property should have a line comment.'
+ }
+ /** @type {{(comments:Comment[]):string}} */
+ const verifyUnlimited = (comments) => {
+ if (comments.length > 0) return ''
+ return 'The "{{name}}" property should have a comment.'
+ }
+
/**
* @param {import('../utils').ComponentProp[]} props
*/
function verifyProps(props) {
for (const prop of props) {
- if (!prop.propName) {
- continue
- }
+ if (!prop.propName) continue
+
const beforeComments = sourceCode.getCommentsBefore(prop.node)
+ let message = ''
+ switch (type) {
+ case 'block':
+ message = verifyBlock(beforeComments)
+ break
+ case 'line':
+ message = verifyLine(beforeComments)
+ break
+ case 'unlimited':
+ message = verifyUnlimited(beforeComments)
+ break
+ default:
+ break
+ }
- if (beforeComments.length > 0) continue
+ if (!message) continue
context.report({
node: prop.node,
- message: 'The "{{name}}" property should have a comment.',
+ message,
data: {
name: prop.propName
}
})
}
}
- // 合成选择器
return utils.compositingVisitors(
- // 遍历
@@ -54,7 +49,24 @@ tester.run('require-prop-comment', rule, {
a: Number
})
- `
+ `,
+ options: [{ type: 'block' }]
+ },
+ {
+ code: `
+ import { defineComponent } from '@vue/composition-api'
+ export const ComponentName = defineComponent({
+ props: {
+ // a comment
+ // a other comment
+ a: Number
+ },
+ render() {
+ return 1
+ }
+ })
+ `,
+ options: [{ type: 'line' }]
},
{
code: `
@@ -64,13 +76,16 @@ tester.run('require-prop-comment', rule, {
/**
* a comment
*/
- a: Number
+ a: Number,
+ // a comment
+ b: Number
},
render() {
return 1
}
})
- `
+ `,
+ options: [{ type: 'unlimited' }]
}
],
invalid: [
@@ -85,18 +100,25 @@ tester.run('require-prop-comment', rule, {
export default defineComponent({
props: {
a: Number,
- // b comment
+ /**
+ * b comment
+ */
+ /**
+ * b other comment
+ */
b: Number,
- // c
- // comment
- c: Number
}
})
`,
errors: [
{
- line: 10
+ line: 10,
+ message: 'The "a" property should have one block comment.'
+ },
+ {
+ line: 17,
+ message: 'The "b" property should have one block comment.'
}
]
},
@@ -115,17 +137,20 @@ tester.run('require-prop-comment', rule, {
*/
a: Number,
b: Number,
- // c
- // comment
- c: Number
},
setup() {}
})
`,
+ options: [{ type: 'line' }],
errors: [
{
- line: 14
+ line: 12,
+ message: 'The "a" property should have a line comment.'
+ },
+ {
+ line: 13,
+ message: 'The "b" property should have a line comment.'
}
]
},
@@ -136,13 +161,21 @@ tester.run('require-prop-comment', rule, {
`,
+ options: [{ type: 'unlimited' }],
errors: [
{
- line: 7
+ line: 7,
+ message: `The "a" property should have a comment.`
}
]
},
@@ -159,25 +192,8 @@ tester.run('require-prop-comment', rule, {
`,
errors: [
{
- line: 7
- }
- ]
- },
- {
- code: `
- import { defineComponent } from '@vue/composition-api'
- export const ComponentName = defineComponent({
- props: {
- a: Number
- },
- render() {
- return 1
- }
- })
- `,
- errors: [
- {
- line: 5
+ line: 7,
+ message: 'The "a" property should have one block comment.'
}
]
},
@@ -192,7 +208,8 @@ tester.run('require-prop-comment', rule, {
`,
errors: [
{
- line: 5
+ line: 5,
+ message: 'The "a" property should have one block comment.'
}
]
}
From f271f4816e95056a8fed6b8a27906bee191355c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Thu, 20 Oct 2022 10:11:21 +0800
Subject: [PATCH 03/22] add jsdoc type
---
docs/rules/require-prop-comment.md | 9 ++--
lib/rules/require-prop-comment.js | 19 +++++--
tests/lib/rules/require-prop-comment.js | 68 +++++++++++++++++++++----
3 files changed, 77 insertions(+), 19 deletions(-)
diff --git a/docs/rules/require-prop-comment.md b/docs/rules/require-prop-comment.md
index 6d481bf13..4dd30ddc4 100644
--- a/docs/rules/require-prop-comment.md
+++ b/docs/rules/require-prop-comment.md
@@ -67,7 +67,8 @@ const props = defineProps({
}]
}
```
-- `type` ... Type of comment.Default is `"block"`
+- `type` ... Type of comment.Default is `"JSDoc"`
+ - `"JSDoc"` ... Only JSDoc comment are allowed,one is allowed.
- `"line"` ... Only line comment are allowed,one or more.
- `"block"` ... Only block comment are allowed,one is allowed.
- `"unlimited"` ... There is no limit to the number and type.
@@ -78,7 +79,7 @@ const props = defineProps({
`,
@@ -60,9 +64,6 @@ tester.run('require-prop-comment', rule, {
// a comment
// a other comment
a: Number
- },
- render() {
- return 1
}
})
`,
@@ -79,9 +80,6 @@ tester.run('require-prop-comment', rule, {
a: Number,
// a comment
b: Number
- },
- render() {
- return 1
}
})
`,
@@ -107,10 +105,54 @@ tester.run('require-prop-comment', rule, {
* b other comment
*/
b: Number,
+ /*
+ * c comment
+ */
+ c: Number
}
})
`,
+ errors: [
+ {
+ line: 10,
+ message: 'The "a" property should have one JSDoc comment.'
+ },
+ {
+ line: 17,
+ message: 'The "b" property should have one JSDoc comment.'
+ },
+ {
+ line: 21,
+ message: 'The "c" property should have one JSDoc comment.'
+ }
+ ]
+ },
+ {
+ code: `
+
+ 1
+
+
+ `,
+ options: [{ type: 'block' }],
errors: [
{
line: 10,
@@ -119,6 +161,10 @@ tester.run('require-prop-comment', rule, {
{
line: 17,
message: 'The "b" property should have one block comment.'
+ },
+ {
+ line: 19,
+ message: 'The "c" property should have one block comment.'
}
]
},
@@ -193,7 +239,7 @@ tester.run('require-prop-comment', rule, {
errors: [
{
line: 7,
- message: 'The "a" property should have one block comment.'
+ message: 'The "a" property should have one JSDoc comment.'
}
]
},
@@ -209,7 +255,7 @@ tester.run('require-prop-comment', rule, {
errors: [
{
line: 5,
- message: 'The "a" property should have one block comment.'
+ message: 'The "a" property should have one JSDoc comment.'
}
]
}
From 07ea38a04e06a2456a12195ef1e5609bab3ad02a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Thu, 20 Oct 2022 14:37:33 +0800
Subject: [PATCH 04/22] edit rule
---
tests/lib/rules/require-prop-comment.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/lib/rules/require-prop-comment.js b/tests/lib/rules/require-prop-comment.js
index a729669dc..ce8f036db 100644
--- a/tests/lib/rules/require-prop-comment.js
+++ b/tests/lib/rules/require-prop-comment.js
@@ -191,11 +191,11 @@ tester.run('require-prop-comment', rule, {
options: [{ type: 'line' }],
errors: [
{
- line: 12,
+ line: 13,
message: 'The "a" property should have a line comment.'
},
{
- line: 13,
+ line: 14,
message: 'The "b" property should have a line comment.'
}
]
From 3ec9ba0ec42ef2a2d8302f60325da8682e6d7d36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Thu, 20 Oct 2022 14:46:12 +0800
Subject: [PATCH 05/22] =?UTF-8?q?npm=20run=20update=E8=BF=90=E8=A1=8C?=
=?UTF-8?q?=E7=BB=93=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/rules/README.md | 68 +++++++++++++--------------
docs/rules/array-bracket-newline.md | 4 +-
docs/rules/array-bracket-spacing.md | 4 +-
docs/rules/arrow-spacing.md | 4 +-
docs/rules/block-spacing.md | 4 +-
docs/rules/brace-style.md | 4 +-
docs/rules/camelcase.md | 4 +-
docs/rules/comma-dangle.md | 4 +-
docs/rules/comma-spacing.md | 4 +-
docs/rules/comma-style.md | 4 +-
docs/rules/dot-location.md | 4 +-
docs/rules/dot-notation.md | 4 +-
docs/rules/eqeqeq.md | 4 +-
docs/rules/func-call-spacing.md | 4 +-
docs/rules/key-spacing.md | 4 +-
docs/rules/keyword-spacing.md | 4 +-
docs/rules/multiline-ternary.md | 4 +-
docs/rules/no-constant-condition.md | 4 +-
docs/rules/no-empty-pattern.md | 4 +-
docs/rules/no-extra-parens.md | 4 +-
docs/rules/no-loss-of-precision.md | 4 +-
docs/rules/no-restricted-syntax.md | 4 +-
docs/rules/no-sparse-arrays.md | 4 +-
docs/rules/no-useless-concat.md | 4 +-
docs/rules/object-curly-newline.md | 4 +-
docs/rules/object-curly-spacing.md | 4 +-
docs/rules/object-property-newline.md | 4 +-
docs/rules/object-shorthand.md | 4 +-
docs/rules/operator-linebreak.md | 4 +-
docs/rules/prefer-template.md | 4 +-
docs/rules/quote-props.md | 4 +-
docs/rules/space-in-parens.md | 4 +-
docs/rules/space-infix-ops.md | 4 +-
docs/rules/space-unary-ops.md | 4 +-
docs/rules/template-curly-spacing.md | 4 +-
35 files changed, 102 insertions(+), 102 deletions(-)
diff --git a/docs/rules/README.md b/docs/rules/README.md
index 6ebf47c9e..5f11c9370 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -277,42 +277,42 @@ The following rules extend the rules provided by ESLint itself and apply them to
| Rule ID | Description | | |
|:--------|:------------|:--:|:--:|
-| [vue/array-bracket-newline](./array-bracket-newline.md) | enforce linebreaks after opening and before closing array brackets in `` | :wrench: | :lipstick: |
-| [vue/array-bracket-spacing](./array-bracket-spacing.md) | enforce consistent spacing inside array brackets in `` | :wrench: | :lipstick: |
-| [vue/arrow-spacing](./arrow-spacing.md) | enforce consistent spacing before and after the arrow in arrow functions in `` | :wrench: | :lipstick: |
-| [vue/block-spacing](./block-spacing.md) | disallow or enforce spaces inside of blocks after opening block and before closing block in `` | :wrench: | :lipstick: |
-| [vue/brace-style](./brace-style.md) | enforce consistent brace style for blocks in `` | :wrench: | :lipstick: |
-| [vue/camelcase](./camelcase.md) | enforce camelcase naming convention in `` | | :hammer: |
-| [vue/comma-dangle](./comma-dangle.md) | require or disallow trailing commas in `` | :wrench: | :lipstick: |
-| [vue/comma-spacing](./comma-spacing.md) | enforce consistent spacing before and after commas in `` | :wrench: | :lipstick: |
-| [vue/comma-style](./comma-style.md) | enforce consistent comma style in `` | :wrench: | :lipstick: |
-| [vue/dot-location](./dot-location.md) | enforce consistent newlines before and after dots in `` | :wrench: | :lipstick: |
-| [vue/dot-notation](./dot-notation.md) | enforce dot notation whenever possible in `` | :wrench: | :hammer: |
-| [vue/eqeqeq](./eqeqeq.md) | require the use of `===` and `!==` in `` | :wrench: | :hammer: |
-| [vue/func-call-spacing](./func-call-spacing.md) | require or disallow spacing between function identifiers and their invocations in `` | :wrench: | :lipstick: |
-| [vue/key-spacing](./key-spacing.md) | enforce consistent spacing between keys and values in object literal properties in `` | :wrench: | :lipstick: |
-| [vue/keyword-spacing](./keyword-spacing.md) | enforce consistent spacing before and after keywords in `` | :wrench: | :lipstick: |
+| [vue/array-bracket-newline](./array-bracket-newline.md) | Enforce linebreaks after opening and before closing array brackets in `` | :wrench: | :lipstick: |
+| [vue/array-bracket-spacing](./array-bracket-spacing.md) | Enforce consistent spacing inside array brackets in `` | :wrench: | :lipstick: |
+| [vue/arrow-spacing](./arrow-spacing.md) | Enforce consistent spacing before and after the arrow in arrow functions in `` | :wrench: | :lipstick: |
+| [vue/block-spacing](./block-spacing.md) | Disallow or enforce spaces inside of blocks after opening block and before closing block in `` | :wrench: | :lipstick: |
+| [vue/brace-style](./brace-style.md) | Enforce consistent brace style for blocks in `` | :wrench: | :lipstick: |
+| [vue/camelcase](./camelcase.md) | Enforce camelcase naming convention in `` | | :hammer: |
+| [vue/comma-dangle](./comma-dangle.md) | Require or disallow trailing commas in `` | :wrench: | :lipstick: |
+| [vue/comma-spacing](./comma-spacing.md) | Enforce consistent spacing before and after commas in `` | :wrench: | :lipstick: |
+| [vue/comma-style](./comma-style.md) | Enforce consistent comma style in `` | :wrench: | :lipstick: |
+| [vue/dot-location](./dot-location.md) | Enforce consistent newlines before and after dots in `` | :wrench: | :lipstick: |
+| [vue/dot-notation](./dot-notation.md) | Enforce dot notation whenever possible in `` | :wrench: | :hammer: |
+| [vue/eqeqeq](./eqeqeq.md) | Require the use of `===` and `!==` in `` | :wrench: | :hammer: |
+| [vue/func-call-spacing](./func-call-spacing.md) | Require or disallow spacing between function identifiers and their invocations in `` | :wrench: | :lipstick: |
+| [vue/key-spacing](./key-spacing.md) | Enforce consistent spacing between keys and values in object literal properties in `` | :wrench: | :lipstick: |
+| [vue/keyword-spacing](./keyword-spacing.md) | Enforce consistent spacing before and after keywords in `` | :wrench: | :lipstick: |
| [vue/max-len](./max-len.md) | enforce a maximum line length in `.vue` files | | :lipstick: |
-| [vue/multiline-ternary](./multiline-ternary.md) | enforce newlines between operands of ternary expressions in `` | :wrench: | :lipstick: |
-| [vue/no-constant-condition](./no-constant-condition.md) | disallow constant expressions in conditions in `` | | :warning: |
-| [vue/no-empty-pattern](./no-empty-pattern.md) | disallow empty destructuring patterns in `` | | :warning: |
-| [vue/no-extra-parens](./no-extra-parens.md) | disallow unnecessary parentheses in `` | :wrench: | :lipstick: |
+| [vue/multiline-ternary](./multiline-ternary.md) | Enforce newlines between operands of ternary expressions in `` | :wrench: | :lipstick: |
+| [vue/no-constant-condition](./no-constant-condition.md) | Disallow constant expressions in conditions in `` | | :warning: |
+| [vue/no-empty-pattern](./no-empty-pattern.md) | Disallow empty destructuring patterns in `` | | :warning: |
+| [vue/no-extra-parens](./no-extra-parens.md) | Disallow unnecessary parentheses in `` | :wrench: | :lipstick: |
| [vue/no-irregular-whitespace](./no-irregular-whitespace.md) | disallow irregular whitespace in `.vue` files | | :warning: |
-| [vue/no-loss-of-precision](./no-loss-of-precision.md) | disallow literal numbers that lose precision in `` | | :warning: |
-| [vue/no-restricted-syntax](./no-restricted-syntax.md) | disallow specified syntax in `` | | :hammer: |
-| [vue/no-sparse-arrays](./no-sparse-arrays.md) | disallow sparse arrays in `` | | :warning: |
-| [vue/no-useless-concat](./no-useless-concat.md) | disallow unnecessary concatenation of literals or template literals in `` | | :hammer: |
-| [vue/object-curly-newline](./object-curly-newline.md) | enforce consistent line breaks after opening and before closing braces in `` | :wrench: | :lipstick: |
-| [vue/object-curly-spacing](./object-curly-spacing.md) | enforce consistent spacing inside braces in `` | :wrench: | :lipstick: |
-| [vue/object-property-newline](./object-property-newline.md) | enforce placing object properties on separate lines in `` | :wrench: | :lipstick: |
-| [vue/object-shorthand](./object-shorthand.md) | require or disallow method and property shorthand syntax for object literals in `` | :wrench: | :hammer: |
-| [vue/operator-linebreak](./operator-linebreak.md) | enforce consistent linebreak style for operators in `` | :wrench: | :lipstick: |
-| [vue/prefer-template](./prefer-template.md) | require template literals instead of string concatenation in `` | :wrench: | :hammer: |
-| [vue/quote-props](./quote-props.md) | require quotes around object literal property names in `` | :wrench: | :hammer: |
-| [vue/space-in-parens](./space-in-parens.md) | enforce consistent spacing inside parentheses in `` | :wrench: | :lipstick: |
-| [vue/space-infix-ops](./space-infix-ops.md) | require spacing around infix operators in `` | :wrench: | :lipstick: |
-| [vue/space-unary-ops](./space-unary-ops.md) | enforce consistent spacing before or after unary operators in `` | :wrench: | :lipstick: |
-| [vue/template-curly-spacing](./template-curly-spacing.md) | require or disallow spacing around embedded expressions of template strings in `` | :wrench: | :lipstick: |
+| [vue/no-loss-of-precision](./no-loss-of-precision.md) | Disallow literal numbers that lose precision in `` | | :warning: |
+| [vue/no-restricted-syntax](./no-restricted-syntax.md) | Disallow specified syntax in `` | | :hammer: |
+| [vue/no-sparse-arrays](./no-sparse-arrays.md) | Disallow sparse arrays in `` | | :warning: |
+| [vue/no-useless-concat](./no-useless-concat.md) | Disallow unnecessary concatenation of literals or template literals in `` | | :hammer: |
+| [vue/object-curly-newline](./object-curly-newline.md) | Enforce consistent line breaks after opening and before closing braces in `` | :wrench: | :lipstick: |
+| [vue/object-curly-spacing](./object-curly-spacing.md) | Enforce consistent spacing inside braces in `` | :wrench: | :lipstick: |
+| [vue/object-property-newline](./object-property-newline.md) | Enforce placing object properties on separate lines in `` | :wrench: | :lipstick: |
+| [vue/object-shorthand](./object-shorthand.md) | Require or disallow method and property shorthand syntax for object literals in `` | :wrench: | :hammer: |
+| [vue/operator-linebreak](./operator-linebreak.md) | Enforce consistent linebreak style for operators in `` | :wrench: | :lipstick: |
+| [vue/prefer-template](./prefer-template.md) | Require template literals instead of string concatenation in `` | :wrench: | :hammer: |
+| [vue/quote-props](./quote-props.md) | Require quotes around object literal property names in `` | :wrench: | :hammer: |
+| [vue/space-in-parens](./space-in-parens.md) | Enforce consistent spacing inside parentheses in `` | :wrench: | :lipstick: |
+| [vue/space-infix-ops](./space-infix-ops.md) | Require spacing around infix operators in `` | :wrench: | :lipstick: |
+| [vue/space-unary-ops](./space-unary-ops.md) | Enforce consistent spacing before or after unary operators in `` | :wrench: | :lipstick: |
+| [vue/template-curly-spacing](./template-curly-spacing.md) | Require or disallow spacing around embedded expressions of template strings in `` | :wrench: | :lipstick: |
diff --git a/docs/rules/array-bracket-newline.md b/docs/rules/array-bracket-newline.md
index 8f1184c47..8b5e9bee2 100644
--- a/docs/rules/array-bracket-newline.md
+++ b/docs/rules/array-bracket-newline.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/array-bracket-newline
-description: enforce linebreaks after opening and before closing array brackets in ``
+description: Enforce linebreaks after opening and before closing array brackets in ``
since: v7.1.0
---
# vue/array-bracket-newline
-> enforce linebreaks after opening and before closing array brackets in ``
+> Enforce linebreaks after opening and before closing array brackets in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/array-bracket-spacing.md b/docs/rules/array-bracket-spacing.md
index 6b5b4003a..d3c937651 100644
--- a/docs/rules/array-bracket-spacing.md
+++ b/docs/rules/array-bracket-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/array-bracket-spacing
-description: enforce consistent spacing inside array brackets in ``
+description: Enforce consistent spacing inside array brackets in ``
since: v5.2.0
---
# vue/array-bracket-spacing
-> enforce consistent spacing inside array brackets in ``
+> Enforce consistent spacing inside array brackets in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/arrow-spacing.md b/docs/rules/arrow-spacing.md
index adfeb2243..07e30e63f 100644
--- a/docs/rules/arrow-spacing.md
+++ b/docs/rules/arrow-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/arrow-spacing
-description: enforce consistent spacing before and after the arrow in arrow functions in ``
+description: Enforce consistent spacing before and after the arrow in arrow functions in ``
since: v5.2.0
---
# vue/arrow-spacing
-> enforce consistent spacing before and after the arrow in arrow functions in ``
+> Enforce consistent spacing before and after the arrow in arrow functions in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/block-spacing.md b/docs/rules/block-spacing.md
index 58280370c..a486c76c0 100644
--- a/docs/rules/block-spacing.md
+++ b/docs/rules/block-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/block-spacing
-description: disallow or enforce spaces inside of blocks after opening block and before closing block in ``
+description: Disallow or enforce spaces inside of blocks after opening block and before closing block in ``
since: v5.2.0
---
# vue/block-spacing
-> disallow or enforce spaces inside of blocks after opening block and before closing block in ``
+> Disallow or enforce spaces inside of blocks after opening block and before closing block in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/brace-style.md b/docs/rules/brace-style.md
index 8f889724a..ac917267d 100644
--- a/docs/rules/brace-style.md
+++ b/docs/rules/brace-style.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/brace-style
-description: enforce consistent brace style for blocks in ``
+description: Enforce consistent brace style for blocks in ``
since: v5.2.0
---
# vue/brace-style
-> enforce consistent brace style for blocks in ``
+> Enforce consistent brace style for blocks in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/camelcase.md b/docs/rules/camelcase.md
index 5b7888251..62c5891fa 100644
--- a/docs/rules/camelcase.md
+++ b/docs/rules/camelcase.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/camelcase
-description: enforce camelcase naming convention in ``
+description: Enforce camelcase naming convention in ``
since: v5.2.0
---
# vue/camelcase
-> enforce camelcase naming convention in ``
+> Enforce camelcase naming convention in ``
This rule is the same rule as core [camelcase] rule but it applies to the expressions in ``.
diff --git a/docs/rules/comma-dangle.md b/docs/rules/comma-dangle.md
index 63d4a2a4e..565cbef7b 100644
--- a/docs/rules/comma-dangle.md
+++ b/docs/rules/comma-dangle.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/comma-dangle
-description: require or disallow trailing commas in ``
+description: Require or disallow trailing commas in ``
since: v5.2.0
---
# vue/comma-dangle
-> require or disallow trailing commas in ``
+> Require or disallow trailing commas in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/comma-spacing.md b/docs/rules/comma-spacing.md
index c25c0608c..e318fb65c 100644
--- a/docs/rules/comma-spacing.md
+++ b/docs/rules/comma-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/comma-spacing
-description: enforce consistent spacing before and after commas in ``
+description: Enforce consistent spacing before and after commas in ``
since: v7.0.0
---
# vue/comma-spacing
-> enforce consistent spacing before and after commas in ``
+> Enforce consistent spacing before and after commas in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/comma-style.md b/docs/rules/comma-style.md
index 477c12abd..17c5dd25c 100644
--- a/docs/rules/comma-style.md
+++ b/docs/rules/comma-style.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/comma-style
-description: enforce consistent comma style in ``
+description: Enforce consistent comma style in ``
since: v7.0.0
---
# vue/comma-style
-> enforce consistent comma style in ``
+> Enforce consistent comma style in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/dot-location.md b/docs/rules/dot-location.md
index 4b88f9cf6..fa58a26af 100644
--- a/docs/rules/dot-location.md
+++ b/docs/rules/dot-location.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/dot-location
-description: enforce consistent newlines before and after dots in ``
+description: Enforce consistent newlines before and after dots in ``
since: v6.0.0
---
# vue/dot-location
-> enforce consistent newlines before and after dots in ``
+> Enforce consistent newlines before and after dots in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/dot-notation.md b/docs/rules/dot-notation.md
index c2bf87478..6e8264c2f 100644
--- a/docs/rules/dot-notation.md
+++ b/docs/rules/dot-notation.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/dot-notation
-description: enforce dot notation whenever possible in ``
+description: Enforce dot notation whenever possible in ``
since: v7.0.0
---
# vue/dot-notation
-> enforce dot notation whenever possible in ``
+> Enforce dot notation whenever possible in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/eqeqeq.md b/docs/rules/eqeqeq.md
index aa77b3f11..d6bdf9700 100644
--- a/docs/rules/eqeqeq.md
+++ b/docs/rules/eqeqeq.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/eqeqeq
-description: require the use of `===` and `!==` in ``
+description: Require the use of `===` and `!==` in ``
since: v5.2.0
---
# vue/eqeqeq
-> require the use of `===` and `!==` in ``
+> Require the use of `===` and `!==` in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/func-call-spacing.md b/docs/rules/func-call-spacing.md
index 0f398e1d0..41c795624 100644
--- a/docs/rules/func-call-spacing.md
+++ b/docs/rules/func-call-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/func-call-spacing
-description: require or disallow spacing between function identifiers and their invocations in ``
+description: Require or disallow spacing between function identifiers and their invocations in ``
since: v7.0.0
---
# vue/func-call-spacing
-> require or disallow spacing between function identifiers and their invocations in ``
+> Require or disallow spacing between function identifiers and their invocations in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/key-spacing.md b/docs/rules/key-spacing.md
index bac4eb735..41ba2f851 100644
--- a/docs/rules/key-spacing.md
+++ b/docs/rules/key-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/key-spacing
-description: enforce consistent spacing between keys and values in object literal properties in ``
+description: Enforce consistent spacing between keys and values in object literal properties in ``
since: v5.2.0
---
# vue/key-spacing
-> enforce consistent spacing between keys and values in object literal properties in ``
+> Enforce consistent spacing between keys and values in object literal properties in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/keyword-spacing.md b/docs/rules/keyword-spacing.md
index 61d2e2731..68e9e7cdf 100644
--- a/docs/rules/keyword-spacing.md
+++ b/docs/rules/keyword-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/keyword-spacing
-description: enforce consistent spacing before and after keywords in ``
+description: Enforce consistent spacing before and after keywords in ``
since: v6.0.0
---
# vue/keyword-spacing
-> enforce consistent spacing before and after keywords in ``
+> Enforce consistent spacing before and after keywords in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/multiline-ternary.md b/docs/rules/multiline-ternary.md
index 9cc3d1134..cc36f7da6 100644
--- a/docs/rules/multiline-ternary.md
+++ b/docs/rules/multiline-ternary.md
@@ -2,11 +2,11 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/multiline-ternary
-description: enforce newlines between operands of ternary expressions in ``
+description: Enforce newlines between operands of ternary expressions in ``
---
# vue/multiline-ternary
-> enforce newlines between operands of ternary expressions in ``
+> Enforce newlines between operands of ternary expressions in ``
- :exclamation: ***This rule has not been released yet.***
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/no-constant-condition.md b/docs/rules/no-constant-condition.md
index 89ea03268..7b5835978 100644
--- a/docs/rules/no-constant-condition.md
+++ b/docs/rules/no-constant-condition.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/no-constant-condition
-description: disallow constant expressions in conditions in ``
+description: Disallow constant expressions in conditions in ``
since: v7.5.0
---
# vue/no-constant-condition
-> disallow constant expressions in conditions in ``
+> Disallow constant expressions in conditions in ``
This rule is the same rule as core [no-constant-condition] rule but it applies to the expressions in ``.
diff --git a/docs/rules/no-empty-pattern.md b/docs/rules/no-empty-pattern.md
index f6593d977..99e2152f1 100644
--- a/docs/rules/no-empty-pattern.md
+++ b/docs/rules/no-empty-pattern.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/no-empty-pattern
-description: disallow empty destructuring patterns in ``
+description: Disallow empty destructuring patterns in ``
since: v6.0.0
---
# vue/no-empty-pattern
-> disallow empty destructuring patterns in ``
+> Disallow empty destructuring patterns in ``
This rule is the same rule as core [no-empty-pattern] rule but it applies to the expressions in ``.
diff --git a/docs/rules/no-extra-parens.md b/docs/rules/no-extra-parens.md
index 09af6d190..0297304b7 100644
--- a/docs/rules/no-extra-parens.md
+++ b/docs/rules/no-extra-parens.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/no-extra-parens
-description: disallow unnecessary parentheses in ``
+description: Disallow unnecessary parentheses in ``
since: v7.0.0
---
# vue/no-extra-parens
-> disallow unnecessary parentheses in ``
+> Disallow unnecessary parentheses in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/no-loss-of-precision.md b/docs/rules/no-loss-of-precision.md
index 82e06d010..bee468e7a 100644
--- a/docs/rules/no-loss-of-precision.md
+++ b/docs/rules/no-loss-of-precision.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/no-loss-of-precision
-description: disallow literal numbers that lose precision in ``
+description: Disallow literal numbers that lose precision in ``
since: v8.0.0
---
# vue/no-loss-of-precision
-> disallow literal numbers that lose precision in ``
+> Disallow literal numbers that lose precision in ``
This rule is the same rule as core [no-loss-of-precision] rule but it applies to the expressions in ``.
diff --git a/docs/rules/no-restricted-syntax.md b/docs/rules/no-restricted-syntax.md
index dcde6897a..590e94d6e 100644
--- a/docs/rules/no-restricted-syntax.md
+++ b/docs/rules/no-restricted-syntax.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/no-restricted-syntax
-description: disallow specified syntax in ``
+description: Disallow specified syntax in ``
since: v5.2.0
---
# vue/no-restricted-syntax
-> disallow specified syntax in ``
+> Disallow specified syntax in ``
This rule is the same rule as core [no-restricted-syntax] rule but it applies to the expressions in ``.
diff --git a/docs/rules/no-sparse-arrays.md b/docs/rules/no-sparse-arrays.md
index 861c82ea1..e8cd10007 100644
--- a/docs/rules/no-sparse-arrays.md
+++ b/docs/rules/no-sparse-arrays.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/no-sparse-arrays
-description: disallow sparse arrays in ``
+description: Disallow sparse arrays in ``
since: v7.0.0
---
# vue/no-sparse-arrays
-> disallow sparse arrays in ``
+> Disallow sparse arrays in ``
This rule is the same rule as core [no-sparse-arrays] rule but it applies to the expressions in ``.
diff --git a/docs/rules/no-useless-concat.md b/docs/rules/no-useless-concat.md
index 9229de0a5..6c4afd423 100644
--- a/docs/rules/no-useless-concat.md
+++ b/docs/rules/no-useless-concat.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/no-useless-concat
-description: disallow unnecessary concatenation of literals or template literals in ``
+description: Disallow unnecessary concatenation of literals or template literals in ``
since: v7.0.0
---
# vue/no-useless-concat
-> disallow unnecessary concatenation of literals or template literals in ``
+> Disallow unnecessary concatenation of literals or template literals in ``
This rule is the same rule as core [no-useless-concat] rule but it applies to the expressions in ``.
diff --git a/docs/rules/object-curly-newline.md b/docs/rules/object-curly-newline.md
index d09c3e28f..9e07953f9 100644
--- a/docs/rules/object-curly-newline.md
+++ b/docs/rules/object-curly-newline.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/object-curly-newline
-description: enforce consistent line breaks after opening and before closing braces in ``
+description: Enforce consistent line breaks after opening and before closing braces in ``
since: v7.0.0
---
# vue/object-curly-newline
-> enforce consistent line breaks after opening and before closing braces in ``
+> Enforce consistent line breaks after opening and before closing braces in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/object-curly-spacing.md b/docs/rules/object-curly-spacing.md
index 12f88793b..dacdf2679 100644
--- a/docs/rules/object-curly-spacing.md
+++ b/docs/rules/object-curly-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/object-curly-spacing
-description: enforce consistent spacing inside braces in ``
+description: Enforce consistent spacing inside braces in ``
since: v5.2.0
---
# vue/object-curly-spacing
-> enforce consistent spacing inside braces in ``
+> Enforce consistent spacing inside braces in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/object-property-newline.md b/docs/rules/object-property-newline.md
index be43ec66e..fb934acf6 100644
--- a/docs/rules/object-property-newline.md
+++ b/docs/rules/object-property-newline.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/object-property-newline
-description: enforce placing object properties on separate lines in ``
+description: Enforce placing object properties on separate lines in ``
since: v7.0.0
---
# vue/object-property-newline
-> enforce placing object properties on separate lines in ``
+> Enforce placing object properties on separate lines in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/object-shorthand.md b/docs/rules/object-shorthand.md
index 7c7b4928f..dafe616bf 100644
--- a/docs/rules/object-shorthand.md
+++ b/docs/rules/object-shorthand.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/object-shorthand
-description: require or disallow method and property shorthand syntax for object literals in ``
+description: Require or disallow method and property shorthand syntax for object literals in ``
since: v8.4.0
---
# vue/object-shorthand
-> require or disallow method and property shorthand syntax for object literals in ``
+> Require or disallow method and property shorthand syntax for object literals in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/operator-linebreak.md b/docs/rules/operator-linebreak.md
index 6f7172a78..71847d82f 100644
--- a/docs/rules/operator-linebreak.md
+++ b/docs/rules/operator-linebreak.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/operator-linebreak
-description: enforce consistent linebreak style for operators in ``
+description: Enforce consistent linebreak style for operators in ``
since: v7.0.0
---
# vue/operator-linebreak
-> enforce consistent linebreak style for operators in ``
+> Enforce consistent linebreak style for operators in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/prefer-template.md b/docs/rules/prefer-template.md
index aa33a3f32..4b668f4c2 100644
--- a/docs/rules/prefer-template.md
+++ b/docs/rules/prefer-template.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/prefer-template
-description: require template literals instead of string concatenation in ``
+description: Require template literals instead of string concatenation in ``
since: v7.0.0
---
# vue/prefer-template
-> require template literals instead of string concatenation in ``
+> Require template literals instead of string concatenation in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/quote-props.md b/docs/rules/quote-props.md
index b45b7150a..facf28cee 100644
--- a/docs/rules/quote-props.md
+++ b/docs/rules/quote-props.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/quote-props
-description: require quotes around object literal property names in ``
+description: Require quotes around object literal property names in ``
since: v8.4.0
---
# vue/quote-props
-> require quotes around object literal property names in ``
+> Require quotes around object literal property names in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/space-in-parens.md b/docs/rules/space-in-parens.md
index 62dcc2485..a29c298ac 100644
--- a/docs/rules/space-in-parens.md
+++ b/docs/rules/space-in-parens.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/space-in-parens
-description: enforce consistent spacing inside parentheses in ``
+description: Enforce consistent spacing inside parentheses in ``
since: v7.0.0
---
# vue/space-in-parens
-> enforce consistent spacing inside parentheses in ``
+> Enforce consistent spacing inside parentheses in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/space-infix-ops.md b/docs/rules/space-infix-ops.md
index a20eecb42..e92623661 100644
--- a/docs/rules/space-infix-ops.md
+++ b/docs/rules/space-infix-ops.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/space-infix-ops
-description: require spacing around infix operators in ``
+description: Require spacing around infix operators in ``
since: v5.2.0
---
# vue/space-infix-ops
-> require spacing around infix operators in ``
+> Require spacing around infix operators in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/space-unary-ops.md b/docs/rules/space-unary-ops.md
index 3019c3eb9..10e545408 100644
--- a/docs/rules/space-unary-ops.md
+++ b/docs/rules/space-unary-ops.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/space-unary-ops
-description: enforce consistent spacing before or after unary operators in ``
+description: Enforce consistent spacing before or after unary operators in ``
since: v5.2.0
---
# vue/space-unary-ops
-> enforce consistent spacing before or after unary operators in ``
+> Enforce consistent spacing before or after unary operators in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
diff --git a/docs/rules/template-curly-spacing.md b/docs/rules/template-curly-spacing.md
index 22fce907a..8760b0385 100644
--- a/docs/rules/template-curly-spacing.md
+++ b/docs/rules/template-curly-spacing.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/template-curly-spacing
-description: require or disallow spacing around embedded expressions of template strings in ``
+description: Require or disallow spacing around embedded expressions of template strings in ``
since: v7.0.0
---
# vue/template-curly-spacing
-> require or disallow spacing around embedded expressions of template strings in ``
+> Require or disallow spacing around embedded expressions of template strings in ``
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
From 1abad76c702f6644d714dc51f4a111f23a8208ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Tue, 25 Oct 2022 15:31:13 +0800
Subject: [PATCH 06/22] npm run update edit
---
docs/rules/README.md | 2 +-
docs/rules/no-required-prop-with-default.md | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/rules/README.md b/docs/rules/README.md
index 5f11c9370..569ad18f0 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -230,7 +230,7 @@ For example:
| [vue/no-multiple-objects-in-class](./no-multiple-objects-in-class.md) | disallow to pass multiple objects into array to class | | :hammer: |
| [vue/no-potential-component-option-typo](./no-potential-component-option-typo.md) | disallow a potential typo in your component property | :bulb: | :hammer: |
| [vue/no-ref-object-destructure](./no-ref-object-destructure.md) | disallow destructuring of ref objects that can lead to loss of reactivity | | :warning: |
-| [vue/no-required-prop-with-default](./no-required-prop-with-default.md) | enforce props with default values to be optional | :wrench::bulb: | :warning: |
+| [vue/no-required-prop-with-default](./no-required-prop-with-default.md) | enforce props with default values to be optional | :wrench::bulb: | :warning: |
| [vue/no-restricted-block](./no-restricted-block.md) | disallow specific block | | :hammer: |
| [vue/no-restricted-call-after-await](./no-restricted-call-after-await.md) | disallow asynchronously called restricted methods | | :hammer: |
| [vue/no-restricted-class](./no-restricted-class.md) | disallow specific classes in Vue components | | :warning: |
diff --git a/docs/rules/no-required-prop-with-default.md b/docs/rules/no-required-prop-with-default.md
index 4e1f1deaa..9a604a812 100644
--- a/docs/rules/no-required-prop-with-default.md
+++ b/docs/rules/no-required-prop-with-default.md
@@ -2,12 +2,12 @@
pageClass: rule-details
sidebarDepth: 0
title: vue/no-required-prop-with-default
-description: enforce props with default values to be optional
+description: enforce props with default values to be optional
since: v9.6.0
---
# vue/no-required-prop-with-default
-> enforce props with default values to be optional
+> enforce props with default values to be optional
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
From 4b58d8b62d3108620fc2c3095d31ed071c0576b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Tue, 25 Oct 2022 15:48:39 +0800
Subject: [PATCH 07/22] Modify according to the requirements during
consolidation
---
lib/rules/require-prop-comment.js | 3 ++-
tests/lib/rules/require-prop-comment.js | 21 ---------------------
2 files changed, 2 insertions(+), 22 deletions(-)
diff --git a/lib/rules/require-prop-comment.js b/lib/rules/require-prop-comment.js
index 874a8c7f8..f33fc4fb3 100644
--- a/lib/rules/require-prop-comment.js
+++ b/lib/rules/require-prop-comment.js
@@ -88,7 +88,8 @@ module.exports = {
if (!prop.propName) continue
const beforeComments = sourceCode.getCommentsBefore(prop.node)
- let message = ''
+ /** @type {string|undefined} */
+ let message
switch (type) {
case 'block':
message = verifyBlock(beforeComments)
diff --git a/tests/lib/rules/require-prop-comment.js b/tests/lib/rules/require-prop-comment.js
index ce8f036db..349ca4ec2 100644
--- a/tests/lib/rules/require-prop-comment.js
+++ b/tests/lib/rules/require-prop-comment.js
@@ -19,9 +19,6 @@ tester.run('require-prop-comment', rule, {
valid: [
{
code: `
-
- 1
-
- `,
- errors: [
- {
- line: 7,
- message: 'The "a" property should have one JSDoc comment.'
- },
- {
- line: 14,
- message: 'The "b" property should have one JSDoc comment.'
- },
- {
- line: 18,
- message: 'The "c" property should have one JSDoc comment.'
- }
- ]
- },
- {
- code: `
-
-```
-
+ // ✗ BAD
-
+ // line comment
+ b: Number,
-```vue
-
-
```
@@ -57,118 +46,95 @@ const props = defineProps({
```json
{
"vue/require-prop-comment": ["error", {
- "type": "block"
+ "type": "JSDoc"
}]
}
```
-- `type` ... Type of comment.Default is `"JSDoc"`
+- `type` ... Type of comment. Default is `"JSDoc"`
- `"JSDoc"` ... Only JSDoc comment are allowed.
- `"line"` ... Only line comment are allowed.
- `"block"` ... Only block comment are allowed.
- - `"unlimited"` ... There is no limit to the type.
+ - `"unlimited"` ... All comment types are allowed.
-### `"type":"block"`
+### `"type": "block"`
-
-
-
-
+// ✗ BAD
+const badProps = defineProps({
+ /** JSDoc comment */
+ b: Number,
-
-
+```
-### `"type":"line"`
+### `"type": "line"`
-
-
-
-
+// ✗ BAD
+const badProps = defineProps({
+ /** JSDoc comment */
+ b: Number,
-
-
+```
-### `"type":"unlimited"`
+### `"type": "unlimited"`
-
-
-
-
-
-
+```
diff --git a/lib/rules/require-prop-comment.js b/lib/rules/require-prop-comment.js
index e27b1ec57..df966fa26 100644
--- a/lib/rules/require-prop-comment.js
+++ b/lib/rules/require-prop-comment.js
@@ -10,7 +10,7 @@ module.exports = {
meta: {
type: 'problem',
docs: {
- description: 'require that props have a comment',
+ description: 'require props to have a comment',
categories: undefined,
url: 'https://eslint.vuejs.org/rules/require-prop-comment.html'
},
@@ -19,7 +19,7 @@ module.exports = {
{
type: 'object',
properties: {
- type: { enum: ['line', 'block', 'unlimited'] }
+ type: { enum: ['JSDoc', 'line', 'block', 'unlimited'] }
},
additionalProperties: false
}
From 57d9c5ff2ebba5ecaaa251a4a85bcbd44ee21149 Mon Sep 17 00:00:00 2001
From: Flo Edelmann
Date: Thu, 27 Oct 2022 16:06:08 +0200
Subject: [PATCH 14/22] Only check last preceding comment
---
lib/rules/require-prop-comment.js | 42 +++++++++++++++----------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/lib/rules/require-prop-comment.js b/lib/rules/require-prop-comment.js
index df966fa26..1f1e89824 100644
--- a/lib/rules/require-prop-comment.js
+++ b/lib/rules/require-prop-comment.js
@@ -36,29 +36,25 @@ module.exports = {
const sourceCode = context.getSourceCode()
- /** @param {Comment[]} comments */
- const verifyBlock = (comments) =>
- comments.length > 0 && comments[0].type === 'Block'
+ /** @param {Comment | undefined} comment */
+ const verifyBlock = (comment) =>
+ comment && comment.type === 'Block' && comment.value.charAt(0) !== '*'
? undefined
: 'The "{{name}}" property should have a block comment.'
- /** @param {Comment[]} comments */
- const verifyLine = (comments) =>
- comments.length > 0 && comments.every((c) => c.type === 'Line')
+ /** @param {Comment | undefined} comment */
+ const verifyLine = (comment) =>
+ comment && comment.type === 'Line'
? undefined
: 'The "{{name}}" property should have a line comment.'
- /** @param {Comment[]} comments */
- const verifyUnlimited = (comments) =>
- comments.length > 0
- ? undefined
- : 'The "{{name}}" property should have a comment.'
+ /** @param {Comment | undefined} comment */
+ const verifyUnlimited = (comment) =>
+ comment ? undefined : 'The "{{name}}" property should have a comment.'
- /** @param {Comment[]} comments */
- const verifyJSDoc = (comments) =>
- comments.length > 0 &&
- comments[0].type === 'Block' &&
- /^\*[^*]+/.test(comments[0].value)
+ /** @param {Comment | undefined} comment */
+ const verifyJSDoc = (comment) =>
+ comment && comment.type === 'Block' && comment.value.charAt(0) === '*'
? undefined
: 'The "{{name}}" property should have a JSDoc comment.'
@@ -71,23 +67,27 @@ module.exports = {
continue
}
- const beforeComments = sourceCode.getCommentsBefore(prop.node)
+ const precedingComments = sourceCode.getCommentsBefore(prop.node)
+ const lastPrecedingComment =
+ precedingComments.length > 0
+ ? precedingComments[precedingComments.length - 1]
+ : undefined
/** @type {string|undefined} */
let message
switch (type) {
case 'block':
- message = verifyBlock(beforeComments)
+ message = verifyBlock(lastPrecedingComment)
break
case 'line':
- message = verifyLine(beforeComments)
+ message = verifyLine(lastPrecedingComment)
break
case 'unlimited':
- message = verifyUnlimited(beforeComments)
+ message = verifyUnlimited(lastPrecedingComment)
break
default:
- message = verifyJSDoc(beforeComments)
+ message = verifyJSDoc(lastPrecedingComment)
break
}
From d304e62e4dbeccda3d6b2a9a91f4497289dd91d7 Mon Sep 17 00:00:00 2001
From: Flo Edelmann
Date: Thu, 27 Oct 2022 16:10:30 +0200
Subject: [PATCH 15/22] Use message IDs
---
lib/rules/require-prop-comment.js | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/lib/rules/require-prop-comment.js b/lib/rules/require-prop-comment.js
index 1f1e89824..f1f8cbd03 100644
--- a/lib/rules/require-prop-comment.js
+++ b/lib/rules/require-prop-comment.js
@@ -25,7 +25,12 @@ module.exports = {
}
],
messages: {
- // ...
+ requireAnyComment: 'The "{{name}}" property should have a comment.',
+ requireLineComment: 'The "{{name}}" property should have a line comment.',
+ requireBlockComment:
+ 'The "{{name}}" property should have a block comment.',
+ requireJSDocComment:
+ 'The "{{name}}" property should have a JSDoc comment.'
}
},
/** @param {RuleContext} context */
@@ -40,23 +45,21 @@ module.exports = {
const verifyBlock = (comment) =>
comment && comment.type === 'Block' && comment.value.charAt(0) !== '*'
? undefined
- : 'The "{{name}}" property should have a block comment.'
+ : 'requireBlockComment'
/** @param {Comment | undefined} comment */
const verifyLine = (comment) =>
- comment && comment.type === 'Line'
- ? undefined
- : 'The "{{name}}" property should have a line comment.'
+ comment && comment.type === 'Line' ? undefined : 'requireLineComment'
/** @param {Comment | undefined} comment */
const verifyUnlimited = (comment) =>
- comment ? undefined : 'The "{{name}}" property should have a comment.'
+ comment ? undefined : 'requireAnyComment'
/** @param {Comment | undefined} comment */
const verifyJSDoc = (comment) =>
comment && comment.type === 'Block' && comment.value.charAt(0) === '*'
? undefined
- : 'The "{{name}}" property should have a JSDoc comment.'
+ : 'requireJSDocComment'
/**
* @param {import('../utils').ComponentProp[]} props
@@ -74,30 +77,30 @@ module.exports = {
: undefined
/** @type {string|undefined} */
- let message
+ let messageId
switch (type) {
case 'block':
- message = verifyBlock(lastPrecedingComment)
+ messageId = verifyBlock(lastPrecedingComment)
break
case 'line':
- message = verifyLine(lastPrecedingComment)
+ messageId = verifyLine(lastPrecedingComment)
break
case 'unlimited':
- message = verifyUnlimited(lastPrecedingComment)
+ messageId = verifyUnlimited(lastPrecedingComment)
break
default:
- message = verifyJSDoc(lastPrecedingComment)
+ messageId = verifyJSDoc(lastPrecedingComment)
break
}
- if (!message) {
+ if (!messageId) {
continue
}
context.report({
node: prop.node,
- message,
+ messageId,
data: {
name: prop.propName
}
From a2d81446b6ad0c86d405eb7000be001114f0cfcb Mon Sep 17 00:00:00 2001
From: Flo Edelmann
Date: Thu, 27 Oct 2022 16:12:59 +0200
Subject: [PATCH 16/22] =?UTF-8?q?Rename=20unlimited=20=E2=86=92=20any?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/rules/require-prop-comment.md | 6 +++---
lib/rules/require-prop-comment.js | 11 +++++------
tests/lib/rules/require-prop-comment.js | 4 ++--
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/docs/rules/require-prop-comment.md b/docs/rules/require-prop-comment.md
index 5a6828cc8..a928a84cd 100644
--- a/docs/rules/require-prop-comment.md
+++ b/docs/rules/require-prop-comment.md
@@ -55,7 +55,7 @@ export default defineComponent({
- `"JSDoc"` ... Only JSDoc comment are allowed.
- `"line"` ... Only line comment are allowed.
- `"block"` ... Only block comment are allowed.
- - `"unlimited"` ... All comment types are allowed.
+ - `"any"` ... All comment types are allowed.
### `"type": "block"`
@@ -111,9 +111,9 @@ const badProps = defineProps({
-### `"type": "unlimited"`
+### `"type": "any"`
-
+
```vue
`,
- options: [{ type: 'unlimited' }],
+ options: [{ type: 'any' }],
errors: [
{
line: 4,
From e8070ace58963909f028c51dfe02146d6b265f02 Mon Sep 17 00:00:00 2001
From: Flo Edelmann
Date: Thu, 27 Oct 2022 16:20:49 +0200
Subject: [PATCH 17/22] Fix docs
---
docs/rules/require-prop-comment.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/docs/rules/require-prop-comment.md b/docs/rules/require-prop-comment.md
index a928a84cd..3b1bc29f1 100644
--- a/docs/rules/require-prop-comment.md
+++ b/docs/rules/require-prop-comment.md
@@ -30,7 +30,7 @@ export default defineComponent({
// line comment
b: Number,
- /* c comment */
+ /* block comment */
c: Number,
d: Number,
@@ -62,7 +62,7 @@ export default defineComponent({
```vue
-
`
},
{
code: `
-
`,
options: [{ type: 'block' }]
},
{
code: `
- import { defineComponent } from '@vue/composition-api'
- export const ComponentName = defineComponent({
- props: {
- // a comment
- // a other comment
- a: Number
- }
+ const goodProps = defineProps({
+ // line comment
+ a: Number,
})
`,
options: [{ type: 'line' }]
},
+
{
code: `
- import { defineComponent } from '@vue/composition-api'
- export const ComponentName = defineComponent({
- props: {
- /**
- * a comment
- */
- a: Number,
- // a comment
- b: Number
- }
+ const goodProps = defineProps({
+ /** JSDoc comment */
+ a: Number,
+
+ /* block comment */
+ b: Number,
+
+ // line comment
+ c: Number,
})
`,
options: [{ type: 'any' }]
@@ -83,99 +65,121 @@ tester.run('require-prop-comment', rule, {
invalid: [
{
code: `
-
`,
- options: [{ type: 'block' }],
errors: [
{
- line: 7,
- message: 'The "a" property should have a block comment.'
+ line: 5,
+ column: 11,
+ message: `The "b" property should have a JSDoc comment.`
},
{
- line: 9,
- message: 'The "c" property should have a block comment.'
+ line: 8,
+ column: 11,
+ message: `The "c" property should have a JSDoc comment.`
+ },
+ {
+ line: 10,
+ column: 11,
+ message: `The "d" property should have a JSDoc comment.`
}
]
},
{
code: `
-
`,
- options: [{ type: 'line' }],
+ options: [{ type: 'block' }],
errors: [
{
- line: 10,
- message: 'The "a" property should have a line comment.'
+ line: 5,
+ column: 9,
+ message: 'The "b" property should have a block comment.'
},
{
- line: 11,
- message: 'The "b" property should have a line comment.'
+ line: 8,
+ column: 9,
+ message: 'The "c" property should have a block comment.'
+ },
+ {
+ line: 10,
+ column: 9,
+ message: 'The "d" property should have a block comment.'
}
]
},
{
code: `
`,
- options: [{ type: 'any' }],
+ options: [{ type: 'line' }],
errors: [
{
- line: 4,
- message: `The "a" property should have a comment.`
+ line: 5,
+ column: 9,
+ message: 'The "b" property should have a line comment.'
+ },
+ {
+ line: 8,
+ column: 9,
+ message: 'The "c" property should have a line comment.'
+ },
+ {
+ line: 10,
+ column: 9,
+ message: 'The "d" property should have a line comment.'
}
]
},
{
code: `
`,
+ options: [{ type: 'any' }],
errors: [
{
line: 4,
- message: 'The "a" property should have a JSDoc comment.'
+ column: 9,
+ message: `The "d" property should have a comment.`
}
]
},
{
code: `
- import Vue from 'vue'
new Vue({
props: {
a: Number
@@ -184,7 +188,8 @@ tester.run('require-prop-comment', rule, {
`,
errors: [
{
- line: 5,
+ line: 4,
+ column: 11,
message: 'The "a" property should have a JSDoc comment.'
}
]
From 5a517aa7c731571f3c16bc392898e19558edc654 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Mon, 31 Oct 2022 10:57:03 +0800
Subject: [PATCH 19/22] edit schema type
---
lib/rules/require-prop-comment.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/rules/require-prop-comment.js b/lib/rules/require-prop-comment.js
index 130c77f1a..9c8ef994d 100644
--- a/lib/rules/require-prop-comment.js
+++ b/lib/rules/require-prop-comment.js
@@ -8,7 +8,7 @@ const utils = require('../utils')
module.exports = {
meta: {
- type: 'problem',
+ type: 'suggestion',
docs: {
description: 'require props to have a comment',
categories: undefined,
@@ -35,9 +35,9 @@ module.exports = {
},
/** @param {RuleContext} context */
create(context) {
- /** @type {{type: "JSDoc" | "line" | "block" | "any"}|undefined} */
+ /** @type {{type?: "JSDoc" | "line" | "block" | "any"}|undefined} */
const schema = context.options[0]
- const type = schema ? schema.type : 'JSDoc'
+ const type = (schema && schema.type) || 'JSDoc'
const sourceCode = context.getSourceCode()
From 310fd2656b4670f68c7b7d493e9ca74fc379ea32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Mon, 31 Oct 2022 11:02:56 +0800
Subject: [PATCH 20/22] update readme.md
---
docs/rules/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/rules/README.md b/docs/rules/README.md
index 4aea17e9e..9ca817e30 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -260,7 +260,7 @@ For example:
| [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: |
| [vue/require-name-property](./require-name-property.md) | require a name property in Vue components | | :hammer: |
-| [vue/require-prop-comment](./require-prop-comment.md) | require props to have a comment | | :warning: |
+| [vue/require-prop-comment](./require-prop-comment.md) | require props to have a comment | | :hammer: |
| [vue/script-indent](./script-indent.md) | enforce consistent indentation in `
`
},
{
code: `
+
`,
options: [{ type: 'block' }]
},
{
code: `
+
`,
options: [{ type: 'line' }]
},
-
{
code: `
+
`,
options: [{ type: 'any' }]
+ },
+ {
+ code: `
+
+ `
}
],
invalid: [
@@ -178,6 +197,24 @@ tester.run('require-prop-comment', rule, {
}
]
},
+ {
+ code: `
+
+ `,
+ errors: [
+ {
+ line: 5,
+ column: 11,
+ message: 'The "a" property should have a JSDoc comment.'
+ }
+ ]
+ },
{
code: `
new Vue({
From 1c0bd963f16a02e48abd750ba5fc773c665050a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=94=A1=E6=9C=9D=E5=8B=83?= <3279338858@qq.com>
Date: Mon, 31 Oct 2022 16:48:19 +0800
Subject: [PATCH 22/22] add rules
---
tests/lib/rules/require-prop-comment.js | 34 +++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tests/lib/rules/require-prop-comment.js b/tests/lib/rules/require-prop-comment.js
index c08648e57..f72d6905b 100644
--- a/tests/lib/rules/require-prop-comment.js
+++ b/tests/lib/rules/require-prop-comment.js
@@ -79,6 +79,20 @@ tester.run('require-prop-comment', rule, {
})
`
+ },
+ {
+ code: `
+
+ `,
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
}
],
invalid: [
@@ -230,6 +244,26 @@ tester.run('require-prop-comment', rule, {
message: 'The "a" property should have a JSDoc comment.'
}
]
+ },
+ {
+ code: `
+
+ `,
+ errors: [
+ {
+ line: 4,
+ column: 9,
+ message: 'The "a" property should have a JSDoc comment.'
+ }
+ ],
+ parserOptions: {
+ parser: require.resolve('@typescript-eslint/parser')
+ }
}
]
})