Lesson 23 / 27
Best Practices & Anti-patterns
Follow ESLint and Prettier best practices: extend shared configs, adopt gradually and never skip CI checks.
Key principles
DO: extend shared configs, prefer warn before error when adopting, commit configs to git. DON'T: switch off core rules, ignore formatter conflicts, skip CI checks.
Good vs bad patterns
Compare good and bad ESLint configuration patterns.
// GOOD: shared config, specific overrides, gradual severity
export default [
js.configs.recommended,
prettier,
{ files: ['**/*.test.js'], rules: { 'no-console': 'off' } },
{ rules: { 'no-console': 'warn' } },
];
// BAD: switch off core rules wholesale
export default [{ rules: { 'no-unused-vars': 'off', 'no-undef': 'off' } }];
// BAD: strict errors on day one
export default [{ rules: { 'no-console': 'error' } }];
Output:
Good patterns use extends, overrides, and warn initially
Evolution over time
Start loose (warn, few rules) and tighten over time (error, more rules) as the team adapts. This reduces friction and improves adoption.
Quick check
Quick check: What's a best practice for team adoption?
- Enforce all rules as errors immediately.
- Disable most rules.
- Start with warn, gradually move to error as team adapts.
- Skip CI checks
Answer
Start with warn, gradually move to error as team adapts. — Gradual enforcement reduces resistance and allows the team to adjust their workflow progressively.