Check Stylus against Pug, and vice versa, for unused and blacklisted classes.
$ npm install stylinpug -g
$ stylinpug [options] <stylusFiles...> <pugFiles...>
OR to find all Stylus and Pug files in current working directory
$ stylinpug [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
$ npm install stylinpug --save
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)
})
Required
Type: Array
An array of .styl
file name patterns.
Required
Type: Array
An array of .pug
file name patterns.
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 |
Required
Type: function
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 |
{ "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 }
]
}
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)
})
The following configuration directives as supported:
Adds the specified pattern to options.stylusWhitelist
- Stylus usage:
/* stylinpug styluswhitelist: <pattern> */
- Pug usage:
//- stylinpug styluswhitelist: <pattern>
Adds the specified pattern to options.pugWhitelist
- Stylus usage:
/* stylinpug pugwhitelist: <pattern> */
- Pug usage:
//- stylinpug pugwhitelist: <pattern>
Adds the specified pattern to both options.stylusWhitelist
and options.pugWhitelist
- Stylus usage:
/* stylinpug whitelist: <pattern> */
- Pug usage:
//- stylinpug whitelist: <pattern>
Adds the specified pattern to options.stylusBlacklist
- Stylus usage:
/* stylinpug stylusblacklist: <pattern> */
- Pug usage:
//- stylinpug stylusblacklist: <pattern>
Adds the specified pattern to options.pugBlacklist
- Stylus usage:
/* stylinpug pugblacklist: <pattern> */
- Pug usage:
//- stylinpug pugblacklist: <pattern>
Adds the specified pattern to both options.stylusBlacklist
and options.pugBlacklist
- Stylus usage:
/* stylinpug blacklist: <pattern> */
- Pug usage:
//- stylinpug blacklist: <pattern>
ISC © Ben Edwards