Skip to content

feat: add prefer-stream-pipeline rule - #539

Draft
aladdin-add with Copilot wants to merge 4 commits into
masterfrom
copilot/new-rule-prefer-stream-pipeline
Draft

feat: add prefer-stream-pipeline rule#539
aladdin-add with Copilot wants to merge 4 commits into
masterfrom
copilot/new-rule-prefer-stream-pipeline

Conversation

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown

The standard Stream#pipe() method requires manual error handling for each stream in the pipeline, which is verbose and error-prone. Node.js provides stream.pipeline() to handle error forwarding and stream cleanup automatically across the entire stream chain.

Changes

  • New Rule (prefer-stream-pipeline): Flags usages of .pipe() in CallExpression nodes, prompting developers to use pipeline from stream or stream/promises instead.
  • Documentation & Registration: Added the rule to the exported all-rules.js index, generated the corresponding Markdown documentation, and updated the README rule list.

Example

// ❌ Incorrect
createReadStream('input.txt')
  .pipe(createGzip())
  .pipe(createWriteStream('output.gz'));

// ✅ Correct
import { pipeline } from 'stream/promises';

await pipeline(
  createReadStream('input.txt'),
  createGzip(),
  createWriteStream('output.gz')
);

Copilot AI changed the title [WIP] Add rule to prefer stream.pipeline over stream.Readable#pipe feat: add prefer-stream-pipeline rule Jun 19, 2026
Copilot AI requested a review from aladdin-add June 19, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants