Skip to content

chore: add pre-commit configuration for code quality checks#27

Closed
Vaishnavi10706 wants to merge 4 commits intoAOSSIE-Org:mainfrom
Vaishnavi10706:chore/pre-commit-config
Closed

chore: add pre-commit configuration for code quality checks#27
Vaishnavi10706 wants to merge 4 commits intoAOSSIE-Org:mainfrom
Vaishnavi10706:chore/pre-commit-config

Conversation

@Vaishnavi10706
Copy link
Copy Markdown
Contributor

@Vaishnavi10706 Vaishnavi10706 commented Feb 19, 2026

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

  • Chores
    • Added automated pre-commit checks to enforce code hygiene and safety: whitespace/line endings and merge-conflict guards, config/data validation (YAML/JSON/TOML), formatting for web assets, JavaScript linting, large-file prevention, and basic secret detection. These run before commits to improve consistency and catch common issues early.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 19, 2026

Warning

Rate limit exceeded

@Vaishnavi10706 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 11 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 959516e4-d9db-4908-9097-376523b58f91

📥 Commits

Reviewing files that changed from the base of the PR and between 12e6b12 and a9b3e8f.

📒 Files selected for processing (3)
  • .pre-commit-config.yaml
  • .prettierrc.json
  • eslint.config.js

Walkthrough

Adds a new .pre-commit-config.yaml registering multiple pre-commit repositories and hooks for file hygiene, config/data validation, code formatting, JavaScript linting, and secret detection to run automated checks before commits.

Changes

Cohort / File(s) Summary
Pre-commit configuration
/.pre-commit-config.yaml
New comprehensive pre-commit setup registering five repositories and multiple hooks: file hygiene (trailing-whitespace, end-of-file-fixer, mixed-line-ending, check-merge-conflict, check-added-large-files), config/data validators (check-yaml, check-json, check-toml), prettier formatting, eslint linting, and detect-secrets scanning.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

Linter

Suggested reviewers

  • kpj2006

Poem

🐇 I hopped through files with nimble paws,
Hooks in place to mend our flaws,
Whitespace gone and secrets sought,
Commits grow tidy — joy is brought! ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change—adding a pre-commit configuration file for code quality checks, which is the primary focus of this PR.
Linked Issues check ✅ Passed The PR successfully implements .pre-commit-config.yaml from issue #18's list of open-source best practices to adopt, meeting the core requirement of the linked issue.
Out of Scope Changes check ✅ Passed The PR contains only the .pre-commit-config.yaml file addition, which directly addresses the linked issue #18's requirement without introducing unrelated changes.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
Copy Markdown
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.

🧹 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. Running pre-commit install installs 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 run pre-commit install after 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-files silently uses the built-in default. It prevents giant files from being committed; the default threshold is 500 kB, configurable via args: ['--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: Bump rev to the current stable release v6.0.0.

v4.6.0 is two major versions behind. The official README and PyPI page for pre-commit-hooks now recommend rev: 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.

@kpj2006
Copy link
Copy Markdown
Contributor

kpj2006 commented Mar 10, 2026

Copy link
Copy Markdown
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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7db821c and c9cefd3.

📒 Files selected for processing (1)
  • .pre-commit-config.yaml

Comment thread .pre-commit-config.yaml
Comment thread .pre-commit-config.yaml
Copy link
Copy Markdown
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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between c9cefd3 and 12e6b12.

📒 Files selected for processing (1)
  • .pre-commit-config.yaml

Comment thread .pre-commit-config.yaml
Comment on lines +31 to +47
- 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)$

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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.json

Repository: 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.js for ESLint configuration (required for ESLint v9+)
  • .prettierrc.json for 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.

@Vaishnavi10706 Vaishnavi10706 force-pushed the chore/pre-commit-config branch from a9b3e8f to 12e6b12 Compare March 13, 2026 14:00
@github-actions
Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the Stale label Mar 31, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 8, 2026

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! 🙏

@github-actions github-actions Bot closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: adding opensource best pratices from our template

2 participants