How to Fix ESLint Violations with AI Assistance
An LLM can produce correct fixes for ESLint violations once it has tools that supply minimal, precise context. ESLint's JSON output for even 100 violations exceeds 10,000 characters, so the full report is written to an ephemeral Docker volume and read through condensed or per-file parse tools rather than passed through the model's context. A Dockerized Tree-sitter tool then fetches the AST node and surrounding code for a given line. Violations are grouped by whether they need source context and human supervision. The agent fixed individual violations such as floating promises and unused vars, but it would not loop through multiple violations unless each prompt named a specific rule.
Related posts
- Adding the ESLint Tool to an AI Assistant: Improving Recommendations for JS/TS Projects
Docker mediumAdeptAn AI assistant gets better at linting JavaScript and TypeScript projects when it is given ESLint tooling instead of relying on the LLM's built-in knowledge. Out of the box, GPT-4 suggests boilerplate ESLint configs that often don't work. A prompt plus a containerized StandardJS function definition lets the assistant pick ts-standard when tsconfig files exist, run it from the right directory, and install Docker-based Git hooks. The LLM can then generate JSON edit ranges for violations that aren't auto-fixable. Showing these fixes in VSCode's problems window, driven by linter output, avoids the hallucinations that context-free Copilot "fix this" requests produce.
- Using Docker AI Tools for Devs to Provide Context for Better Code Fixes
Docker mediumAdeptLLMs fix lint violations far better when given the surrounding code, so Docker Labs built a prompt-driven pipeline where each step runs in a container: Pylint produces a violation report, violations are loaded into SQLite, and Tree-sitter parses the project into an AST whose top-level statement ranges are indexed alongside the source. The LLM then queries this database (writing its own SQL from the schema) to retrieve the enclosing function for a violation before proposing a fix. This sidesteps context-window limits of reading whole files, and the same pattern generalizes to any tool that maps code locations to issues.
- Using an AI Assistant to Script Tools
Docker mediumAdeptInstead of feeding large datasets like Pylint violation JSON through an LLM to transform them into SQL INSERT statements, the assistant can be prompted to write a JavaScript program that performs the transformation, then run it through a tool call. The tool is defined in YAML and backed by a minimal Docker container with no network, host filesystem, GPU or shell access, only shared volumes and Node.js. Having the model generate tools this way limits how much data goes into the context window and lets repeated tasks run without going back to the LLM.
- Publish a lint rule, get a prize
Deno mediumAdeptDeno 2.2 adds a plugin system for `deno lint`, letting anyone write custom lint rules in TypeScript using either an ESLint-style AST visitor API or CSS-like node selectors, with types under the `Deno.lint` namespace. A worked example flags variables named `foo`, then shows publishing the plugin to JSR via `exports` in deno.json and `deno publish`, and consuming plugins from jsr: or npm: specifiers in `lint.plugins`. A contest (now closed) rewarded published rules with stickers; standout submissions included no-empty-function, ban-enum and ports of ESLint rules like curly.
- Fixing security vulnerabilities with AI
GitHub Engineering mediumAdeptCopilot Autofix turns CodeQL security alerts into LLM-suggested fixes by building a prompt from the query help, the alert message, and code snippets along the data-flow path. The model returns a natural-language explanation, before/after code blocks (chosen over raw diffs because models miscompute line numbers), and a list of needed dependencies. Post-processing then applies fuzzy matching, syntax and semantic checks, and package-registry vetting. An automated harness over 1,400+ JavaScript/TypeScript alerts with test coverage counts a fix as successful only if it clears the alert, adds no new alerts or syntax errors, and leaves test outcomes unchanged; iterating against it tripled the success rate while cutting LLM compute sixfold.