0

For example I got:

<Image
 alt=""
 src="/img/logo.svg"
 width="30"
 height="30"
 className="d-inline-block align-top"
 />

Any plugin to sort these attributes according to some rules, such as alphabetical order, type, etc.? I am using VS Code, ESLint and Prettier.

2 Answers 2

1

First select the lines you want sorted, then press ctrl + shift + p (or cmd + shift + p on mac) to open command palette in vscode. Search for Sort Lines Ascending (or Descending).

enter image description here

2
  • It only works on single-line attributes. Do you know a solution for multi-line attributes?
    – Nahom
    Commented Jun 14 at 11:29
  • No, sorry... :( Commented Jun 17 at 8:46
0

Try to use ESLint Perfectionist and sort-jsx-props rule: https://perfectionist.dev/rules/sort-jsx-props

There information about usage with VS Code: https://perfectionist.dev/guide/integrations#visual-studio-code

Not the answer you're looking for? Browse other questions tagged or ask your own question.