capsule-lint
Advanced tools
Comparing version 0.4.8 to 0.4.9
@@ -66,11 +66,15 @@ export interface FilePosition { | ||
export type PeggySyntaxError = _PeggySyntaxError; | ||
export type Start = (Conditional | Tag | Text)[]; | ||
export type Start = (If | List | Assign | Tag | Text)[]; | ||
export type Text = string; | ||
export type Char = string; | ||
export type Tag = string; | ||
export type Conditional = If | Elseif | Else | Endif; | ||
export type If = string; | ||
export type If = Openif | Elseif | Else | Endif; | ||
export type Openif = string; | ||
export type Elseif = string; | ||
export type Else = "<#else>"; | ||
export type Endif = "</#if>"; | ||
export type List = Openlist | Endlist; | ||
export type Openlist = string; | ||
export type Endlist = "</#list>"; | ||
export type Assign = string; | ||
export type TagExpression = any; | ||
@@ -77,0 +81,0 @@ export type Expression = string; |
{ | ||
"name": "capsule-lint", | ||
"version": "0.4.8", | ||
"version": "0.4.9", | ||
"description": "The official Capsule linting package.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -14,7 +14,10 @@ import { Block } from 'htmlhint/htmlparser'; | ||
const blockTags = ['#if', '#list']; | ||
const pattern = new RegExp(`^<(${blockTags.join('|')})`) | ||
parser.addListener('text', (event) => { | ||
try { | ||
for(const tag of parse(event.raw)) { | ||
if(tag.match(/^<#if/)) { | ||
stack.push({ tag, event }); | ||
if(tag.match(pattern)) { | ||
stack.push({ tag, event }); | ||
} | ||
@@ -37,3 +40,3 @@ } | ||
parser.addListener('tagend', (event) => { | ||
if(event.tagName !== '#if') { | ||
if(!blockTags.includes(event.tagName)) { | ||
return; | ||
@@ -51,3 +54,3 @@ } | ||
for(const { tag, event } of stack) { | ||
reporter.error(`Conditional [${tag}] is missing a closing tag: [</#if>]`, event.line, event.col, this, event.raw) | ||
reporter.error(`Tag [${tag}] is missing a closing tag: [</${tag.match(pattern)[1]}>]`, event.line, event.col, this, event.raw) | ||
} | ||
@@ -54,0 +57,0 @@ }) |
@@ -24,3 +24,3 @@ import { Block } from 'htmlhint/htmlparser'; | ||
if(tagName === '#if') { | ||
if(tagName.startsWith('#')) { | ||
return; | ||
@@ -27,0 +27,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1004205
7718