eslint-formatter-prompter
raw JSON → 0.1.1 verified Fri May 01 auth: no javascript
An ESLint custom formatter that transforms standard lint output into structured, directive-rich prompts for AI tools. Version 0.1.1 (experimental) converts ESLint violations into grouped, actionable instructions telling AI what to fix and why, reducing noise and improving automated fix accuracy. Key differentiators: includes per-rule directive context, a mandatory fix header, minimum token usage via grouping, and full customizability of messages. Requires ESLint >=8.x. Ships TypeScript types. Early release with evolving API.
Common errors
error Error: Cannot find module 'eslint-formatter-prompter' ↓
cause Package not installed or ESLint not resolving correctly with non-standard formatter name.
fix
Run
pnpm add --save-dev eslint-formatter-prompter (or npm/yarn equivalent) and ensure the format argument is exactly 'prompter'. error TypeError: formatter is not a function ↓
cause Importing default export incorrectly or using require() in CJS.
fix
Use
import prompter from 'eslint-formatter-prompter' in ESM. For CJS, use const prompter = require('eslint-formatter-prompter').default or switch to ESM. error ESLint: Invalid option '--format' - 'prompter' ↓
cause ESLint version too old (<8.0.0) or formatter is not installed in node_modules.
fix
Upgrade ESLint to >=8.0.0 and verify the package is installed. Try
npx eslint --format prompter .. error error: Unsupported format: prompter ↓
cause ESLint resolves formatters from eslint-formatter-<name> but the package isn't in node_modules or is incorrectly named.
fix
Ensure package name is exactly 'eslint-formatter-prompter' and run
npm ls eslint-formatter-prompter to verify install. Warnings
gotcha Formatted output may be truncated by the terminal when very long ↓
fix Pipe output to a file or use pager (less). Example: eslint --format prompter . | less
gotcha ESLint automatic formatter resolution only works with 'eslint-formatter-*' prefix ↓
fix Install the package exactly as named; do not rename. CLI format argument is 'prompter' (without prefix).
breaking createPrompter options object shape may change in future versions ↓
fix Check the latest README or type definitions before upgrading.
gotcha Programmatic usage requires ESM; CJS require() will not work ↓
fix Use import syntax or configure Node.js to treat .js files as ESM.
deprecated No known deprecated options yet, but API is experimental ↓
fix Subscribe to GitHub releases for API changes.
Install
npm install eslint-formatter-prompter yarn add eslint-formatter-prompter pnpm add eslint-formatter-prompter Imports
- default wrong
import { prompter } from 'eslint-formatter-prompter'correctimport prompter from 'eslint-formatter-prompter' - createPrompter wrong
import createPrompter from 'eslint-formatter-prompter'correctimport { createPrompter } from 'eslint-formatter-prompter' - FormattedResult wrong
import { FormattedResult } from 'eslint-formatter-prompter'correctimport type { FormattedResult } from 'eslint-formatter-prompter'
Quickstart
// Install: pnpm add --save-dev eslint-formatter-prompter
// Run ESLint with the formatter:
eslint --format prompter .
// Programmatic usage (ESM):
import { createPrompter } from 'eslint-formatter-prompter';
import { ESLint } from 'eslint';
const eslint = new ESLint();
const results = await eslint.lintFiles(['src/**/*.js']);
const formatter = createPrompter({
header: 'Custom header message',
footer: 'Custom footer message',
ruleMessages: {
'no-var': 'Replace var with let or const (prefer const).',
},
});
const output = formatter(results);
console.log(output);