eslint-plugin-command icon indicating copy to clipboard operation
eslint-plugin-command copied to clipboard

/// keep-sorted by keys, for ObjectExpression

Open GauBen opened this issue 1 year ago • 1 comments

Clear and concise description of the problem

Hey there, still me!

I'd like to sort an object by keys, but it is only supported for arrays as of now:

// @keep-sorted {"keys":["label"]}
export default <Record<Enum, { icon: string; label: string }>>{
  ANALYTICS: { icon: 'chart-mixed', label: 'Analytics' },
  EVENT_MANAGEMENT: { icon: 'calendar-days', label: 'Calendar' },
  CLOUD_STORAGE: { icon: 'sensor-cloud', label: 'Cloud' },
  HEALTH: { icon: 'house-medical', label: 'Health' },
};
[keep-sorted] error: Only arrays can be sorted by keys, but got ObjectExpression

Suggested solution

Alternative

No response

Additional context

Thanks for your help!

(Can you guess which command I use the most? Is it OCD? 👀)

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

GauBen avatar Jun 18 '24 09:06 GauBen

PR welcome :)

antfu avatar Jun 18 '24 09:06 antfu

Hi,@antfu @GauBen. I am willing to submit a PR ! Wondering if anyone is currently doing this work?

Mori-Yang avatar Mar 20 '25 05:03 Mori-Yang