Fix Cursor ignoring custom ESLint rules by migrating from legacy .cursorrules to .cursor/rules/ with proper glob patterns, referencing your ESLint config with @file in prompts, and adding explicit linting rules that list your custom plugin names and rule IDs. Cursor does not run ESLint directly but can follow your lint rules when they are documented in project rules.
Why Cursor Does Not Follow Your ESLint Config by Default
Cursor does not execute ESLint or read your .eslintrc configuration. It generates code based on AI model knowledge and project rules, which means custom ESLint plugins, team-specific lint rules, and monorepo configurations are invisible to it. This tutorial shows you how to bridge the gap by encoding your most important lint rules into Cursor project rules, using @Lint Errors to catch violations, and structuring monorepo rules for per-package enforcement.
Prerequisites
- Cursor installed (Pro recommended for monorepo context)
- ESLint configured with custom plugins or rules
- A monorepo or multi-package project structure
- Understanding of your team's ESLint rule set
Step-by-step guide
Document critical ESLint rules in .cursorrules
Document critical ESLint rules in .cursorrules
Identify your most important custom ESLint rules and translate them into natural language instructions in .cursorrules. Focus on rules that Cursor violates most frequently rather than trying to encode your entire ESLint config.
1# .cursorrules23## Linting Rules (from our ESLint config)4- No default exports — use named exports only (eslint: import/no-default-export)5- No console.log in production code (eslint: no-console) — use our logger utility6- Prefer const over let, never use var (eslint: prefer-const, no-var)7- Use explicit return types on all exported functions (eslint: @typescript-eslint/explicit-function-return-type)8- Maximum 1 component per file (eslint: react/no-multi-comp)9- No inline styles in React (eslint: react/no-inline-styles) — use sx prop or theme10- Import order: external → internal → relative (eslint: import/order)11- No unused variables — prefix intentionally unused with _ (eslint: @typescript-eslint/no-unused-vars)Pro tip: Include the ESLint rule ID in parentheses next to each instruction. This helps team members understand which lint rule each Cursor rule corresponds to.
Expected result: Cursor follows your most critical ESLint conventions in generated code.
Create per-package rules for monorepo ESLint configs
Create per-package rules for monorepo ESLint configs
In a monorepo, different packages often have different ESLint configs. Create nested .cursor/rules/ directories in each package with rules matching that package's ESLint configuration.
1---2description: Frontend package ESLint rules3globs: "packages/frontend/**"4alwaysApply: false5---67- React rules apply: use functional components only, no class components8- Use React.FC type for all components9- Props must be defined as separate interface above the component10- No direct DOM manipulation (no document.querySelector)11- Use next/image instead of img tags12- All event handlers prefixed with 'handle': handleClick, handleSubmit13- Custom hooks must start with 'use' and be in hooks/ directoryPro tip: Create separate rule files for each package: packages/backend/.cursor/rules/lint.mdc, packages/shared/.cursor/rules/lint.mdc, etc.
Expected result: Different Cursor rules apply to different monorepo packages matching their ESLint configs.
Use @Lint Errors to catch violations after generation
Use @Lint Errors to catch violations after generation
After Cursor generates code, use the @Lint Errors context in Chat to identify ESLint violations. Open Chat (Cmd+L) and reference @Lint Errors to have Cursor read the current linting errors from the Problems panel and fix them.
1// After generating code, if ESLint shows errors in the Problems panel:2// Open Chat (Cmd+L) and type:3// @Lint Errors4// Fix all linting errors in the current file.5// Follow our ESLint config rules for:6// - Import ordering (external → internal → relative)7// - Explicit return types on exported functions8// - Named exports only, no default exportsPro tip: @Lint Errors captures the current ESLint errors from the active file. This is the closest integration between Cursor and ESLint without a custom plugin.
Expected result: Cursor reads the lint errors and fixes each violation according to your ESLint rules.
Reference your ESLint config in complex prompts
Reference your ESLint config in complex prompts
For complex code generation where lint compliance is critical, reference your ESLint config file directly. This gives Cursor the actual rule definitions so it can follow them more precisely than natural language descriptions.
1// Prompt to type in Cursor Composer (Cmd+I):2// @.eslintrc.js @packages/frontend/eslint.config.mjs3// Generate a new UserSettings page component in packages/frontend/.4// Follow ALL rules from the ESLint configs referenced above.5// Pay special attention to:6// - Named exports only7// - Explicit return types8// - React hook rules9// - Import orderingExpected result: Cursor generates code that follows your actual ESLint configuration more closely.
Create a post-generation lint check command
Create a post-generation lint check command
Create a custom Cursor command that runs ESLint on generated files and feeds violations back to the AI for automatic fixing. Save it in .cursor/commands/ for team-wide use.
1---2description: Lint and fix generated code3---451. Run ESLint on the files that were just generated or modified62. Read the ESLint output for any violations73. Fix each violation following our project's ESLint rules84. Re-run ESLint to verify all violations are resolved95. If auto-fixable, apply eslint --fix first, then handle remaining issues1011Common violations to watch for:12- Missing return types → add explicit TypeScript return type13- Default exports → convert to named exports14- console.log → replace with logger.info/error/debug15- Unused imports → remove them16- Wrong import order → reorder: external, internal, relativePro tip: Team members can trigger this with /lint-fix after any code generation session.
Expected result: A reusable command that automatically lints and fixes generated code.
Complete working example
1---2description: ESLint conventions for code generation3globs: "**/*.ts, **/*.tsx, **/*.js, **/*.jsx"4alwaysApply: false5---67# ESLint Rules for Cursor Code Generation89## Exports10- Use named exports ONLY (no default exports)11- Pattern: `export function MyComponent()` or `export const myUtil =`12- Exception: Next.js page components may use default export1314## Types15- Explicit return types on all exported functions16- Props as separate interface above component: `interface MyComponentProps {}`17- Use `unknown` instead of `any`18- Prefer type aliases for unions, interfaces for objects1920## Imports21- Order: 1) external packages, 2) @/ internal aliases, 3) relative paths22- Blank line between each group23- No unused imports24- Use import type for type-only imports2526## React27- Functional components only (no class components)28- Event handlers prefixed with 'handle': handleClick, handleSubmit29- Custom hooks start with 'use', placed in hooks/ directory30- No inline styles — use sx prop or CSS modules3132## General33- const over let, never var34- No console.log — use logger utility from @/lib/logger35- No magic numbers — extract to named constants36- Prefer early returns over nested conditionals37- Maximum 300 lines per fileCommon mistakes
Why it's a problem: Expecting Cursor to read and execute your .eslintrc automatically
How to avoid: Encode your most violated ESLint rules into .cursor/rules/ files and use @Lint Errors to fix violations post-generation.
Why it's a problem: Putting all monorepo ESLint rules in a single root .cursorrules
How to avoid: Use nested .cursor/rules/ directories in each package with package-specific lint rules.
Why it's a problem: Not referencing the ESLint config in complex generation prompts
How to avoid: Add @.eslintrc.js or @eslint.config.mjs to prompts for critical code generation where lint compliance matters.
Best practices
- Encode your top 10 most-violated ESLint rules in .cursorrules with the rule ID in parentheses
- Use nested .cursor/rules/ in monorepo packages for per-package lint conventions
- Reference @Lint Errors in Chat after code generation to catch and fix violations
- Reference your actual ESLint config file with @file for complex generation prompts
- Create a /lint-fix custom command for automated post-generation lint compliance
- Focus on rules Cursor violates most often rather than encoding your entire config
- Update Cursor rules when ESLint config changes to keep them in sync
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I have a monorepo with different ESLint configs per package. The frontend uses React rules (no default exports, explicit return types, import ordering). Generate a .cursor/rules/ file that encodes these lint rules for an AI code editor to follow when generating code.
@.eslintrc.js @Lint Errors Fix all ESLint violations in the current file. Follow our config: named exports only, explicit return types, import order (external → internal → relative), no console.log (use logger), const over let.
Frequently asked questions
Why does Cursor ignore my custom ESLint rules?
Cursor does not run ESLint or read .eslintrc files. It generates code based on AI training and .cursorrules only. Encode your critical ESLint rules into .cursor/rules/ files and reference @Lint Errors post-generation to catch violations.
Can Cursor run ESLint automatically after generating code?
In Agent mode with YOLO enabled, Cursor can run eslint --fix as a terminal command. Add it to your YOLO allowed commands. Alternatively, if your editor has ESLint auto-fix on save, violations are caught when Cursor saves files.
How do I handle different ESLint configs in a monorepo?
Create nested .cursor/rules/ directories in each package with rules matching that package's ESLint config. These auto-attach when editing files in the respective package.
Does Cursor support Prettier formatting rules?
Cursor respects your editor's Format On Save setting. If Prettier is configured as your formatter, files are auto-formatted when Cursor saves them. Add formatting preferences to .cursorrules for generation-time compliance.
Should I encode ALL ESLint rules in .cursorrules?
No. Focus on the 10-15 rules that Cursor violates most often. Standard rules like no-unused-vars are usually followed by default. Custom plugin rules and team-specific conventions need explicit documentation.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation