Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadPreset(presetName: string) {
/*
Caution: Rules of preset are defined as following.
{
"rules": {
"preset-gizmo": {
"ruleA": false
}
}
It mean that "ruleA" is defined as "preset-gizmo/ruleA"
*/
const presetRuleNameWithoutPrefix = normalizeTextlintRulePresetKey(presetName);
// ignore plugin's rule
if (isPluginRuleKey(presetRuleNameWithoutPrefix)) {
Logger.warn(`${presetRuleNameWithoutPrefix} is Plugin's rule. This is unknown case, please report issue.`);
return;
}
const pkgPath = this.moduleResolver.resolvePresetPackageName(presetName);
debug("Loading rules from preset: %s", pkgPath);
const preset = moduleInterop(require(pkgPath));
const entities = TextLintModuleMapper.createEntities(preset.rules, presetRuleNameWithoutPrefix);
entities.forEach(entry => {
this.emit(TextLintModuleLoader.Event.rule, entry);
});
}