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 🙏

© 2024 – Pkg Stats / Ryan Hefner

stylinpug

v2.0.2

Published

Check Stylus against Pug, and vice versa, for unused and blacklisted classes

Downloads

5

Readme

Stylin' Pug

Check Stylus against Pug, and vice versa, for unused and blacklisted classes.

build status coverage status dependency status npm

CLI

Installation

$ npm install stylinpug -g

Usage

$ stylinpug [options] <stylusFiles...> <pugFiles...>

OR to find all Stylus and Pug files in current working directory

$ stylinpug [options] .

options

  • -h, --help: output usage information
  • -V, --version: output the version number
  • -v, --verbose: displays the full visual representation of blacklisted and unused classes
  • -C, --chdir <path>: change the working directory
  • -c, --config <path>: set path to load config file from. Defaults to ./.stylinpugrc

API

Installation

$ npm install stylinpug --save

Usage

var stylinpug = require('stylinpug')

  , stylusFiles = [ 'index.styl', '**/index*.styl' ]
  , pugFiles = [ 'default.pug', 'includes/header.pug' ]
  , options =
    { ignoreFiles: [ '**/footer.styl', '**/header.pug' ]
    , stylusWhitelist: [ 'js', 'no-svg', 'icon--*', 'is-*' ]
    , pugWhitelist: [ 'js-*', 'style-guide-nav' ]
    , stylusBlacklist: [ 'js-*' ]
    , pugBlacklist: []
    }

stylinpug(stylusFiles, pugFiles, options, function (err, results) {
  console.log(results.report)
})

stylinpug(stylusFiles, pugFiles, [options,] callback)

stylusFiles

Required Type: Array

An array of .styl file name patterns.

pugFiles

Required Type: Array

An array of .pug file name patterns.

options

Type: object

| Name | Type | Description | | --- | --- | --- | | cwd | string | The alternative path to the current working directory | | verbose | boolean | Displays the full visual representation of blacklisted and unused classes | | ignoreFiles | Array | An array of patterns for file names to ignore when they exist in .styl files, .pug files | | stylusBlacklist | Array | An array of patterns for classes that should never exist in .stylus files | | stylusWhitelist | Array | An array patterns for classes to ignore when they exist in .stylus files but not in .pug files | | pugBlacklist | Array | An array of patterns for classes that should never exist in .pug files | | pugWhitelist | Array | An array of patterns for classes to ignore when they exist in .pug files but not in .stylus files | | config | string | The alternative path to a config file to load options from |

callback(error, results)

Required Type: function

results

Type: object

| Name | Type | Description | | --- | --- | --- | | blacklistedStylusClasses | object | The blacklisted classes found in .stylus files | | blacklistedStylusCount | int | The number of blacklisted classes found in .stylus files | | blacklistedPugClasses | object | The blacklisted classes found in .pug files | | blacklistedPugCount | int | The number of blacklisted classes found in .pug files | | blacklistedTotal | int | The total number of blacklisted classes found in all files | | unusedStylusClasses | object | The classes found that exist in .stylus but not .pug files | | unusedStylusCount | int | The number of classes found that exist in .stylus but not .pug files | | unusedPugClasses | object | The classes found that exist in .pug but not .stylus files | | unusedPugCount | int | The number of classes found that exist in .pug but not .stylus files | | unusedTotal | int | The total number of ununsed classes found in all files | | report | string | The visual representation of blacklisted and unused classes found across all files |

Example classes object
{ "name": "style-guide-nav"
, "locations":
  [ { "file": "/path/to/.stylus/or/.pug", "line": 1, "column": 1 }
  , { "file": "/path/to/another/.stylus/or/.pug", "line": 5, "column": 3 }
  ]
}
Example report

Configuration file

Options can be specified in a config file (see example). If no options have been specified, the current working directory is checked to see if there is a .stylinpugrc file present. This can be overridden by setting options.config to the path of the desired configuration file:

var options = { config: '/path/to/.stylinpugrc' }

stylinpug(stylusFiles, pugFiles, options, function (err, results) {
  console.log(results.report)
})

Directives

The following configuration directives as supported:

styluswhitelist

Adds the specified pattern to options.stylusWhitelist

  • Stylus usage: /* stylinpug styluswhitelist: <pattern> */
  • Pug usage: //- stylinpug styluswhitelist: <pattern>

pugwhitelist

Adds the specified pattern to options.pugWhitelist

  • Stylus usage: /* stylinpug pugwhitelist: <pattern> */
  • Pug usage: //- stylinpug pugwhitelist: <pattern>

whitelist

Adds the specified pattern to both options.stylusWhitelist and options.pugWhitelist

  • Stylus usage: /* stylinpug whitelist: <pattern> */
  • Pug usage: //- stylinpug whitelist: <pattern>

stylusblacklist

Adds the specified pattern to options.stylusBlacklist

  • Stylus usage: /* stylinpug stylusblacklist: <pattern> */
  • Pug usage: //- stylinpug stylusblacklist: <pattern>

pugblacklist

Adds the specified pattern to options.pugBlacklist

  • Stylus usage: /* stylinpug pugblacklist: <pattern> */
  • Pug usage: //- stylinpug pugblacklist: <pattern>

blacklist

Adds the specified pattern to both options.stylusBlacklist and options.pugBlacklist

  • Stylus usage: /* stylinpug blacklist: <pattern> */
  • Pug usage: //- stylinpug blacklist: <pattern>

Licence

ISC © Ben Edwards