@html-eslint/parser
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -27,2 +27,5 @@ /** | ||
const converted = this.convertedStack.pop(); | ||
if (!converted) { | ||
return; | ||
} | ||
if (this.convertedStack.isEmpty()) { | ||
@@ -33,3 +36,8 @@ this.ast = converted; | ||
while(this.convertedStack.top() === null) { | ||
this.convertedStack.pop(); | ||
} | ||
const parent = this.convertedStack.top(); | ||
!Array.isArray(parent.childNodes) && (parent.childNodes = []); | ||
@@ -41,4 +49,6 @@ parent.childNodes.push(converted); | ||
const esNode = NodeConverter.toNode(node); | ||
esNode.childNodes = []; | ||
this.convertedStack.push(NodeConverter.toNode(node)); | ||
if (esNode) { | ||
esNode.childNodes = []; | ||
} | ||
this.convertedStack.push(esNode); | ||
} | ||
@@ -45,0 +55,0 @@ } |
const utils = require("./utils"); | ||
const NodeConverter = { | ||
toNode({ | ||
childNodes, | ||
parentNode, // eslint-disable-line no-unused-vars | ||
nodeName, | ||
attrs, | ||
sourceCodeLocation, | ||
...extra | ||
}) { | ||
toNode(node) { | ||
if (utils.isEmptyHTMLNode(node)) { | ||
return null; | ||
} | ||
const {childNodes, | ||
parentNode, // eslint-disable-line no-unused-vars | ||
nodeName, | ||
attrs, | ||
sourceCodeLocation, | ||
...extra | ||
} = node; | ||
const type = utils.toType(nodeName); | ||
@@ -13,0 +16,0 @@ return { |
@@ -77,2 +77,5 @@ function getLocFromChildNodes(childNodes) { | ||
}, | ||
isEmptyHTMLNode(node) { | ||
return !node || (node.nodeName !== "#document" && !node.sourceCodeLocation); | ||
} | ||
}; |
{ | ||
"name": "@html-eslint/parser", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Parser for @html-eslint/eslint-plugin", | ||
@@ -24,3 +24,3 @@ "author": "yeonjuan", | ||
"scripts": { | ||
"test": "jest --coverage --verbose --updateSnapshot" | ||
"test": "jest --coverage --updateSnapshot" | ||
}, | ||
@@ -33,3 +33,3 @@ "bugs": { | ||
}, | ||
"gitHead": "1bac029775d06cac9f8f4a3c1d606295ef13913d" | ||
"gitHead": "229d0fa2f80eb6f34da26fe45768beea16bec53f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9957
327