over_react icon indicating copy to clipboard operation
over_react copied to clipboard

over_react analyzer not reporting at compile time required props that are missing, and at runtime, reporting error on required props that are specified

Open dave-doty opened this issue 5 months ago • 8 comments

  • Issue Type: BUG
  • over_react Version(s): 5.3.0
  • dart version 2.19.6

I got the analyzer plugin set up, and it is indeed showing some warnings in WebStorm, so it's running:

image

However, the main bug I had with pre-null-safe overreact was forgetting to include a required prop and having it default to null. I had really hoped to be warned about this (in fact it seems like the severity should default to error), but in the following code, I have commented out the line // ..mouseover_datas = state.ui_state.mouseover_datas to see if the analyzer plugin will warn me that the required prop mouseover_datas is not being specified, but that does not show up:

UiFactory<DesignFooterProps> ConnectedDesignFooter = connect<AppState, DesignFooterProps>(
  mapStateToProps: (state) {
    BuiltList<MouseoverData> mouseover_datas = state.ui_state.mouseover_datas;
    MouseoverData? first_mouseover_data =
        mouseover_datas.isNotEmpty ? state.ui_state.mouseover_datas.first : null;
    Strand? strand_first_mouseover_data =
        mouseover_datas.isNotEmpty ? state.design.substrand_to_strand[first_mouseover_data!.domain] : null;
    String loaded_filename = state.ui_state.loaded_filename;
    return (DesignFooter()
      // ..mouseover_datas = state.ui_state.mouseover_datas // This should be an error since `mouseover_datas` is declared as `late` below
      ..strand_first_mouseover_data = strand_first_mouseover_data
      ..loaded_filename = loaded_filename);
  },
)(DesignFooter);

UiFactory<DesignFooterProps> DesignFooter = _$DesignFooter;

mixin DesignFooterProps on UiProps {
  late BuiltList<MouseoverData> mouseover_datas;
  Strand? strand_first_mouseover_data;
  late String loaded_filename;
}

class DesignFooterComponent extends UiComponent2<DesignFooterProps> {
  @override
  render() {
    BuiltList<MouseoverData> mouseover_datas = props.mouseover_datas;
    ...

I did try restarting the analyzer server by clicking the red curved arrows in the upper left, but still nothing about this error.

Is there something I need to configure in the overreact analyzer to ask it to warn me about missing required props?

I noticed that this page mentions some customization:

"To configure the plugin, add a over_react key to analysis_options.yaml:"

analyzer:
  plugins:
    - over_react

over_react:
  errors:
    over_react_boilerplate_error: error
    over_react_incorrect_doc_comment_location: warning
    over_react_unnecessary_key: info
    over_react_pseudo_static_lifecycle: ignore

But I can't find any documentation of what all the options are for the analyzer, and what "over_react_missing_required_prop" would actually be.

FYI: @greglittlefield-wf @aaronlademann-wf @kealjones-wk @evanweible-wf @maxwellpeterson-wf

dave-doty avatar Sep 10 '24 03:09 dave-doty