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
configFilestring✓The file path of the configuration. When specified, the automatic search for a configuration file is not performed.
configObject✓The configuration. A relative path in it is based on the working directory.
defaultConfigObject✓The Fallback configuration when the auto search finds none or is disabled. A relative path in it is based on the working directory.
noSearchConfigboolean✓No search a configure file automatically.
localestring✓Locale.
fixboolean✓Returns the fixed code after the execution.
ignoreExtboolean✓Evaluates files even though the type of extension.
rulesObject[]✓Additional custom rules.
importPresetRulesboolean✓No imports preset rules.
debugboolean✓Outputs logs for debugging.
watchboolean✓Fires lint event when the config file or a component file that pretenders reads is updated. The target file is not watched; tell the engine of its edits with setCode.

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.