chore: add pre-commit configuration for code quality checks#27
chore: add pre-commit configuration for code quality checks#27Vaishnavi10706 wants to merge 4 commits intoAOSSIE-Org:mainfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughAdds a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
.pre-commit-config.yaml (3)
1-10: Add a CI step to enforce hooks on every push — local-only hooks can be bypassed.Pre-commit hooks only run for contributors who have executed
pre-commit install. Anyone who clones the repo without that step (or pushes directly) will skip all the checks entirely. Runningpre-commit installinstalls pre-commit into git hooks so it runs on every local commit, but this is a manual, per-contributor action.Consider one of:
- Adding a GitHub Actions workflow step (
pre-commit run --all-files) to enforce checks in CI.- Opting in to pre-commit.ci (free for open source), which automatically runs and auto-fixes hooks on every PR. You can also keep hook revisions current with
pre-commit autoupdate, which brings hooks to the latest tag on the default branch.Also ensure
CONTRIBUTING.md(or equivalent onboarding docs) instructs contributors to runpre-commit installafter cloning.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.pre-commit-config.yaml around lines 1 - 10, Add a CI enforcement step so pre-commit hooks in .pre-commit-config.yaml run on every push: add a GitHub Actions workflow that runs `pre-commit run --all-files` (or opt into pre-commit.ci) as part of PR/CI jobs, and document the onboarding step in CONTRIBUTING.md to run `pre-commit install` after cloning; ensure the workflow uses the same hooks/rev as the .pre-commit-config.yaml and fails the job when hooks return non-zero so checks cannot be bypassed.
10-10: Consider documenting the large-file threshold explicitly via--maxkb.Without an explicit argument,
check-added-large-filessilently uses the built-in default. It prevents giant files from being committed; the default threshold is 500 kB, configurable viaargs: ['--maxkb=123']. Making the limit explicit in config avoids surprises when the default changes between hook versions and communicates the project's intent to contributors.🔧 Example with explicit threshold
- - id: check-added-large-files + - id: check-added-large-files + args: ['--maxkb=500']🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.pre-commit-config.yaml at line 10, Update the check-added-large-files hook entry to explicitly set the maximum allowed file size by adding an args field (e.g., args: ['--maxkb=500']) to the hook configuration for check-added-large-files in .pre-commit-config.yaml so the large-file threshold is explicit and stable across hook versions.
3-3: Bumprevto the current stable releasev6.0.0.
v4.6.0is two major versions behind. The official README and PyPI page forpre-commit-hooksnow recommendrev: v6.0.0, released in August 2025. Running on an older revision means missing bug fixes and potentially relying on a hook definition that has since changed.🔧 Proposed update
- rev: v4.6.0 + rev: v6.0.0🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.pre-commit-config.yaml at line 3, Update the pre-commit hook revision: change the rev value used for the pre-commit-hooks entry (the current "rev: v4.6.0") to the current stable release "v6.0.0" so hooks use the latest definitions; after updating the rev, run pre-commit autoupdate or at minimum run pre-commit hooks locally to verify there are no breaking changes in the pipeline.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.pre-commit-config.yaml:
- Around line 1-10: Add a CI enforcement step so pre-commit hooks in
.pre-commit-config.yaml run on every push: add a GitHub Actions workflow that
runs `pre-commit run --all-files` (or opt into pre-commit.ci) as part of PR/CI
jobs, and document the onboarding step in CONTRIBUTING.md to run `pre-commit
install` after cloning; ensure the workflow uses the same hooks/rev as the
.pre-commit-config.yaml and fails the job when hooks return non-zero so checks
cannot be bypassed.
- Line 10: Update the check-added-large-files hook entry to explicitly set the
maximum allowed file size by adding an args field (e.g., args: ['--maxkb=500'])
to the hook configuration for check-added-large-files in .pre-commit-config.yaml
so the large-file threshold is explicit and stable across hook versions.
- Line 3: Update the pre-commit hook revision: change the rev value used for the
pre-commit-hooks entry (the current "rev: v4.6.0") to the current stable release
"v6.0.0" so hooks use the latest definitions; after updating the rev, run
pre-commit autoupdate or at minimum run pre-commit hooks locally to verify there
are no breaking changes in the pipeline.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.pre-commit-config.yaml:
- Around line 8-27: The YAML contains duplicate pre-commit repo blocks for
https://github.com/pre-commit/pre-commit-hooks (rev v4.6.0); merge them into a
single repo entry and combine the hooks lists (include trailing-whitespace,
end-of-file-fixer, check-merge-conflict, check-added-large-files,
mixed-line-ending with args ["--fix=lf"], plus check-yaml, check-json,
check-toml) so there is only one repo: and rev: stanza with a single hooks:
array to avoid duplication and simplify configuration.
- Around line 49-52: Add a baseline to the detect-secrets hook by creating or
adding the .secrets.baseline file to the repo and updating the detect-secrets
hook configuration in .pre-commit-config.yaml (the detect-secrets hook entry) to
include args: ["--baseline", ".secrets.baseline"]; ensure the baseline file is
committed and referenced exactly as ".secrets.baseline" so the detect-secrets
hook uses the baseline during runs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5ba99c66-b16a-484d-b4e9-0c0a7b6d01d0
📒 Files selected for processing (1)
.pre-commit-config.yaml
There was a problem hiding this comment.
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 @.pre-commit-config.yaml:
- Around line 31-47: The pre-commit hooks for Prettier and ESLint are configured
but there are no committed config files, causing default fallbacks; add a
committed eslint.config.js (required for ESLint v9+) and a .prettierrc.json to
pin formatting rules, e.g., eslint.config.js exporting a config that targets
"**/*.{js,jsx}" with appropriate languageOptions (ecmaVersion/sourceType) and
your project rules, and .prettierrc.json containing your Prettier options (e.g.,
singleQuote setting); commit both files so the prettier and eslint hooks use
these configs and update the repository so the hooks run deterministically.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: f7fd5903-04a4-4a2d-8b75-c6568b9bd232
📒 Files selected for processing (1)
.pre-commit-config.yaml
| - repo: https://github.com/pre-commit/mirrors-prettier | ||
| rev: v3.2.5 | ||
| hooks: | ||
| - id: prettier | ||
| types_or: [javascript, css, html] | ||
|
|
||
| # ---------------------------------- | ||
| # 4. JavaScript linting | ||
| # ---------------------------------- | ||
| - repo: https://github.com/pre-commit/mirrors-eslint | ||
| rev: v9.4.0 | ||
| hooks: | ||
| - id: eslint | ||
| types: [javascript] | ||
| args: ["--fix"] | ||
| files: \.(js|jsx)$ | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Read-only verification: confirm lint/format hook setup and config presence.
echo "== Hook entries =="
rg -n -C2 'mirrors-prettier|mirrors-eslint|id: prettier|id: eslint|args|additional_dependencies' .pre-commit-config.yaml
echo
echo "== ESLint config files =="
fd -H '^(eslint\.config\.(js|cjs|mjs)|\.eslintrc(\.(js|cjs|json|yaml|yml))?)$' .
echo
echo "== Prettier config files =="
fd -H '^(\.prettierrc(\.(json|ya?ml|js|cjs|mjs))?|prettier\.config\.(js|cjs|mjs))$' .
echo
echo "== package.json fallback config =="
rg -n -C2 '"eslintConfig"|"prettier"' package.jsonRepository: AOSSIE-Org/SocialShareButton
Length of output: 846
Add explicit config files for ESLint and Prettier hooks.
ESLint (line 40) and Prettier (line 31) are configured without any committed configuration files (eslint.config.*, .eslintrc*, package.json config for ESLint; .prettierrc*, prettier.config.*, package.json config for Prettier). Both tools will fall back to defaults, causing inconsistent behavior and avoidable style churn across the codebase.
Create the following files:
eslint.config.jsfor ESLint configuration (required for ESLint v9+).prettierrc.jsonfor Prettier configuration
Example configurations
// eslint.config.js
export default [
{
files: ["**/*.{js,jsx}"],
languageOptions: { ecmaVersion: "latest", sourceType: "module" },
rules: {}
}
];// .prettierrc.json
{
"singleQuote": false
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.pre-commit-config.yaml around lines 31 - 47, The pre-commit hooks for
Prettier and ESLint are configured but there are no committed config files,
causing default fallbacks; add a committed eslint.config.js (required for ESLint
v9+) and a .prettierrc.json to pin formatting rules, e.g., eslint.config.js
exporting a config that targets "**/*.{js,jsx}" with appropriate languageOptions
(ecmaVersion/sourceType) and your project rules, and .prettierrc.json containing
your Prettier options (e.g., singleQuote setting); commit both files so the
prettier and eslint hooks use these configs and update the repository so the
hooks run deterministically.
a9b3e8f to
12e6b12
Compare
|
Hello 👋 This PR has had no activity for more than 2 weeks. If you are still working on it, please push an update or leave a comment. Ping a maintainer if you believe it is ready for review or merge! This PR will be automatically closed in 7 days if there is no further activity. |
|
This PR was automatically closed after being stale for 7 days with no activity. 😔 If you would like to continue, please reopen it and ping a maintainer for a review. Thank you for your contribution to AOSSIE! 🙏 |
Fixes: #18
Summary
This PR implements one of the open-source best practices by adding a .pre-commit-config.yaml file to improve code quality and prevent common issues before commits.
Changes Introduced
The configuration includes standard hooks for:
Removing trailing whitespace
Ensuring files end with a newline
Validating YAML and JSON files
Detecting merge conflict markers
Preventing large files from being committed
Impact
Enforces basic code hygiene
Prevents common formatting and configuration errors
Reduces avoidable review comments by catching issues early in the development workflow
Please review and let me know if any adjustments or additional hooks should be included. I’ll be happy to update it accordingly.
Summary by CodeRabbit