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
*/
// ruleName is filePath
if (isFile(ruleName)) {
const ruleCreator = moduleInterop(require(ruleName));
const ruleEntry = [ruleName, ruleCreator];
this.emit(TextLintModuleLoader.Event.rule, ruleEntry);
return;
}
// ignore already defined rule
// ignore rules from rulePaths because avoid ReferenceError is that try to require.
const definedRuleName = normalizeTextlintRuleKey(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.resolveRulePackageName(ruleName);
debug("Loading rules from %s", pkgPath);
const ruleCreator = moduleInterop(require(pkgPath));
const ruleEntry = [definedRuleName, ruleCreator];
this.emit(TextLintModuleLoader.Event.rule, ruleEntry);
}