Skip to main content

API Changes

This page covers breaking changes to the Node.js API. If you call Markuplint programmatically or build editor integrations, read on.

Summary

ChangeWho is affected
exec() function removedUsers calling exec() directly
New FixSummary on resultAPI consumers using fix: true
New computeCursorOffset()Editor integration developers

exec() function removed

Breaking Change

The legacy exec() function has been removed. It was deprecated since v1.

Replace exec() with MLEngine.

Before (v4):

import { exec } from 'markuplint';

const results = await exec({
files: 'index.html',
config: '.markuplintrc',
});

After (v5):

import { MLEngine } from 'markuplint';

const file = await MLEngine.toMLFile('index.html');
const engine = new MLEngine(file, {
configFile: '.markuplintrc',
});
const result = await engine.exec();

Option mapping

Use this table to translate old exec() options to MLEngine:

exec() option (v4)MLEngine equivalent (v5)
filesFirst argument to MLEngine.toMLFile()
sourceCodes / names / workspaceMLEngine.toMLFile({ sourceCode, name, workspace })
config (string)configFile option
config (object)config option
defaultConfigdefaultConfig option
rulesrules option
rulesAutoResolveautoLoad option
fixfix option
localelocale option

New: FixSummary on results

When you run with fix: true, the result now includes a fixSummary field. It tells you what happened during the fix process.

const result = await engine.exec();
if (result?.fixSummary) {
console.log(`Passes: ${result.fixSummary.passCount}`);
console.log(`Applied: ${result.fixSummary.totalApplied}`);
console.log(`Skipped: ${result.fixSummary.totalSkipped}`);
}
FieldTypeDescription
passCountnumberNumber of fix passes executed
totalAppliednumberTotal fixes applied across all passes
totalSkippednumberFixes skipped due to overlapping edits
reachedMaxPassesbooleanWhether the 10-pass safety cap was hit
firstPassEditsreadonly TextEdit[]Edits from the first pass (original offsets)
info

This is a new addition, not a breaking change. Existing code is unaffected.

New: computeCursorOffset()

For editor integrations, @markuplint/ml-core now exports computeCursorOffset(). It remaps a cursor position from the original source to the fixed source.

import { computeCursorOffset } from '@markuplint/ml-core';

const newOffset = computeCursorOffset(result.fixSummary.firstPassEdits, originalCursorOffset);

This uses the first-pass edits (which reference original source offsets) to compute where the cursor belongs in the fixed code.

tip

Combine FixSummary and computeCursorOffset() for a smooth fix-and-navigate experience in your editor plugin.