Skip to content

feat: add no-useless-echo rule - #8

Open
nzakas wants to merge 3 commits into
rule/no-unquoted-expansionsfrom
rule/no-useless-echo
Open

nzakas wants to merge 3 commits into
rule/no-unquoted-expansionsfrom
rule/no-useless-echo

Conversation

@nzakas

@nzakas nzakas commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Adds shell/no-useless-echo, which mirrors ShellCheck SC2116: cmd $(echo foo) is just cmd foo.

Behavior

  • Reports a command substitution ($(...) or backticks) whose body is exactly one echo command, not negated and with no redirects.
  • The check doesn't look at echo's arguments, so $(echo -n foo) is reported too.
  • Not reported: substitutions with more than one statement ($(echo a; echo b)), pipelines ($(echo foo | tr a-z A-Z)), or redirected echoes.
  • No autofix: removing the substitution can change quoting and word splitting.
  • Recommended config: "error".

Documentation

Adds docs/rules/no-useless-echo.md, following the format of the @eslint/json, @eslint/css, and @eslint/markdown rule docs: description, background, rule details with incorrect and correct examples, options, when not to use it, and the ShellCheck reference. The rule's meta.docs.url points at that file, and its README table entry links to it.

Testing

8 RuleTester cases and 5 documentation checks (233 total); build, lint, and format checks pass.

🤖 Generated with Claude Code


Stack created with GitHub Stacks CLI • Give Feedback 💬

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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 31 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7e662514-01fc-4832-b706-af89076f6026
📥 Commits

Reviewing files that changed from the base of the PR and between ff13b63 and f572af5.

📒 Files selected for processing (6)
  • README.md
  • docs/rules/no-useless-echo.md
  • src/index.spec.ts
  • src/index.ts
  • src/rules/no-useless-echo.spec.ts
  • src/rules/no-useless-echo.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nzakas
nzakas added this pull request to stack #16 September 18, 2026 15:00
@nzakas
nzakas marked this pull request as ready for review September 18, 2026 15:01
@nzakas
nzakas force-pushed the rule/no-useless-echo branch 2 times, most recently from e851aa8 to 8fa190d Compare September 22, 2026 19:56
@nzakas
nzakas force-pushed the rule/no-useless-echo branch from 8fa190d to b109771 Compare September 22, 2026 20:23
@nzakas
nzakas force-pushed the rule/no-useless-echo branch 2 times, most recently from 995a047 to 389b27d Compare September 22, 2026 21:21
@nzakas
nzakas requested a balanced review from Copilot September 28, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation and integration are sound; only a minor test-coverage gap remains.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Adds a ShellCheck-inspired rule detecting redundant echo command substitutions.

Changes:

  • Implements and tests bash/no-useless-echo.
  • Enables the rule in the recommended configuration.
  • Adds rule documentation and README registration.
File Description
src/​rules/​no-useless-echo.ts Implements detection logic.
src/​rules/​no-useless-echo.spec.ts Adds RuleTester coverage.
src/​index.ts Registers and enables the rule.
src/​index.spec.ts Verifies rule exposure.
README.md Adds the rule to the catalog.
docs/​rules/​no-useless-echo.md Documents behavior and usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/rules/no-useless-echo.spec.ts
@nzakas

nzakas commented Sep 29, 2026

Copy link
Copy Markdown
Member Author

@copilot address review comments. Be sure to add tests.

Copilot AI commented Sep 29, 2026

Copy link
Copy Markdown

@copilot address review comments. Be sure to add tests.

Added the negated echo regression case and verified it with the targeted test suite. Commit: 7b6d5b7.

@nzakas
nzakas force-pushed the rule/no-useless-echo branch 2 times, most recently from 74ee27b to beb554a Compare October 2, 2026 16:05
@nzakas
nzakas force-pushed the rule/no-useless-echo branch from beb554a to 541faf4 Compare October 2, 2026 16:18
@nzakas
nzakas force-pushed the rule/no-useless-echo branch from 541faf4 to 80483df Compare October 6, 2026 19:09
@nzakas
nzakas force-pushed the rule/no-useless-echo branch from 80483df to 1424070 Compare October 6, 2026 19:26
nzakas and others added 3 commits October 6, 2026 15:35
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>
@nzakas
nzakas force-pushed the rule/no-useless-echo branch from 1424070 to f572af5 Compare October 6, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants