Skip to content

feat(eslint): enforce explicit return type #247

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

Merged
merged 2 commits into from
Apr 11, 2025
Merged

Conversation

mheob
Copy link
Owner

@mheob mheob commented Apr 11, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a rule enforcing explicit return types to boost code consistency.
  • Chores

    • Upgraded various dependencies and updated the package manager for enhanced performance and stability.
  • Refactor

    • Streamlined configuration and import handling to simplify project setup.

mheob added 2 commits April 11, 2025 14:58
Refactors code for better readability and maintainability by:
- Using the `path` module consistently

Updates eslint configuration:
- Disables explicit return type for tsx files
- Enforces explicit return types for functions and methods
@mheob mheob added dependencies Pull requests that update a dependency file eslint Belongs to ESLint config labels Apr 11, 2025
Copy link

height bot commented Apr 11, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

Copy link

changeset-bot bot commented Apr 11, 2025

🦋 Changeset detected

Latest commit: 5ae9f7a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@mheob/eslint-config Minor

Not sure what this means? Click here to learn what changesets are.

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

Copy link

vercel bot commented Apr 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eslint-config ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 11, 2025 0:59am

Copy link

coderabbitai bot commented Apr 11, 2025

Walkthrough

This pull request introduces several configuration and dependency updates. Two new changeset files have been added for patch and minor updates of the @mheob/eslint-config package—one of which specifies an explicit return type enforcement rule. The commitlint configuration now standardizes path imports, and type annotations have been added to key functions. Updates in the root and workspace configuration files adjust several dependency versions. Additionally, the ESLint configuration package gains new rule entries: one disables the explicit return type rule for JSX files and another enforces explicit return types for TypeScript files.

Changes

File(s) Change Summary
.changeset/smooth-dolls-live.md
.changeset/social-rabbits-count.md
Introduced new changeset files for dependency updates on @mheob/eslint-config. One file specifies a patch update while the other details a minor update and enforces explicit return types.
commitlint.config.js Modified import statements by replacing individual imports with a single path import from node:path and updating the usage of dirname and resolve accordingly.
package.json Updated dependency versions: @types/node from ^22.13.17 to ^22.14.0, turbo from ^2.4.4 to ^2.5.0, and upgraded the package manager version from [email protected] to [email protected].
packages/commitlint-config/src/index.ts Added explicit return type annotations to functions (getPackagesFromPath, getScopes, and getIssue) to improve type safety.
packages/eslint-config/package.json Updated multiple ESLint-related dependency versions (e.g., @clack/prompts, @typescript-eslint/eslint-plugin, eslint-config-next, etc.) for maintenance and compatibility.
packages/eslint-config/.../disables.ts
packages/eslint-config/.../globs.ts
Added a new configuration entry targeting JSX files by introducing GLOB_TSX and disabling the ts/explicit-function-return-type rule for these files.
packages/eslint-config/.../typescript.ts Introduced a new rule: 'ts/explicit-function-return-type': ['error', { allowExpressions: true }], enforcing explicit function return types (with allowed expressions) for TypeScript files.
pnpm-workspace.yaml Updated dependency versions in the workspace: eslint from ^9.23.0 to ^9.24.0 and typescript from ^5.8.2 to ^5.8.3.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant ESLint
    participant ConfigLoader

    Developer->>ESLint: Run lint on codebase
    ESLint->>ConfigLoader: Load ESLint configurations (disables & typescript)
    ConfigLoader-->>ESLint: Return updated lint rules
    ESLint->>Developer: Report lint issues (e.g., explicit return type errors)
Loading
sequenceDiagram
    participant Developer
    participant CommitLint
    participant NodePath

    Developer->>CommitLint: Submit commit message
    CommitLint->>NodePath: Resolve paths using path.dirname & path.resolve
    NodePath-->>CommitLint: Return resolved paths
    CommitLint->>Developer: Validate commit message format
Loading

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.

Scope: all 2 workspace projects
Progress: resolved 0, reused 0, downloaded 1, added 0
Progress: resolved 39, reused 0, downloaded 38, added 0
/tmp/eslint/packages/eslint-config:
 ERR_PNPM_WORKSPACE_PKG_NOT_FOUND  In packages/eslint-config: "@mheob/tsconfig@workspace:*" is in the dependencies but no package named "@mheob/tsconfig" is present in the workspace

This error happened while installing a direct dependency of /tmp/eslint/packages/eslint-config

Packages found in the workspace:

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 999e0fe and 5ae9f7a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • .changeset/smooth-dolls-live.md (1 hunks)
  • .changeset/social-rabbits-count.md (1 hunks)
  • commitlint.config.js (1 hunks)
  • package.json (2 hunks)
  • packages/commitlint-config/src/index.ts (3 hunks)
  • packages/eslint-config/package.json (3 hunks)
  • packages/eslint-config/src/configs/disables.ts (2 hunks)
  • packages/eslint-config/src/configs/typescript.ts (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/eslint-config/src/configs/disables.ts (1)
packages/eslint-config/src/globs.ts (1)
  • GLOB_TSX (8-8)
🔇 Additional comments (19)
.changeset/smooth-dolls-live.md (1)

1-6: LGTM! Good use of changesets for dependency updates.

The changeset file correctly specifies a patch update for @mheob/eslint-config with a clear description of the update purpose. This follows the semantic versioning standard where dependency updates are handled as patch changes.

.changeset/social-rabbits-count.md (1)

1-6: LGTM! Appropriate version bump for enforcing explicit return types.

The changeset correctly specifies a minor version update for @mheob/eslint-config as the new rule enforcement would be considered a feature addition. The description clearly communicates the intent of the change.

commitlint.config.js (1)

2-2: Standardizing path imports looks good.

The change to import the full path module rather than destructuring individual methods is a good practice for Node.js standard library modules. The adjustments to use path.dirname and path.resolve have been made consistently throughout the file.

Also applies to: 7-7, 11-11

pnpm-workspace.yaml (1)

4-4: LGTM! Dependency version updates look good.

The updates to ESLint (^9.23.0 → ^9.24.0) and TypeScript (^5.8.2 → ^5.8.3) versions are minor increments that should provide bug fixes and new features without breaking changes.

Also applies to: 6-6

package.json (1)

36-36: Dependencies updated to newer versions

The update of Node types, Turbo, and PNPM package manager to newer versions looks good. These are routine dependency updates that should provide bug fixes and new features from the respective packages.

Also applies to: 45-45, 48-48

packages/eslint-config/src/configs/disables.ts (2)

1-1: Import updated correctly

The GLOB_TSX import has been added to support the new rule configuration.


56-62: Good exemption for JSX files

This is a sensible addition to disable explicit return types for TSX files. React components often have implicit JSX return types that would be verbose and unnecessary to type explicitly.

packages/eslint-config/src/configs/typescript.ts (1)

126-126: Core feature implemented correctly

The rule to enforce explicit function return types is properly configured with allowExpressions: true, which is a good balance - it requires explicit typing for named functions while not being overly strict with arrow function expressions.

packages/commitlint-config/src/index.ts (1)

16-16: Return types added appropriately

Return type annotations have been correctly added to all utility functions, matching the actual values being returned. This brings the code into compliance with the new ESLint rule being implemented.

Also applies to: 34-34, 47-47

packages/eslint-config/package.json (10)

37-37: Update Dependency: @clack/prompts
The version for @clack/prompts has been bumped to ^0.10.1. This minor upgrade appears standard; please ensure that any functionality relying on this package continues to work as expected.


39-41: Update Dependencies: TypeScript ESLint Packages & Vitest ESLint Plugin
The versions for @typescript-eslint/eslint-plugin and @typescript-eslint/parser have been updated to ^8.29.1 and @vitest/eslint-plugin to ^1.1.42. These updates should align with recent improvements and fixes. Verify that the new versions work well with your explicit return type enforcement and that there are no conflicts with your ESLint rules.


43-44: Update ESLint Configurations for Next & Prettier
Both eslint-config-next and eslint-config-prettier have been bumped to ^15.3.0 and ^10.1.2 respectively. These bumps are in line with maintaining up-to-date configurations. Please confirm that the upgraded versions do not inadvertently override any of the explicit return type rules you plan to enforce.


49-49: Update Dependency: eslint-plugin-import-x
The version has been updated to ^4.10.2. This is a straightforward minor version bump; ensure that this version continues to support any import-related rules in your ESLint setup.


56-56: Update Dependency: eslint-plugin-prettier
The dependency eslint-plugin-prettier is now at ^5.2.6. This update should help keep formatting consistent with Prettier; confirm that it works smoothly with the overall ESLint configuration, especially with the new explicit return type rules.


68-68: Update Dependency: svelte
The svelte dependency has been upgraded to ^5.25.12. Make sure that this version is fully compatible with your linting rules and that any Svelte-specific ESLint configurations are revisited if necessary.


70-70: Update Dependency: vue-eslint-parser
Bumping vue-eslint-parser to ^10.1.3 should provide improved parsing for Vue files. Verify that this version works correctly with your ESLint setup and that it does not conflict with any React or TypeScript rules in the configuration.


75-75: Update Dev Dependency: @eslint-react/eslint-plugin
The package @eslint-react/eslint-plugin has been updated to ^1.45.0. Ensure that this update maintains compatibility with your React linting rules and the new explicit return type enforcement where applicable.


84-84: Update Dev Dependency: eslint-plugin-svelte
eslint-plugin-svelte has been updated to ^3.5.1. This minor version bump should help with Svelte file linting consistency; confirm that the new version correctly integrates with the rest of your ESLint config.


89-89: Update Dev Dependency: svelte-eslint-parser
The developer dependency svelte-eslint-parser is now at ^1.1.2. Please verify that this update is aligned with any adjustments or new rules (such as enforcing explicit return types) in your ESLint configuration for Svelte files.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

@kodiakhq kodiakhq bot merged commit 237c11c into main Apr 11, 2025
10 checks passed
@kodiakhq kodiakhq bot deleted the force-explicit-return-type branch April 11, 2025 13:03
kodiakhq bot pushed a commit that referenced this pull request Apr 11, 2025
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.


# Releases
## @mheob/[email protected]

### Minor Changes

-   [#247](#247) ([@mheob](https://github.com/mheob)): enforce explicit return type

### Patch Changes

-   [#247](#247) ([@mheob](https://github.com/mheob)): update dependencies




## Summary by CodeRabbit

- **New Features**
	- Updated the ESLint configuration package to version 8.6.0.
	- Introduced enhancements that improve dependency management and enforce explicit return types for better code quality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file eslint Belongs to ESLint config
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant