Repository navigation
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 55 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (6)
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PR adds the ChangesRequire CD Guard
Estimated code review effort: 3 (Moderate) | ~20 minutes 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 |
f6eca2c to
bd4436e
Compare
56a1409 to
b797e24
Compare
b797e24 to
334383f
Compare
334383f to
8437b3a
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Status-use detection has false positives and negatives, and the suggested guard can incorrectly terminate scripts.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds the bash/require-cd-guard rule based on ShellCheck SC2164.
Changes:
- Detects unguarded
cdcommands and offers an|| exitsuggestion. - Enables the rule in the recommended configuration.
- Adds tests and documentation.
| File | Description |
|---|---|
src/rules/require-cd-guard.ts |
Implements detection and suggestions. |
src/rules/require-cd-guard.spec.ts |
Tests rule behavior. |
src/index.ts |
Registers and enables the rule. |
src/index.spec.ts |
Verifies rule registration. |
README.md |
Adds the rule to the catalog. |
docs/rules/require-cd-guard.md |
Documents usage and behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot address review comments. Be sure to add tests. |
Updated the rule to walk enclosing logical-expression ancestors and added |
df636d5 to
abceb0a
Compare
e8aaecc to
aaebfa7
Compare
266647f to
9e108b4
Compare
9e108b4 to
5109a9b
Compare
1675915 to
8b66100
Compare
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: nzakas <38546+nzakas@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rule only listed shell/bash in meta.languages, so ESLint rejected it when used with the shell/posix or shell/mksh language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8b66100 to
fa0e219
Compare

Adds
shell/require-cd-guard, which mirrors ShellCheck SC2164: ifcdfails, the script keeps running in the wrong directory.Behavior
cdunless its exit status is used:&&or||(cd dir || exit,cd dir && make);if,while, oruntilcondition;!.cdon the right of&&is still reported.|| exit. It's a suggestion becausereturnmay be the right choice inside functions. It isn't offered when thecdhas redirects or runs in the background."error".Known limitations
set -eisn't taken into account, so scripts that rely on errexit still get reports.cdinside a subshell ((cd dir; make)) is reported too.Documentation
Adds
docs/rules/require-cd-guard.md, following the format of the@eslint/json,@eslint/css, and@eslint/markdownrule docs: description, background, rule details with incorrect and correct examples, options, when not to use it, and the ShellCheck reference. The rule'smeta.docs.urlpoints at that file, and its README table entry links to it.Testing
10 RuleTester cases, including suggestion output, and 5 documentation checks (312 total); build, lint, and format checks pass.
🤖 Generated with Claude Code
Stack created with GitHub Stacks CLI • Give Feedback 💬
Summary by CodeRabbit
New Features
cdcommands, based on ShellCheck SC2164.|| exitwhere appropriate.Documentation
Tests