Skip to content

Commit

Permalink
fix(plugin): normalize user input for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip9587 committed Apr 12, 2024
1 parent cf7e597 commit 756a18c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nx-stylelint/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,15 @@ async function buildStylelintTargets(
}

function normalizeOptions(options: StylelintPluginOptions | undefined): Required<StylelintPluginOptions> {
// Normalize user input for extensions (strip leading . characters)
let extensions: string[] | undefined;
if (Array.isArray(options?.extensions)) {
extensions = [...new Set(options.extensions.map((f) => f.replace(/^\.+/, '')))];
}

return {
targetName: options?.targetName ?? 'stylelint',
extensions: [...new Set(options?.extensions ?? ['css'])].filter(Boolean),
extensions: extensions ?? ['css'],
};
}

Expand Down

0 comments on commit 756a18c

Please sign in to comment.