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

style-guard-cli

v1.0.0

Published

A CLI tool to detect hardcoded CSS values and duplicated styles

Downloads

89

Readme

Style Guard CLI

npm version License: MIT

A powerful CLI tool that detects hardcoded CSS values and promotes the use of design tokens in your codebase. Style Guard helps maintain consistent styling by identifying hardcoded colors, pixel values, and other CSS properties that should be replaced with design tokens.

🚀 Features

  • Hardcoded Color Detection: Identifies hex color values (#fff, #333333) that should use design tokens
  • Pixel Value Detection: Finds hardcoded pixel values (16px, 24px) that should use spacing/size tokens
  • Multi-Format Support: Scans CSS, SCSS, JSX, TSX, and HTML files
  • Configurable Rules: Enable/disable specific checks via configuration file
  • Colorized Output: Clear, readable terminal reports with syntax highlighting
  • Zero Dependencies: Lightweight tool with no external dependencies

📦 Installation

Global Installation (Recommended)

npm install -g style-guard-cli

Local Installation

npm install --save-dev style-guard-cli

🛠️ Usage

Basic Usage

Scan the current directory:

style-guard

Scan a specific directory:

style-guard ./src

With npm scripts

Add to your package.json:

{
  "scripts": {
    "lint:styles": "style-guard src",
    "lint:styles:ci": "style-guard src --no-color"
  }
}

Then run:

npm run lint:styles

⚙️ Configuration

Create a styleguard.config.json file in your project root to customize the behavior:

{
  "extensions": [".css", ".scss", ".jsx", ".tsx", ".html"],
  "ignore": ["node_modules", "dist", "build", ".git", "coverage"],
  "rules": {
    "hardcodedColors": true,
    "hardcodedPx": true
  }
}

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | extensions | string[] | [".css", ".scss", ".jsx", ".tsx", ".html"] | File extensions to scan | | ignore | string[] | ["node_modules", "dist", "build", ".git"] | Directories to ignore | | rules.hardcodedColors | boolean | true | Detect hardcoded hex colors | | rules.hardcodedPx | boolean | true | Detect hardcoded pixel values |

📋 Examples

Example Output

🔍 Scanning: /path/to/your/project

ℹ️  No styleguard.config.json found — using defaults

Found 12 file(s). Checking for violations...

──────────────────────────────────────────────────
📁 src/components/Button.jsx
──────────────────────────────────────────────────

Line 15: Hardcoded color "#3498db" — use a design token instead
Line 22: Hardcoded px value "16px" — use a spacing/size token instead

──────────────────────────────────────────────────
📁 src/styles/header.scss  
──────────────────────────────────────────────────

Line 8: Hardcoded color "#ffffff" — use a design token instead
Line 12: Hardcoded px value "24px" — use a spacing/size token instead

──────────────────────────────────────────────────
❌ Found 4 style violations across 2 files
──────────────────────────────────────────────────

Before Style Guard

.button {
  background-color: #3498db;
  padding: 16px 24px;
  border-radius: 8px;
  color: #ffffff;
}

After Style Guard (Recommended)

.button {
  background-color: var(--color-primary);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  color: var(--color-white);
}

🔧 Integration

Pre-commit Hooks

With husky:

npx husky add .husky/pre-commit "npx style-guard src"

CI/CD Integration

# GitHub Actions
- name: Run Style Guard
  run: |
    npm install -g style-guard-cli
    style-guard src

VS Code Integration

Add a task to .vscode/tasks.json:

{
  "type": "shell",
  "label": "Style Guard",
  "command": "style-guard",
  "args": ["src"],
  "group": "test",
  "presentation": {
    "echo": true,
    "reveal": "always",
    "panel": "new"
  }
}

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Made with ❤️ by Hija Happy