API Document

Packages

Basic Usage:

import { MLEngine } from 'markuplint';

const file = await MLEngine.toMLFile('./path/to/page.html');

const engine = new MLEngine(file, {
  configFile: './path/to/.markuplintrc',
});

const result = await engine.exec();

engine.on('log', (id, message) => {
  console.log(id, message);
});

console.log(result.violations);

API

MLEngine Class

Constructor

new MLEngine(file, options);
Parameter
file
  • MLFile
  • Required

Use the toMLFile static method, create a MLFile instance.

const file = await MLEngine.toMLFile('./path/to/page.html');
options
  • Object
  • Optional
PropertyTypeOptionalDescription
configFilestringThe file path of the configuration.
configObjectThe configuration.
defaultConfigObjectThe Fallback configuration when failing to auto search.
noSearchConfigbooleanNo search a configure file automatically.
localestringLocale.
fixbooleanReturns the fixed code after the execution.
ignoreExtbooleanEvaluates files even though the type of extension.
rulesObject[]Additional custom rules.
importPresetRulesbooleanNo imports preset rules.
debugbooleanOutputs logs for debugging.
watchbooleanFires lint event when the target file or the config file is updated.

exec

const result = await engine.exec();

if (result) {
  const { violations, filePath, sourceCode, fixedCode } = result;
}
Parameter

None

Return
  • Promise<Object | null>
PropertyTypeDescription
violationsObject[]The array of results.
filePathstringThe absolute path of the target file
sourceCodestringThe original source code.
fixedCodestringThe Fixed source code. It is the same as the original code if didn't specify fix option.

Interface Document

The details are said by https://api.markuplint.dev.