Skip to content

Commit 371a656

Browse files
committed
feat: Add code style guide
1 parent d45213e commit 371a656

File tree

5 files changed

+622
-12
lines changed

5 files changed

+622
-12
lines changed

.agent/rules/code-style.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Code Style
2+
3+
All code must follow the RiLiGar formatting standards enforced by Prettier.
4+
5+
## Formatting Rules
6+
7+
| Rule | Value | Example |
8+
| --- | --- | --- |
9+
| Indentation | 4 spaces | ` const x = 1` |
10+
| Tabs | Never | Use spaces only |
11+
| Semicolons | Never | `const x = 1` not `const x = 1;` |
12+
| Quotes | Single | `'string'` not `"string"` |
13+
| Trailing Commas | ES5 | Arrays and objects, not function params |
14+
| Bracket Spacing | Yes | `{ key: value }` not `{key: value}` |
15+
| Arrow Parens | Avoid | `x => x` not `(x) => x` |
16+
| Line Endings | LF | Unix-style |
17+
| Print Width | 300 | Long lines allowed |
18+
| JSX Attributes | One per line | See below |
19+
20+
## JSX Formatting
21+
22+
```jsx
23+
// Good - one attribute per line
24+
<Button
25+
variant="filled"
26+
color="blue"
27+
onClick={handleClick}
28+
>
29+
Submit
30+
</Button>
31+
32+
// Bad - multiple attributes on same line
33+
<Button variant="filled" color="blue" onClick={handleClick}>Submit</Button>
34+
```
35+
36+
## Code Examples
37+
38+
```javascript
39+
// Good
40+
const getUserData = async id => {
41+
const response = await fetch(`/api/users/${id}`)
42+
return response.json()
43+
}
44+
45+
const config = {
46+
apiUrl: 'https://api.example.com',
47+
timeout: 5000,
48+
retries: 3,
49+
}
50+
51+
// Bad
52+
const getUserData = async (id) => {
53+
const response = await fetch("/api/users/" + id);
54+
return response.json();
55+
};
56+
57+
const config = {apiUrl: "https://api.example.com", timeout: 5000, retries: 3}
58+
```
59+
60+
## Object and Array Formatting
61+
62+
```javascript
63+
// Good - trailing comma
64+
const options = {
65+
name: 'app',
66+
version: '1.0.0',
67+
debug: true,
68+
}
69+
70+
const items = [
71+
'first',
72+
'second',
73+
'third',
74+
]
75+
76+
// Bad - no trailing comma
77+
const options = {
78+
name: 'app',
79+
version: '1.0.0',
80+
debug: true
81+
}
82+
```
83+
84+
## Import Organization
85+
86+
```javascript
87+
// 1. External dependencies
88+
import { useState, useEffect } from 'react'
89+
import { Button, Text } from '@mantine/core'
90+
91+
// 2. Internal modules
92+
import { useAuth } from '@/hooks/useAuth'
93+
import { api } from '@/services/api'
94+
95+
// 3. Components
96+
import { Header } from '@/components/Header'
97+
98+
// 4. Styles, assets, types (if any)
99+
import styles from './styles.module.css'
100+
```
101+
102+
## Prettier Config Reference
103+
104+
```json
105+
{
106+
"printWidth": 300,
107+
"singleAttributePerLine": true,
108+
"tabWidth": 4,
109+
"useTabs": false,
110+
"semi": false,
111+
"singleQuote": true,
112+
"quoteProps": "as-needed",
113+
"trailingComma": "es5",
114+
"bracketSpacing": true,
115+
"bracketSameLine": false,
116+
"arrowParens": "avoid",
117+
"endOfLine": "lf"
118+
}
119+
```
120+
121+
## Auto-Format
122+
123+
Run Prettier before committing:
124+
125+
```bash
126+
bunx prettier --write .
127+
```
Lines changed: 90 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,96 @@
1-
# Conventional Commits Standards
1+
# Conventional Commits
22

3-
All commits in this repository must follow the Conventional Commits specification. This ensures that our automated release pipeline can correctly calculate version bumps and generate changelogs.
3+
All commits must follow the Conventional Commits specification for automated releases and changelogs.
44

55
## Format
66

7-
`<type>(<scope>): <description>`
7+
```
8+
<type>(<scope>): <description>
89
9-
## Types
10+
[optional body]
1011
11-
- `feat`: A new feature (triggers a MINOR version bump)
12-
- `fix`: A bug fix (triggers a PATCH version bump)
13-
- `docs`: Documentation only changes
14-
- `style`: Changes that do not affect the meaning of the code
15-
- `refactor`: A code change that neither fixes a bug nor adds a feature
16-
- `perf`: A code change that improves performance
17-
- `test`: Adding missing tests or correcting existing tests
18-
- `chore`: Changes to the build process or auxiliary tools and libraries
12+
[optional footer(s)]
13+
```
14+
15+
## Types and Version Bumps
16+
17+
| Type | Description | Version Bump |
18+
| --- | --- | --- |
19+
| `feat` | New feature | MINOR |
20+
| `fix` | Bug fix | PATCH |
21+
| `docs` | Documentation changes | PATCH (if scope: README) |
22+
| `style` | Code style (formatting, no logic change) | PATCH |
23+
| `refactor` | Code refactoring (no new feature, no fix) | PATCH |
24+
| `perf` | Performance improvement | PATCH |
25+
| `test` | Adding or fixing tests | No release |
26+
| `chore` | Build process, dependencies, tooling | No release |
27+
| `chore(release)` | Automated release commits | No release (skip CI) |
28+
29+
## Breaking Changes
30+
31+
For MAJOR version bumps, add `BREAKING CHANGE:` in the footer or `!` after type:
32+
33+
```
34+
feat!: remove deprecated API endpoints
35+
36+
BREAKING CHANGE: The /v1/users endpoint has been removed. Use /v2/users instead.
37+
```
38+
39+
## Scope (Optional)
40+
41+
Scope provides context. Common scopes:
42+
43+
- `feat(auth)`: Authentication feature
44+
- `fix(api)`: API bug fix
45+
- `docs(README)`: README update
46+
- `refactor(components)`: Component refactoring
47+
48+
## Examples
49+
50+
```bash
51+
# Feature (MINOR bump)
52+
feat: add dark mode toggle to settings
53+
54+
# Bug fix (PATCH bump)
55+
fix: resolve race condition in form submission
56+
57+
# Documentation (PATCH bump if README)
58+
docs(README): update installation instructions
59+
60+
# Refactor (PATCH bump)
61+
refactor: extract validation logic to separate module
62+
63+
# Style (PATCH bump)
64+
style: format code with prettier
65+
66+
# Chore (no release)
67+
chore: update dependencies
68+
69+
# Breaking change (MAJOR bump)
70+
feat!: redesign authentication flow
71+
72+
BREAKING CHANGE: Session tokens now use JWT format.
73+
```
74+
75+
## Branches
76+
77+
| Branch | Release Type | Tag |
78+
| --- | --- | --- |
79+
| `prod` | Production release | `v1.2.3` |
80+
| `main` | Pre-release | `v1.2.3-rc.1` |
81+
82+
## Quick Reference
83+
84+
```bash
85+
# Good
86+
feat: add user profile page
87+
fix(auth): handle expired tokens gracefully
88+
docs: update API documentation
89+
refactor(utils): simplify date formatting
90+
91+
# Bad
92+
added new feature # no type
93+
feat add something # missing colon
94+
Feat: Add Something # wrong case
95+
feat(): empty scope # don't use empty scope
96+
```

.agent/rules/javascript-only.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# JavaScript Only
2+
3+
RiLiGar projects use **JavaScript ES6+ exclusively**. TypeScript is prohibited.
4+
5+
## Why No TypeScript
6+
7+
- **Simplicity** — Less tooling, faster builds, no compilation step
8+
- **Bun Native** — Bun runs JavaScript directly with excellent performance
9+
- **Reduced Complexity** — No type gymnastics, no `any` escapes, no config overhead
10+
- **Runtime Validation** — Use runtime checks where needed (Zod, validators)
11+
12+
## Allowed
13+
14+
```javascript
15+
// Modern JavaScript ES6+
16+
const fetchUser = async id => {
17+
const response = await fetch(`/api/users/${id}`)
18+
return response.json()
19+
}
20+
21+
// Destructuring
22+
const { name, email } = user
23+
24+
// Spread operator
25+
const newConfig = { ...config, debug: true }
26+
27+
// Optional chaining
28+
const city = user?.address?.city
29+
30+
// Nullish coalescing
31+
const value = input ?? 'default'
32+
33+
// Array methods
34+
const names = users.map(u => u.name).filter(Boolean)
35+
```
36+
37+
## Prohibited
38+
39+
```typescript
40+
// NO TypeScript files
41+
// ❌ .ts, .tsx files
42+
// ❌ tsconfig.json
43+
// ❌ Type annotations
44+
45+
// Bad
46+
const fetchUser = async (id: string): Promise<User> => { ... }
47+
interface User { name: string; email: string }
48+
type Status = 'active' | 'inactive'
49+
50+
// Good (JavaScript)
51+
const fetchUser = async id => { ... }
52+
```
53+
54+
## File Extensions
55+
56+
| Allowed | Prohibited |
57+
| --- | --- |
58+
| `.js` | `.ts` |
59+
| `.jsx` | `.tsx` |
60+
| `.mjs` | `.mts` |
61+
| `.cjs` | `.cts` |
62+
63+
## Runtime Validation (When Needed)
64+
65+
For API boundaries or user input, use runtime validation:
66+
67+
```javascript
68+
// Using Zod for runtime validation
69+
import { z } from 'zod'
70+
71+
const UserSchema = z.object({
72+
name: z.string().min(1),
73+
email: z.string().email(),
74+
age: z.number().optional(),
75+
})
76+
77+
const validateUser = data => {
78+
return UserSchema.parse(data)
79+
}
80+
```
81+
82+
## JSDoc (Optional)
83+
84+
If documentation is needed, use JSDoc comments:
85+
86+
```javascript
87+
/**
88+
* Fetches user data from the API
89+
* @param {string} id - The user ID
90+
* @returns {Promise<Object>} The user data
91+
*/
92+
const fetchUser = async id => {
93+
const response = await fetch(`/api/users/${id}`)
94+
return response.json()
95+
}
96+
```
97+
98+
## IDE Support
99+
100+
For better IDE experience without TypeScript:
101+
102+
1. Use JSDoc annotations where helpful
103+
2. Configure VS Code `jsconfig.json` for path aliases
104+
3. Rely on Prettier for consistent formatting
105+
106+
```json
107+
// jsconfig.json
108+
{
109+
"compilerOptions": {
110+
"baseUrl": ".",
111+
"paths": {
112+
"@/*": ["src/*"]
113+
}
114+
}
115+
}
116+
```

0 commit comments

Comments
 (0)