Skip to content

Commit

Permalink
Fix false positive for filename in vue/multi-word-component-names r…
Browse files Browse the repository at this point in the history
…ule (#1689)
  • Loading branch information
ota-meshi committed Oct 29, 2021
1 parent c6ca602 commit fa1675c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/multi-word-component-names.js
Expand Up @@ -8,6 +8,7 @@
// Requirements
// ------------------------------------------------------------------------------

const path = require('path')
const casing = require('../utils/casing')
const utils = require('../utils')

Expand Down Expand Up @@ -111,7 +112,7 @@ module.exports = {
if (hasName) return
if (!hasVue && node.body.length > 0) return
const fileName = context.getFilename()
const componentName = fileName.replace(/\.[^/.]+$/, '')
const componentName = path.basename(fileName, path.extname(fileName))
if (
utils.isVueFile(fileName) &&
!isValidComponentName(componentName)
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/multi-word-component-names.js
Expand Up @@ -39,6 +39,10 @@ tester.run('multi-word-component-names', rule, {
filename: 'app.vue',
code: ''
},
{
filename: 'path/to/app.vue',
code: '<script></script>'
},
{
filename: 'invalid.vue',
code: `
Expand Down

0 comments on commit fa1675c

Please sign in to comment.