diff --git a/lib/styles/context/style/index.ts b/lib/styles/context/style/index.ts index caf31147..cbf71582 100644 --- a/lib/styles/context/style/index.ts +++ b/lib/styles/context/style/index.ts @@ -136,7 +136,7 @@ export class StyleContext { needReport: eof.inDocumentFragment, loc: { line: eof.error.lineNumber, column: eof.error.column }, } - } else if (endTag == null) { + } else if (endTag == null && !startTag.selfClosing) { this.invalid = { message: "Missing end tag", needReport: true, @@ -148,11 +148,10 @@ export class StyleContext { this.lang = ((style && getLang(style)) || "css").toLowerCase() - if (!this.invalid && endTag != null) { - this.cssText = sourceCode.text.slice( - startTag.range[1], - endTag.range[0], - ) + if (!this.invalid) { + this.cssText = endTag + ? sourceCode.text.slice(startTag.range[1], endTag.range[0]) + : "" this.cssNode = parse( sourceCode, startTag.loc.end, diff --git a/package.json b/package.json index 50e6a824..656e2d5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-vue-scoped-css", - "version": "0.2.1", + "version": "0.2.2", "description": "ESLint plugin for Scoped CSS in Vue.js", "main": "dist/index.js", "scripts": { diff --git a/tests/lib/rules/no-parsing-error.ts b/tests/lib/rules/no-parsing-error.ts index 85469057..a88a74ec 100644 --- a/tests/lib/rules/no-parsing-error.ts +++ b/tests/lib/rules/no-parsing-error.ts @@ -22,6 +22,10 @@ tester.run("no-parsing-error", rule, { ` `, + ` + +