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.
configObject✓The configuration.
defaultConfigObject✓The Fallback configuration when failing to auto search.
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 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.