When implementing configuration logic, prefer using built-in configuration mechanisms and existing framework parameters over creating custom configuration options. This reduces complexity, improves maintainability, and follows established patterns.
When implementing configuration logic, prefer using built-in configuration mechanisms and existing framework parameters over creating custom configuration options. This reduces complexity, improves maintainability, and follows established patterns.
Key principles:
Example from plugin configuration:
// Instead of passing custom parameters
export function MastodonThemes(projectRoot: string): Plugin {
return {
name: 'mastodon-themes',
config: () => {
// custom logic with projectRoot
}
}
}
// Leverage built-in config object
export function MastodonThemes(): Plugin {
return {
name: 'mastodon-themes',
async config(userConfig) { // Type inferred from Plugin interface
const root = userConfig.root || process.cwd();
// Use framework-provided configuration
}
}
}
This approach reduces the API surface, eliminates redundant parameters, and ensures consistency with framework conventions.
Enter the URL of a public GitHub repository