Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve logic for determining package name for scoped plugins #332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions test/configs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ const configFiles = fs
* Generally this is done by returning the plugin name with `eslint-plugin-`
* appended to it (if the name does not already start with that string).
*
* Scoped plugins must be explicitly checked for to handle properly;
* Currently the `@typescript-eslint` is the only supported scoped plugin.
*
* @param {string} plugin
*
* @return {string}
Expand All @@ -32,8 +29,16 @@ const determinePluginPackageName = (plugin: string): string => {
return plugin;
}

if (plugin === '@typescript-eslint') {
return `${plugin}/eslint-plugin`;
if (plugin.startsWith('@')) {
const [scope, name] = plugin.split('/');

let packageName = `${scope}/eslint-plugin`;

if (name) {
packageName += `-${name}`;
}

return packageName;
}

return `eslint-plugin-${plugin}`;
Expand Down
15 changes: 10 additions & 5 deletions tools/generate-configs-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ const requireConfig = (config: string): Required<ESLint.Linter.Config> => {
* Generally this is done by returning the plugin name with `eslint-plugin-`
* appended to it (if the name does not already start with that string).
*
* Scoped plugins must be explicitly checked for to handle properly;
* Currently the `@typescript-eslint` is the only supported scoped plugin.
*
* @param {string} plugin
*
* @return {string}
Expand All @@ -57,8 +54,16 @@ const determinePluginPackageName = (plugin: string): string => {
return plugin;
}

if (plugin === '@typescript-eslint') {
return `${plugin}/eslint-plugin`;
if (plugin.startsWith('@')) {
const [scope, name] = plugin.split('/');

let packageName = `${scope}/eslint-plugin`;

if (name) {
packageName += `-${name}`;
}

return packageName;
}

return `eslint-plugin-${plugin}`;
Expand Down