Skip to content

refactor: Add pre-commit hook for running prettier on affected files#784

Merged
kingston merged 1 commit into
mainfrom
Add-pre-commit-hook-for-running-prettier-on-affected-files
Feb 26, 2026
Merged

refactor: Add pre-commit hook for running prettier on affected files#784
kingston merged 1 commit into
mainfrom
Add-pre-commit-hook-for-running-prettier-on-affected-files

Conversation

@kingston

@kingston kingston commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores

    • Updated linting and formatting configuration to apply file-type-specific rules.
    • Added conditional control mechanism for linting execution to improve build flexibility.
  • Style

    • Enhanced code quality checking workflows with improved environment-based configuration.

@changeset-bot

changeset-bot Bot commented Feb 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: be13df1

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

@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes configure lint-staged to handle different file types separately, using a SKIP_ESLINT environment variable for TypeScript/JSX files while running Prettier on other files. The format-and-lint script is updated to respect this flag, and cross-env is added as a dependency.

Changes

Cohort / File(s) Summary
Lint-staged and environment variable support
package.json
Split lint-staged configuration into separate globs for TypeScript/JSX files (with SKIP_ESLINT=1) and other file types (Prettier only). Added cross-env as a production and development dependency.
ESLint conditional execution
scripts/format-and-lint.ts
Added a guard condition to skip ESLint execution when the SKIP_ESLINT environment variable is set or when ESLint is not present in dependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title focuses on adding a pre-commit hook for Prettier, but the changeset actually modifies lint-staged configuration and adds conditional ESLint execution logic. While Prettier is mentioned, the primary changes involve lint-staged splitting and ESLint guards, making the title partially but not fully aligned with the main changes. Revise the title to reflect the actual changes: 'refactor: Split lint-staged configuration and add ESLint skip guard' or similar, to accurately describe both the configuration restructuring and the conditional ESLint execution logic.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Add-pre-commit-hook-for-running-prettier-on-affected-files

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcross-env@​10.1.010010010082100

View full report

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Line 53: The lint-staged command for "*.{ts,tsx,js,jsx}" runs TypeScript via
"node scripts/format-and-lint.ts" but omits the Node 22 TypeScript runtime flag;
update the command to invoke node with --experimental-strip-types (i.e., "node
--experimental-strip-types scripts/format-and-lint.ts") so the TypeScript file
executes correctly—modify the package.json entry that currently maps
"*.{ts,tsx,js,jsx}" to add this flag.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bd1095e and be13df1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json
  • scripts/format-and-lint.ts

Comment thread package.json
},
"lint-staged": {
"*.(js|ts|tsx|jsx|json|md|mdx|css|scss|yaml|yml|html|yml|yaml|json)": "prettier --write"
"*.{ts,tsx,js,jsx}": "cross-env SKIP_ESLINT=1 node scripts/format-and-lint.ts",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Missing --experimental-strip-types flag for TypeScript execution.

The command invokes node scripts/format-and-lint.ts directly, but other scripts in this file (e.g., line 11) use node --experimental-strip-types to run TypeScript files. Without this flag, Node 22 won't execute the TypeScript file correctly.

🐛 Proposed fix
-    "*.{ts,tsx,js,jsx}": "cross-env SKIP_ESLINT=1 node scripts/format-and-lint.ts",
+    "*.{ts,tsx,js,jsx}": "cross-env SKIP_ESLINT=1 node --experimental-strip-types scripts/format-and-lint.ts",
📝 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
"*.{ts,tsx,js,jsx}": "cross-env SKIP_ESLINT=1 node scripts/format-and-lint.ts",
"*.{ts,tsx,js,jsx}": "cross-env SKIP_ESLINT=1 node --experimental-strip-types scripts/format-and-lint.ts",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 53, The lint-staged command for "*.{ts,tsx,js,jsx}"
runs TypeScript via "node scripts/format-and-lint.ts" but omits the Node 22
TypeScript runtime flag; update the command to invoke node with
--experimental-strip-types (i.e., "node --experimental-strip-types
scripts/format-and-lint.ts") so the TypeScript file executes correctly—modify
the package.json entry that currently maps "*.{ts,tsx,js,jsx}" to add this flag.

@kingston kingston merged commit 76f6bd6 into main Feb 26, 2026
8 checks passed
@kingston kingston deleted the Add-pre-commit-hook-for-running-prettier-on-affected-files branch February 26, 2026 11:47
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.

1 participant