[codex] harden formatter regex replacements#208
Conversation
|
Moved this out of draft after pushing follow-up commit Validation after the follow-up:
Wide test note: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2c3e42d24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| endIndex = output.indexOf(`"'`, endIndex); | ||
| if (endIndex === -1) break; | ||
| if (output[endIndex - 1] !== "\\") break; |
There was a problem hiding this comment.
Prevent quoted-literal scan from spanning across newlines
The new replaceQuotedStringLiteralTypes scanner searches for the closing "' with indexOf and never stops at \n, so it now matches across line boundaries where the previous regex did not. In any multi-line diagnostic that contains '" on one line and "' later, this rule can consume unrelated lines into one replacement and also drop the next character via matchEnd + 1, which corrupts the rendered message rather than just formatting one literal.
Useful? React with 👍 / 👎.
| { | ||
| pattern: | ||
| /(module|file|file name|imported via) ['"“](.*?)['"“](?=[\s(.|,]|$)/gi, | ||
| /(module|file|file name|imported via) ['"“]([^'"“”\r\n]*)['"“](?=[\s(.|,]|$)/gi, |
There was a problem hiding this comment.
Allow apostrophes in quoted module/file names
This character class now forbids ' inside the captured module/file name, so diagnostics like module "C:/Users/O'Connor/project/file.ts" no longer match this formatting rule at all. The previous (.*?) pattern handled apostrophes when the outer quotes were double quotes; this change drops that common path-name case and regresses formatting for valid TypeScript messages.
Useful? React with 👍 / 👎.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Pushed follow-up commit
Validation after the follow-up:
|
Summary
Fixes #187
Validation
npm run build --workspace @pretty-ts-errors/utilsnpm run test --workspace @pretty-ts-errors/formatternpm run lint --workspace @pretty-ts-errors/formatternpm run build --workspace @pretty-ts-errors/formatternpm run test --workspace @pretty-ts-errors/vscode-formatternpx prettier --check packages/formatter/src/addMissingParentheses.ts packages/formatter/test/formatter.vitest.tsgit diff --checkNotes
xvfb-run -a npm test; formatter and vscode-formatter Vitest suites passed and the extension pretest compiled/linted, but the local VS Code 1.77 Electron integration harness exited with X connection/GPU errors under Xvfb.Prepared with OpenAI Codex.