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-lambda-html

v1.2.0

Published

ESLint plugin for lambda.html - lint rules for setClass() including known modifiers, spacing, duplicates, conflicts, and empty calls

Readme

eslint-plugin-lambda-html

ESLint plugin for lambda.html that warns when .setClass() is used with Tailwind CSS classes that have dedicated SwiftUI-style methods.

The Problem

When using lambda.html's SwiftUI-style API, calling .setClass() can override styles set by dedicated methods:

// This is problematic:
Div()
  .background("green-700")  // Sets bg-green-700
  .padding("4")             // Sets p-4
  .setClass("bg-red-500")   // Overwrites everything! Only bg-red-500 remains

The .setClass() method replaces all classes, while dedicated methods like .background(), .padding(), etc., append classes safely.

The Solution

This ESLint plugin warns you when .setClass() contains classes that have dedicated methods:

// ❌ Warning: Use .background() instead
Div().setClass("bg-red-500 p-4")

// ✅ Correct: Use dedicated methods
Div()
  .background("red-500")
  .padding("4")

// ✅ Also correct: Use .addClass() for additional classes
Div()
  .background("red-500")
  .padding("4")
  .addClass("hover:bg-red-600")  // For pseudo-classes, this is fine

Installation

npm install --save-dev eslint-plugin-lambda-html

Usage

Flat Config (ESLint 9+)

// eslint.config.js
import lambdaHtml from "eslint-plugin-lambda-html";

export default [
  {
    plugins: {
      "lambda-html": lambdaHtml
    },
    rules: {
      "lambda-html/no-known-modifiers-in-setclass": "warn"
    }
  }
];

Legacy Config (ESLint 8 and below)

// .eslintrc.js
module.exports = {
  plugins: ["lambda-html"],
  extends: ["plugin:lambda-html/recommended"],
};

Or configure manually:

// .eslintrc.js
module.exports = {
  plugins: ["lambda-html"],
  rules: {
    "lambda-html/no-known-modifiers-in-setclass": "warn",
  },
};

Rule: no-known-modifiers-in-setclass

Warns when .setClass() is called with Tailwind classes that have dedicated SwiftUI-style methods.

Detected Patterns

The rule checks for these Tailwind class patterns and suggests alternatives:

| Pattern | Suggested Method | |---------|-----------------| | p-*, px-*, py-*, pt-*, etc. | .padding() | | m-*, mx-*, my-*, mt-*, etc. | .margin() | | bg-* | .background() | | text-red-*, text-blue-*, etc. | .textColor() | | text-xl, text-2xl, etc. | .textSize() | | text-center, text-left, etc. | .textAlign() | | font-bold, font-semibold, etc. | .fontWeight() | | w-*, h-* | .w(), .h() | | max-w-*, min-w-* | .maxW(), .minW() | | flex, flex-col, flex-row | .flex(), .flexDirection() | | justify-*, items-* | .justifyContent(), .alignItems() | | gap-* | .gap() | | grid, grid-cols-* | .grid(), .gridCols() | | border, border-* | .border(), .borderColor() | | rounded, rounded-* | .rounded() | | shadow, shadow-* | .shadow() | | relative, absolute, fixed, etc. | .position() | | z-*, opacity-*, cursor-* | .zIndex(), .opacity(), .cursor() | | overflow-* | .overflow() |

Examples

❌ Incorrect

// Will trigger warnings
Div().setClass("bg-red-500")
Div().setClass("p-4 m-2")
Div().setClass("flex justify-center items-center")
Div().setClass("text-xl font-bold text-center")

✅ Correct

// Use dedicated methods
Div().background("red-500")
Div().padding("4").margin("2")
Div().flex().justifyContent("center").alignItems("center")
Div().textSize("xl").fontWeight("bold").textAlign("center")

// Use .addClass() for classes without dedicated methods
Div()
  .background("red-500")
  .addClass("hover:bg-red-600 focus:ring-2")  // Pseudo-classes are fine

// Or use .setClass() for completely custom classes
Div().setClass("my-custom-class another-custom-class")

When to Use .setClass() vs .addClass()

  • Use dedicated methods (.background(), .padding(), etc.) for base styles
  • Use .addClass() for:
    • Responsive variants: md:w-1/2, lg:flex-row
    • Pseudo-classes: hover:bg-blue-600, focus:ring-2
    • State variants: active:scale-95, disabled:opacity-50
    • Custom classes without dedicated methods
  • Use .setClass() only when:
    • You need to completely replace all classes
    • You're using custom classes that don't conflict with SwiftUI methods

Configuration

Severity Levels

// Error (blocks build)
"lambda-html/no-known-modifiers-in-setclass": "error"

// Warning (shows warning but doesn't block)
"lambda-html/no-known-modifiers-in-setclass": "warn"

// Disabled
"lambda-html/no-known-modifiers-in-setclass": "off"

License

ISC