over_react_incorrect_doc_comment_location

Severity: AnalysisErrorSeverity.INFO

Maturity: stable

Since 1.0.0

View the Project on GitHub workiva/over_react

PREFER to place documentation comments on the UiFactory since that is what consumers use to build / render in their application.

If the documentation comment that contains details such as usage instructions, documentation links, etc. is placed on the UiComponent2 instance, the consumer will not be able to easily find it when consuming it.

GOOD:

/// Use a `FooBar` to render a `Bar` wrapped with a `Foo` so that it brings more fooness to the bar. 
///
/// Example:
///
/// ```dart
/// FooBar()('Bar with more foo!')
/// ```
UiFactory<FooBarProps> FooBar = _$FooBar; // ignore: undefined_identifier

mixin FooBarPropsMixin on UiProps, FooProps {
  Map barProps;
}

class FooBarProps = UiProps with FooProps, FooBarPropsMixin;

class FooBarComponent extends UiComponent2<FooBarProps> {
  @override
  get consumedProps => propsMeta.forMixins({
    FooBarPropsMixin,
  });

  @override
  render() {
    return (Foo()..modifyProps(addUnconsumedProps))(
      (Bar()..addProps(props.barProps))(props.children)
    );
  }
}

BAD:

UiFactory<FooBarProps> FooBar = _$FooBar; // ignore: undefined_identifier

mixin FooBarPropsMixin on UiProps, FooProps {
  Map barProps;
}

class FooBarProps = UiProps with FooProps, FooBarPropsMixin;

/// Use a `FooBar` to render a `Bar` wrapped with a `Foo` so that it brings more fooness to the bar. 
///
/// Example:
///
/// ```dart
/// FooBar()('Bar with more foo!')
/// ```
class FooBarComponent extends UiComponent2<FooBarProps> {
  @override
  get consumedProps => propsMeta.forMixins({
    FooBarPropsMixin,
  });

  @override
  render() {
    return (Foo()..modifyProps(addUnconsumedProps))(
      (Bar()..addProps(props.barProps))(props.children)
    );
  }
}