A Prettier plugin that automatically organizes HTML attributes in Angular, Vue, and plain HTML files. Version 1.0.1 requires Prettier ^3.0.0 and Node >=14.0.0. It groups attributes using RegExps or predefined presets (e.g., HTML, Angular, Vue, Code-Guide) and supports sorting within groups in ascending or descending order. Unlike alternative attribute formatters, it integrates directly into Prettier's workflow with zero configuration for common frameworks. Ships with TypeScript typings.
npm install squidex-prettier-plugin-organize-attributesVerified import paths — ran on the pinned version, not inferred.
Installs and configures the plugin to organize HTML attributes in Prettier, grouping by regex and sorting alphabetically.
Add 'plugins' array to your Prettier config: { "plugins": ["prettier-plugin-organize-attributes"] }If you want unmatched attributes to be placed in a specific position, include $DEFAULT in your attributeGroups array.
Ensure your files have the correct extension. For custom extensions, you may need to configure Prettier's overrides.
Use attributeSort: 'ASC' or 'DESC' globally. If per-group sorting is needed, consider workarounds like separating into multiple runs.
Run: npm i -D prettier-plugin-organize-attributes. Ensure it's in your devDependencies.
Use valid preset names: $ANGULAR_OUTPUT, $ANGULAR_TWO_WAY_BINDING, $ANGULAR_INPUT, $ANGULAR_STRUCTURAL_DIRECTIVE, or custom regex strings.
Ensure you run Prettier on .html, .component.html, or .vue files. Verify the HTML is valid.