checkcss
TypeScript icon, indicating that this package has built-in type declarations

2.0.9 • Public • Published

checkcss

Detect DOM elements that reference undefined CSS classes

Installation

npm install checkcss
# or
yarn add checkcss

Usage

import { CheckCSS } from 'checkcss';

// Create CheckCSS instance
const checkcss = new CheckCSS();
checkcss.scan().watch();

... then look for messages like this in your browser console: image

Hooks

The following hooks are supported:

// OPTIONAL: Hook for filtering classnames
checkcss.onClassnameDetected = function (classname, element) {
  // Return `false` to disable checks for `classname`.
  // For example, to ignore classnames starting with
  // "license-" or "maintainer-"...
  return /^license-|^maintainer-/.test(classname) ? false : true;
};

// OPTIONAL: Hook for custom logging
checkcss.onUndefinedClassname = function (classname) {
  // Custom logging goes here (replaces default log method)
};

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i checkcss

    Weekly Downloads

    156

    Version

    2.0.9

    License

    ISC

    Unpacked Size

    31.7 kB

    Total Files

    15

    Last publish

    Collaborators

    • broofa