Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
Merge 56301ff into a76cf82
Browse files Browse the repository at this point in the history
  • Loading branch information
benedfit committed Jun 9, 2016
2 parents a76cf82 + 56301ff commit 3689b0d
Show file tree
Hide file tree
Showing 31 changed files with 464 additions and 459 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -8,5 +8,5 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.jade]
[*.pug]
trim_trailing_whitespace = false
4 changes: 2 additions & 2 deletions .stylperjaderc
Expand Up @@ -5,13 +5,13 @@
, "stylusWhitelist":
[
]
, "jadeWhitelist":
, "pugWhitelist":
[
]
, "stylusBlacklist":
[
]
, "jadeBlacklist":
, "pugBlacklist":
[
]
}
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
@@ -1,6 +1,6 @@
# Contribution guide

Thanks for wanting to contribute! This document describes some points about the contribution process for Stylperjade.
Thanks for wanting to contribute! This document describes some points about the contribution process for this project.

1. [Maintainers](#maintainers)
1. [Pull requests](#pull-requests)
Expand Down Expand Up @@ -56,8 +56,8 @@ When it comes to bugs, the more details you provide, the easier it is to reprodu
Some helpful points to provide (if you can):

1. A failing test would be amazing
1. Code snippets that make Stylperjade exhibit the issue
1. The version of Stylperjade that you're using
1. Code snippets that exhibit the issue
1. The version that you're using
1. Your operating system (Windows, Mac, or Linux)
1. Screen-shots

Expand All @@ -69,9 +69,9 @@ If you've got an idea for a new feature, file an issue providing some details on

## Implementing features

It's likely that you'll have to implement feature requests or enhancements on your own. To do that, you'll need to be comfortable with JavaScript, Node.js, and familiar with [Jade's abstract syntax tree format](https://github.com/jadejs/jade-parser).
It's likely that you'll have to implement feature requests or enhancements on your own. To do that, you'll need to be comfortable with JavaScript, Node.js, and familiar with [Stylus'](https://github.com/stylus/stylus) and [Pug's](https://github.com/pugjs/pug-lexer) abstract syntax tree format.

To understand how Stylperjade works, the best place to start is in the `lib/` directory: starting with `lib/cli.js` (to see the processing flow when `stylperjade` is invoked in the terminal) then going to `lib/stylperjade.js` for understanding how Stylperjade checks files.
To understand how the project works, the best place to start is in the `lib/` directory: starting with `lib/cli.js` (to see the processing flow when `stylperjade` is invoked in the terminal) then going to `lib/report.js` for understanding how files are checked.

If you cannot implement the feature, but you feel that it would be helpful to others, you can create an issue on GitHub. If the maintainers feel that the issue satisfies our [criteria for closing issues](#prissue-closing-criteria), your issue will be closed with a genuine thank you and an explanation for the closure.

Expand Down
91 changes: 45 additions & 46 deletions README.md
@@ -1,6 +1,6 @@
# Stylperjade

Pronounced: /[stʌɪl](//ssl.gstatic.com/dictionary/static/sounds/de/0/style.mp3) [pəˈreɪd](//ssl.gstatic.com/dictionary/static/sounds/de/0/parade.mp3)/ - Checks Jade against Stylus, and vice versa, for unused and blacklisted classes.
Pronounced: /[stʌɪl](//ssl.gstatic.com/dictionary/static/sounds/de/0/style.mp3) [pəˈreɪd](//ssl.gstatic.com/dictionary/static/sounds/de/0/parade.mp3)/ - Checks Pug against Stylus, and vice versa, for unused and blacklisted classes.

[![build status](https://img.shields.io/travis/benedfit/stylperjade/master.svg)](https://travis-ci.org/benedfit/stylperjade)
[![coverage status](https://img.shields.io/coveralls/benedfit/stylperjade/master.svg)](https://coveralls.io/github/benedfit/stylperjade)
Expand All @@ -18,11 +18,11 @@ $ npm install stylperjade -g
## Usage

```shell
$ stylperjade [options] <stylusFiles...> <jadeFiles...>
$ stylperjade [options] <stylusFiles...> <pugFiles...>

```

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

```
$ stylperjade [options] .
Expand Down Expand Up @@ -50,21 +50,21 @@ $ npm install stylperjade --save
var stylperjade = require('stylperjade')

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

stylperjade(stylusFiles, jadeFiles, options, function (err, results) {
stylperjade(stylusFiles, pugFiles, options, function (err, results) {
console.log(results.report)
})
```

### stylperjade(stylusFiles, jadeFiles, [options,] callback)
### stylperjade(stylusFiles, pugFiles, [options,] callback)

#### stylusFiles

Expand All @@ -73,12 +73,12 @@ Type: `Array`

An array of `.styl` file name patterns.

#### jadeFiles
#### pugFiles

*Required*
Type: `Array`

An array of `.jade` file name patterns.
An array of `.pug` file name patterns.

#### options

Expand All @@ -88,12 +88,12 @@ Type: `object`
| --- | --- | --- |
| cwd | `string` | The alternative path to the current working directory |
| verbose | `boolean` | Displays the full [visual representation](#user-content-example-report) of blacklisted and unused classes |
| ignoreFiles | `Array` | An array of patterns for file names to ignore when they exist in `.styl` files, `.jade` files, or source map sources |
| ignoreFiles | `Array` | An array of patterns for file names to ignore when they exist in `.styl` files, `.pug` files, or source map sources |
| stylusBlacklist | `Array` | An array of patterns for classes that should never exist in `.stylus` files or source map sources |
| stylusWhitelist | `Array` | An array patterns for classes to ignore when they exist in `.stylus` files or source maps sources but not in `.jade` files |
| jadeBlacklist | `Array` | An array of patterns for classes that should never exist in `.jade` files |
| jadeWhitelist | `Array` | An array of patterns for classes to ignore when they exist in `.jade` files but not in `.stylus` files or source map sources |
| stylperjaderc | `string` | The alternative path to a `.stylperjaderc` file to load options from |
| stylusWhitelist | `Array` | An array patterns for classes to ignore when they exist in `.stylus` files or source maps sources 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 or source map sources |
| config | `string` | The alternative path to a config file to load options from |

#### callback(error, results)

Expand All @@ -108,13 +108,13 @@ Type: `object`
| --- | --- | --- |
| [blacklistedStylusClasses](#user-content-example-classes-object) | `object` | The blacklisted classes found in `.stylus` files |
| blacklistedStylusCount | `int` | The number of blacklisted classes found in `.stylus` files |
| [blacklistedJadeClasses](#user-content-example-classes-object) | `object` | The blacklisted classes found in `.jade` files |
| blacklistedJadeCount | `int` | The number of blacklisted classes found in `.jade` files |
| [blacklistedPugClasses](#user-content-example-classes-object) | `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](#user-content-example-classes-object) | `object` | The classes found that exist in `.stylus` but not `.jade` files |
| unusedStylusCount | `int` | The number of classes found that exist in `.stylus` but not `.jade` files |
| [unusedJadeClasses](#user-content-example-classes-object) | `object` | The classes found that exist in `.jade` but not `.stylus` files |
| unusedJadeCount | `int` | The number of classes found that exist in `.jade` but not `.stylus` files |
| [unusedStylusClasses](#user-content-example-classes-object) | `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](#user-content-example-classes-object) | `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](#user-content-example-report) | `string` | The visual representation of blacklisted and unused classes found across all files |

Expand All @@ -123,9 +123,8 @@ Type: `object`
```json
{ "name": "style-guide-nav"
, "locations":
[ { "file": "/path/to/.stylus/or/.jade", "line": 1, "column": 1 }
, { "file": "/path/to/another/.stylus/or/.jade", "line": 5, "column": 3 }
, { "file": "/path/to/original/source/using/source/map", "line": 20 }
[ { "file": "/path/to/.stylus/or/.pug", "line": 1, "column": 1 }
, { "file": "/path/to/another/.stylus/or/.pug", "line": 5, "column": 3 }
]
}
```
Expand All @@ -136,12 +135,12 @@ Type: `object`

## Configuration file

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

```js
var options = { stylperjaderc: '/path/to/.stylperjaderc' }
var options = { config: '/path/to/.stylperjaderc' }

stylperjade(stylusFiles, jadeFiles, options, function (err, results) {
stylperjade(stylusFiles, pugFiles, options, function (err, results) {
console.log(results.report)
})
```
Expand All @@ -154,43 +153,43 @@ The following configuration directives as supported by Stylperjade:

Adds the specified pattern to [`options.stylusWhitelist`](#options-1)

* Stylus usage: `/*! stylperjade styluswhitelist: <pattern> */`
* Jade usage: `//- stylperjade styluswhitelist: <pattern>`
* Stylus usage: `/* stylperjade styluswhitelist: <pattern> */`
* Pug usage: `//- stylperjade styluswhitelist: <pattern>`

### jadewhitelist
### pugwhitelist

Adds the specified pattern to [`options.jadeWhitelist`](#options-1)
Adds the specified pattern to [`options.pugWhitelist`](#options-1)

* Stylus usage: `/*! stylperjade jadewhitelist: <pattern> */`
* Jade usage: `//- stylperjade jadewhitelist: <pattern>`
* Stylus usage: `/* stylperjade pugwhitelist: <pattern> */`
* Pug usage: `//- stylperjade pugwhitelist: <pattern>`

### whitelist

Adds the specified pattern to both [`options.stylusWhitelist`](#options-1) and [`options.jadeWhitelist`](#options-1)
Adds the specified pattern to both [`options.stylusWhitelist`](#options-1) and [`options.pugWhitelist`](#options-1)

* Stylus usage: `/*! stylperjade whitelist: <pattern> */`
* Jade usage: `//- stylperjade whitelist: <pattern>`
* Stylus usage: `/* stylperjade whitelist: <pattern> */`
* Pug usage: `//- stylperjade whitelist: <pattern>`

### stylusblacklist

Adds the specified pattern to [`options.stylusBlacklist`](#options-1)

* Stylus usage: `/*! stylperjade stylusblacklist: <pattern> */`
* Jade usage: `//- stylperjade stylusblacklist: <pattern>`
* Stylus usage: `/* stylperjade stylusblacklist: <pattern> */`
* Pug usage: `//- stylperjade stylusblacklist: <pattern>`

### jadeblacklist
### pugblacklist

Adds the specified pattern to [`options.jadeBlacklist`](#options-1)
Adds the specified pattern to [`options.pugBlacklist`](#options-1)

* Stylus usage: `/*! stylperjade jadeblacklist: <pattern> */`
* Jade usage: `//- stylperjade jadeblacklist: <pattern>`
* Stylus usage: `/* stylperjade pugblacklist: <pattern> */`
* Pug usage: `//- stylperjade pugblacklist: <pattern>`

### blacklist

Adds the specified pattern to both [`options.stylusBlacklist`](#options-1) and [`options.jadeBlacklist`](#options-1)
Adds the specified pattern to both [`options.stylusBlacklist`](#options-1) and [`options.pugBlacklist`](#options-1)

* Stylus usage: `/*! stylperjade blacklist: <pattern> */`
* Jade usage: `//- stylperjade blacklist: <pattern>`
* Stylus usage: `/* stylperjade blacklist: <pattern> */`
* Pug usage: `//- stylperjade blacklist: <pattern>`

## Licence
ISC © [Ben Edwards](https://github.com/benedfit/)
19 changes: 10 additions & 9 deletions lib/cli.js
@@ -1,33 +1,34 @@
var stylperjade = require('../lib/stylperjade')
var reporter = require('../lib/reporter')
, packageDetails = require('../package.json')
, program = require('commander')
, utils = require('../lib/utils')

function run (args) {

program
.version(packageDetails.version)
.description(packageDetails.description)
.usage('[options] <stylusFiles ...> <jadeFiles ...>')
.usage('[options] <stylusFiles ...> <pugFiles ...>')
.option('-v, --verbose'
, 'displays the full visual representation of blacklisted and unused classes')
.option('-C, --chdir <path>'
, 'change the working directory')
.option('-c, --config <path>'
, 'set path to load options from. Defaults to ./.stylperjaderc')
, 'set path to load options from. Defaults to ./' + utils.configPath)
.parse(args)

var stylusFiles = []
, jadeFiles = []
, pugFiles = []
, options = {}

parseOptions()
parseArgs(program.args)

if (!stylusFiles.length || !jadeFiles.length) {
if (!stylusFiles.length || !pugFiles.length) {
program.help()
}

stylperjade(stylusFiles, jadeFiles, options, function (err, results) {
reporter(stylusFiles, pugFiles, options, function (err, results) {
if (err) {
console.error(err)
process.exit(1)
Expand All @@ -46,10 +47,10 @@ function run (args) {

if (args.length === 1 && args[0] === '.') {
stylusFiles = [ '**/*.styl' ]
jadeFiles = [ '**/*.jade' ]
pugFiles = [ '**/*.pug' ]
} else {
stylusFiles = args[0] && typeof args[0] === 'string' ? [ args[0] ] : []
jadeFiles = args[1] && typeof args[1] === 'string' ? [ args[1] ] : []
pugFiles = args[1] && typeof args[1] === 'string' ? [ args[1] ] : []
}

}
Expand All @@ -60,7 +61,7 @@ function run (args) {
}

if (program.config) {
options.stylperjaderc = program.config
options.config = program.config
}

if (program.verbose) {
Expand Down

0 comments on commit 3689b0d

Please sign in to comment.