Skip to content

Latest commit

Β 

History

History
559 lines (406 loc) Β· 16.6 KB

CONTRIBUTING.md

File metadata and controls

559 lines (406 loc) Β· 16.6 KB

Contributing to Memo

⭐ First off, thank you for considering contributing to this project! ⭐

We welcome contributions from everyone. By participating in this project, you agree to abide by our Code of Conduct.

οΏ½ IMPORTANT: Discord Communication is Mandatory

All project communication MUST happen on Discord. We do not pay attention to GitHub notifications.

  • Join our Discord server before starting any work.
  • Post your PR/issue updates in the relevant Discord channel (MANDATORY).
  • All discussions, questions, and updates should be on Discord.
  • GitHub is for code only - Discord is for communication.
  • We use our own Gitcord bot to integrate Github and Discord. Please follow the steps in Discord to link your Github account with your Discord account.

PRs without Discord updates will not be reviewed or may face delays.

οΏ½πŸ“‹ Table of Contents

🀝 How Can I Contribute?

Submit Issues

  • Use the repo's issue tracker to submit bug reports or feature requests.
  • See the issues that already exist and do not submit duplicate issues.
  • When submitting a new issue, select the issue type (bug report or feature request) and fill the template appropriately.

Contribute Code

For changes that require a significant amount of code, follow the steps below:

  1. Submit an Issue: Describe the bug that you would like to fix or the feature that you would like to implement as an issue in our issue tracker.
  2. Get Assigned: Preferably, wait to be assigned before starting. If there is no assignment and no active PRs for an issue for 2+ days, mention your intent under the issue and start working on the issue even without assignment.
  3. Submit Your PR: Once assigned, create a PR addressing the issue.

For simple changes that require only a small amount of code, steps 1 and 2 may be skipped. Submit the PR directly.

Pull requests unrelated to issues may be closed or take longer to review.

Triage Issues and PRs

If you see poor-quality issues and PRs that should be closed, please inform the maintainers in the Discord channel.

If you see good-quality stale PRs that could be merged, please inform the maintainers in the Discord channel.

Spam Prevention

Do not submit spam issues or PRs. Make sure your contributions are valuable.

Various tools, bots, limit configurations and workflows are in use to automatically prevent the submission of spam issues and PRs or to automatically close them. If you believe any of these methods has incorrectly prevented your contributions, please notify the maintainers in Discord.

πŸ€– Coding with AI

We accept the use of AI-powered tools (GitHub Copilot, ChatGPT, Claude, Cursor, etc.) for contributions, whether for code, tests, or documentation.

⚠️ However, transparency is required: if you use AI assistance, please mention it in your PR description. This helps maintainers during code review and ensure the quality of contributions.

What we expect:

  • Disclose AI usage: A simple note like "Used GitHub Copilot for autocompletion" or "Generated initial test structure with ChatGPT" is sufficient.
  • Specify the scope: Indicate which parts of your contribution involved AI assistance.
  • Review AI-generated content: Ensure you understand and have verified any AI-generated code before submitting.

πŸš€ Getting Started

Prerequisites

  • Node.js 20 or newer (with npm)
  • Git
  • A modern browser (Chrome, Edge, Firefox or Safari) to try the app
  • No accounts, API keys or environment variables are needed: the app is fully local

Setup

  1. Fork the Repository

    # Click the 'Fork' button at the top right of this page
  2. Clone Your Fork

    git clone https://github.com/YOUR_USERNAME/Memo-EducationalGame.git
    cd Memo-EducationalGame
  3. Add Upstream Remote

    git remote add upstream https://github.com/AOSSIE-Org/Memo-EducationalGame.git
  4. Install Dependencies

    npm install
    # or yarn install
    # or pnpm install
  5. Run the Project

    npm run dev

πŸ”„ Development Workflow

1. Create a Feature Branch

Always work on a new branch, never on main or dev:

git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix

2. Make Your Changes

  • Write clean, readable code
  • Follow the project's code style
  • Add comments where necessary
  • Update documentation if needed

3. Test Your Changes

Before opening a PR, make sure all of these pass:

npm run check   # Svelte + TypeScript type checking
npm test        # unit tests (Vitest): selection algorithm, streaks, IndexedDB layer
npm run build   # production build, including the PWA service worker

Then try your change in the browser with npm run dev (or npm run build && npm run preview to test the PWA/offline behaviour):

  • Check the page never scrolls at desktop sizes (e.g. 1280Γ—720) and on a phone in landscape (e.g. 844Γ—390). Use your browser's device toolbar.
  • Check both light and dark mode.
  • Check all three difficulty levels (3, 6 and 9 options).
  • If you change what is saved (the IndexedDB data in src/lib/db.ts, the player files or backups in src/lib/transfer.ts), players must never lose their progress:
    1. First record a fixture of the current version in src/lib/fixtures/ (export-v<N>.json, backup-v<N>.json, cardset-v<N>.json; database versions are tested in src/lib/db.test.ts), ideally from the deployed app: play a little, then copy what DevTools β†’ Application β†’ IndexedDB shows, or a downloaded file.
    2. Bump the version, add a migration (upgrade() in db.ts, or the import in transfer.ts) and document the new version in the comment above it.
    3. Older files and databases must keep loading: npm test (src/lib/compat.test.ts) opens every fixture with the new code, and fails if a version has no fixture.
    4. Never remove or rename a saved field without migrating it; prefer adding fields with defaults (src/lib/users.ts).

4. Commit Your Changes

Write clear, concise commit messages:

git add .
git commit -m "feat: add user authentication"
# or
git commit -m "fix: resolve navigation bug"

Commit Message Format:

  • feat: for new features
  • fix: for bug fixes
  • docs: for documentation changes
  • style: for formatting changes
  • refactor: for code refactoring
  • test: for adding tests
  • chore: for maintenance tasks

5. Keep Your Branch Updated

git fetch upstream
git rebase upstream/main
# or upstream/dev depending on the project

6. Push Your Changes

git push origin feature/your-feature-name

πŸ“€ Pull Request Guidelines

Before Submitting

  • Your code follows the project's style guidelines
  • You've tested your changes thoroughly
  • You've updated relevant documentation
  • Your commits are clean and well-organized
  • You've rebased with the latest upstream changes
  • You've thought from the reviewer's perspective and made your PR easy to review

Submitting a Pull Request

  1. Go to the original repository on GitHub
  2. Click "New Pull Request"
  3. Select your fork and branch
  4. Fill out the PR template with:
    • Clear description of changes
    • Link to related issue(s)
    • Screenshots (if UI changes)
    • Testing steps

PR Description Template

## Description
Brief description of what this PR does

## Related Issue
Closes #issue_number


## Screenshots/Video (if applicable)
Add screenshots here

## Testing(if applicable)
Steps to test the changes

## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] Tests added/updated

After Submission

  • Post your PR in the project's Discord channel for visibility(IMPORTANT)
  • Respond to review comments promptly
  • Make requested changes in new commits
  • Be patient - maintainers will review when available
  • Use [WIP] in your PR title for incomplete PRs. Don't use this as a way to gatekeep; focus on one change until it gets merged.

Reviewing PRs

  • Instead of opening duplicate PRs, help review and improve existing ones.
  • When reviewing, assess whether the change is actually necessary before diving into implementation details and functionality testing.

πŸ“ Code Style Guidelines

  • The UI is for young children: prefer icons over text, keep text to a minimum, and give every icon-only button an aria-label and a title.
  • Use the AOSSIE brand: colours from the CSS variables in src/app.css (Golden Wallet #FFCD00, Baggy Green #00843D, #121212, #FFFFFF, #7A7A7A) and the Inter font. Do not hard-code new colours when a token exists.
  • Use Svelte 5 runes ($state, $derived, $props, $effect). Shared state lives in src/lib/app.svelte.ts.
  • Keep game logic in plain, testable TypeScript modules under src/lib/ and add tests next to them (*.test.ts).
  • The app must stay purely local: no network requests at runtime, no analytics, no external fonts or CDNs.
  • Do not edit generated content by hand: change and re-run the scripts instead β€” npm run build-shapes (public/cards/shapes/, drawn by src/lib/shapes.ts), npm run build-capitals (public/cards/capitals/, from Flag Quiz's photos) and npm run build-credits (public/credits.html, public/credits-i18n/).
  • Built-in card sets are in src/lib/sets.ts: a set is a name, topics and cards (picture + description), and every text must exist in every language (src/locales/<lang>.ts, and for the shapes src/locales/shapes/<lang>.json). npm test checks that.
  • Every photo must be freely licensed and credited: keep the author, licence and source of each one (the capitals script does this for Wikimedia Commons).

General Guidelines

  • Use meaningful variable and function names
  • Keep functions small and focused
  • Add comments for complex logic
  • Remove console.logs before committing
  • Avoid code duplication
  • Avoid unnecessary complexity and minor over-optimization

JavaScript/TypeScript

  • Use ES6+ syntax
  • Prefer const over let, avoid var
  • Use arrow functions where appropriate
  • Follow ESLint rules

Python

  • Follow PEP 8 style guide
  • Use type hints where applicable
  • Write docstrings for functions/classes

πŸ”§ Debugging Pre-commit Hooks

Pre-commit hooks help maintain code quality by running automated checks before each commit. This section helps you troubleshoot common issues.

Initial Setup

If pre-commit is configured in this project, install it first:

pip install pre-commit
pre-commit install

Common Errors and Solutions

1. Pre-commit Hook Failed: Trailing Whitespace

Error:

Trim Trailing Whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Solution:

# Pre-commit automatically fixes this. Just re-stage and commit:
git add .
git commit -m "your message"

2. Pre-commit Hook Failed: End of File Fixer

Error:

Fix End of Files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Solution:

# Files are automatically fixed. Re-add and commit:
git add .
git commit -m "your message"

3. Pre-commit Hook Failed: Check YAML/JSON/TOML

Error:

Check Yaml..........................................Failed
- hook id: check-yaml
- exit code: 1

File .github/workflows/test.yml: mapping values are not allowed here

Solution:

# Fix the syntax error in the file (check line number in error)
# Common issues:
# - Incorrect indentation
# - Missing colons
# - Invalid characters
# Then commit again

4. Pre-commit Hook Failed: Detect Secrets

Error:

detect-secrets...........................................................Failed
- hook id: detect-secrets
- exit code: 1

Potential secrets about to be added to git repo:

  Secret Type: AWS Access Key
  Location:    config/settings.py:42

Solution:

# Option 1: Remove the secret and use environment variables
# Replace hardcoded secrets with:
# API_KEY = os.getenv('API_KEY')

# Option 2: If it's a false positive, update baseline:
# detect-secrets scan > .secrets.baseline
# git add .secrets.baseline

5. Pre-commit Hook Failed: Mixed Line Endings

Error:

Mixed line ending........................................................Failed
- hook id: mixed-line-ending
- exit code: 1
- files were modified by this hook

Solution:

# Automatically fixed to LF. Re-add and commit:
git add .
git commit -m "your message"

6. Pre-commit Hook Failed: Large Files

Error:

Check for added large files..............................................Failed
- hook id: check-added-large-files
- exit code: 1

large.zip (5.2 MB) exceeds 500 KB

Solution:

# Option 1: Remove large files
git rm --cached large.zip

# Option 2: Use Git LFS for large files
git lfs install
git lfs track "*.zip"
git add .gitattributes

# Option 3: Increase limit (not recommended)
# Edit .pre-commit-config.yaml:
# args: ['--maxkb=10000']  # 10MB

7. Pre-commit Hook Failed: Merge Conflict Markers

Error:

Check for merge conflicts................................................Failed
- hook id: check-merge-conflict
- exit code: 1

Merge conflict markers found in:
  src/main.js:45

Solution:

# Open the file and remove conflict markers:
# <<<<<<< HEAD
# =======
# >>>>>>> branch-name

# Then commit again

8. Pre-commit Not Running

Problem: Commits go through without pre-commit checks

Solution:

# Reinstall pre-commit hooks
pre-commit uninstall
pre-commit install

# Verify installation
pre-commit run --all-files

9. Pre-commit Takes Too Long

Problem: Pre-commit is slow on every commit

Solution:

# Run only on changed files (default behavior)
git commit -m "message"

# Skip pre-commit for quick commits (use sparingly!)
git commit --no-verify -m "message"

# Update pre-commit hooks
pre-commit autoupdate

10. Hook Installation Failed

Error:

An error has occurred: InvalidManifestError:
=====> /path/to/.pre-commit-config.yaml does not exist

Solution:

# Ensure you're in the project root directory
cd /path/to/project/root

# Verify config file exists
ls -la .pre-commit-config.yaml

# Reinstall
pre-commit install

Bypassing Pre-commit (Emergency Only)

⚠️ Use only when absolutely necessary:

# Skip pre-commit hooks for a single commit
git commit --no-verify -m "emergency fix"

# Or use the short flag
git commit -n -m "emergency fix"

Note: This should be rare. If you need to bypass frequently, discuss with maintainers.

Running Pre-commit Manually

# Run all hooks on all files
pre-commit run --all-files

# Run a specific hook
pre-commit run trailing-whitespace --all-files

# Run on specific files
pre-commit run --files src/main.js src/utils.js

Updating Pre-commit Hooks

# Update to latest versions
pre-commit autoupdate

# Clean and reinstall
pre-commit clean
pre-commit install

Getting Help

If you encounter issues not covered here:

  1. Check pre-commit documentation
  2. Review the error message carefully (it usually tells you what's wrong)
  3. Ask in the project's Discord channel
  4. Search for similar issues in the repository

Remember: Pre-commit hooks are there to help you maintain code quality. Don't fight them - fix the issues they find!

🌟 Community Guidelines

Communication

  • Be respectful and inclusive
  • Provide constructive feedback
  • Help others when you can
  • Ask questions - no question is too small!

Progress Updates

  • If your work is taking longer than expected, comment on the discord with updates
  • Issues should be completed within 5-30 days depending on complexity
  • If you can no longer work on an issue, let maintainers know on discord

Getting Help

  • Check existing documentation first
  • Search closed issues for similar problems
  • Ask in Discord
  • Tag maintainers if your PR is unattended for 1-2 weeks on discord

Thank you for contributing to Memo! Your efforts help make this project better for everyone. πŸš€