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)
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 |
c7d54bf to
ec12388
Compare
d5e2840 to
506c93a
Compare
506c93a to
6371159
Compare
6371159 to
9c3d0e5
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Several valid Bash read/write contexts are misclassified, producing both false positives and false negatives.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds the recommended bash/no-unused-vars rule with documentation and tests.
Changes:
- Implements file-wide variable read/write tracking.
- Registers the rule in the plugin and recommended configuration.
- Adds rule documentation, options, and test coverage.
| File | Description |
|---|---|
src/rules/no-unused-vars.ts |
Implements unused-variable analysis. |
src/rules/no-unused-vars.spec.ts |
Tests core rule behavior. |
src/index.ts |
Registers and enables the rule. |
src/index.spec.ts |
Verifies rule exposure. |
README.md |
Documents the rule and option. |
docs/rules/no-unused-vars.md |
Adds detailed rule documentation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot address the review comment. Be sure to add tests. |
Addressed in d2a28ce, with tests for each case:
I also updated the docs. |
d2a28ce to
0a6d0d9
Compare
|
/easycla |
35512c5 to
cdabef0
Compare
cdabef0 to
b68b241
Compare
1fd3372 to
fad280b
Compare
fad280b to
92da739
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>
92da739 to
17c3d55
Compare
| const SPECIAL_VARIABLES = new Set([ | ||
| "BASH_ENV", | ||
| "CDPATH", | ||
| "EDITOR", | ||
| "ENV", | ||
| "GLOBIGNORE", | ||
| "HISTCONTROL", | ||
| "HISTFILE", | ||
| "HISTFILESIZE", | ||
| "HISTSIZE", | ||
| "HOME", | ||
| "IFS", | ||
| "LANG", | ||
| "LD_LIBRARY_PATH", | ||
| "OPTARG", | ||
| "OPTERR", | ||
| "OPTIND", | ||
| "PAGER", | ||
| "PATH", | ||
| "PROMPT_COMMAND", | ||
| "PS1", | ||
| "PS2", | ||
| "PS3", | ||
| "PS4", | ||
| "REPLY", | ||
| "TERM", | ||
| "TMOUT", | ||
| "TZ", | ||
| "VISUAL", | ||
| ]); |
There was a problem hiding this comment.
A note that ShellCheck has a more comprehensive list of special variables: https://github.com/koalaman/shellcheck/blob/61ceb720d121fb448b4e98bc10a14b756ac4da8c/src/ShellCheck/Data.hs#L27-L70

Adds
shell/no-unused-vars, which mirrors ShellCheck SC2034: variables that are assigned but never read.Behavior
Writes tracked:
declare/local/typesetandarr[i]=;forloop variables;read,mapfile, andreadarray(skippingreadflags that take an argument, like-p prompt);getoptsvariable;(( total = 1 + 2 )),x++).Reads tracked:
$varor${...}expansion;$((x + 1)));unset,export, andreadonly;exportordeclare -x);FOO=1 cmd), which are passed to the command.Never reported:
_;IFS,PS1,PATH,OPTIND,REPLY,LC_*, and others);{ "allowed": ["NAME"] }.Skipped files: if the file uses
eval,source/., or a nameref (declare -n/nameref), the rule reports nothing, since variables can then be read in ways static analysis can't see.Other details:
allowed), and this PR adds the README's "Rule options" section for it."error".Known limitations
local xinside a function isn't reported if some otherxis read elsewhere in the file.${!ref}counts as a read ofrefonly, not of the variable it points to.Documentation
Adds
docs/rules/no-unused-vars.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
23 RuleTester cases and 5 documentation checks (374 total); build, lint, and format checks pass.
🤖 Generated with Claude Code
Stack created with GitHub Stacks CLI • Give Feedback 💬