Fix ESLint warnings triggered by AI-generated Lovable syntax. Learn to resolve issues and adopt best practices for flawless code.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
AI-generated syntax often triggers ESLint warnings in Lovable because the model produces valid-looking code that doesn't follow the specific lint rules, TypeScript expectations, or project-level module/resolver conventions your repo enforces — and Lovable’s chat-first edits insert that code without running your local linter or build tool. This mismatch (AI patterns vs. repo rules + no terminal/lint pass inside Lovable) is the usual root cause.
// Prompt A: Create an annotated report linking ESLint rules to AI-generated code examples
// Action: read .eslintrc.* and tsconfig.json (if present), scan project files under src/, app/, pages/,
// find code patterns likely to trigger warnings, but DO NOT change code to fix them.
// Create a new file lovable/eslint-ai-analysis.md with:
// - Short summary of which ESLint/TS rules are most often triggered by AI output in this repo
// - For each rule: explanation why AI output commonly trips it
// - For each example: file path and exact line snippet (with surrounding 1-2 lines) that matches the pattern
// - Mark each example with whether it looks like AI-generated style (placeholder names, TODOs, non-null assertions, etc.)
// Save the report and open Preview.
// Prompt B: Inline annotate offending lines without fixing them
// Action: For every example found in src/, app/, pages/ that likely causes an ESLint warning,
// add a one-line comment immediately above the offending line:
// // LOVABLE-ESLINT-ANALYSIS: <ESLint rule name> — <short reason why AI pattern triggers it>
// Do not modify code other than adding these analysis comments.
// Commit those edits in Lovable and open Preview.
This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.
Create a root ESLint config in the project (or update it), add a sensible .eslintignore and lint scripts, then use Lovable Chat Mode to make code edits that fix the lint errors you see. If you need to actually run eslint --fix or install plugins, export/sync to GitHub and run those commands outside Lovable (terminal required).
Paste this prompt into Lovable chat to create or update config files. It will add a standard TypeScript/React-friendly .eslintrc.json, .eslintignore, and update package.json scripts. I will not run npm install here; if your project needs extra ESLint plugins, I’ll list them and mark “outside Lovable (terminal required)” steps.
// Please create or update these files in the project root.
// 1) Create or replace .eslintrc.json with this content
create_or_update .eslintrc.json
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"ecmaFeatures": { "jsx": true }
},
"plugins": ["@typescript-eslint", "react", "react-hooks", "import", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier"
],
"settings": { "react": { "version": "detect" } },
"rules": {
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"no-unused-vars": "off",
"prettier/prettier": "warn"
}
}
// 2) Create .eslintignore
create_if_missing .eslintignore
node_modules
.build
dist
.next
.vite
// 3) Update package.json scripts (merge into existing scripts)
update package.json -> modify "scripts" to include:
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix"
// After applying files, list any missing npm packages required by the config (e.g., @typescript-eslint/parser, eslint-plugin-react, eslint-plugin-react-hooks, eslint-plugin-prettier).
// If packages are missing, mark them as: OUTSIDE LOVABLE (terminal required) and provide the exact npm install command.
Use this prompt when you paste ESLint error lines. Lovable will edit only the referenced files/lines and show diffs before applying. This avoids guessing.
// I will paste ESLint error output below. For each error line, edit the specific file/path and fix it.
// Only make minimal, rule-driven fixes. Show a unified diff for each file and ask for my confirmation before saving.
// Example ESLint output I will paste (replace with your actual output):
// src/components/Button.tsx:10:5 - 'unusedVar' is assigned a value but never used. [no-unused-vars]
// Fix rules to apply:
// - For no-unused-vars, remove unused binding or rename to _unused to intentionally ignore.
// - For missing React import in older projects, add: import React from 'react';
// - For missing dependency in useEffect, add the dependency or add a comment explaining why it is intentionally omitted with // eslint-disable-next-line react-hooks/exhaustive-deps
// - For default export warnings, convert to named export if the rule demands.
// For each reported error line I pasted, produce:
// 1) a unified diff for the file changes
// 2) a short rationale sentence
// 3) ask for my approval to apply the change
If ESLint or plugins need installation or you want to run eslint --fix across the repo, export to GitHub / pull locally and run these commands in a terminal. Marked OUTSIDE LOVABLE (terminal required).
// OUTSIDE LOVABLE (terminal required)
// Install packages required by the created config
npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-prettier prettier
// Run lint check
npm run lint
// Auto-fix where safe
npm run lint:fix
Follow these Lovable-first steps: create/update the config inside Lovable, use the targeted-fix prompt with your lint output so Lovable edits files safely, and only export to run installs or auto-fix commands outside Lovable when necessary.
The practical short answer: keep linting light and forgiving inside Lovable (to avoid noisy AI-generated edits blocking your flow), enforce stricter rules in CI/GitHub, and centralize rules + ignores so Lovable edits can be auto-fixed or excluded. Use Lovable chat edits to add config files, an ESLint ignore/overrides pattern for AI-generated code, package.json scripts, and a GitHub Actions lint job — then let CI enforce the stricter baseline outside Lovable.
.eslintrc.json in the project root with overrides for generated files.// Please create file .eslintrc.json with the following content:
// update/replace root ESLint config. Relax rules for AI/generated folders and enforce stricter rules otherwise.
{
"root": true,
"env": {
"browser": true,
"node": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"ecmaFeatures": { "jsx": true }
},
"rules": {
// baseline rules for human-authored code
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"no-console": "off"
},
"overrides": [
{
"files": ["src/generated/**", "src/**/__ai__/**", "src/**/generated/**"],
"rules": {
// relax noisy rules for AI-generated code so Lovable edits don't spam warnings
"no-unused-vars": "off",
"react/prop-types": "off"
}
},
{
"files": ["**/*.test.*", "**/__tests__/**"],
"env": { "jest": true }
}
]
}
.eslintignore.// Please create file .eslintignore with the following content:
node_modules
dist
.build
coverage
.vscode
package.json to add scripts "lint" and "lint:fix". (Lovable will edit the file; installing deps happens in CI or locally outside Lovable.)// Please update package.json at the root: add or merge the following "scripts" fields.
"scripts": {
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
"lint:fix": "eslint --fix \"src/**/*.{js,jsx,ts,tsx}\""
}
.github/workflows/lint.yml. This runs on GitHub (no terminal inside Lovable needed).// Please create file .github/workflows/lint.yml with this content:
// Lint runs on push and pull_request; it installs dependencies and runs npm run lint.
name: Lint
on:
push:
pull_request:
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
// When you need to silence a specific line, add this comment directly above it:
// /* eslint-disable-next-line no-unused-vars */
// // Lovable: when generating code with false positives, insert the single-line disable comment as shown.
.eslintrc.json. This keeps the chat-first flow smooth.lint:fix script in a branch or add a GitHub Action to auto-fix and push — this part requires GitHub tokens/permissions and may need additional setup outside Lovable.src/generated or similar so rules/ignores are easy and explicit.
Follow these prompts in Lovable to add config files, scripts, and CI; use the CI workflow as the strict enforcer and keep Lovable-local edits forgiving to avoid blocking your chat-first development flow.
From startups to enterprises and everything in between, see for yourself our incredible impact.
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.