Skip to content

Set Up Linting, Formatting, and Pre-commit Hooks for Backend Codebase #236

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
'plugin:import/recommended',
'prettier', // Must be last to override other configs
],
parser: '@babel/eslint-parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
requireConfigFile: false,
babelOptions: {
presets: ['@babel/preset-react'],
},
},
plugins: ['react', 'react-hooks', 'jsx-a11y', 'import'],
rules: {
// React specific rules
'react/react-in-jsx-scope': 'off', // Not needed with React 17+
'react/prop-types': 'off', // Using TypeScript for prop validation
'react/jsx-uses-react': 'off',
'react/jsx-uses-vars': 'error',
'react/jsx-key': 'error',
'react/no-unescaped-entities': 'warn',

// React Hooks rules
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

// Import rules
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'import/no-unresolved': 'off', // Docusaurus handles this
'import/no-duplicates': 'error',

// General rules
'no-console': 'warn',
'no-debugger': 'error',
'no-unused-vars': 'warn',
'prefer-const': 'error',
'no-var': 'error',

// Accessibility rules
'jsx-a11y/anchor-is-valid': 'off', // Docusaurus Link components handle this
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-static-element-interactions': 'warn',
},
settings: {
react: {
version: 'detect',
},
},
overrides: [
{
files: ['docusaurus.config.ts', '*.config.js', '*.config.ts'],
rules: {
'no-console': 'off',
'import/no-default-export': 'off',
},
},
],
ignorePatterns: [
'build/',
'.docusaurus/',
'node_modules/',
'*.min.js',
'static/',
'**/*.ts',
'**/*.tsx',
],
};
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/Create feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 💡Feature Request
description: Suggest a feature
title: "💡[Feature]: "
labels: "enhancement"
title: '💡[Feature]: '
labels: 'enhancement'
body:
- type: checkboxes
id: existing-issue
Expand Down Expand Up @@ -55,9 +55,9 @@ body:
attributes:
label: Record
options:
- label: "I have read the Contributing Guidelines"
- label: 'I have read the Contributing Guidelines'
required: true
- label: "Are you a GSSOC'25 contributor"
required: false
- label: "I want to work on this issue"
- label: 'I want to work on this issue'
required: false
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bug report 🐞
description: File a bug report
title: "🐞[Bug]: "
title: '🐞[Bug]: '
labels: 'bug'
body:
- type: checkboxes
Expand Down Expand Up @@ -46,9 +46,9 @@ body:
attributes:
label: Record
options:
- label: "I have read the Contributing Guidelines"
- label: 'I have read the Contributing Guidelines'
required: true
- label: "Are you a GSSOC'25 contributor"
required: false
- label: "I want to work on this issue"
- label: 'I want to work on this issue'
required: false
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/documentation_update.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 📝 Documentation Update
description: Improve Documentation
title: "📝[Docs]: "
title: '📝[Docs]: '
labels: 'enhancement'
body:
- type: checkboxes
Expand Down Expand Up @@ -52,9 +52,9 @@ body:
attributes:
label: Record
options:
- label: "I have read the Contributing Guidelines"
- label: 'I have read the Contributing Guidelines'
required: true
- label: "Are you a GSSOC'25 contributor"
required: false
- label: "I want to work on this issue"
- label: 'I want to work on this issue'
required: false
8 changes: 5 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Description

Provide a brief summary of the changes made to the website and the motivation behind them. Include any relevant issues or tickets.
This helps fast tracking your PR and merge it, Check the respective box below.
Provide a brief summary of the changes made to the website and the motivation behind them. Include
any relevant issues or tickets. This helps fast tracking your PR and merge it, Check the respective
box below.

Fixes # (issue)

Expand All @@ -27,5 +28,6 @@ Fixes # (issue)

- [ ] My code follows the style guidelines of this project.
- [ ] I have tested my changes across major browsers/devices
- [ ] My changes do not generate new console warnings or errors , I ran `npm run build` and attached scrrenshot in this PR.
- [ ] My changes do not generate new console warnings or errors , I ran `npm run build` and attached
scrrenshot in this PR.
- [ ] This is already assigned Issue to me, not an unassigned issue.
2 changes: 1 addition & 1 deletion .github/workflows/Create close-old-issue.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Close Old Issues
on:
schedule:
- cron: "0 0 * * *"
- cron: '0 0 * * *'

jobs:
close-issues:
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/Create close-old-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ jobs:
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- uses: actions/stale@v7
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR has been automatically closed due to inactivity from the owner for 15 days.'
days-before-pr-stale: 15
days-before-pr-close: 0
exempt-pr-author: false
exempt-pr-labels: ''
only-labels: ''
operations-per-run: 30
remove-stale-when-updated: true
debug-only: false
- uses: actions/stale@v7
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR has been automatically closed due to inactivity from the owner for 15 days.'
days-before-pr-stale: 15
days-before-pr-close: 0
exempt-pr-author: false
exempt-pr-labels: ''
only-labels: ''
operations-per-run: 30
remove-stale-when-updated: true
debug-only: false
34 changes: 17 additions & 17 deletions .github/workflows/Update autocomment-pr-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ jobs:
if: github.event.pull_request.merged == true

steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Checkout Repository
uses: actions/checkout@v2

- name: Add Comment to Issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMENT=$(cat <<EOF
{
"body": "🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. \n\n I would be grateful if you can nominate for keeping this opensource project live and running [Link to Nominate](https://stars.github.com/nominate/). Please do star the repo and Keep up the fantastic work! 🚀"
}
EOF
)
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT"
- name: Add Comment to Issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMENT=$(cat <<EOF
{
"body": "🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. \n\n I would be grateful if you can nominate for keeping this opensource project live and running [Link to Nominate](https://stars.github.com/nominate/). Please do star the repo and Keep up the fantastic work! 🚀"
}
EOF
)
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT"
1 change: 0 additions & 1 deletion .github/workflows/autocomment-iss-raise.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Auto Comment on Issue Opened

on:
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/autocomment-pr-raise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ jobs:
permissions:
pull-requests: write
steps:
- name: Add Comment to Pull Request
run: |
COMMENT=$(cat <<EOF
{
"body": "Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. The estimated time for response is 5–8 hrs. \\n\n In the meantime, please provide all necessary screenshots and make sure you run - npm build run , command and provide a screenshot, a video recording, or an image of the update you made below, which helps speed up the review and assignment. If you have questions, reach out to [LinkedIn](https://www.linkedin.com/in/sanjay-k-v/). Your contributions are highly appreciated!😊 \n\n Note: I maintain the repo issue every day twice at 8:00 AM IST and 9:00 PM IST. If your PR goes stale for more than one day, you can tag and comment on this same issue by tagging **@sanjay-kv**.\n\n We are here to help you on this journey of open source. Consistent 20 contributions are eligible for sponsorship 💰 \n\n 🎁 check our list of amazing people we sponsored so far: [GitHub Sponsorship](https://www.recodehive.com/our-sponsors). ✨ \n\n 📚Your perks for contribution to this community 👇🏻 \n\n 1. Get free Consultation use code recode50 to get free: [Mentorship for free](https://event.recodehive.com/git). \n\n 2. Get the Ebook for free use code recode at checkout: [Data Science cheatsheet for Beginners](https://dev.recodehive.com/book). \n\n 3. Check out this weekly Newsletter: [Sanjay's Newsletter.](https://recodehive.substack.com/) \n\n If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊"
}
EOF
)
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT")
cat response.json
if [ "$RESPONSE" -ne 201 ]; then
echo "Failed to add comment"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add Comment to Pull Request
run: |
COMMENT=$(cat <<EOF
{
"body": "Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. The estimated time for response is 5–8 hrs. \\n\n In the meantime, please provide all necessary screenshots and make sure you run - npm build run , command and provide a screenshot, a video recording, or an image of the update you made below, which helps speed up the review and assignment. If you have questions, reach out to [LinkedIn](https://www.linkedin.com/in/sanjay-k-v/). Your contributions are highly appreciated!😊 \n\n Note: I maintain the repo issue every day twice at 8:00 AM IST and 9:00 PM IST. If your PR goes stale for more than one day, you can tag and comment on this same issue by tagging **@sanjay-kv**.\n\n We are here to help you on this journey of open source. Consistent 20 contributions are eligible for sponsorship 💰 \n\n 🎁 check our list of amazing people we sponsored so far: [GitHub Sponsorship](https://www.recodehive.com/our-sponsors). ✨ \n\n 📚Your perks for contribution to this community 👇🏻 \n\n 1. Get free Consultation use code recode50 to get free: [Mentorship for free](https://event.recodehive.com/git). \n\n 2. Get the Ebook for free use code recode at checkout: [Data Science cheatsheet for Beginners](https://dev.recodehive.com/book). \n\n 3. Check out this weekly Newsletter: [Sanjay's Newsletter.](https://recodehive.substack.com/) \n\n If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊"
}
EOF
)
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT")
cat response.json
if [ "$RESPONSE" -ne 201 ]; then
echo "Failed to add comment"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Code Quality & Build

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
lint-and-format:
name: Lint & Format Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Run ESLint
run: npm run lint

- name: Check Prettier formatting
run: npm run format:check

- name: TypeScript type check
run: npm run typecheck
continue-on-error: true

build:
name: Build Project
runs-on: ubuntu-latest
needs: lint-and-format

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Build project
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-files
path: build/
retention-days: 7

test:
name: Run Tests
runs-on: ubuntu-latest
needs: lint-and-format
if: false # Disable until tests are added

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Run tests
run: npm test
Loading
Loading