Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
Task
- check already define
- resolve package name
- load package
- emit rule
*/
// ignore already defined rule
// ignore rules from rulePaths because avoid ReferenceError is that try to require.
if (isFile(ruleName)) {
const ruleCreator = moduleInterop(require(ruleName));
const ruleEntry = [ruleName, ruleCreator];
this.emit(TextLintModuleLoader.Event.filterRule, ruleEntry);
return;
}
const definedRuleName = normalizeTextlintFilterRuleKey(ruleName);
// ignore plugin's rule
if (isPluginRuleKey(definedRuleName)) {
Logger.warn(`${definedRuleName} is Plugin's rule. This is unknown case, please report issue.`);
return;
}
const pkgPath = this.moduleResolver.resolveFilterRulePackageName(ruleName);
debug("Loading filter rules from %s", pkgPath);
const ruleCreator = moduleInterop(require(pkgPath));
const ruleEntry = [definedRuleName, ruleCreator];
this.emit(TextLintModuleLoader.Event.filterRule, ruleEntry);
}
}