Skip to content

Conversation

@ryota-murakami
Copy link
Contributor

@ryota-murakami ryota-murakami commented May 6, 2025

Summary by CodeRabbit

  • New Features

    • Introduced linting capabilities with ESLint, including configuration files and integration into the development workflow.
    • Added TypeScript support and configuration to enhance code quality and consistency.
    • Set up automated linting on pull requests and pushes via GitHub Actions.
  • Chores

    • Updated project dependencies and scripts to support linting and TypeScript.
    • Improved code formatting and import order for better readability.
  • Tests

    • Minor updates to test files for consistency and improved async handling.

- Updated .eslintrc.cjs to disable the no-unused-vars rule for test files located in tests//.js and utils//.test.js.
-
@coderabbitai
Copy link

coderabbitai bot commented May 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces ESLint and TypeScript configuration files, adds a GitHub Actions workflow for linting, and updates package.json with linting scripts and dependencies. Several files are reformatted, primarily adjusting import order and parameter naming for clarity. Minor changes are made to test files to align with linting and code style conventions.

Changes

File(s) Change Summary
.eslintignore, .eslintrc.cjs, tsconfig.json Added ESLint ignore/configuration and TypeScript configuration files.
.github/workflows/lint.yml Added GitHub Actions workflow for linting on PRs and pushes to main.
package.json Added linting scripts and ESLint/TypeScript devDependencies.
index.js Reordered imports, renamed unused parameter in gitExtension, and removed obsolete comments.
tests/index.test.js, tests/setup.js, utils/sanitizeCommitMessage.test.js, vitest.config.js Reordered imports and/or added blank lines for formatting and readability.
tests/setup-mocks.js Renamed unused parameters in mocks and updated error variable in catch block.
tests/utils/mocks.js Changed returned mock function from synchronous to asynchronous in mockUserInput.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub
    participant ActionsRunner
    participant ESLint

    Developer->>GitHub: Push or PR to main
    GitHub->>ActionsRunner: Trigger lint workflow
    ActionsRunner->>ActionsRunner: Checkout code
    ActionsRunner->>ActionsRunner: Prepare environment (.github/actions/prepare)
    ActionsRunner->>ESLint: Run pnpm lint
    ESLint-->>ActionsRunner: Lint results
    ActionsRunner-->>GitHub: Report status
Loading

Poem

In the warren, code is neat,
With ESLint’s hop and TypeScript’s feet.
A workflow runs on every push,
Ensuring code is free from mush.
Imports in order, mocks async too—
The garden’s clean, thanks to the crew!
🐇✨


📜 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 3543a34 and 6848dbb.

📒 Files selected for processing (1)
  • tests/index.test.js (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

…e no changes

- Modified the test case to expect getGitSummary to return null when there are no changes instead of throwing an error.
- Updated the mock implementation
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: 2

🧹 Nitpick comments (1)
tsconfig.json (1)

20-29: Refine include glob patterns for completeness
The patterns like "./**.js" may not behave as expected. Use standard globs ("**/*.js", "**/*.ts", etc.) to ensure all files are picked up.

Suggested update:

-  "include": [
-    "./**.js",
-    "./**.ts",
-    "./**.cjs",
-    "./**.mjs",
+  "include": [
+    "**/*.js",
+    "**/*.ts",
+    "**/*.cjs",
+    "**/*.mjs",
     "fixtures/**/*.js",
     "tests/**/*.js",
     "utils/**/*.js",
     "utils/**/*.test.js"
   ]
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between baca82b and 3543a34.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • .eslintignore (1 hunks)
  • .eslintrc.cjs (1 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • index.js (2 hunks)
  • package.json (2 hunks)
  • tests/index.test.js (2 hunks)
  • tests/setup-mocks.js (2 hunks)
  • tests/setup.js (1 hunks)
  • tests/utils/mocks.js (1 hunks)
  • tsconfig.json (1 hunks)
  • utils/sanitizeCommitMessage.test.js (1 hunks)
  • vitest.config.js (1 hunks)
🧰 Additional context used
🪛 GitHub Check: test
tests/index.test.js

[failure] 88-88: tests/index.test.js > Git GPT Commit > getGitSummary > throws an error when there are no changes
AssertionError: expected [AsyncFunction] to throw an error

  • Expected:
    null
  • Received:
    undefined

❯ tests/index.test.js:88:56

🪛 GitHub Actions: Test
tests/index.test.js

[error] 88-88: AssertionError: expected [AsyncFunction] to throw an error 'No changes to commit'. Test failed at line 88.

🔇 Additional comments (19)
vitest.config.js (1)

1-4: Formatting improvement: import ordering and spacing adjusted
The import of defineConfig is now grouped after Node built-in imports with appropriate blank lines, aligning with the project's ESLint import-order rules and enhancing readability.

utils/sanitizeCommitMessage.test.js (1)

1-2: Formatting improvement: added blank line after imports
The blank line after the Vitest imports improves readability and matches the project's new linting style. No changes to test logic.

.eslintignore (1)

1-11: 🛠️ Refactor suggestion

Fix ignore pattern for fixtures directory
The entry /fixture will not match your actual fixtures directory (plural). Consider updating it to ignore the correct path and adding trailing slashes for directories.

Proposed diff:

- /fixture
+ fixtures/

Likely an incorrect or invalid review comment.

tests/setup.js (1)

4-5: Formatting improvement: blank line after built-ins
Grouping all Node.js built-in imports (child_process, fs, os, path) followed by a blank line before third-party imports (dotenv) enhances clarity and adheres to the new ESLint rules.

.github/workflows/lint.yml (1)

1-13: Well-structured GitHub Actions workflow for linting

This workflow correctly sets up a CI process to run linting on PRs and pushes to main, using the project's lint script.

tests/index.test.js (1)

2-4: Improved import organization

The imports are now better organized with a clear separation between modules.

index.js (3)

5-11: Improved import organization

Imports are now logically grouped with standard libraries first, followed by third-party modules.


125-125: Better indication of unused parameter

Renaming args to _args clearly indicates this parameter is intentionally unused, following common naming conventions.


129-129: Cleaner code with removed redundant comment

Removing the outdated comment about manual command extraction improves code clarity since Commander is now handling this.

tests/utils/mocks.js (1)

57-57: Explicitly async implementation

Making the mock implementation explicitly asynchronous better reflects its behavior and aligns with the Promise-based return.

.eslintrc.cjs (2)

13-21: Good job handling test files differently.

The override configuration correctly disables the no-unused-vars rule for test files, which is a good practice as test files often have variables that appear unused in certain test scenarios.


5-5:

Details

❓ Verification inconclusive

Verify the ts-prefixer preset covers all necessary rules.

The configuration extends 'ts-prefixer', but it's important to ensure this preset includes all the necessary rules for your project. Consider reviewing the preset's contents and adding any missing rules that are specific to your project's needs.


🏁 Script executed:

#!/bin/bash
# Check what's included in the ts-prefixer preset
npm explore eslint-config-ts-prefixer -- cat index.js

# Alternatively, if it's a local file or doesn't have a simple index.js
find node_modules/eslint-config-ts-prefixer -type f -name "*.js" | xargs cat

Length of output: 444


🏁 Script executed:

#!/bin/bash
# Verify that eslint-config-ts-prefixer is declared in package.json
grep -R '"eslint-config-ts-prefixer"' -n package.json

# Check if the package is installed under node_modules
npm ls eslint-config-ts-prefixer || true

# List the module directory to locate its entry point or rule definitions
ls -R node_modules/eslint-config-ts-prefixer 2>/dev/null

Length of output: 2353


🏁 Script executed:

#!/bin/bash
# Display the main configuration exported by ts-prefixer
sed -n '1,200p' node_modules/eslint-config-ts-prefixer/index.cjs

Length of output: 3591


Confirm ts-prefixer covers your project’s needs
The ts-prefixer preset includes a comprehensive set of core ESLint rules plus TypeScript, import and Prettier plugins, but it doesn’t pull in any “recommended” rule sets out of the box. Please review whether you need additional rules or plugins for your codebase. For example, you might consider adding:

  • plugin:@typescript-eslint/recommended (e.g. for no-floating-promises, explicit-module-boundary-types)
  • plugin:import/recommended or plugin:import/typescript (for stricter import validation)
  • Any project-specific rules around accessibility, security, or coding conventions

If you identify gaps, update your .eslintrc.cjs accordingly:

 extends: [
-  'ts-prefixer',
+  'ts-prefixer',
+  'plugin:@typescript-eslint/recommended',
+  'plugin:import/recommended',
],
tests/setup-mocks.js (3)

27-27: Good use of underscore prefix for unused parameters.

Prefixing unused parameters with an underscore (_options) is a good practice that indicates the parameter is intentionally unused while suppressing linter warnings.


40-40: Good use of discard variable in catch block.

Using __ as a discard variable in the catch block is appropriate when you don't need to use the error object itself but still need to catch exceptions.


44-44: Consistent use of underscore prefix for unused parameters.

The change from options to _options with default value maintains consistent naming conventions for unused parameters throughout the codebase.

package.json (4)

11-12: Great addition of lint scripts.

Adding dedicated scripts for linting and fixing issues simplifies the development workflow and ensures consistent code quality checks across the team.


42-50: Comprehensive ESLint and TypeScript setup.

The added dependencies provide a complete setup for ESLint with TypeScript support, including necessary plugins for import handling and Prettier integration.

Also applies to: 54-54


10-10:

Details

❌ Incorrect review comment

Changes to test script.

The test script was simplified to "vitest run". Ensure this doesn't remove any important options that were previously configured.


🏁 Script executed:

#!/bin/bash
# Look at git history for previous version of the test script
git show HEAD~1:package.json | grep -A2 "\"scripts\""

Length of output: 147


🏁 Script executed:

#!/bin/bash
# Extract the entire scripts section from the previous commit
git show HEAD~1:package.json | sed -n '/"scripts": {/,/}/p'

Length of output: 305


No changes to test script detected

After reviewing the commit history, the test entry in package.json remains "vitest run" in both the current and previous versions. There were no modifications to this script, so no further action is required.

Likely an incorrect or invalid review comment.


39-39:

Details

❓ Verification inconclusive

Verify Node.js version compatibility.

The Volta configuration specifies Node.js version 22.15.0, which is very recent. Consider whether this might cause compatibility issues for team members or CI environments.


🏁 Script executed:

#!/bin/bash
# Check the latest LTS Node.js version for reference
curl -s https://nodejs.org/dist/index.json | jq -r 'map(select(.lts != false)) | .[0].version'

# Check if any packages have Node.js engine restrictions
grep -r "\"engines\"" package.json

Length of output: 186


I’m not seeing the package.json in the sandbox (likely due to skip_cloning), so let’s pull it in and inspect the engines and Volta fields directly:


🏁 Script executed:

#!/bin/bash
# Locate package.json in the repo
fd --hidden --max-depth 2 'package.json'

# Show any engines or volta config in package.json
grep -R '"engines"' -n package.json || true
grep -R '"volta"' -n package.json || true

# Preview the first 100 lines of package.json
sed -n '1,100p' package.json

Length of output: 2025


Confirm Node.js 22.x support across your team and CI

The Volta config is pinning Node to v22.15.0 (package.json @ line 38), which is the current LTS—but it’s still a fairly new major release. Before locking everyone into this exact version, please:

  • Verify that all CI workflows (e.g. GitHub Actions’ actions/setup-node, other build pipelines) support Node 22.x out of the box.
  • Confirm that all contributors are on a Volta version that can install v22.15.0 without issues.
  • Consider adding an "engines" field in package.json (e.g. "node": ">=18 <25") instead of a fixed patch version to allow flexibility for minor/patch updates.
  • If broad compatibility is more important than the very latest LTS, you may want to target Node 20.x instead.

Comment on lines 88 to 90
expect(async () => gitGptCommit.getGitSummary()).toThrow(
'No changes to commit',
)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix async test assertion

The test is failing because wrapping an async function in another async function doesn't properly capture thrown errors in the way expect() requires.

Apply this diff to fix the async error assertion:

-      expect(async () => gitGptCommit.getGitSummary()).toThrow(
-        'No changes to commit',
-      )
+      await expect(gitGptCommit.getGitSummary()).rejects.toThrow(
+        'No changes to commit'
+      )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(async () => gitGptCommit.getGitSummary()).toThrow(
'No changes to commit',
)
await expect(gitGptCommit.getGitSummary()).rejects.toThrow(
'No changes to commit'
)
🧰 Tools
🪛 GitHub Check: test

[failure] 88-88: tests/index.test.js > Git GPT Commit > getGitSummary > throws an error when there are no changes
AssertionError: expected [AsyncFunction] to throw an error

  • Expected:
    null
  • Received:
    undefined

❯ tests/index.test.js:88:56

🪛 GitHub Actions: Test

[error] 88-88: AssertionError: expected [AsyncFunction] to throw an error 'No changes to commit'. Test failed at line 88.

@@ -0,0 +1,22 @@
module.exports = {
root: true,
env: {},
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Specify the execution environment in the ESLint configuration.

The env object is currently empty, but it should specify the execution environments for proper linting. For a Node.js project with tests, consider adding the appropriate environments.

-  env: {},
+  env: {
+    node: true,
+    es2022: true,
+    jest: true
+  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
env: {},
env: {
node: true,
es2022: true,
jest: true
},

@ryota-murakami ryota-murakami merged commit 9afed24 into main May 6, 2025
2 of 3 checks passed
@ryota-murakami ryota-murakami deleted the add/linter branch May 13, 2025 14:56
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