Skip to content

Commit

Permalink
Fixed parsing-error when self-closing (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Nov 26, 2019
1 parent 2175019 commit 651ddc7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/styles/context/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-parsing-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ tester.run("no-parsing-error", rule, {
`
<template></template>
`,
`
<template><!-- When using vue-eslint-parser@5, a template tag is required. --></template>
<style scoped/>
`,
],
invalid: [
{
Expand Down

0 comments on commit 651ddc7

Please sign in to comment.