Keep shadow context across template interpolations

Review finding on #553: the end-anchored shadow-context tails excluded
`}` (JS) and `{`/`}` (CSS), so a documented shadow color after a ${...}
interpolation in a boxShadow template literal or a CSS-in-JS
box-shadow line lost its allowance and fired as drift. Both tails now
admit complete ${...} interpolations; a bare `}`, quote, or `;` still
ends the context, so the allowance cannot leak past a template's
closing backtick into a later property.

AI-assisted (Cursor agent), reviewed by maintainer.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Abdul Wahab
2026-08-10 13:05:24 +05:00
co-authored by Cursor
parent 92c857a9ef
commit 94e957d7fc
2 changed files with 25 additions and 3 deletions
+6 -3
View File
@@ -742,9 +742,12 @@ function isShadowPropertyContext(line, match) {
const before = line.slice(0, index);
// Unlike jsColorKeyContext, the JS tail admits commas: a multi-layer shadow
// string is comma-separated, and a later property on the same line is still
// blocked because it sits past the string's closing quote.
return /(?:^|[{\s;"'`(,])(?:box-shadow|text-shadow)\s*:\s*[^;{}"'`]*$/i.test(before)
|| /(?:^|[,{]\s*)(?:boxShadow|textShadow)\s*[:=]\s*["'`]?[^"'`}]*$/i.test(before);
// blocked because it sits past the string's closing quote. Both tails also
// admit complete `${...}` interpolations, so a tokenized dynamic shadow
// (template literal or CSS-in-JS) keeps its context; a bare `}`, quote, or
// `;` still ends it.
return /(?:^|[{\s;"'`(,])(?:box-shadow|text-shadow)\s*:\s*(?:\$\{[^}"'`]*\}|[^;{}"'`])*$/i.test(before)
|| /(?:^|[,{]\s*)(?:boxShadow|textShadow)\s*[:=]\s*["'`]?(?:\$\{[^}"'`]*\}|[^"'`}])*$/i.test(before);
}
function isInsideCssAttributeSelector(line, index) {