Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fx: no ignored replay buffer rule does not check supplied config for buffer size #39

Conversation

DaveMBush
Copy link
Owner

@DaveMBush DaveMBush commented Jan 5, 2025

Issue Number: #37

Body

Now fails on config files that have no bufferSize

Summary by CodeRabbit

  • Documentation

    • Updated documentation for the no-ignored-replay-buffer ESLint rule
    • Added code examples demonstrating correct and incorrect usage of shareReplay
  • New Features

    • Enhanced ESLint rule to validate bufferSize configuration in shareReplay function calls
    • Improved linting process for RxJS replay buffer implementations
  • Tests

    • Added new test cases for shareReplay configuration scenarios
    • Expanded test coverage for the ESLint rule

Copy link

coderabbitai bot commented Jan 5, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/eslint-plugin-rxjs/src/lib/rules/no-ignored-replay-buffer.ts

Oops! Something went wrong! :(

ESLint: 9.17.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

Walkthrough

The pull request enhances the no-ignored-replay-buffer ESLint rule for RxJS by improving its ability to detect and warn about replay buffer configurations. The changes focus on adding more comprehensive checks for shareReplay and publishReplay function calls, specifically ensuring that a bufferSize is explicitly specified when using these operators. The documentation is also updated with clearer examples to illustrate correct and incorrect usage.

Changes

File Change Summary
packages/eslint-plugin-rxjs/docs/rules/no-ignored-replay-buffer.md Added new code examples demonstrating correct and incorrect usage of shareReplay with buffer configuration
packages/eslint-plugin-rxjs/src/lib/rules/no-ignored-replay-buffer.ts Added checkShareReplayConfig function to validate bufferSize in shareReplay configuration objects; updated node checking logic
packages/eslint-plugin-rxjs/src/lib/tests/rules/no-ignored-replay-buffer.spec.ts Added new test cases for shareReplay with configuration options, covering both valid and invalid scenarios

Possibly related issues

  • DaveMBush/eslint-plugin-rxjs#37: The changes directly address this issue by adding checks for bufferSize in shareReplay configuration objects, which was the specific problem reported in the issue.

Poem

🐰 Hop, hop, ESLint's got a new trick!
Replay buffers now checked with a click
No more ignored configs so sly
Our RxJS code now flies high
A linting rabbit's delight! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

nx-cloud bot commented Jan 5, 2025

View your CI Pipeline Execution ↗ for commit 5a58c4e.

Command Status Duration Result
nx affected -t lint test build ✅ Succeeded 1m 46s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-05 22:13:44 UTC

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/eslint-plugin-rxjs/src/lib/rules/no-ignored-replay-buffer.ts (1)

56-61: Selective check for object-based shareReplay configuration.
This logic efficiently handles scenarios with a single config object. If you want to support multiple arguments (e.g. shareReplay(1, someScheduler)), consider extending this logic.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17532e3 and 5a58c4e.

📒 Files selected for processing (3)
  • packages/eslint-plugin-rxjs/docs/rules/no-ignored-replay-buffer.md (2 hunks)
  • packages/eslint-plugin-rxjs/src/lib/rules/no-ignored-replay-buffer.ts (2 hunks)
  • packages/eslint-plugin-rxjs/src/lib/tests/rules/no-ignored-replay-buffer.spec.ts (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: main
🔇 Additional comments (22)
packages/eslint-plugin-rxjs/src/lib/rules/no-ignored-replay-buffer.ts (11)

1-1: No issues with the updated import statement.


5-7: References and acknowledgments look good.
Comments referencing external sources do not raise any issues.


26-43: Solid check for 'bufferSize' in shareReplay configuration.
This function correctly enforces the presence of the bufferSize property. If you'd like to enforce additional constraints, such as restricting bufferSize to positive integers, consider adding further checks.


44-44: No concerns.
A blank line added for readability is fine.


46-47: New parameter types are correctly declared.


51-51: Robust error reporting for zero-arg usage.
Reporting is appropriately triggered if no arguments are passed.


55-55: Blank line for logical separation.
No issues here.


68-68: Correct usage of the parent node for ReplaySubject.


74-75: Extends the same approach for replay usage in a MemberExpression.


81-81: Ensures publishReplay or shareReplay calls are also handled.


84-89: Consistent coverage for namespaced publishReplay/shareReplay.
This ensures the rule won’t miss prefixed or namespaced usage.

packages/eslint-plugin-rxjs/src/lib/tests/rules/no-ignored-replay-buffer.spec.ts (6)

29-33: Positive test with shareReplay config.
Well-structured valid case verifying bufferSize presence.


55-60: Namespaced valid test for shareReplay config.
Helps confirm the rule remains robust under different import patterns.


72-76: Additional valid coverage for shareReplay config.
Reinforces consistent passing scenarios.


122-131: Invalid test ensures missing bufferSize is caught.
This effectively validates the newly added logic.


132-141: Further invalid case for missing bufferSize, strengthening coverage.


185-194: Namespaced shareReplay invalid test.
Adds valuable coverage for namespaced usage without bufferSize.

packages/eslint-plugin-rxjs/docs/rules/no-ignored-replay-buffer.md (5)

14-17: Helpful incorrect code example.
Demonstrates the absence of bufferSize in shareReplay configuration clearly.


18-18: Blank line is fine.


31-34: Clear correct code example.
Showcases the recommended approach using bufferSize.


35-35: Blank line for formatting.


38-38: Reiterates no options for the rule.
No changes needed.

@DaveMBush DaveMBush merged commit d0032b1 into main Jan 5, 2025
3 checks passed
@DaveMBush DaveMBush deleted the dmb/no-ignored-replay-buffer-rule-does-not-check-supplied-config-for-buffer-size/37 branch January 5, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

no-ignored-replay-buffer rule does not check supplied config for buffer size
1 participant