antfu / eslint-plugin-command

Comment-as-command for one-off codemod with ESLint.
https://eslint-plugin-command.antfu.me/
MIT License
170 stars 9 forks source link

/// keep-sorted by keys, for ObjectExpression #21

Open GauBen opened 1 week ago

GauBen commented 1 week ago

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

antfu commented 1 week ago

PR welcome :)