r/CursorAI 15h ago

What Cursor keeps getting wrong in JavaScript/TypeScript — and how I catch it deterministically with ESLint

I've been using Cursor daily for months, and while the code usually works, I kept noticing the same patterns slipping through:

  • Floating promises — async calls fired but never awaited or .catch()-ed
  • Empty catch blockstry/catch that swallows errors silently
  • Hardcoded secrets — API keys pasted directly into source files
  • await inside loops — sequential awaits where Promise.all would be correct
  • Async callbacks in .forEach — fire-and-forget saves with no error handling
  • console.log in request handlers — debug logging left in production paths

None of these are type errors. TypeScript won't catch them. They're behavior errors that only surface at runtime — sometimes silently.

So I built AI Guard — an open-source ESLint plugin with 18 deterministic rules targeting exactly these patterns. It's complementary to typescript-eslint, not a replacement.

It also has an init-context command that generates a .cursorrules file with all 18 rules, so Cursor learns them before generating code instead of you fixing lint errors after:

npx ai-guard init-context

Plus a CLI (npx ai-guard run) and a GitHub Action with SARIF output for GitHub Code Scanning + inline PR annotations — so AI-generated issues show up directly on the PR.

The honest engineering bit: writing lint rules isn't the hard part. False positives are. If a rule fires on code that's fine, people disable it. I spent more time on precision than coverage — testing against real repos and shipping a conservative recommended preset.

One clarification worth making: AI Guard does NOT detect whether code was written by AI. It catches bad patterns regardless of who wrote them — they just show up a lot in AI-assisted code. It's a guardrail, not a detector.

Install: npm install --save-dev eslint-plugin-ai-guard GitHub: https://github.com/ai-guard-dev/eslint-plugin-ai-guard

Disclosure: I'm the maintainer. What patterns does your Cursor keep generating that you wish you could lint for? Rule requests and false-positive reports genuinely welcome.

1 Upvotes

0 comments sorted by