@html-eslint/parser
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -8,3 +8,2 @@ const utils = require("./utils"); | ||
nodeName, | ||
attrs, | ||
sourceCodeLocation, | ||
@@ -14,23 +13,29 @@ ...extra | ||
const type = utils.toType(nodeName); | ||
return { | ||
const baseNode = { | ||
type, | ||
...extra, | ||
...utils.toESLocation(sourceCodeLocation, childNodes), | ||
// start tag | ||
}; | ||
addTags(baseNode, sourceCodeLocation); | ||
addAttrs(baseNode, sourceCodeLocation); | ||
return baseNode; | ||
} | ||
function addTags(node, sourceCodeLocation) { | ||
return Object.assign(node, { | ||
startTag: | ||
sourceCodeLocation && sourceCodeLocation.startTag | ||
? { | ||
...utils.toESLocation(sourceCodeLocation.startTag), | ||
} | ||
? utils.toESLocation(sourceCodeLocation.startTag) | ||
: null, | ||
// end tag | ||
endTag: | ||
sourceCodeLocation && sourceCodeLocation.endTag | ||
? { | ||
...utils.toESLocation(sourceCodeLocation.endTag), | ||
} | ||
? utils.toESLocation(sourceCodeLocation.endTag) | ||
: null, | ||
// attributes | ||
attrs: attrs | ||
? attrs.map((attr) => ({ | ||
}); | ||
} | ||
function addAttrs(node, sourceCodeLocation) { | ||
return Object.assign(node, { | ||
attrs: node.attrs | ||
? node.attrs.map((attr) => ({ | ||
...attr, | ||
@@ -42,3 +47,3 @@ ...(sourceCodeLocation && sourceCodeLocation.attrs | ||
: [], | ||
}; | ||
}); | ||
} | ||
@@ -45,0 +50,0 @@ |
@@ -119,3 +119,5 @@ function getLocFromChildNodes(childNodes) { | ||
return text.split("\n").map((textLine) => { | ||
const indentLength = (textLine.match(/[^\S\n\r]/g) || []).length; | ||
const lengthWithoutIndent = textLine.trimStart().length; | ||
const indentLength = textLine.length - lengthWithoutIndent; | ||
rangeStart += indentLength; | ||
@@ -139,4 +141,4 @@ startOffset += indentLength; | ||
}; | ||
rangeStart += textLine.trimStart().length + 1; | ||
startOffset += textLine.trimStart().length + 1; | ||
rangeStart += lengthWithoutIndent + 1; | ||
startOffset += lengthWithoutIndent + 1; | ||
line += 1; | ||
@@ -143,0 +145,0 @@ return lineNode; |
{ | ||
"name": "@html-eslint/parser", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Parser for @html-eslint/eslint-plugin", | ||
@@ -32,3 +32,3 @@ "author": "yeonjuan", | ||
}, | ||
"gitHead": "eef02fe80c18eead290d77b41b38b4281a2599ef" | ||
"gitHead": "0171c6eccb93800af6af3e6988dd5c6bcd0f4958" | ||
} |
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
12507
426