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

eslint-plugin-playwright-tagging

v2.1.0

Published

ESLint rule to enforce tagging of Playwright tests

Readme

ESLint Plugin Playwright Tagging

An ESLint plugin to enforce tagging of Playwright tests.

Installation

You can install the plugin using npm:

npm i -D eslint-plugin-playwright-tagging

Usage

This plugin supports both the new "flat config" format (ESLint v9+) and the legacy .eslintrc.js format (ESLint v8).

With ESLint 9+ (Flat Config)

Add the plugin to your eslint.config.js file:

// eslint.config.js
import playwrightTagging from 'eslint-plugin-playwright-tagging';

export default [
  {
    files: ["tests/**/*.spec.js"], // Or your test files
    ...playwrightTagging.configs['recommended-flat'],
    // To add custom options:
    rules: {
      'playwright-tagging/validate-tags-playwright': ['error', {
        allow: {
          title: false, // Do not allow tags in test titles
          tagAnnotation: true // Allow tags via test.info().annotations
        },
        tagGroups: {
          tier: ['@tier1', '@tier2'],
          team: ['@squad-a', '@squad-b']
        }
      }]
    }
  }
];

With ESLint 8 (Legacy Config)

Add playwright-tagging to the plugins section of your .eslintrc.js configuration file. You can omit the eslint-plugin- prefix:

// .eslintrc.js
module.exports = {
  plugins: [
    'playwright-tagging'
  ],
  overrides: [
    {
      files: ['tests/**/*.spec.js'], // Or your test files
      extends: [
        'plugin:playwright-tagging/recommended'
      ],
      // To add custom options:
      rules: {
        'playwright-tagging/validate-tags-playwright': ['error', {
          allow: {
            title: true, // Allow tags in test titles
            tagAnnotation: false // Do not allow tags via test.info().annotations
          },
          tagGroups: {
            tier: ['@tier1', '@tier2'],
            team: ['@squad-a', '@squad-b']
          }
        }]
      }
    }
  ]
};

Rule: validate-tags-playwright

This rule ensures that every Playwright test block is associated with one or more tags.

Options

The rule takes an optional object with the following properties:

  • tagGroups (optional): An object where each key is a "group name" and the value is an array of tags. The rule will enforce that every test has at least one tag from each defined group.
  • optionalTagGroups (optional): An object where each key is a group name and the value is an array of tags. These tags are considered valid by the linter, but their presence is not enforced. This is useful for tags that are allowed but not mandatory.
  • allow (optional): An object to control where tags can be placed.
    • title: boolean (default: true). Allows tags in the test title (e.g., test('@smoke ...')). If set to false, an error will be reported if tags are found in the title.
    • tagAnnotation: boolean (default: false). Allows tags via the test's options object, which is commonly used for test.info().annotations. The plugin specifically looks for a tag property that can be a string or an array of strings.

Automatic Fixes

When no tagGroups are configured and a test is missing a tag, the rule can automatically add a placeholder tag (@tagme) to the test title as a fix. This feature is only active when allow.title is true.

Example: tagGroups and optionalTagGroups

If you want to ensure every test has a required tier tag and also allow for optional team tags, you can configure it like this:

{
  "tagGroups": {
    "tier": ["@tier1", "@tier2", "@tier3"]
  },
  "optionalTagGroups": {
    "team": ["@squad-a", "@squad-b"]
  }
}
  • A test titled test('@tier1 @squad-a my test') would pass.
  • A test titled test('@tier1 my test') would also pass because the team tag is optional.
  • A test titled test('@squad-a my test') would fail because it is missing a required tag from the tier group.
  • A test titled test('@tier1 @unknown-tag my test') would fail because @unknown-tag is not defined in any of the required or optional groups.

Note: The plugin normalizes tags by removing the leading @ symbol and trimming whitespace before validation. This means you can define tags in your configuration with or without the @ prefix (e.g., '@tier1' and 'tier1' are treated as the same tag).