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 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-astro-standards

v1.0.6

Published

ESLint plugin to enforce Astro best practices: mandatory base layout, SEO props, and no raw HTML structure in pages

Readme

eslint-plugin-astro-standards

Custom ESLint plugin that extends eslint-plugin-astro to enforce best practices in Astro projects.

🎯 Goal

Ensure all Astro pages follow a consistent pattern:

  • Mandatory use of a base layout
  • Prohibition of structural HTML tags (<html>, <head>, <body>) in pages
  • Mandatory SEO through props (title, description)

📦 Installation

If you already have an Astro project with ESLint configured:

pnpm add -D eslint-plugin-astro-standards

If you're starting from scratch:

pnpm add -D eslint eslint-plugin-astro eslint-plugin-astro-standards

Or with npm:

npm install -D eslint eslint-plugin-astro eslint-plugin-astro-standards

Note: The plugin automatically installs @typescript-eslint/parser as a dependency. You only need to have eslint and eslint-plugin-astro installed beforehand.

⚙️ Configuration

Create or update your eslint.config.mjs:

import astro from "eslint-plugin-astro";
import astroStandards from "eslint-plugin-astro-standards";

export default [
  ...astro.configs.recommended,
  astroStandards.configs.recommended,
];

That's it! The plugin automatically registers itself and all required plugins (unused-imports, simple-import-sort, jsx-a11y) with sensible defaults. No extra imports needed.

📋 Rules

no-raw-html-shell-in-pages

Disallows the use of <html>, <head>, and <body> in Astro page files.

❌ Incorrect:

---
---

<html>
  <head>
    <title>My page</title>
  </head>
  <body>
    <h1>Hello world</h1>
  </body>
</html>

✅ Correct:

---
import Layout from "../layouts/Layout.astro";
---

<Layout title="My page" description="My page description">
  <h1>Hello world</h1>
</Layout>

Reason: The HTML structure should live in the base layout to maintain consistency and facilitate global changes.


require-base-layout-in-pages

Requires all pages to import and use a specific layout.

Options:

{
  layoutName: "Layout",  // Layout component name (default: "Layout")
  layoutFile: "Layout.astro"  // File name (default: "Layout.astro")
}

❌ Incorrect:

---
---

<main>
  <h1>Page without layout</h1>
</main>

✅ Correct:

---
import Layout from "../layouts/Layout.astro";
---

<Layout title="Home" description="Main page">
  <main>
    <h1>Page with layout</h1>
  </main>
</Layout>

Reason: Ensures all pages have a consistent HTML structure and proper SEO.


require-layout-seo-props

Requires specific props (by default title and description) to be passed to the layout.

Options:

{
  layoutName: "Layout",  // Layout name to verify (default: "Layout")
  requiredProps: ["title", "description"]  // Required props (default: ["title", "description"])
}

❌ Incorrect:

---
import Layout from "../layouts/Layout.astro";
---

<Layout>
  <h1>Without SEO</h1>
</Layout>

✅ Correct:

---
import Layout from "../layouts/Layout.astro";
---

<Layout title="Home" description="Main page">
  <h1>With SEO</h1>
</Layout>

Reason: Ensures all pages have basic SEO metadata.


🏗️ Base Layout Example

---
interface Props {
  title: string;
  description: string;
}

const { title, description } = Astro.props as Props;
---

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>{title}</title>
    <meta name="description" content={description} />
  </head>
  <body>
    <slot />
  </body>
</html>

🚀 Recommended Scripts

Add these scripts to your package.json:

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix",
    "lint:astro-pages": "eslint src/pages/**/*.astro"
  }
}

🔧 Customization

If you need to customize the default configuration, you can override specific rules:

import astro from "eslint-plugin-astro";
import astroStandards from "eslint-plugin-astro-standards";

export default [
  ...astro.configs.recommended,
  {
    ...astroStandards.configs.recommended,
    rules: {
      ...astroStandards.configs.recommended.rules,
      // Change the layout name
      "astro-standards/require-base-layout-in-pages": [
        "error",
        {
          layoutName: "MainLayout",
          layoutFile: "MainLayout.astro",
        },
      ],

      // Add more required props
      "astro-standards/require-layout-seo-props": [
        "error",
        {
          layoutName: "Layout",
          requiredProps: ["title", "description", "ogImage"],
        },
      ],

      // Disable a specific rule
      "astro-standards/no-raw-html-shell-in-pages": "off",
    },
  },
];

🤝 Contributing

This is a personal plugin, but if you find bugs or have suggestions, feel free to open an issue.

📄 License

MIT