CodeMirror Lint Fix Addon

raw JSON →
1.1.0 verified Fri May 01 auth: no javascript

A CodeMirror addon that provides a UI for applying quick fixes to lint issues, such as those reported by ESLint. Version 1.1.0 is the latest stable release; the package is actively maintained but with low release cadence. It ships TypeScript definitions and integrates with CodeMirror's built-in lint addon. Key differentiator: it adds a fix button inline next to lint markers, allowing users to apply automatic fixes without context menu. Built specifically for CodeMirror 5.x and requires the core codemirror package.

error TypeError: Cannot read properties of undefined (reading 'getOption')
cause lintFix called before editor is fully initialized or lint option not set.
fix
Ensure lint: true is passed to CodeMirror options and call lintFix after editor creation.
error Error: CodeMirror lint addon is not loaded
cause Missing import of codemirror/addon/lint/lint.js.
fix
Add import 'codemirror/addon/lint/lint.js' before using lintFix.
gotcha Requires CodeMirror's lint addon to be loaded and lint option enabled.
fix Import 'codemirror/addon/lint/lint.js' and set lint: true in options.
gotcha The lintFix function must be called after editor initialization and lint is active.
fix Call lintFix(editor) after editor instance is created and lint is configured.
gotcha In TypeScript, the import should use ESM syntax; CommonJS require may not work depending on bundler configuration.
fix Use import { lintFix } from 'codemirror-addon-lint-fix'.
npm install codemirror-addon-lint-fix
yarn add codemirror-addon-lint-fix
pnpm add codemirror-addon-lint-fix

Imports CodeMirror core, lint addon, and lintFix function; attaches fix UI to the editor instance.

import CodeMirror from 'codemirror';
import 'codemirror/addon/lint/lint.css';
import 'codemirror/addon/lint/lint.js';
import { lintFix } from 'codemirror-addon-lint-fix';

const editor = CodeMirror.fromTextArea(document.getElementById('editor'), {
  mode: 'javascript',
  gutters: ['CodeMirror-lint-markers'],
  lint: true
});
lintFix(editor);