Skip to content

Commit 4d7eac1

Browse files
committed
Fix: improve Vue file detection
eslint-plugin-import seems to not give filenames.
1 parent cc923dc commit 4d7eac1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/parse-component.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const transformHtml = require("./transform-html")
2121
// Helpers
2222
//------------------------------------------------------------------------------
2323

24+
const STARTS_WITH_LT = /^\s*</
25+
2426
/**
2527
* Parse the given component.
2628
*
@@ -138,7 +140,9 @@ function parse(code, options) {
138140
const filePath = options.filePath
139141
const scriptOptions = options
140142
const templateOptions = options.template || {}
141-
const isVue = path.extname(filePath || "unknown.js") === ".vue"
143+
const isVue =
144+
path.extname(filePath || "unknown.js") === ".vue" ||
145+
STARTS_WITH_LT.test(code)
142146
const scriptParser = new ScriptParser(code, scriptOptions)
143147
let ast = null
144148

0 commit comments

Comments
 (0)