Skip to main content
RapidDev - Software Development Agency
cursor-tutorial

Why Cursor Ignores Custom ESLint Rules

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.

What you'll learn

  • Why Cursor ignores ESLint rules and how to fix it
  • How to encode ESLint conventions into .cursor/rules/ files
  • How to use @Lint Errors context to catch violations after generation
  • How to set up monorepo-specific rules for different packages
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate7 min read10-15 minCursor Pro+, ESLint, monorepo setupsMarch 2026RapidDev Engineering Team
TL;DR

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

1

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.

.cursorrules
1# .cursorrules
2
3## 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 utility
6- 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 theme
10- 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.

2

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.

packages/frontend/.cursor/rules/lint.mdc
1---
2description: Frontend package ESLint rules
3globs: "packages/frontend/**"
4alwaysApply: false
5---
6
7- React rules apply: use functional components only, no class components
8- Use React.FC type for all components
9- Props must be defined as separate interface above the component
10- No direct DOM manipulation (no document.querySelector)
11- Use next/image instead of img tags
12- All event handlers prefixed with 'handle': handleClick, handleSubmit
13- Custom hooks must start with 'use' and be in hooks/ directory

Pro 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.

3

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.

Cursor Chat prompt
1// After generating code, if ESLint shows errors in the Problems panel:
2// Open Chat (Cmd+L) and type:
3// @Lint Errors
4// 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 functions
8// - Named exports only, no default exports

Pro 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.

4

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.

Cursor Composer prompt
1// Prompt to type in Cursor Composer (Cmd+I):
2// @.eslintrc.js @packages/frontend/eslint.config.mjs
3// 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 only
7// - Explicit return types
8// - React hook rules
9// - Import ordering

Expected result: Cursor generates code that follows your actual ESLint configuration more closely.

5

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.

.cursor/commands/lint-fix.md
1---
2description: Lint and fix generated code
3---
4
51. Run ESLint on the files that were just generated or modified
62. Read the ESLint output for any violations
73. Fix each violation following our project's ESLint rules
84. Re-run ESLint to verify all violations are resolved
95. If auto-fixable, apply eslint --fix first, then handle remaining issues
10
11Common violations to watch for:
12- Missing return types add explicit TypeScript return type
13- Default exports convert to named exports
14- console.log replace with logger.info/error/debug
15- Unused imports remove them
16- Wrong import order reorder: external, internal, relative

Pro 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

.cursor/rules/eslint-conventions.mdc
1---
2description: ESLint conventions for code generation
3globs: "**/*.ts, **/*.tsx, **/*.js, **/*.jsx"
4alwaysApply: false
5---
6
7# ESLint Rules for Cursor Code Generation
8
9## Exports
10- 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 export
13
14## Types
15- Explicit return types on all exported functions
16- Props as separate interface above component: `interface MyComponentProps {}`
17- Use `unknown` instead of `any`
18- Prefer type aliases for unions, interfaces for objects
19
20## Imports
21- Order: 1) external packages, 2) @/ internal aliases, 3) relative paths
22- Blank line between each group
23- No unused imports
24- Use import type for type-only imports
25
26## React
27- Functional components only (no class components)
28- Event handlers prefixed with 'handle': handleClick, handleSubmit
29- Custom hooks start with 'use', placed in hooks/ directory
30- No inline styles use sx prop or CSS modules
31
32## General
33- const over let, never var
34- No console.log use logger utility from @/lib/logger
35- No magic numbers extract to named constants
36- Prefer early returns over nested conditionals
37- Maximum 300 lines per file

Common 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.

ChatGPT Prompt

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.

Cursor Prompt

@.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.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.