skip to Main Content

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


  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

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search