Conversation
…l call patching typo
📝 WalkthroughWalkthroughThis PR systematically replaces word-boundary anchors ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/patches/patchesAppliedIndication.ts (1)
97-97:\w+increateElementPatternshould be[$\w]+.The
(?:\w+|\{[^}]+\})alternative uses\w+to match a simple argument, but a minified identifier that starts with$would not match.♻️ Use `[$\w]+` for the simple-argument alternative
- /[^$\w]([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g; + /[^$\w]([$\w]+)\.createElement\(([$\w]+),(?:[$\w]+|\{[^}]+\}),/g;As per coding guidelines: "Use
[\$\\w]+instead of\\w+for identifier matching in regex patterns to include$for React refs."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/patchesAppliedIndication.ts` at line 97, The regex assigned to createElementPattern currently uses \w+ in the simple-argument alternative which misses identifiers starting with $; update the alternative from (?:\w+|\{[^}]+\}) to use a character class allowing $ (?:[$\w]+|\{[^}]+\}) so that createElementPattern correctly matches minified/JS identifiers with $ (adjust the same change wherever createElementPattern is defined or used).src/patches/toolsets.ts (1)
79-79:\w+:for property name matching — prefer[$\w]+:per guidelines.The
\w+:in the destructuring pattern is used to match property names likecommands:,initialFileHistorySnapshots:, etc. While these specific names won't start with$, the coding guidelines prefer[$\w]+uniformly for identifier matching.♻️ Use `[$\w]+:` for consistency with coding guidelines
- /function ([$\w]+)\(\{(?:\w+:[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+initialFileHistorySnapshots:[$\w]+,(?:\w+:[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g; + /function ([$\w]+)\(\{(?:[$\w]+:[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+initialFileHistorySnapshots:[$\w]+,(?:[$\w]+:[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g;As per coding guidelines: "Use
[\$\\w]+instead of\\w+for identifier matching in regex patterns to include$for React refs."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/toolsets.ts` at line 79, Update the regex literal that matches destructured property names to use the allowed identifier character class with dollar: replace occurrences of `\w+:` with `[$\w]+:` in the pattern `/function ([$\w]+)\(\{(?:\w+:[$\w]+(...))+initialFileHistorySnapshots:[$\w]+,(?:\w+:[$\w]+(...))+\\)/g` so all property-name matches use `[$\w]+:` (preserve the rest of the pattern and escaping exactly as in the existing regex).src/patches/helpers.ts (2)
166-167: Comment now slightly misleading after the\b→[^$\w]change.The comment on line 166 still reads
;([$\w]+)=T\(fH\(\),1\)(documenting a;prefix), but the actual pattern now accepts any[^$\w]character.♻️ Update comment
- // ;([$\w]+)=T\(fH\(\),1\) - // Pattern: ;X=moduleLoader(reactModuleBun,1) + // [^$\w]([$\w]+)=T\(fH\(\),1\) + // Pattern: <non-$\w>X=moduleLoader(reactModuleBun,1)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/helpers.ts` around lines 166 - 167, Update the misleading comment that still shows a leading semicolon `;([$\w]+)=T\(fH\(\),1\)` to reflect the actual regex change from a `\b` boundary to `[^$\w]` — e.g., mention the pattern now accepts any non-$\w character (showing `[^$\w]([$\w]+)=T\(fH\(\),1)` or equivalent description). Locate the comment near the pattern in src/patches/helpers.ts and replace the old example/comment text so it accurately documents the current regex behavior.
6-6: Residual\bin thefindChalkVarpattern.The
\bafter each method name (e.g.,cyan\b,bold\b) is redundant — the next character is always.or(, both non-word, so\bis vacuously true — but the guidelines say to avoid\bentirely due to V8 performance.♻️ Remove the redundant `\b`
- /[^$\w]([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g; + /[^$\w]([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline))+\(/g;As per coding guidelines: "Avoid
\\bin regex patterns due to V8 performance issues; use literal character alternatives."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patches/helpers.ts` at line 6, The regex assigned to findChalkVar contains residual \b tokens after each chalk method (e.g., cyan\b, bold\b); remove those \b instances and update the pattern to use literal-character checks instead (for example replace each \b with a lookahead like (?=[.(]) or simply drop them since the next char is always '.' or '(') so the regex still matches chained chalk methods without using word-boundary anchors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/patches/helpers.ts`:
- Around line 166-167: Update the misleading comment that still shows a leading
semicolon `;([$\w]+)=T\(fH\(\),1\)` to reflect the actual regex change from a
`\b` boundary to `[^$\w]` — e.g., mention the pattern now accepts any non-$\w
character (showing `[^$\w]([$\w]+)=T\(fH\(\),1)` or equivalent description).
Locate the comment near the pattern in src/patches/helpers.ts and replace the
old example/comment text so it accurately documents the current regex behavior.
- Line 6: The regex assigned to findChalkVar contains residual \b tokens after
each chalk method (e.g., cyan\b, bold\b); remove those \b instances and update
the pattern to use literal-character checks instead (for example replace each \b
with a lookahead like (?=[.(]) or simply drop them since the next char is always
'.' or '(') so the regex still matches chained chalk methods without using
word-boundary anchors.
In `@src/patches/patchesAppliedIndication.ts`:
- Line 97: The regex assigned to createElementPattern currently uses \w+ in the
simple-argument alternative which misses identifiers starting with $; update the
alternative from (?:\w+|\{[^}]+\}) to use a character class allowing $
(?:[$\w]+|\{[^}]+\}) so that createElementPattern correctly matches minified/JS
identifiers with $ (adjust the same change wherever createElementPattern is
defined or used).
In `@src/patches/toolsets.ts`:
- Line 79: Update the regex literal that matches destructured property names to
use the allowed identifier character class with dollar: replace occurrences of
`\w+:` with `[$\w]+:` in the pattern `/function
([$\w]+)\(\{(?:\w+:[$\w]+(...))+initialFileHistorySnapshots:[$\w]+,(?:\w+:[$\w]+(...))+\\)/g`
so all property-name matches use `[$\w]+:` (preserve the rest of the pattern and
escaping exactly as in the existing regex).
…l call patching typo (Piebald-AI#538)
Closes #534