Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadPlugin(pluginName: string) {
const pkgPath = this.moduleResolver.resolvePluginPackageName(pluginName);
debug("Loading rules from plugin: %s", pkgPath);
const plugin = moduleInterop(require(pkgPath));
const pluginNameWithoutPrefix = normalizeTextlintPluginKey(pluginName);
// Notes: plugins not support "rules" and "rulesConfig"
// https://github.com/textlint/textlint/issues/291
if (plugin.hasOwnProperty("rules")) {
throw new Error(`textlint plugins not support "rules" and "rulesConfig".
But ${pluginName} has these filed.
For more details, See https://github.com/textlint/textlint/issues/291`);
}
// register plugin.Processor
if (!plugin.hasOwnProperty("Processor")) {
throw new Error(`textlint plugin should have "Processor".
For more details. See https://github.com/textlint/textlint/blob/master/docs/plugin.md`);
}
const pluginEntry = [pluginNameWithoutPrefix, plugin];
this.emit(TextLintModuleLoader.Event.plugin, pluginEntry);
}