Back to all reviewers

Validate configuration interdependencies

sveltejs/svelte
Based on 2 comments
TypeScript

When configuration options have logical dependencies or constraints, implement both smart defaults and validation checks to ensure consistent behavior. Set dependent options to appropriate default values based on other configuration values, and validate that the final combination of options represents a valid state.

Configurations TypeScript

Reviewer Prompt

When configuration options have logical dependencies or constraints, implement both smart defaults and validation checks to ensure consistent behavior. Set dependent options to appropriate default values based on other configuration values, and validate that the final combination of options represents a valid state.

For interdependent options, derive defaults from related settings:

options = assign({ 
  generate: 'dom', 
  dev: false, 
  shadowDom: options.customElement  // Default based on another option
}, options);

Then validate the final configuration to catch invalid combinations:

if (!customElement && shadowDom) {
  throw new Error(`options.shadowDom cannot be true if options.customElement is false`);
}

This approach prevents invalid configuration states while maintaining backwards compatibility and providing clear error messages when constraints are violated.

2
Comments Analyzed
TypeScript
Primary Language
Configurations
Category

Source Discussions