Code Style
JavaScript/Astro
The project uses Prettier for automatic code formatting with the following configuration:- Indentation: 2 spaces
- Quotes: Double quotes for strings
- Semicolons: Enabled
- Max line width: 100 characters
- Trailing commas: ES5 style
Best Practices
- Use
constinstead ofletwhen possible - Variable and function names in camelCase
- Component names in PascalCase
- Avoid
var- useconstorlet
CSS/Tailwind
The project uses Tailwind CSS with automatic class ordering viaprettier-plugin-tailwindcss.
Best Practices
- Use CSS variables for colors and theme values
- Prioritize Tailwind classes over custom CSS
- Maintain consistency with the design system
- Use defined border-radius variables
File Organization
Directory Structure
Naming Conventions
| File Type | Convention | Example |
|---|---|---|
| Astro Components | PascalCase | WordCard.astro, SearchBox.astro |
| JavaScript files | camelCase | slug.js, helpers.js |
| CSS files | kebab-case | global.css, theme-vars.css |
| Word files (Markdown) | kebab-case, no accents, lowercase | chapin.md, a-huevo.md |
Important: Word filenames must be:
- All lowercase
- Without accents (e.g.,
puchica.mdnotpúchica.md) - Use hyphens for spaces (e.g.,
a-huevo.md) - Same filename in both
words-es/andwords-en/
Commit Conventions
The project follows Conventional Commits specification:Commit Types
feat:- New feature or functionalityfix:- Bug fixdocs:- Documentation updatesstyle:- Formatting changes (no functional changes)refactor:- Code refactoringtest:- Adding testschore:- Maintenance tasks (dependencies, etc.)
Commit Message Format
Examples from the Project
Here are actual commit messages from the Chapinismos repository:Writing Good Commit Messages
Do:- Use lowercase for the description
- Be concise but descriptive
- Start with a verb (add, update, fix, remove)
- Focus on “what” and “why”, not “how”
- Reference issues when relevant:
fix: resolve search bug (#123)
- End with a period
- Use vague messages like “fix stuff” or “updates”
- Include multiple unrelated changes in one commit
Examples
Word Entry Guidelines
Required Fields
Every word entry must include:Valid Categories
Spanish (words-es/):
"sustantivo"(noun)"verbo"(verb)"adjetivo"(adjective)"expresión"(expression)"modismo"(idiom)
words-en/):
"noun""verb""adjective""expression""idiom"
Content Quality Standards
Writing examples:- Use realistic, everyday scenarios
- Show the word in different contexts
- Make examples relatable and culturally relevant
- Keep examples concise but complete
Code Quality Tools
Prettier (Code Formatter)
Format all code before committing:- Automatic Tailwind class ordering
- Astro file support
- Consistent code style across the project
ESLint (Code Linter)
Run linter to catch potential issues:eslint-plugin-astro- Astro-specific ruleseslint-plugin-jsx-a11y- Accessibility validation- Modern ES6+ rules
- Best practices enforcement
Zod Validation
The project uses Zod for runtime validation of word entries:- Missing required fields
- Invalid data types
- Invalid category values
- Other schema violations
Pre-Commit Checklist
Before committing your changes, ensure:
- ✅ Code follows style guidelines
- ✅ Run
pnpm run formatto format code - ✅ Run
pnpm run lintto check for issues - ✅ Run
pnpm run buildto validate content - ✅ Test changes with
pnpm run dev - ✅ Commit message follows Conventional Commits
- ✅ No console errors or warnings
VS Code Configuration
The project includes recommended VS Code settings:- Format on save - Automatic Prettier formatting
- ESLint auto-fix - Fix issues on save
- Recommended extensions:
- Astro
- Prettier
- ESLint
- Tailwind CSS IntelliSense
Additional Resources
- Prettier Documentation
- ESLint Documentation
- Conventional Commits Spec
- Zod Documentation
- Astro Style Guide
Next, learn about the Pull Request process to submit your contributions!