eslint-doc-generator
Version:
Automatic documentation generator for ESLint plugins and rules.
13 lines (12 loc) • 428 B
JavaScript
/**
* Construct the plugin prefix out of the plugin's name.
*/
export function getPluginPrefix(name) {
if (name.endsWith('/eslint-plugin')) {
const scope = name.split('/')[0];
// Scoped plugin name like @my-scope/eslint-plugin.
return scope ?? name;
}
// Unscoped name like eslint-plugin-foo or scoped name like @my-scope/eslint-plugin-foo.
return name.replace('eslint-plugin-', '');
}