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

style(eslint-config): enforce consistent brace style and control stat… #2992

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

shanegrouber
Copy link
Collaborator

@shanegrouber shanegrouber commented Jan 27, 2025

  • Add ESLint rules for curly braces, brace style, and newline positioning
  • Optimize object curly brace newline consistency

(your code spacing is more inconsistent than a taco truck's salsa recipe)

Summary by CodeRabbit

Based on the comprehensive summary, here are the release notes:

  • Style

    • Added consistent code formatting across multiple services
    • Improved readability by adding explicit braces to conditional statements
    • Enhanced code structure with more consistent control flow
  • Chores

    • Removed unused import statements from various files
    • Simplified dependencies in multiple services
    • Cleaned up unnecessary type imports
  • Refactor

    • Minor improvements to error handling and control flow in workflow and service methods
    • Standardized code formatting across different components

No significant functional changes or new features were introduced in this set of modifications.

…ements

- Add ESLint rules for curly braces, brace style, and newline positioning
- Optimize object curly brace newline consistency

(your code spacing is more inconsistent than a taco truck's salsa recipe)
Copy link

changeset-bot bot commented Jan 27, 2025

⚠️ No Changeset found

Latest commit: c1b1c1a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Jan 27, 2025

Walkthrough

This pull request introduces a comprehensive set of ESLint configuration updates and code formatting changes across multiple services in the workflows service. The primary focus is on enhancing code readability and consistency by enforcing stricter formatting rules, particularly around the use of curly braces for control statements. The changes span numerous files, systematically adding explicit block statements and improving the clarity of conditional logic without altering the underlying functionality.

Changes

File/Path Change Summary
packages/eslint-config/index.js Added ESLint rules for curly, brace-style, nonblock-statement-body-position, and object-curly-newline
services/workflows-service/src/*/ Multiple files modified to use explicit block statements with curly braces
Various service files Removed unused imports like AnyRecord, UseCustomerAuthGuard, PageDto

Sequence Diagram

sequenceDiagram
    participant Developer
    participant ESLintConfig
    participant CodeBase
    
    Developer->>ESLintConfig: Add new formatting rules
    ESLintConfig->>CodeBase: Enforce curly brace usage
    CodeBase-->>Developer: Improved code readability
Loading

Possibly related PRs

Suggested Reviewers

  • alonp99
  • tomer-shvadron

Poem

🐰 Curly Braces, Oh So Fine!
Wrapping logic, line by line
Code now dances with such grace
ESLint rules set the pace
Readability's new design! 🎨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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
Contributor

@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 (2)
services/workflows-service/src/events/get-webhooks.ts (1)

Line range hint 14-19: Consider improving type safety and documentation.

While the formatting changes look good, here are some suggestions to further improve the code:

  1. Consider extracting the subscription type to improve readability:
type Subscription = TCustomerSubscription['subscriptions'][number];
type Subscriptions = Array<Subscription>;

export const mergeSubscriptions = (
  customerSubscriptions: Subscriptions,
  workflowSubscriptions: Subscriptions,
): Subscriptions => {
  1. Add JSDoc comments to document the merging behavior:
/**
 * Merges workflow and customer subscriptions with special handling:
 * - Returns customer subscriptions if workflow subscriptions are empty
 * - Returns workflow subscriptions if customer subscriptions are empty
 * - Filters out customer subscription events that exist in workflow subscriptions
 * 
 * @param customerSubscriptions - Array of customer-specific subscriptions
 * @param workflowSubscriptions - Array of workflow-specific subscriptions
 * @returns Merged array of subscriptions with duplicates handled
 */
packages/eslint-config/index.js (1)

39-42: LGTM! Well-chosen ESLint rules for consistent formatting.

The added rules effectively enforce consistent brace style and control statement formatting:

  • curly: ['error', 'all'] prevents ambiguous single-line control statements
  • brace-style ensures uniform brace placement
  • nonblock-statement-body-position improves readability
  • object-curly-newline maintains consistent object formatting

Consider adding @typescript-eslint/brace-style instead of brace-style for better TypeScript support:

-    'brace-style': ['error', '1tbs', { allowSingleLine: false }],
+    '@typescript-eslint/brace-style': ['error', '1tbs', { allowSingleLine: false }],
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3dc144c and 1513024.

📒 Files selected for processing (36)
  • packages/eslint-config/index.js (1 hunks)
  • services/workflows-service/plugins/verify-repository-project-scoped/verify-repository-project-scoped.rule.js (1 hunks)
  • services/workflows-service/src/alert/alert.controller.external.ts (1 hunks)
  • services/workflows-service/src/alert/alert.service.ts (0 hunks)
  • services/workflows-service/src/alert/dtos/get-alerts.dto.ts (1 hunks)
  • services/workflows-service/src/auth/auth.service.ts (1 hunks)
  • services/workflows-service/src/auth/session-serializer.ts (1 hunks)
  • services/workflows-service/src/case-management/case-management.service.ts (1 hunks)
  • services/workflows-service/src/collection-flow/collection-flow.service.ts (1 hunks)
  • services/workflows-service/src/collection-flow/controllers/collection-flow.controller.ts (1 hunks)
  • services/workflows-service/src/collection-flow/workflow-adapter.manager.ts (1 hunks)
  • services/workflows-service/src/common/filters/prisma-client-validation-filter/utils/parsers/invalid-argument-parser/invalid-argument.parser.ts (1 hunks)
  • services/workflows-service/src/common/filters/prisma-client-validation-filter/utils/parsers/parser/IParser.ts (1 hunks)
  • services/workflows-service/src/common/filters/prisma-client-validation-filter/utils/parsers/unknown-argument-parser/unknown-argument-parser.ts (1 hunks)
  • services/workflows-service/src/common/get-file-extension/get-file-extension.ts (1 hunks)
  • services/workflows-service/src/common/middlewares/user-session-audit.middleware.ts (1 hunks)
  • services/workflows-service/src/common/utils/bytes.ts (1 hunks)
  • services/workflows-service/src/common/utils/log-document-without-id/log-document-without-id.ts (1 hunks)
  • services/workflows-service/src/customer/customer.controller.external.ts (1 hunks)
  • services/workflows-service/src/customer/customer.controller.internal.ts (1 hunks)
  • services/workflows-service/src/customer/customer.repository.ts (1 hunks)
  • services/workflows-service/src/events/get-webhooks.ts (1 hunks)
  • services/workflows-service/src/filter/filter.controller.external.ts (0 hunks)
  • services/workflows-service/src/metrics/repository/metrics.repository.ts (1 hunks)
  • services/workflows-service/src/storage/storage.service.ts (1 hunks)
  • services/workflows-service/src/test/db-setup.ts (2 hunks)
  • services/workflows-service/src/test/db-teardown.ts (1 hunks)
  • services/workflows-service/src/transaction/transaction.controller.external.intg.test.ts (0 hunks)
  • services/workflows-service/src/transaction/transaction.repository.ts (0 hunks)
  • services/workflows-service/src/ui-definition/ui-definition.service.ts (1 hunks)
  • services/workflows-service/src/ui-definition/utils/schema-utils/countries.ts (1 hunks)
  • services/workflows-service/src/workflow-defintion/workflow-definition.repository.ts (1 hunks)
  • services/workflows-service/src/workflow/hook-callback-handler.service.ts (2 hunks)
  • services/workflows-service/src/workflow/update-documents.ts (1 hunks)
  • services/workflows-service/src/workflow/utils/add-properties-schema-to-document.ts (1 hunks)
  • services/workflows-service/src/workflow/workflow.service.ts (9 hunks)
💤 Files with no reviewable changes (4)
  • services/workflows-service/src/transaction/transaction.repository.ts
  • services/workflows-service/src/filter/filter.controller.external.ts
  • services/workflows-service/src/alert/alert.service.ts
  • services/workflows-service/src/transaction/transaction.controller.external.intg.test.ts
✅ Files skipped from review due to trivial changes (22)
  • services/workflows-service/src/auth/auth.service.ts
  • services/workflows-service/src/test/db-teardown.ts
  • services/workflows-service/src/common/filters/prisma-client-validation-filter/utils/parsers/parser/IParser.ts
  • services/workflows-service/src/collection-flow/collection-flow.service.ts
  • services/workflows-service/src/case-management/case-management.service.ts
  • services/workflows-service/src/collection-flow/workflow-adapter.manager.ts
  • services/workflows-service/src/alert/alert.controller.external.ts
  • services/workflows-service/src/common/filters/prisma-client-validation-filter/utils/parsers/invalid-argument-parser/invalid-argument.parser.ts
  • services/workflows-service/src/test/db-setup.ts
  • services/workflows-service/src/alert/dtos/get-alerts.dto.ts
  • services/workflows-service/src/customer/customer.controller.internal.ts
  • services/workflows-service/src/common/filters/prisma-client-validation-filter/utils/parsers/unknown-argument-parser/unknown-argument-parser.ts
  • services/workflows-service/src/common/utils/log-document-without-id/log-document-without-id.ts
  • services/workflows-service/src/common/utils/bytes.ts
  • services/workflows-service/src/collection-flow/controllers/collection-flow.controller.ts
  • services/workflows-service/src/common/middlewares/user-session-audit.middleware.ts
  • services/workflows-service/src/ui-definition/ui-definition.service.ts
  • services/workflows-service/src/storage/storage.service.ts
  • services/workflows-service/src/workflow/hook-callback-handler.service.ts
  • services/workflows-service/src/metrics/repository/metrics.repository.ts
  • services/workflows-service/src/workflow/workflow.service.ts
  • services/workflows-service/src/common/get-file-extension/get-file-extension.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: test_windows
  • GitHub Check: test_linux
  • GitHub Check: build (windows-latest)
🔇 Additional comments (9)
services/workflows-service/src/ui-definition/utils/schema-utils/countries.ts (1)

268-270: LGTM! The changes align with the PR objectives.

The addition of explicit braces for the if statement improves code readability and maintains consistent style across the codebase.

services/workflows-service/src/auth/session-serializer.ts (1)

64-66: LGTM! The brace style changes improve readability.

The addition of explicit braces for the if block aligns with the PR's objective of enforcing consistent brace styles. This change enhances code clarity without altering the underlying error handling logic.

services/workflows-service/src/events/get-webhooks.ts (1)

20-26: LGTM! Clean and consistent formatting.

The addition of braces improves readability while maintaining the existing logic. The null coalescing operator is used appropriately for handling undefined values.

services/workflows-service/src/workflow/update-documents.ts (1)

18-20: LGTM! Consistent brace style applied.

The addition of braces to the early return statement improves code consistency and readability.

services/workflows-service/src/workflow/utils/add-properties-schema-to-document.ts (1)

17-19: LGTM! Improved readability of complex condition.

The addition of braces clarifies the scope of the return statement in a complex conditional check.

services/workflows-service/src/customer/customer.repository.ts (1)

18-20: LGTM! Consistent error handling style.

The addition of braces to all conditional statements in validateApiKey improves readability and maintains consistent error handling style.

Also applies to: 22-24, 28-30

services/workflows-service/src/workflow-defintion/workflow-definition.repository.ts (1)

162-162: LGTM! Improved readability with better code segmentation.

The added newline helps separate the validation logic from the deletion operation, making the code more readable while maintaining the existing functionality.

services/workflows-service/plugins/verify-repository-project-scoped/verify-repository-project-scoped.rule.js (1)

22-24: LGTM! Consistent brace style improves readability.

The addition of braces around the early returns aligns with the PR objective and makes the control flow more explicit.

Also applies to: 30-32

services/workflows-service/src/customer/customer.controller.external.ts (1)

55-57: LGTM! Consistent error handling style.

The addition of braces around the throw statement aligns with the PR objective and makes the error handling more explicit.

@shanegrouber shanegrouber enabled auto-merge (squash) January 29, 2025 13:56
@tomer-shvadron tomer-shvadron merged commit 11ad58f into dev Jan 29, 2025
17 of 18 checks passed
@tomer-shvadron tomer-shvadron deleted the BAL-3309 branch January 29, 2025 14:22
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