Skip to main content

Classes

MLEngine

Constructor

new MLEngine(file, options);

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.

Methods

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.