Skip to content

Commit ee7bbde

Browse files
VarnasrImpactMojo Standards Bot
andauthored
Chore: add git best-practice standards
Co-authored-by: ImpactMojo Standards Bot <hello@impactmojo.in>
1 parent a5045dc commit ee7bbde

13 files changed

Lines changed: 370 additions & 0 deletions

.editorconfig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# EditorConfig — consistent formatting across editors and contributors
2+
# https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
indent_style = space
10+
indent_size = 2
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.{html,css}]
18+
indent_size = 2
19+
20+
[*.js]
21+
indent_size = 2
22+
23+
[*.{json,yml,yaml}]
24+
indent_size = 2
25+
26+
[*.py]
27+
indent_size = 4
28+
29+
[*.{r,R}]
30+
indent_size = 2
31+
32+
[Makefile]
33+
indent_style = tab

.gitattributes

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Auto-detect text files and normalise line endings to LF
2+
* text=auto eol=lf
3+
4+
# Explicitly declare text files
5+
*.html text eol=lf
6+
*.css text eol=lf
7+
*.js text eol=lf
8+
*.ts text eol=lf
9+
*.json text eol=lf
10+
*.md text eol=lf
11+
*.yml text eol=lf
12+
*.yaml text eol=lf
13+
*.toml text eol=lf
14+
*.xml text eol=lf
15+
*.svg text eol=lf
16+
*.txt text eol=lf
17+
*.sh text eol=lf
18+
*.py text eol=lf
19+
*.r text eol=lf
20+
*.R text eol=lf
21+
22+
# Windows-specific files keep CRLF
23+
*.bat text eol=crlf
24+
*.cmd text eol=crlf
25+
*.ps1 text eol=crlf
26+
27+
# Binary files — no diff, no merge, no line-ending conversion
28+
*.png binary
29+
*.jpg binary
30+
*.jpeg binary
31+
*.gif binary
32+
*.ico binary
33+
*.webp binary
34+
*.avif binary
35+
*.woff binary
36+
*.woff2 binary
37+
*.ttf binary
38+
*.eot binary
39+
*.otf binary
40+
*.pdf binary
41+
*.zip binary
42+
*.gz binary
43+
*.tar binary
44+
*.mp4 binary
45+
*.webm binary
46+
*.mp3 binary
47+
*.ogg binary
48+
49+
# Lock files — exact merge to prevent conflicts
50+
package-lock.json merge=ours
51+
yarn.lock merge=ours

.githooks/commit-msg

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
# Commit message hook: enforce prefix convention from CONTRIBUTING.md
3+
set -euo pipefail
4+
5+
MSG_FILE="$1"
6+
MSG=$(head -1 "$MSG_FILE")
7+
8+
RED='\033[0;31m'
9+
NC='\033[0m'
10+
11+
# Skip merge commits and fixup/squash commits
12+
if echo "$MSG" | grep -qE '^(Merge|Revert|fixup!|squash!)'; then
13+
exit 0
14+
fi
15+
16+
# Allowed prefixes (from CONTRIBUTING.md)
17+
PREFIXES="Add|Fix|Update|Translate|Docs|Refactor|Test|CI|Chore|Merge"
18+
19+
if ! echo "$MSG" | grep -qE "^(${PREFIXES}):"; then
20+
echo -e "${RED}Invalid commit message format.${NC}"
21+
echo ""
22+
echo "Commit message must start with one of these prefixes:"
23+
echo " Add: — New feature, course, or tool"
24+
echo " Fix: — Bug fix or broken link"
25+
echo " Update: — Improvement to existing content or code"
26+
echo " Translate: — Translation work"
27+
echo " Docs: — Documentation changes"
28+
echo " Refactor: — Code restructuring (no behaviour change)"
29+
echo " Test: — Adding or updating tests"
30+
echo " CI: — CI/CD pipeline changes"
31+
echo " Chore: — Maintenance (deps, configs, tooling)"
32+
echo ""
33+
echo "Example: Add: interactive Theory of Change lab"
34+
echo ""
35+
echo "Your message was: $MSG"
36+
exit 1
37+
fi
38+
39+
# Warn if subject line is too long
40+
if [ ${#MSG} -gt 72 ]; then
41+
echo -e "\033[0;33mWARNING:\033[0m Commit subject is ${#MSG} chars (recommended max: 72)"
42+
fi

.githooks/pre-commit

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
# Pre-commit hook: catch common mistakes before they're committed
3+
set -euo pipefail
4+
5+
RED='\033[0;31m'
6+
YELLOW='\033[0;33m'
7+
NC='\033[0m' # No Color
8+
9+
echo "Running pre-commit checks..."
10+
11+
# 1. Block commits of sensitive files
12+
SENSITIVE_PATTERNS=('.env' '.env.local' '.env.production' 'credentials.json' '*.pem' '*.key')
13+
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
14+
15+
for pattern in "${SENSITIVE_PATTERNS[@]}"; do
16+
while IFS= read -r file; do
17+
if [[ -n "$file" ]]; then
18+
echo -e "${RED}BLOCKED:${NC} Refusing to commit sensitive file: $file"
19+
echo "If this is intentional, use: git commit --no-verify"
20+
exit 1
21+
fi
22+
done < <(echo "$STAGED_FILES" | grep -E "^${pattern//\*/.*}$" 2>/dev/null || true)
23+
done
24+
25+
# 2. Check for debug/console statements in staged JS/TS/Python files
26+
CODE_FILES=$(echo "$STAGED_FILES" | grep -E '\.(js|ts|py)$' || true)
27+
if [ -n "$CODE_FILES" ]; then
28+
ISSUES=0
29+
while IFS= read -r file; do
30+
if git diff --cached "$file" | grep -E '^\+.*console\.(log|debug|warn)\(' | grep -v '// keep' > /dev/null 2>&1; then
31+
echo -e "${YELLOW}WARNING:${NC} console.log/debug/warn found in $file"
32+
ISSUES=$((ISSUES + 1))
33+
fi
34+
if git diff --cached "$file" | grep -E '^\+.*(debugger|breakpoint\(\))' > /dev/null 2>&1; then
35+
echo -e "${RED}BLOCKED:${NC} debugger statement found in $file"
36+
exit 1
37+
fi
38+
done <<< "$CODE_FILES"
39+
if [ $ISSUES -gt 0 ]; then
40+
echo -e "${YELLOW}Found $ISSUES file(s) with console statements. Consider removing them.${NC}"
41+
fi
42+
fi
43+
44+
# 3. Check for merge conflict markers
45+
if [ -n "$STAGED_FILES" ]; then
46+
while IFS= read -r file; do
47+
if [ -f "$file" ] && grep -rn '<<<<<<<\|=======\|>>>>>>>' "$file" > /dev/null 2>&1; then
48+
echo -e "${RED}BLOCKED:${NC} Merge conflict markers found in $file"
49+
exit 1
50+
fi
51+
done <<< "$STAGED_FILES"
52+
fi
53+
54+
# 4. Warn on large files (> 500KB)
55+
while IFS= read -r file; do
56+
if [ -f "$file" ]; then
57+
SIZE=$(wc -c < "$file")
58+
if [ "$SIZE" -gt 512000 ]; then
59+
SIZE_KB=$((SIZE / 1024))
60+
echo -e "${YELLOW}WARNING:${NC} Large file (${SIZE_KB}KB): $file"
61+
fi
62+
fi
63+
done <<< "$STAGED_FILES"
64+
65+
echo "Pre-commit checks passed."

.github/CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CODEOWNERS — defines default reviewers for pull requests
2+
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
3+
4+
# Default owner for everything
5+
* @Varnasr
6+
7+
.github/ @Varnasr
8+
scripts/ @Varnasr
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Bug Report
3+
about: Report a broken link, layout issue, or JavaScript error
4+
title: "[Bug] "
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear description of what's wrong.
11+
12+
**Page/URL**
13+
Which page is affected?
14+
15+
**Steps to reproduce**
16+
1. Go to '...'
17+
2. Click on '...'
18+
3. See error
19+
20+
**Expected behavior**
21+
What should happen instead?
22+
23+
**Screenshots**
24+
If applicable, add screenshots.
25+
26+
**Device**
27+
- Browser: [e.g., Chrome 120]
28+
- Device: [e.g., desktop / iPhone 14]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Content Issue
3+
about: Report outdated, incorrect, or missing content
4+
title: "[Content] "
5+
labels: content
6+
assignees: ''
7+
---
8+
9+
**Page/Course affected**
10+
Which page or course has the issue?
11+
12+
**What's wrong?**
13+
Describe the content issue (outdated stat, broken citation, missing topic, etc.)
14+
15+
**Suggested correction**
16+
If you know the correct information, please share it with a source/reference.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new tool, course, or improvement
4+
title: "[Feature] "
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
**What problem does this solve?**
10+
A clear description of the need.
11+
12+
**Proposed solution**
13+
How you'd like it to work.
14+
15+
**Alternatives considered**
16+
Any other approaches you've thought about.
17+
18+
**Additional context**
19+
Any relevant links, screenshots, or examples.

.github/SECURITY.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | --------- |
7+
| Latest (main branch) | Yes |
8+
9+
## Reporting a Vulnerability
10+
11+
If you discover a security vulnerability in RootStack, please report it responsibly.
12+
13+
**Do NOT open a public GitHub issue for security vulnerabilities.**
14+
15+
Instead, please email **hello@impactmojo.in** with:
16+
17+
- A description of the vulnerability
18+
- Steps to reproduce the issue
19+
- Any potential impact
20+
- Suggested fix (if you have one)
21+
22+
We will acknowledge your report within 48 hours and aim to release a fix within 7 days for critical issues.
23+
24+
## Scope
25+
26+
The following are in scope:
27+
28+
- Cross-site scripting (XSS) in any page
29+
- Authentication or authorisation bypass
30+
- Exposed secrets or credentials
31+
- Insecure dependencies with known CVEs
32+
- Open redirects
33+
34+
## Out of Scope
35+
36+
- Denial of service attacks
37+
- Social engineering
38+
- Issues in third-party services
39+
40+
## Recognition
41+
42+
We're happy to credit security researchers in our changelog. Let us know if you'd like to be acknowledged.

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
# GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
open-pull-requests-limit: 5
10+
labels:
11+
- "ci"
12+
commit-message:
13+
prefix: "CI:"

0 commit comments

Comments
 (0)