api-doc-validator
Advanced tools
Comparing version 2.19.1 to 2.20.0
const fs = require('fs'); | ||
const parser = require('@babel/parser'); | ||
@@ -8,2 +9,3 @@ const TEXT = 1; | ||
const COMMENT_NL = 4; | ||
const ARRAY_WAIT = 5; | ||
@@ -49,3 +51,3 @@ const propRule = /^[\r\n\t\s]*((?:class\s+|var\s+|let\s+|const\s+|async\s+|static\s+|function\s+)*)([$\w]+)(\s*[:=]\s*async\b)?/; | ||
if (start === -1) { | ||
slice(text); | ||
updatePos(text); | ||
return; | ||
@@ -129,3 +131,9 @@ } | ||
loc = null; | ||
list.push(item); | ||
if (item.value.trim().startsWith('@array ')) { | ||
state = ARRAY_WAIT; | ||
continue; | ||
} | ||
const match = text.match(propRule); | ||
@@ -163,4 +171,2 @@ | ||
} | ||
list.push(item); | ||
} | ||
@@ -178,2 +184,22 @@ else { | ||
} | ||
if (state === ARRAY_WAIT) { | ||
const start = text.indexOf('['); | ||
if (start === -1) { | ||
updatePos(text); | ||
return; | ||
} | ||
text = slice(text, start); | ||
const end = text.indexOf(']'); | ||
if (end === -1) { | ||
return; | ||
} | ||
list.at(-1).array = toArray(text.slice(0, end + 1)); | ||
text = slice(text, end + 1); | ||
state = TEXT; | ||
} | ||
} | ||
@@ -205,2 +231,8 @@ }; | ||
return match ? match[1].length : 0; | ||
} | ||
function toArray(code) { | ||
const ast = parser.parseExpression(code); | ||
return ast.elements.map(node => node.value); | ||
} |
{ | ||
"name": "api-doc-validator", | ||
"version": "2.19.1", | ||
"version": "2.20.0", | ||
"description": "api doc and validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
65616
1859