npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

prettier-plugin-astro-attributes

v1.0.1

Published

A Prettier plugin that automatically sorts HTML attributes alphabetically in .astro files for consistent code formatting.

Downloads

31

Readme

Prettier Plugin for Sorting HTML Attributes in Astro Files

A Prettier plugin that automatically sorts HTML attributes alphabetically in .astro files to ensure clean, consistent code formatting.

Installation

1. Install Prettier

If you haven’t already, install Prettier in your project:

  • Run npm install --save-dev prettier.

2. Install the Plugin

Install the prettier-plugin-astro-attributes plugin:

  • Run npm install --save-dev prettier-plugin-astro-attributes.

3. Configure Prettier

In your .prettierrc or prettier.config.js file, add the plugin:

  • Add the following configuration to your Prettier setup:
{
  "overrides": [
    {
      "files": "*.astro",
      "options": {
        "parser": "astro"
      }
    }
  ],
  "plugins": ["prettier-plugin-astro-attributes"]
}

Note: This plugin extends the official prettier-plugin-astro parser. It is designed to work only with the official Astro plugin. It is not compatible with other Astro formatting plugins such as prettier-plugin-tailwindcss. If you have any Tailwind-related Prettier plugins installed, please remove them to avoid conflicts.

Usage

Once installed and configured, run Prettier to format your .astro files:

  • Run npx prettier --write .

The plugin will automatically sort HTML attributes in your .astro files alphabetically, ensuring consistent and readable code.

Features

  • Alphabetical Sorting:
    Sorts attributes in HTML tags (such as <meta>, <link>, etc.) alphabetically by attribute name.

  • Easy Integration:
    Works seamlessly with Prettier when used in combination with the official Astro plugin.

  • Supports .astro Files:
    Specifically designed for Astro projects.

Benefits

  • Consistency:
    Enforces a consistent style for attribute ordering across your Astro files.

  • Cleaner Code:
    Improves the readability and maintainability of your .astro templates.

  • Time-Saving:
    Automates the formatting process, reducing manual code adjustments.

Compatibility Notice

This plugin extends the official prettier-plugin-astro to sort HTML attributes. It is only compatible with the official Astro plugin. If you use other plugins (e.g. prettier-plugin-tailwindcss), this plugin may not work as expected.

If you discover a solution that allows compatibility with Tailwind or other plugins, please open an issue or submit a pull request. Your help is appreciated!

Contributing

Feel free to open an issue or pull request if you have suggestions, bug reports, or improvements. We welcome contributions!

License

This project is licensed under the MIT License.