|
| 1 | +# ESLint Rules Decision Tree |
| 2 | + |
| 3 | +``` |
| 4 | +┌─────────────────────────────────────────────────────────────┐ |
| 5 | +│ Start: Which ESLint rules should I implement? │ |
| 6 | +└────────────────────┬────────────────────────────────────────┘ |
| 7 | + │ |
| 8 | + ▼ |
| 9 | + ┌─────────────────────┐ |
| 10 | + │ How much time do │ |
| 11 | + │ you have? │ |
| 12 | + └─┬─────────┬─────────┘ |
| 13 | + │ │ |
| 14 | + ┌────────┘ └────────┐ |
| 15 | + │ │ |
| 16 | + ▼ ▼ |
| 17 | +┌───────────┐ ┌────────────────┐ |
| 18 | +│ 5 minutes │ │ 4 weeks │ |
| 19 | +└─────┬─────┘ └────────┬───────┘ |
| 20 | + │ │ |
| 21 | + ▼ ▼ |
| 22 | +┌─────────────────────┐ ┌──────────────────────┐ |
| 23 | +│ QUICK WINS │ │ COMPREHENSIVE │ |
| 24 | +│ │ │ │ |
| 25 | +│ 1. Security rules │ │ Week 1: High Priority│ |
| 26 | +│ (zero violations)│ │ - Security │ |
| 27 | +│ │ │ - Type imports │ |
| 28 | +│ 2. Type imports │ │ - Console rules │ |
| 29 | +│ (auto-fix) │ │ │ |
| 30 | +│ │ │ Week 2: Medium │ |
| 31 | +│ 3. prefer-const │ │ - Import order │ |
| 32 | +│ (auto-fix) │ │ - Node.js rules │ |
| 33 | +│ │ │ │ |
| 34 | +│ ✅ Zero breaking │ │ Week 3: Return types │ |
| 35 | +│ ✅ 20-30% rules │ │ - Function returns │ |
| 36 | +│ ✅ Done in 5 min │ │ (start with warn) │ |
| 37 | +└─────────────────────┘ │ │ |
| 38 | + │ Week 4+: Low Priority│ |
| 39 | + │ - Documentation │ |
| 40 | + │ - Comment quality │ |
| 41 | + │ - Test standards │ |
| 42 | + │ │ |
| 43 | + │ ✅ All 20 rules │ |
| 44 | + │ ✅ ~700 → <100 errors│ |
| 45 | + └──────────────────────┘ |
| 46 | +
|
| 47 | +┌─────────────────────────────────────────────────────────────┐ |
| 48 | +│ Or: Pick specific categories you care about │ |
| 49 | +└────────────────────┬────────────────────────────────────────┘ |
| 50 | + │ |
| 51 | + ▼ |
| 52 | + ┌────────────┴────────────┐ |
| 53 | + │ │ |
| 54 | + ▼ ▼ |
| 55 | + ┌──────────┐ ┌──────────────┐ |
| 56 | + │ Priority?│ │ Goal? │ |
| 57 | + └─┬───┬───┬┘ └─┬────┬───┬───┘ |
| 58 | + │ │ │ │ │ │ |
| 59 | + High Medium Low Type Code Security |
| 60 | + │ │ │ Safety Org |
| 61 | + │ │ │ │ │ │ |
| 62 | + ▼ ▼ ▼ ▼ ▼ ▼ |
| 63 | + |
| 64 | +HIGH PRIORITY TYPE SAFETY |
| 65 | +├─ Security (PR #3) ├─ consistent-type-imports (PR #2) |
| 66 | +├─ Type imports (PR #2) ├─ explicit-function-return-type (PR #5) |
| 67 | +└─ Console rules (PR #1) └─ no-non-null-assertion |
| 68 | +
|
| 69 | +MEDIUM PRIORITY CODE ORGANIZATION |
| 70 | +├─ Import order (PR #4) ├─ import/order (PR #4) |
| 71 | +├─ Return types (PR #5) ├─ import/no-default-export (PR #4) |
| 72 | +└─ Node.js rules (PR #6) └─ Comment quality (PR #8) |
| 73 | +
|
| 74 | +LOW PRIORITY SECURITY |
| 75 | +├─ Modern JS (PR #7) ├─ no-eval (PR #3) |
| 76 | +├─ Comments (PR #8) ├─ no-implied-eval (PR #3) |
| 77 | +└─ Docs (PR #9) └─ prefer-promise-reject-errors (PR #3) |
| 78 | +
|
| 79 | +┌─────────────────────────────────────────────────────────────┐ |
| 80 | +│ Implementation Checklist │ |
| 81 | +└─────────────────────────────────────────────────────────────┘ |
| 82 | +
|
| 83 | +Phase 1: Immediate (No Breaking Changes) |
| 84 | +┌─────────────────────────────────────────┐ |
| 85 | +│ □ Add security baseline rules │ ← 2 min |
| 86 | +│ □ Add modern JS rules (no-var, etc) │ ← 1 min |
| 87 | +│ □ Verify zero violations │ ← 1 min |
| 88 | +│ □ Commit │ ← 1 min |
| 89 | +└─────────────────────────────────────────┘ = 5 min total |
| 90 | +
|
| 91 | +Phase 2: Auto-fixable (Week 1) |
| 92 | +┌─────────────────────────────────────────┐ |
| 93 | +│ □ Install eslint-plugin-unicorn │ ← 1 min |
| 94 | +│ □ Enable consistent-type-imports │ ← 2 min |
| 95 | +│ □ Run npm run lint -- --fix │ ← 1 min |
| 96 | +│ □ Review changes │ ← 5 min |
| 97 | +│ □ Commit │ ← 1 min |
| 98 | +└─────────────────────────────────────────┘ = 10 min total |
| 99 | +
|
| 100 | +Phase 3: Import Organization (Week 2) |
| 101 | +┌─────────────────────────────────────────┐ |
| 102 | +│ □ Install eslint-plugin-import │ ← 1 min |
| 103 | +│ □ Configure import/order │ ← 3 min |
| 104 | +│ □ Run npm run lint -- --fix │ ← 1 min |
| 105 | +│ □ Review changes │ ← 10 min |
| 106 | +│ □ Test builds │ ← 2 min |
| 107 | +│ □ Commit │ ← 1 min |
| 108 | +└─────────────────────────────────────────┘ = 18 min total |
| 109 | +
|
| 110 | +Phase 4: Gradual Adoption (Week 3-4) |
| 111 | +┌─────────────────────────────────────────┐ |
| 112 | +│ □ Add no-console with CLI exceptions │ ← 5 min config |
| 113 | +│ □ Add explicit-return-type as "warn" │ ← 2 min config |
| 114 | +│ □ Address violations gradually │ ← Ongoing |
| 115 | +│ □ Upgrade to "error" when ready │ ← Later |
| 116 | +└─────────────────────────────────────────┘ |
| 117 | +
|
| 118 | +Phase 5: Additional Tooling (Ongoing) |
| 119 | +┌─────────────────────────────────────────┐ |
| 120 | +│ □ Install eslint-plugin-n │ |
| 121 | +│ □ Install eslint-plugin-jsdoc (warn) │ |
| 122 | +│ □ Install eslint-plugin-eslint-comments │ |
| 123 | +│ □ Add test-specific rules │ |
| 124 | +└─────────────────────────────────────────┘ |
| 125 | +
|
| 126 | +┌─────────────────────────────────────────────────────────────┐ |
| 127 | +│ Success Metrics │ |
| 128 | +└─────────────────────────────────────────────────────────────┘ |
| 129 | +
|
| 130 | +Current State: |
| 131 | + Lint errors: ~700 (mostly no-unsafe-*) |
| 132 | + eslint-disable: 2 instances |
| 133 | + Config: ESLint 9.32 + typescript-eslint 8.38 |
| 134 | + |
| 135 | +After Quick Wins (5 min): |
| 136 | + New rules: 6-8 rules enabled |
| 137 | + Violations: 0 (all zero-impact) |
| 138 | + Rules coverage: 20-30% |
| 139 | + |
| 140 | +After Comprehensive (4 weeks): |
| 141 | + New rules: 20 rules enabled |
| 142 | + Target violations: <100 errors |
| 143 | + Rules coverage: 100% |
| 144 | + Packages added: 6 optional plugins |
| 145 | +
|
| 146 | +┌─────────────────────────────────────────────────────────────┐ |
| 147 | +│ Rule Categories Quick Reference │ |
| 148 | +└─────────────────────────────────────────────────────────────┘ |
| 149 | +
|
| 150 | +Security (PR #3) ⭐⭐⭐ |
| 151 | + no-eval, no-implied-eval, no-throw-literal |
| 152 | + Impact: Low | Auto-fix: No | Breaking: No |
| 153 | + |
| 154 | +Type Safety (PR #2, #5) ⭐⭐⭐ |
| 155 | + consistent-type-imports, explicit-function-return-type |
| 156 | + Impact: High | Auto-fix: Partial | Breaking: No |
| 157 | + |
| 158 | +Code Org (PR #4) ⭐⭐ |
| 159 | + import/order, import/no-default-export |
| 160 | + Impact: Medium | Auto-fix: Yes | Breaking: No |
| 161 | + |
| 162 | +Console (PR #1) ⭐⭐ |
| 163 | + no-console (with CLI exceptions) |
| 164 | + Impact: Medium | Auto-fix: No | Breaking: No |
| 165 | + |
| 166 | +Node.js (PR #6) ⭐⭐ |
| 167 | + n/no-deprecated-api, n/prefer-node-protocol |
| 168 | + Impact: Low | Auto-fix: Partial | Breaking: No |
| 169 | + |
| 170 | +Modern JS (PR #7) ⭐ |
| 171 | + prefer-const, no-var, prefer-template |
| 172 | + Impact: Low | Auto-fix: Yes | Breaking: No |
| 173 | + |
| 174 | +Comments (PR #8) ⭐ |
| 175 | + no-warning-comments, eslint-comments/* |
| 176 | + Impact: Low | Auto-fix: Partial | Breaking: No |
| 177 | + |
| 178 | +Docs (PR #9) ⭐ |
| 179 | + jsdoc/require-jsdoc |
| 180 | + Impact: High | Auto-fix: No | Breaking: No |
| 181 | + |
| 182 | +Tests (PR #10) ⭐ |
| 183 | + Test-specific overrides |
| 184 | + Impact: Low | Auto-fix: No | Breaking: No |
| 185 | +
|
| 186 | +┌─────────────────────────────────────────────────────────────┐ |
| 187 | +│ When to Use Which Document │ |
| 188 | +└─────────────────────────────────────────────────────────────┘ |
| 189 | +
|
| 190 | +ESLINT_README.md |
| 191 | + ├─ First-time reading |
| 192 | + ├─ Need overview |
| 193 | + └─ Choosing your path |
| 194 | + |
| 195 | +ESLINT_RECOMMENDATIONS.md |
| 196 | + ├─ Understanding patterns |
| 197 | + ├─ Deep analysis |
| 198 | + └─ The "why" behind rules |
| 199 | + |
| 200 | +ESLINT_PR_PROPOSALS.md |
| 201 | + ├─ Creating PRs |
| 202 | + ├─ Copy-paste configs |
| 203 | + └─ Step-by-step guides |
| 204 | + |
| 205 | +ESLINT_QUICKSTART.md |
| 206 | + ├─ Just getting started |
| 207 | + ├─ Need templates |
| 208 | + └─ Quick reference |
| 209 | +
|
| 210 | +┌─────────────────────────────────────────────────────────────┐ |
| 211 | +│ Decision: Start Now! │ |
| 212 | +└─────────────────────────────────────────────────────────────┘ |
| 213 | +
|
| 214 | + Choose your path above ↑ |
| 215 | + |
| 216 | + Then: |
| 217 | + 1. Open the appropriate document |
| 218 | + 2. Follow the steps |
| 219 | + 3. Commit changes |
| 220 | + 4. Ship it! 🚀 |
| 221 | +
|
| 222 | + All paths lead to better code quality! |
| 223 | +``` |
0 commit comments