Skip to content

Commit

Permalink
Fix pylint error at no-deprecated-router-link-tag-prop
Browse files Browse the repository at this point in the history
  • Loading branch information
csordasmarton committed Oct 18, 2021
1 parent be4e0e8 commit ce5f19c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
13 changes: 7 additions & 6 deletions lib/rules/no-deprecated-router-link-tag-prop.js
Expand Up @@ -21,7 +21,7 @@ module.exports = {
description:
'disallow using deprecated `tag` property on `RouterLink` (in Vue.js 3.0.0+)',
categories: undefined,
url: 'https://eslint.vuejs.org/rules/no-deprecated-router-link-tag-prop'
url: 'https://eslint.vuejs.org/rules/no-deprecated-router-link-tag-prop.html'
},
fixable: null,
schema: [
Expand All @@ -40,7 +40,8 @@ module.exports = {
}
],
messages: {
deprecated: "'tag' property on '{{element}}' component is deprecated. Use scoped slots instead."
deprecated:
"'tag' property on '{{element}}' component is deprecated. Use scoped slots instead."
}
},
/** @param {RuleContext} context */
Expand All @@ -51,16 +52,16 @@ module.exports = {
}

return utils.defineTemplateBodyVisitor(context, {
"VElement"(node) {
VElement(node) {
if (!components.includes(node.rawName)) return

const attributes = node.startTag.attributes
attributes.forEach(attr => {
attributes.forEach((attr) => {
/** @type VIdentifier | null */
let tagAttr = null;
let tagAttr = null

if (attr.key.type === 'VIdentifier') {
tagAttr = attr.key;
tagAttr = attr.key
} else if (attr.directive && attr.key.type === 'VDirectiveKey') {
const arg = attr.key.argument
if (arg && arg.type === 'VIdentifier') {
Expand Down
34 changes: 20 additions & 14 deletions tests/lib/rules/no-deprecated-router-link-tag-prop.js
Expand Up @@ -52,7 +52,7 @@ tester.run('no-deprecated-router-link-tag-prop', rule, {
</NuxtLink>
</template>
`
},
}
],
invalid: [
{
Expand All @@ -64,10 +64,11 @@ tester.run('no-deprecated-router-link-tag-prop', rule, {
`,
errors: [
{
message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.",
message:
"'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.",
line: 3,
column: 21
},
}
]
},
{
Expand All @@ -80,10 +81,11 @@ tester.run('no-deprecated-router-link-tag-prop', rule, {
options: [{ components: ['RouterLink'] }],
errors: [
{
message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.",
message:
"'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.",
line: 3,
column: 21
},
}
]
},
{
Expand All @@ -95,10 +97,11 @@ tester.run('no-deprecated-router-link-tag-prop', rule, {
`,
errors: [
{
message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.",
message:
"'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.",
line: 3,
column: 22
},
}
]
},
{
Expand All @@ -111,10 +114,11 @@ tester.run('no-deprecated-router-link-tag-prop', rule, {
options: [{ components: ['RouterLink'] }],
errors: [
{
message: "'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.",
message:
"'tag' property on 'RouterLink' component is deprecated. Use scoped slots instead.",
line: 3,
column: 22
},
}
]
},
{
Expand All @@ -127,10 +131,11 @@ tester.run('no-deprecated-router-link-tag-prop', rule, {
options: [{ components: ['NuxtLink'] }],
errors: [
{
message: "'tag' property on 'NuxtLink' component is deprecated. Use scoped slots instead.",
message:
"'tag' property on 'NuxtLink' component is deprecated. Use scoped slots instead.",
line: 3,
column: 19
},
}
]
},
{
Expand All @@ -143,11 +148,12 @@ tester.run('no-deprecated-router-link-tag-prop', rule, {
options: [{ components: ['NuxtLink'] }],
errors: [
{
message: "'tag' property on 'NuxtLink' component is deprecated. Use scoped slots instead.",
message:
"'tag' property on 'NuxtLink' component is deprecated. Use scoped slots instead.",
line: 3,
column: 20
},
}
]
},
}
]
})

0 comments on commit ce5f19c

Please sign in to comment.