Conversation
`updateThemeProps` matched the owner call with a non paren-aware
`owner\([\s\S]+?\);` regex, so for a theme nested in another call -
`@include scrollbar(scrollbar-theme($sb-size: 6px))` - the match swallowed
the closing bracket of the surrounding call. That bracket ended up riding on
the last argument and was dropped together with it whenever the last (or the
only) argument was removed, leaving invalid SCSS behind:
@include scrollbar(scrollbar-theme();
Locate the call's own closing bracket by scanning and counting brackets
instead, skipping strings and comments, and splice the rewritten argument
list in by index. This also lets a theme call that is not terminated by `;`
on the same statement be migrated.
Closes #17642
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes migration parsing so nested theme calls remain balanced and safely handle strings/comments.
Changes:
- Replaces regex matching with parenthesis-aware call detection.
- Preserves formatting and supports calls without semicolons.
- Adds migration regression tests.
File summaries
| File | Description |
|---|---|
| projects/igniteui-angular/migrations/update-22_2_0/index.spec.ts | Updated as part of this pull request. |
| projects/igniteui-angular/migrations/common/UpdateChanges.ts | Updated as part of this pull request. |
| projects/igniteui-angular/migrations/common/UpdateChanges.spec.ts | Updated as part of this pull request. |
Review details
Suppressed comments (1)
projects/igniteui-angular/migrations/common/UpdateChanges.ts:968
splitFunctionPropsstill treats commas in//comments as argument separators. For example,igx-theme-func($remove-me: 1, // keep this, too\n $prop: red)is split atkeep this,, so the migration can leave comment text as a synthetic parameter and change or corrupt the call instead of only removing$remove-me. Since this parser is now used for the new nested-call path, skip line/block comments here asfindClosingBracketdoes, and add a comma-in-comment regression case.
if (char === '\'' || char === '"') {
i = this.skipString(body, i);
continue;
}
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
`$` is a regex anchor, so the single-occurrence `replace` the escaping relied on was incomplete. Flagged by CodeQL (js/incomplete-sanitization). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…rty regex The hand-rolled `$` escaping was incomplete either way - CodeQL flagged the single-occurrence replace, then the unescaped backslash. The file already imports `escapeRegExp` from ./util and uses it elsewhere, so reuse it here rather than keeping a partial escape of our own. No behavior change: a theme property name only ever contains `$` and `-`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`findFunctionCalls` located the opening `owner(` with a plain `indexOf`, so a theme function merely mentioned in a comment or a quoted value was taken for a real call. With an unbalanced `(` in the comment the scan then ran past it and claimed the closing bracket of the next genuine call, rewriting across unrelated source and leaving that call unmigrated. Scan for the opening the same way the bracket matching already did, stepping over strings and comments via a shared `skipNonCode`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Argument parsing still treats commas inside Sass comments as separators.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
projects/igniteui-angular/migrations/common/UpdateChanges.ts:999
splitFunctionPropsstill treats commas inside Sass comments as argument separators. For example, a removed property followed by// keep, this notecan split the comment in the middle and the rebuilt argument list can lose the real separator before the next property, even though the new scanner explicitly promises to ignore comments. SkipskipNonCodespans here as well before processing commas/parentheses so comments cannot affect argument parsing.
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17642
What
UpdateChanges.updateThemeProps()matched the owner call with a non paren-aware regex:For a theme function nested in another call — the documented
@include scrollbar(scrollbar-theme($sb-size: 6px));pattern — the match ran to the first);and therefore swallowed the closing bracket of the surrounding call. That stray)ended up attached to the last argument, and when that argument was one of the removed ones it was dropped along with it, producing invalid SCSS:Since
update-22_2_0removes the whole$sb-*set fromscrollbar-theme, practically every such usage broke. Real fallout in the samples app: IgniteUI/igniteui-angular-samples#4031.The bug is in the shared
UpdateChangescode, not in the 22.2.0 changes file, so any futuretype: "property"/remove: truetheme change would have hit it too.How
findFunctionCalls/findClosingBracketlocate eachowner(and scan forward counting brackets to find that call's own). Brackets inside strings and comments are ignored, andisLineCommentStartkeepsurl(https://…)from being mistaken for a//comment.String.replace(match, …), and the calls are rewritten back to front so the collected indices stay valid.splitFunctionPropsnow skips strings as well, so a(or,inside a quoted value no longer throws off the argument split.Dropping the
\);anchor also means a theme call that is not terminated by;on the same statement is now migrated instead of silently skipped.Behavior
@include scrollbar(scrollbar-theme($sb-size: 6px));@include scrollbar(scrollbar-theme();❌@include scrollbar(scrollbar-theme());@include scrollbar(scrollbar-theme($thumb-bg: red, $sb-size: 6px));@include scrollbar(scrollbar-theme($thumb-bg: red);❌@include scrollbar(scrollbar-theme($thumb-bg: red));@include scrollbar(scrollbar-theme($sb-size: 6px, $thumb-bg: red));$t: scrollbar-theme($sb-size: 6px);Formatting of the non-nested, single-theme-per-statement case — by far the common one — is byte-for-byte what it was; the existing specs cover that and pass untouched.
Tests
UpdateChanges.spec.ts— new spec over the generic path: nested call with the only / last / first argument removed, a rename inside a nested call, and brackets and commas hiding in a string, aurl()and a trailing comment.update-22_2_0/index.spec.ts— the two@include scrollbar(scrollbar-theme(…))shapes from the samples repo, plus a theme call with no terminating;.Both new specs fail on
masterand pass with the fix.npm run test:schematics: 468 specs, 0 failures.🤖 Generated with Claude Code