feat(editor): add dotenv parser#802
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a CodeMirror StreamParser for ChangesDotenv tokenizer and integration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/modules/editor/lib/dotenv.test.ts (1)
24-68: ⚡ Quick winAdd regression for empty-value comments.
Please add a case for
KEY=#comment`` and assert#commentis `comment` (not `string`) so this edge case stays protected.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/modules/editor/lib/dotenv.test.ts` around lines 24 - 68, Add a regression test in the existing "dotenv tokenizer" suite that calls tokenizeLine with the string `KEY= `#comment`` and asserts the resulting tokens mark `#comment` as a comment (not a string); specifically add an it block (e.g., it("treats empty-value comments as comments", ...)) that expects tokenizeLine("KEY= `#comment`") toEqual [["KEY","variableName.definition"],["=","operator"],["`#comment`","comment"]]. Place this new test alongside the other it cases in the same describe so the tokenizer behavior for empty-value comments is protected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/modules/editor/lib/dotenv.ts`:
- Around line 73-77: The space-eating branch currently only sets
state.afterValueSpace when state.mode === "value" && state.valueStarted, which
misclassifies "KEY= `#comment`"; change the condition so that when
stream.eatSpace() and state.mode === "value" you set state.afterValueSpace =
true regardless of state.valueStarted (remove the valueStarted guard), so
trailing spaces after '=' correctly mark comments (update the block that
references stream.eatSpace(), state.mode, state.valueStarted and
state.afterValueSpace in src/modules/editor/lib/dotenv.ts).
---
Nitpick comments:
In `@src/modules/editor/lib/dotenv.test.ts`:
- Around line 24-68: Add a regression test in the existing "dotenv tokenizer"
suite that calls tokenizeLine with the string `KEY= `#comment`` and asserts the
resulting tokens mark `#comment` as a comment (not a string); specifically add
an it block (e.g., it("treats empty-value comments as comments", ...)) that
expects tokenizeLine("KEY= `#comment`") toEqual
[["KEY","variableName.definition"],["=","operator"],["`#comment`","comment"]].
Place this new test alongside the other it cases in the same describe so the
tokenizer behavior for empty-value comments is protected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fb095433-30ff-4674-8ce5-ded167aca526
📒 Files selected for processing (3)
src/modules/editor/lib/dotenv.test.tssrc/modules/editor/lib/dotenv.tssrc/modules/editor/lib/languageResolver.ts
What
Adds .env / dotenv syntax highlighting in the editor, including variable keys, values, comments, quoted strings, escapes, and common dotenv prefixes like export.
Why
.env files were previously rendered without language-aware highlighting, making variables and comments harder to scan.
How
Adds a lightweight CodeMirror stream parser for dotenv files and wires it into the editor language resolver. Includes regression coverage for leading # values so KEY=#hash is treated as a
value, not a comment.
Testing
Additional verification:
Screenshots / GIFs
Notes for reviewer
Summary by CodeRabbit
New Features
Tests