diff --git a/docs/rules/no-deprecated-slot-attribute.md b/docs/rules/no-deprecated-slot-attribute.md
index 59e2c068f..afe02f830 100644
--- a/docs/rules/no-deprecated-slot-attribute.md
+++ b/docs/rules/no-deprecated-slot-attribute.md
@@ -37,6 +37,49 @@ This rule reports deprecated `slot` attribute in Vue.js v2.6.0+.
+## :wrench: Options
+
+```json
+{
+ "vue/no-deprecated-slot-attribute": ["error", {
+ "ignore": ["my-component"]
+ }]
+}
+```
+
+- `"ignore"` (`string[]`) An array of tags that ignore this rules. This option will check both kebab-case and PascalCase versions of the given tag names. Default is empty.
+
+### `"ignore": ["my-component"]`
+
+
+
+```vue
+
+
+
+
+ {{ props.title }}
+
+
+
+
+
+
+ {{ props.title }}
+
+
+
+
+
+
+ {{ props.title }}
+
+
+
+```
+
+
+
## :books: Further Reading
- [API - slot](https://v2.vuejs.org/v2/api/#slot-deprecated)
diff --git a/lib/rules/no-deprecated-slot-attribute.js b/lib/rules/no-deprecated-slot-attribute.js
index 6459cdff4..f4c893538 100644
--- a/lib/rules/no-deprecated-slot-attribute.js
+++ b/lib/rules/no-deprecated-slot-attribute.js
@@ -16,7 +16,19 @@ module.exports = {
url: 'https://eslint.vuejs.org/rules/no-deprecated-slot-attribute.html'
},
fixable: 'code',
- schema: [],
+ schema: [
+ {
+ type: 'object',
+ properties: {
+ ignore: {
+ type: 'array',
+ items: { type: 'string' },
+ uniqueItems: true
+ }
+ },
+ additionalProperties: false
+ }
+ ],
messages: {
forbiddenSlotAttribute: '`slot` attributes are deprecated.'
}
diff --git a/lib/rules/syntaxes/slot-attribute.js b/lib/rules/syntaxes/slot-attribute.js
index 3292cd9de..57d567bc1 100644
--- a/lib/rules/syntaxes/slot-attribute.js
+++ b/lib/rules/syntaxes/slot-attribute.js
@@ -5,12 +5,17 @@
'use strict'
const canConvertToVSlot = require('./utils/can-convert-to-v-slot')
+const casing = require('../../utils/casing')
module.exports = {
deprecated: '2.6.0',
supported: '<3.0.0',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
+ const options = context.options[0] || {}
+ /** @type {Set} */
+ const ignore = new Set(options.ignore)
+
const sourceCode = context.getSourceCode()
const tokenStore =
context.parserServices.getTemplateBodyTokenStore &&
@@ -95,6 +100,15 @@ module.exports = {
* @returns {void}
*/
function reportSlot(slotAttr) {
+ const componentName = slotAttr.parent.parent.rawName
+ if (
+ ignore.has(componentName) ||
+ ignore.has(casing.pascalCase(componentName)) ||
+ ignore.has(casing.kebabCase(componentName))
+ ) {
+ return
+ }
+
context.report({
node: slotAttr.key,
messageId: 'forbiddenSlotAttribute',
diff --git a/tests/lib/rules/no-deprecated-slot-attribute.js b/tests/lib/rules/no-deprecated-slot-attribute.js
index 8f61e9225..7f3bcbf0d 100644
--- a/tests/lib/rules/no-deprecated-slot-attribute.js
+++ b/tests/lib/rules/no-deprecated-slot-attribute.js
@@ -46,7 +46,19 @@ tester.run('no-deprecated-slot-attribute', rule, {
- `
+ `,
+ {
+ code: `
+
+
+
+
+
+
+
+ `,
+ options: [{ ignore: ['one', 'two', 'my-component'] }]
+ }
],
invalid: [
{
@@ -594,6 +606,26 @@ tester.run('no-deprecated-slot-attribute', rule, {
'`slot` attributes are deprecated.',
'`slot` attributes are deprecated.'
]
+ },
+ {
+ code: `
+
+
+
+ A
+
+
+ B
+
+
+ `,
+ output: null,
+ options: [
+ {
+ ignore: ['one']
+ }
+ ],
+ errors: ['`slot` attributes are deprecated.']
}
]
})