Skip to content

feat: add no-useless-cat rule - #10

Open
nzakas wants to merge 5 commits into
rule/no-ls-iterationfrom
rule/no-useless-cat
Open

nzakas wants to merge 5 commits into
rule/no-ls-iterationfrom
rule/no-useless-cat

Conversation

@nzakas

@nzakas nzakas commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Adds shell/no-useless-cat, which mirrors ShellCheck SC2002: cat file | cmd can be cmd < file or cmd file.

Behavior

  • Reports a pipeline whose first command is cat with exactly one static, non-flag argument and no redirects.
  • Not reported:
    • cat with several files (a real concatenation).
    • cat with flags (cat -n file | head).
    • Dynamic arguments such as cat "$f" | sort.
    • cat that isn't first in a pipeline.
  • No autofix: whether cmd < file or cmd file is right depends on the command.
  • Recommended config: "error".

Documentation

Adds docs/rules/no-useless-cat.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 (279 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 55 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: Repository: eslint/coderabbit/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 927b2d94-818d-4cf2-ae39-1ffc385e272c
📥 Commits

Reviewing files that changed from the base of the PR and between a7458b2 and f62c9b8.

📒 Files selected for processing (6)
  • README.md
  • docs/rules/no-useless-cat.md
  • src/index.spec.ts
  • src/index.ts
  • src/rules/no-useless-cat.spec.ts
  • src/rules/no-useless-cat.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-cat branch from b2375f1 to fa0ec7a Compare September 18, 2026 19:01
@nzakas
nzakas force-pushed the rule/no-useless-cat branch 2 times, most recently from 8c9275c to b9bf917 Compare September 22, 2026 20:23
@nzakas
nzakas force-pushed the rule/no-useless-cat branch from b9bf917 to c1496ac Compare September 22, 2026 20:34
@nzakas
nzakas force-pushed the rule/no-useless-cat branch from c1496ac to 6ab5a1a 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

🟡 Changes recommended

Shell expansion handling currently causes false positives for multi-file expansions and ANSI-C-quoted options.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds the recommended bash/no-useless-cat rule, modeled after ShellCheck SC2002.

Changes:

  • Implements and registers the rule.
  • Adds rule and plugin tests.
  • Adds documentation and README metadata.
File Description
src/​rules/​no-useless-cat.ts Implements pipeline detection.
src/​rules/​no-useless-cat.spec.ts Adds RuleTester cases.
src/​index.ts Registers and recommends the rule.
src/​index.spec.ts Verifies rule exposure.
README.md Adds the rules-table entry.
docs/​rules/​no-useless-cat.md Documents behavior and examples.

💡 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-cat.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 checks for unquoted glob/brace patterns and ANSI-C-quoted arguments, with regression tests. Committed as 9312963.

@nzakas
nzakas force-pushed the rule/no-useless-cat branch from 9312963 to 2469abc Compare October 1, 2026 18:07
@nzakas
nzakas force-pushed the rule/no-useless-cat branch 2 times, most recently from 9f3bd79 to cade9ff Compare October 2, 2026 16:18
@nzakas
nzakas force-pushed the rule/no-useless-cat branch 2 times, most recently from 0c227e0 to e983fb2 Compare October 6, 2026 19:26
@nzakas
nzakas force-pushed the rule/no-useless-cat branch 2 times, most recently from 5844ce2 to 203d0c8 Compare October 8, 2026 19:46
nzakas and others added 5 commits October 8, 2026 16:49
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>
@nzakas
nzakas force-pushed the rule/no-useless-cat branch from 203d0c8 to f62c9b8 Compare October 8, 2026 20:51
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