Marketplace
Browse and adopt engineering standards, rules, and configurations. Fork to customize for your organization.
Use async/await over callbacks and .then()
javascript
Prefer async/await for asynchronous code: - More readable than callbacks or .then() chains - Easier error handling with try/catch - Works naturally...
Use const and let, never var
javascript
Always use `const` by default, `let` when reassignment is needed: - `const`: Block-scoped, cannot be reassigned - `let`: Block-scoped, can be reass...
Avoid N+1 queries
rails
Use eager loading to prevent N+1 queries: - `includes`: For associations you'll access - `preload`: Force separate queries (useful for complex cond...
Fat models, skinny controllers
rails
Keep controllers thin - they should only: - Authenticate and authorize - Parse params and set instance variables - Call model/service methods - Ren...
Use background jobs for slow operations
rails
Move slow operations to background jobs: - Email sending - File processing - External API calls - Report generation - Data imports/exports Use Sol...
Use functional components with hooks
react
Always use functional components with hooks, not class components: - Simpler, less boilerplate - Better TypeScript support - Easier to test - Hooks...
Prefer composition over inheritance
ruby
In Ruby, favor composition and modules over deep inheritance hierarchies: - Use modules for shared behavior (concerns in Rails) - Inject dependenci...
Test behavior, not implementation
testing
Write tests that verify behavior, not internal implementation: - Test public interfaces, not private methods - Focus on inputs and outputs - Tests ...
Use has_many :through over HABTM
rails
Always use `has_many :through` instead of `has_and_belongs_to_many`: - Allows adding attributes to the join model - Provides a model for the join t...
Use scopes for common queries
rails
Define scopes for frequently used query conditions: - Makes code more readable - Enables method chaining - Centralizes query logic - Easier to test...
Explicit return values in methods
ruby
Be intentional about method return values: - Methods that perform actions should return meaningful results or self - Query methods should return th...
Integration tests over unit tests for web apps
testing
For web applications, prefer integration/request tests over isolated unit tests: - Test the full request/response cycle - Catch issues with middlew...
One assertion per test (conceptually)
testing
Each test should verify one logical concept: - Multiple assertions are fine if they test the same thing - Separate tests for separate behaviors - C...
Use fixtures for test data
testing
Use fixtures for consistent test data. Fixtures are: - Fast: loaded at database level, not through ActiveRecord - Simple: YAML files, no DSL to lea...