feat: add JS-009 rule for Utils.showToast() and update naming docs
Architecture rules: - Add JS-009: Use Utils.showToast() instead of alert() or window.showToast - Supports inline noqa comments to suppress warnings Documentation: - Update naming-conventions.md to emphasize plural table names (industry standard) - Document that plural table names follow Rails/Django/Laravel conventions Schema: - Add from_attributes to VendorUserResponse for ORM compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -285,17 +285,42 @@ frontend/
|
||||
|
||||
### Database Naming
|
||||
|
||||
**Table Names**: Use singular, lowercase with underscores
|
||||
**Table Names**: Use plural, lowercase with underscores (industry standard)
|
||||
|
||||
Following Rails, Django, Laravel conventions - tables represent collections of entities,
|
||||
so plural names are natural and read well in SQL queries.
|
||||
|
||||
```sql
|
||||
-- ✅ Correct
|
||||
inventory
|
||||
inventory_movements
|
||||
-- ✅ Correct (plural table names)
|
||||
users
|
||||
vendors
|
||||
products
|
||||
orders
|
||||
customers
|
||||
order_items
|
||||
cart_items
|
||||
vendor_users
|
||||
|
||||
-- ❌ Incorrect
|
||||
inventories
|
||||
inventory_movement
|
||||
vendorusers
|
||||
-- ❌ Incorrect (singular table names)
|
||||
user
|
||||
vendor
|
||||
product
|
||||
order
|
||||
customer
|
||||
```
|
||||
|
||||
**Rationale**:
|
||||
- A table holds a *collection* of records (many users, many products)
|
||||
- SQL reads naturally: `SELECT * FROM users WHERE id = 1`
|
||||
- Follows conventions of most ORMs (ActiveRecord, Django ORM, Laravel Eloquent)
|
||||
- Used by ~80% of modern web frameworks
|
||||
|
||||
**Junction/Join Tables**: Combine both entity names in plural
|
||||
```sql
|
||||
-- ✅ Correct
|
||||
vendor_users -- Links vendors and users
|
||||
order_items -- Links orders and products
|
||||
product_translations -- Translations for products
|
||||
```
|
||||
|
||||
**Column Names**: Use singular, descriptive names
|
||||
@@ -410,7 +435,7 @@ class Customer:
|
||||
- [ ] File names follow singular/plural conventions
|
||||
- [ ] Class names use appropriate terminology (inventory vs stock)
|
||||
- [ ] API endpoints use plural resource names
|
||||
- [ ] Database models use singular names
|
||||
- [ ] Database table names use plural (industry standard)
|
||||
- [ ] Variables names match their content (singular vs plural)
|
||||
|
||||
### Automated Checks
|
||||
@@ -428,13 +453,13 @@ Consider implementing linting rules or pre-commit hooks to enforce:
|
||||
| Component | Naming | Example |
|
||||
|-----------|--------|---------|
|
||||
| API Endpoint Files | PLURAL | `products.py`, `orders.py` |
|
||||
| Database Models | SINGULAR | `product.py`, `order.py` |
|
||||
| Database Models (files) | SINGULAR | `product.py`, `order.py` |
|
||||
| Schema/Pydantic | SINGULAR | `product.py`, `order.py` |
|
||||
| Services | SINGULAR + service | `product_service.py` |
|
||||
| Exceptions | SINGULAR | `product.py`, `order.py` |
|
||||
| Middleware | SIMPLE NOUN | `auth.py`, `logging.py`, `context.py` |
|
||||
| Middleware Tests | test_{name}.py | `test_auth.py`, `test_logging.py` |
|
||||
| Database Tables | SINGULAR | `product`, `inventory` |
|
||||
| **Database Tables** | **PLURAL** | `users`, `products`, `orders` |
|
||||
| Database Columns | SINGULAR | `vendor_id`, `created_at` |
|
||||
| API Endpoints | PLURAL | `/products`, `/orders` |
|
||||
| Functions (single) | SINGULAR | `create_product()` |
|
||||
|
||||
Reference in New Issue
Block a user