Skip to content

Commit

Permalink
Ignore well known tags in component-name-in-template-casing (#2031)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaciras committed Nov 23, 2022
1 parent 0fd431e commit 2d46741
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/rules/component-name-in-template-casing.js
Expand Up @@ -90,23 +90,21 @@ module.exports = {
return false
}

if (
(!utils.isHtmlElementNode(node) && !utils.isSvgElementNode(node)) ||
utils.isHtmlWellKnownElementName(node.rawName) ||
utils.isSvgWellKnownElementName(node.rawName)
) {
return false
}

if (!registeredComponentsOnly) {
// If the user specifies registeredComponentsOnly as false, it checks all component tags.
if (
(!utils.isHtmlElementNode(node) && !utils.isSvgElementNode(node)) ||
utils.isHtmlWellKnownElementName(node.rawName) ||
utils.isSvgWellKnownElementName(node.rawName)
) {
return false
}
return true
}
// We only verify the registered components.
if (registeredComponents.has(casing.pascalCase(node.rawName))) {
return true
}

return false
// We only verify the registered components.
return registeredComponents.has(casing.pascalCase(node.rawName))
}

let hasInvalidEOF = false
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/component-name-in-template-casing.js
Expand Up @@ -162,6 +162,15 @@ tester.run('component-name-in-template-casing', rule, {
`
},

{
code: `
<template><div/></template>
<script setup>const Div = 0</script>
`,
options: ['PascalCase'],
filename: 'test.vue'
},

// globals
{
code: `
Expand Down

0 comments on commit 2d46741

Please sign in to comment.