sugar-high
Advanced tools
Comparing version 0.7.4 to 0.7.5
@@ -223,5 +223,7 @@ // @ts-check | ||
let __strQuote = null | ||
let __regexQuoteStart = false | ||
let __strTemplateExprStack = 0 | ||
let __strTemplateQuoteStack = 0 | ||
const inStringQuotes = () => __strQuote !== null | ||
const inRegexQuotes = () => __regexQuoteStart | ||
const inStrTemplateLiterals = () => (__strTemplateQuoteStack > __strTemplateExprStack) | ||
@@ -279,8 +281,16 @@ const inStrTemplateExpr = () => __strTemplateQuoteStack > 0 && (__strTemplateQuoteStack === __strTemplateExprStack) | ||
const append = (_type, _token) => { | ||
if (_token) { | ||
current = _token | ||
/** | ||
* | ||
* @param {number} type_ | ||
* @param {string} token_ | ||
*/ | ||
const append = (type_, token_) => { | ||
if (type_ || token_) { | ||
const nType = types[type_] | ||
} | ||
if (token_) { | ||
current = token_ | ||
} | ||
if (current) { | ||
type = _type || classify(current) | ||
type = type_ || classify(current) | ||
/** @type [number, string] */ | ||
@@ -461,3 +471,9 @@ const pair = [type, current] | ||
if (curr === '<' && (next === '/' || isAlpha(next))) { | ||
__jsxEnter = true | ||
if ( | ||
!inStringContent() && | ||
!inJsxLiterals() && | ||
!inRegexQuotes() | ||
) { | ||
__jsxEnter = true | ||
} | ||
} | ||
@@ -493,2 +509,3 @@ } | ||
__regexQuoteStart = true | ||
const start = i++ | ||
@@ -501,7 +518,8 @@ | ||
let foundClose = false | ||
// regex | ||
// traverse to find closing regex slash | ||
for (; !isEol(); i++) { | ||
if (code[i] === '/' && code[i - 1] !== '\\') { | ||
foundClose = true | ||
// append regex flags | ||
// end of regex, append regex flags | ||
while (start !== i && /^[a-z]$/.test(code[i + 1]) && !isEol()) { | ||
@@ -513,2 +531,4 @@ i++ | ||
} | ||
__regexQuoteStart = false | ||
if (start !== i && foundClose) { | ||
@@ -515,0 +535,0 @@ // If current line is fully closed with string quotes or regex slashes, |
{ | ||
"name": "sugar-high", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
19411
664