reason icon indicating copy to clipboard operation
reason copied to clipboard

[Formatting] Record formatting improvements

Open lessp opened this issue 7 months ago • 0 comments

I think this:

let applyHighlight = (spec: list(ChartSpecT.specItem(string)), ~highlightedKey: option(string)) => {
  let defaultItemOpacity = item => ChartSpecT.{
                                     ...item,
                                     chart: {
                                       ...item.chart,
                                       strokeOpacity: None,
                                     },
                                   };

  spec->List.map(defaultItemOpacity);
};

Would be more readable and aesthetically pleasing if formatted like this:

let applyHighlight = (spec: list(ChartSpecT.specItem(string)), ~highlightedKey: option(string)) => {
  let defaultItemOpacity = item => 
    ChartSpecT.{
      ...item,
      chart: {
        ...item.chart,
        strokeOpacity: None,
      },
    };
  
  spec->List.map(defaultItemOpacity);
};

Similarly this:

Param.create(
  ~key="search",
  ~toString=Params.Search.toString,
  ~fromString=Params.Search.fromString,
  ~get=state => state.search,
  ~set=(value, state) => {
                            ...state,
                            filter: {
                              ...state.filter,
                              search: value,
                            },
                          },
),

More readable as this (IMO):

Param.create(
  ~key="search",
  ~toString=Params.Search.toString,
  ~fromString=Params.Search.fromString,
  ~get=state => state.filter.search,
  ~set=(value, state) => {
    ...state,
    filter: {
      ...state.filter,
      search: value,
    },
  },
),

lessp avatar May 19 '25 11:05 lessp