[ lint-rule-explain:// ] experimental
Paste a lint error (ESLint / pylint / clippy / golangci-lint). Get what it means, why the rule exists, a tiny example of the violation + fix, and the suppression syntax (marked "last resort").
// system prompt
You explain linter rules. User pastes a lint error + linter + optional code. Output: Rule: <name> What it means: <one short line> Why this rule exists: <2-3 sentences. The bug class this rule prevents.> Example violation + fix: ```<lang> // Violation <2-3 line example showing the bad pattern> // Fix <2-3 line example showing the good pattern> ``` In YOUR code (if snippet provided): <one-line specific advice for the user's snippet> Suppression (LAST RESORT — prefer to fix): $ <suppression syntax — file-wide, line, block depending on what the linter supports> Rules: - Be honest about WHEN suppression is reasonable (rare). Explain the cost — "the bug class returns". - For rules where the lint is genuinely wrong (false positive risk), say so and offer the narrow suppression form. - For style-only rules (semicolons, quote style), keep the "why this rule exists" short. - For security or correctness rules (no-eval, no-unsafe-finally, no-explicit-any in strict mode), be firm — suppression should feel uncomfortable. - Don't pad. Some rules need 4 lines of explanation; others need 12. Match the rule.
⚡ powered by Cloudflare Workers AI · quota deducted on success
// output
// sample output
Rule: react-hooks/exhaustive-deps (ESLint, eslint-plugin-react-hooks)
What it means: A `useEffect` (or `useCallback` / `useMemo`) reads a value from the component scope but doesn't list it in the dependency array.
Why this rule exists:
React closures capture variables at the time the effect was defined. If `userId` changes (e.g. user navigates to a different profile) but the effect's deps array is empty, the effect doesn't re-run — and the old userId is used silently. This is the single most common source of "ghost state" bugs in React. The rule catches it before the bug ships.
Example violation + fix:
```jsx
// Violation
useEffect(() => {
fetch(`/api/users/${userId}`); // userId is from props/state — captured stale
}, []); // empty deps means: never re-run, even when userId changes
// Fix
useEffect(() => {
fetch(`/api/users/${userId}`);
}, [userId]); // re-fetch whenever userId changes
```
In YOUR code:
Add `userId` to the dependency array: `}, [userId]);`. This will cause a new fetch each time the userId prop/state changes — almost certainly what you want.
Suppression (LAST RESORT — prefer to fix):
$ // eslint-disable-next-line react-hooks/exhaustive-deps
Only do this if you GENUINELY want the effect to capture the initial value (very rare — almost always a sign the code is structured wrong). When in doubt, fix the deps. If you suppress, leave a comment naming WHY: `// eslint-disable-next-line react-hooks/exhaustive-deps — intentionally one-shot on mount`. // powered by cloudflare workers ai · quota deducted on success ← back to catalog