mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Initial commit
This commit is contained in:
28
node_modules/colorguard/CHANGELOG.md
generated
vendored
Normal file
28
node_modules/colorguard/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# CSS COLORGUARD CHANGELOG
|
||||
|
||||
## 2016-04-30 - 1.2.0
|
||||
|
||||
- Added `allowEquivalentNotation` option
|
||||
|
||||
## 2016-03-15 - 1.1.1
|
||||
|
||||
- Upgraded pipetteur to `2.0.0` (thanks to @davidtheclark)
|
||||
|
||||
## 2016-03-11 - 1.1.0
|
||||
|
||||
- Added `firstColor` & `secondColor` to generated warnings, enabling easier
|
||||
warning consumption (thanks to @davidtheclark)
|
||||
|
||||
## 2015-09-23 - 1.0.1
|
||||
|
||||
- Added a CHANGELOG per PostCSS guidelines for plugins
|
||||
- Switched the license to MIT, since npm didn't like Apache 2.0 as a license field
|
||||
|
||||
## 2015-09-23 - 1.0.0
|
||||
|
||||
- Switched to PostCSS from reworkcss
|
||||
- Changed the output format to use postcss notification api
|
||||
- Exposes self as a postcss plugin
|
||||
- `inspect` is now `process` in order to match PostCSS style
|
||||
- Test suite changed to @substack's tape
|
||||
- Supports sourcemap inputs via PostCSS api
|
124
node_modules/colorguard/README.md
generated
vendored
Normal file
124
node_modules/colorguard/README.md
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
[](https://travis-ci.org/SlexAxton/css-colorguard)
|
||||
|
||||
# CSS Colorguard
|
||||
|
||||
Every CSS project starts out with good intentions, but inevitably, one too many people eye-dropper
|
||||
colors into nooks and crannies that you never knew existed. CSS Colorguard helps you maintain the
|
||||
color set that you want, and warns you when colors you've added are too similar to ones that already
|
||||
exist. Naturally, it's all configurable to your tastes.
|
||||
|
||||
## How it works
|
||||
|
||||
Colorguard uses the [CIEDE2000](http://en.wikipedia.org/wiki/Color_difference#CIEDE2000) algorithm to determine
|
||||
the similarity of each of the colors in your CSS file. This algorithm is quite complex, but is used
|
||||
in the broadcasting community as the best approximation of human ability to discern differences in
|
||||
color. RGB on the other hand, is pretty bad at representing differences in color purely based on the
|
||||
numerical difference of the hex values.
|
||||
|
||||
Luckily, [someone else already implemented CIEDE2000](https://github.com/markusn/color-diff), so I
|
||||
didn't have to. Tight. Cause this thing is mathy as hell.
|
||||
|
||||

|
||||
|
||||
### Alpha Transparency
|
||||
|
||||
Currently, alpha transparency is just stripped from the colors. So `rgb(0, 0, 0)` exactly matches
|
||||
`rgba(0,0,0,0.5)`. This is usually fine unless someone is alphatransparency-happy and uses it for
|
||||
darkening and lightening colors too often. It could probably be its own check in the future that
|
||||
there aren't too many different alpha transparencies of the same color. This is not currently a
|
||||
thing though.
|
||||
|
||||
## API
|
||||
|
||||
### `colorguard.process(css, [options]).then(function(result) {})`
|
||||
|
||||
#### options
|
||||
|
||||
##### ignore
|
||||
|
||||
Type: `array`
|
||||
|
||||
Specify hex codes of colors that you would like to ignore completely.
|
||||
Use with caution.
|
||||
|
||||
##### threshold
|
||||
|
||||
Type: `number`
|
||||
Default: `3`
|
||||
|
||||
`0` through `100`. Lower values are more precise; the default is `3` but that's
|
||||
mostly personal opinion.
|
||||
|
||||
##### whitelist
|
||||
|
||||
Type: `array`
|
||||
|
||||
Pass an array of color pairs to ignore:
|
||||
|
||||
```js
|
||||
[['#000000', '#010101']]
|
||||
```
|
||||
|
||||
##### allowEquivalentNotation
|
||||
|
||||
Type: `boolean`
|
||||
Default: `false`
|
||||
|
||||
By default, colorguard will complain if identical colors are represented with different notations.
|
||||
For example, `#000`, `#000000`, `rgba(0, 0, 0, 0), and `black`. If you want to permit these
|
||||
equivalent notations, set this option to `true`.
|
||||
|
||||
### `postcss([ colorguard(opts) ])`
|
||||
|
||||
CSS Colorguard can be consumed as a PostCSS plugin. See the
|
||||
[documentation](https://github.com/postcss/postcss#usage) for examples for
|
||||
your environment.
|
||||
|
||||
### Build Time
|
||||
|
||||
CSS Colorguard can be used in conjunction with other javascript build systems, such as:
|
||||
|
||||
* [gulp-colorguard](https://github.com/pgilad/gulp-colorguard)
|
||||
* [broccoli-colorguard](https://github.com/SlexAxton/broccoli-colorguard)
|
||||
* [grunt-colorguard](https://github.com/elliottwilliams/grunt-colorguard)
|
||||
|
||||
### CLI
|
||||
|
||||
CSS Colorguard also ships with a CLI app. To see the available options, just run:
|
||||
|
||||
```bash
|
||||
$ colorguard --help
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
With npm, to get the command do:
|
||||
|
||||
```bash
|
||||
npm install -g colorguard
|
||||
```
|
||||
|
||||
To get the library & PostCSS plugin, do:
|
||||
|
||||
```bash
|
||||
npm install colorguard
|
||||
```
|
||||
|
||||
## Thanks
|
||||
|
||||
* [Stripe](https://stripe.com/) - They let me build this at work
|
||||
* [@markusn](https://github.com/markusn) - Best CIEDE2000 implementation ever
|
||||
|
||||
## License
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
63
node_modules/colorguard/bin/colorguard
generated
vendored
Executable file
63
node_modules/colorguard/bin/colorguard
generated
vendored
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env node
|
||||
var yargs = require('yargs');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var stdin = process.stdin;
|
||||
var argv = yargs.argv;
|
||||
var assign = require('object-assign');
|
||||
|
||||
yargs
|
||||
.describe('file', 'A CSS file')
|
||||
.describe('threshold', 'Threshold of allowable color difference')
|
||||
.describe('allow-equivalent-notation', 'Allow equivalent notation of the same color, e.g. #000 and #000000')
|
||||
.describe('options', 'An optional JSON file containing all options (Overrides `--threshold`)')
|
||||
.usage('Usage: colorguard --file [style.css] ');
|
||||
|
||||
process.title = 'colorguard';
|
||||
|
||||
var colorguard = require('..');
|
||||
var css = [];
|
||||
var options = {};
|
||||
|
||||
if (argv.file) {
|
||||
run(fs.readFileSync(path.resolve(process.cwd(), argv.file), 'utf8'));
|
||||
}
|
||||
else {
|
||||
stdin.setEncoding('utf8');
|
||||
|
||||
if (process.stdin.isTTY) {
|
||||
yargs.showHelp();
|
||||
}
|
||||
else {
|
||||
stdin.on('data', function(chunk) {
|
||||
css.push(chunk);
|
||||
});
|
||||
|
||||
stdin.on('end', function() {
|
||||
css = css.join();
|
||||
run(css);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function run (css) {
|
||||
if (argv.options) {
|
||||
options = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), argv.options), 'utf8'));
|
||||
}
|
||||
else {
|
||||
if (argv.threshold) {
|
||||
options.threshold = argv.threshold;
|
||||
}
|
||||
options.allowEquivalentNotation = argv.allowEquivalentNotation;
|
||||
}
|
||||
if (argv.file) {
|
||||
options = assign({
|
||||
from: argv.file
|
||||
}, options);
|
||||
}
|
||||
colorguard.process(css, options).then(function (result) {
|
||||
if (result.warnings().length) {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
3
node_modules/colorguard/index.js
generated
vendored
Normal file
3
node_modules/colorguard/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var colorguard = require('./lib/colorguard');
|
||||
|
||||
module.exports = colorguard;
|
121
node_modules/colorguard/lib/colorguard.js
generated
vendored
Normal file
121
node_modules/colorguard/lib/colorguard.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
var assign = require('object-assign');
|
||||
var colorDiff = require('color-diff');
|
||||
var formatter = require('./formatter');
|
||||
var postcss = require('postcss');
|
||||
var pipetteur = require('pipetteur');
|
||||
var reporter = require('postcss-reporter');
|
||||
|
||||
function convertToLab (clr) {
|
||||
clr = clr.rgb();
|
||||
|
||||
try {
|
||||
return colorDiff.rgb_to_lab({
|
||||
R: Math.round(clr.red() * 255),
|
||||
G: Math.round(clr.green() * 255),
|
||||
B: Math.round(clr.blue() * 255)
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error('Error converting color ' + clr.hex() + ' to lab format.');
|
||||
}
|
||||
}
|
||||
|
||||
// returns correct column number of the color declaration
|
||||
// pipetteur finds the position from the beginning of value declaration,
|
||||
// we need line position instead
|
||||
function getColumnPositionRelativeToLine (position) {
|
||||
var decl = position.declaration;
|
||||
return decl.source.start.column + position.column + decl.prop.length;
|
||||
}
|
||||
|
||||
function getWhitelistHashKey (pair) {
|
||||
pair = pair.sort();
|
||||
return pair[0] + '-' + pair[1];
|
||||
}
|
||||
|
||||
function getDiff (a, b) {
|
||||
return Math.min(colorDiff.diff(convertToLab(a), convertToLab(b)), 100);
|
||||
}
|
||||
|
||||
var stripUrl = /url\(['|"]?.*?['|"]?\)/;
|
||||
|
||||
var colorguard = postcss.plugin('css-colorguard', function (opts) {
|
||||
opts = assign({
|
||||
ignore: [],
|
||||
threshold: 3
|
||||
}, opts);
|
||||
|
||||
var whitelistHash = {};
|
||||
if (opts.whitelist) {
|
||||
opts.whitelist.forEach(function (pair) {
|
||||
if (!Array.isArray(pair)) {
|
||||
throw new Error('The whitelist option takes an array of array pairs. ' +
|
||||
'You probably sent an array of strings.');
|
||||
}
|
||||
whitelistHash[getWhitelistHashKey(pair)] = true;
|
||||
});
|
||||
}
|
||||
|
||||
return function (css, result) {
|
||||
var colors = {};
|
||||
|
||||
css.walkDecls(function (decl) {
|
||||
var cleanValue = decl.value.replace(stripUrl, '');
|
||||
var matches = pipetteur(cleanValue);
|
||||
matches.forEach(function (match) {
|
||||
// FIXME: This discards alpha channel
|
||||
var name = match.color.hex();
|
||||
// Just bail if we want to ignore the color
|
||||
if (opts.ignore.indexOf(name) > -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
match.declaration = decl;
|
||||
|
||||
if (!(name in colors)) {
|
||||
colors[name] = colors[name] || [];
|
||||
colors[name].push(match);
|
||||
}
|
||||
|
||||
Object.keys(colors).forEach(function (color) {
|
||||
var cached = colors[color];
|
||||
if (cached[0] === match || cached[0].match === match.match) {
|
||||
return;
|
||||
}
|
||||
var diffAmount = getDiff(cached[0].color, match.color);
|
||||
|
||||
// If colors are the same (no diff) but have a different representation
|
||||
// (e.g. #000 and #000000 and black), do not complain
|
||||
if (opts.allowEquivalentNotation && diffAmount === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var whitelisted = getWhitelistHashKey([color, name]);
|
||||
if (diffAmount < opts.threshold && !whitelistHash[whitelisted]) {
|
||||
var message = (
|
||||
match.match +
|
||||
' collides with ' +
|
||||
cached[0].match +
|
||||
' (' +
|
||||
cached[0].declaration.source.start.line +
|
||||
':' +
|
||||
getColumnPositionRelativeToLine(cached[0]) +
|
||||
')'
|
||||
);
|
||||
decl.warn(result, message, {
|
||||
secondColor: match.match,
|
||||
firstColor: cached[0].match
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
colorguard.process = function (css, opts) {
|
||||
opts = opts || {};
|
||||
var processor = postcss([ colorguard(opts), reporter({formatter: formatter}) ]);
|
||||
return processor.process(css, opts);
|
||||
};
|
||||
|
||||
module.exports = colorguard;
|
43
node_modules/colorguard/lib/formatter.js
generated
vendored
Normal file
43
node_modules/colorguard/lib/formatter.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var chalk = require('chalk');
|
||||
var logSymbols = require('log-symbols');
|
||||
var path = require('path');
|
||||
var plur = require('plur');
|
||||
var table = require('text-table');
|
||||
|
||||
function logFrom (fromValue) {
|
||||
if (!fromValue.indexOf('<')) {
|
||||
return fromValue;
|
||||
}
|
||||
return path.relative(process.cwd(), fromValue);
|
||||
}
|
||||
|
||||
function collisions (messages) {
|
||||
var num = messages.length + plur(' collision', messages.length);
|
||||
return '\n\n ' + logSymbols.error + ' ' + num + ' found.\n';
|
||||
}
|
||||
|
||||
module.exports = function (input) {
|
||||
var messages = input.messages;
|
||||
var source = input.source;
|
||||
|
||||
if (!messages.length) {
|
||||
return ' ' + logSymbols.success + ' No collisions found.';
|
||||
}
|
||||
|
||||
var filename = chalk.underline(logFrom(source)) + '\n';
|
||||
|
||||
return filename + table(messages.map(function (msg) {
|
||||
var last = msg.text.lastIndexOf('(');
|
||||
var warning = msg.text.slice(0, last).trim();
|
||||
var position = msg.text.slice(last, msg.text.length);
|
||||
return [
|
||||
'',
|
||||
chalk.gray('line ' + msg.node.source.start.line),
|
||||
chalk.gray('col ' + msg.node.source.start.column),
|
||||
warning,
|
||||
chalk.gray(position)
|
||||
];
|
||||
})) + collisions(messages);
|
||||
};
|
47
node_modules/colorguard/node_modules/postcss-reporter/CHANGELOG.md
generated
vendored
Normal file
47
node_modules/colorguard/node_modules/postcss-reporter/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# Changelog
|
||||
|
||||
## 1.4.1
|
||||
- Add `filter` option.
|
||||
- Add blacklist functionality to `plugins` option with `!` prefix`.
|
||||
|
||||
## 1.3.3
|
||||
- Fix regression that caused positions from sources without incoming sourcemaps not to be logged.
|
||||
|
||||
## 1.3.2
|
||||
- Find more accurate positions of preprocessed files with sourcemaps.
|
||||
|
||||
## 1.3.1
|
||||
- Fix Windows path bug.
|
||||
|
||||
## 1.3.0
|
||||
- Check individual messages for distinct sources, then group messages by those sources,
|
||||
instead of always using the PostCSS Result's source.
|
||||
- Output empty string from `formatter` if there are no messages, instead of `undefined`.
|
||||
|
||||
## 1.2.1
|
||||
- Handle variable and absent input sources.
|
||||
|
||||
## 1.2.0
|
||||
- Add `noIcon` and `noPlugin` options to both reporter and formatter.
|
||||
|
||||
## 1.1.0
|
||||
- Use PostCSS 5's line/column properties on warnings, instead of relying on the source node.
|
||||
|
||||
## 1.0.0
|
||||
- Upgrade to PostCSS 5.
|
||||
|
||||
## 0.4.0
|
||||
- Add `positionless` option (to both the reporter and the formatter), with default value `"first"`.
|
||||
- Cleaner npm install (files specified in `package.json`).
|
||||
|
||||
## 0.3.1
|
||||
- Remove leftover debugging log statement.
|
||||
|
||||
## 0.3.0
|
||||
- Add `sortByPosition` option (to both the reporter and the formatter), with default value `true`.
|
||||
|
||||
## 0.2.0
|
||||
- Alter `defaultFormatter` to use warning symbol and not repeat `# postcss-reporter`.
|
||||
|
||||
## 0.1.0
|
||||
- First release.
|
22
node_modules/colorguard/node_modules/postcss-reporter/LICENSE
generated
vendored
Normal file
22
node_modules/colorguard/node_modules/postcss-reporter/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 David Clark
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
134
node_modules/colorguard/node_modules/postcss-reporter/README.md
generated
vendored
Normal file
134
node_modules/colorguard/node_modules/postcss-reporter/README.md
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
# postcss-reporter
|
||||
[](https://travis-ci.org/postcss/postcss-reporter)[](https://ci.appveyor.com/project/davidtheclark/postcss-reporter)
|
||||
|
||||
A PostCSS plugin to `console.log()` the messages (warnings, etc.) registered by other PostCSS plugins.
|
||||
|
||||
## Purpose
|
||||
|
||||
As of PostCSS 4.1, a single PostCSS process can accumulate messages from all of the plugins it uses.
|
||||
Most of these messages are [warnings](https://github.com/postcss/postcss/blob/master/docs/guidelines/plugin.md#32-use-resultwarn-for-warnings).
|
||||
Presumably, plugin authors want you to see those messages.
|
||||
So this plugin exists to read the accumulated messages (or messages from only the plugins you've specified), format them, and print them to the console.
|
||||
|
||||
By default, the messages are formatted for human legibility and sorted according to the line/column positions attached to the messages. But another formatting function can be passed in with an option, and sorting can be turned of with an option.
|
||||
|
||||
## Example Output
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install postcss-reporter
|
||||
```
|
||||
|
||||
Version 1.0.0+ is compatible with PostCSS 5+. (Earlier versions are compatible with PostCSS 4.)
|
||||
|
||||
## Usage
|
||||
|
||||
Add it to your plugin list *after any plugins whose messages you want to log*, and optionally pass it an object of options.
|
||||
|
||||
For example, using [gulp-postcss](https://github.com/postcss/gulp-postcss):
|
||||
|
||||
```js
|
||||
gulp.task('css', function() {
|
||||
return gulp.src('./src/*.css')
|
||||
.pipe(postcss([
|
||||
bemLinter(),
|
||||
customProperties(),
|
||||
calc(),
|
||||
rejectAllColors(),
|
||||
reporter(myOptions) // <------ ding
|
||||
]))
|
||||
.pipe(gulp.dest('./dist'));
|
||||
});
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
**clearMessages** (boolean, default = `false`)
|
||||
|
||||
If true, the plugin will clear the result's messages after it logs them. This prevents other plugins, or the whatever runner you use, from logging the same information again and causing confusion.
|
||||
|
||||
**formatter** (function, default = the default formatter)
|
||||
|
||||
By default, this reporter will format the messages for human legibility in the console.
|
||||
To use another formatter, pass a function that
|
||||
|
||||
- accepts an object containing a `messages` array and a `source` string
|
||||
- returns the string to report
|
||||
|
||||
For example, you could write a formatter like this:
|
||||
|
||||
```js
|
||||
reporter({
|
||||
formatter: function(input) {
|
||||
return input.source + ' produced ' + input.messages.length + ' messages';
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**plugins** (array of strings, default = `[]`)
|
||||
|
||||
If `plugins` is empty (as it is by default), the reporter will log messages from every PostCSS plugin.
|
||||
|
||||
There are 2 ways to limit output:
|
||||
|
||||
- **Whitelist:** Provide an array of the plugins whose messages you would like to show.
|
||||
For example, `{ plugins: ['postcss-bem-linter'] }` will only log messages from the `postcss-bem-linter` plugin.
|
||||
- **Blacklist:** Prefix all plugins in the array with `!` to specify only those plugins whose messages you would like to hide.
|
||||
(All other plugins will be shown.)
|
||||
For example, `{ plugins: ['!postcss-bem-linter'] }` will never log messages from the `postcss-bem-linter` plugin; but will log messages from every other plugin.
|
||||
|
||||
**filter** (function)
|
||||
|
||||
Provide a filter function. It receives the message object and returns a truthy or falsy value, indicating whether that particular message should be reported or not.
|
||||
|
||||
For example, `function(message) { return message.type === 'warning'; }` will only log `warning` messages, regardless of the plugin.
|
||||
|
||||
**throwError** (boolean, default = `false`)
|
||||
|
||||
If `true`, after the plugin logs your messages it will throw an error if it found any warnings.
|
||||
|
||||
**sortByPosition** (boolean, default = `true`)
|
||||
|
||||
If `false`, messages will not be sorted by line/column position.
|
||||
|
||||
**positionless** (`"first"|"last"|"any"`, default = `"first"`)
|
||||
|
||||
By default, messages without line/column positions will be grouped at the beginning of the output.
|
||||
To put them at the end, instead, use `"last"`.
|
||||
To not bother sorting these, use `"any"`.
|
||||
|
||||
**noIcon** (boolean, default = `false`)
|
||||
|
||||
If `true`, no exclamatory triangle icons will be printed next to warnings.
|
||||
|
||||
**noPlugin** (boolean, default = `false`)
|
||||
|
||||
If `true`, plugin names will not be printed in brackets after messages.
|
||||
|
||||
## How to get output without colors
|
||||
|
||||
If you would like no colors in the console output, simply pass `--no-colors` when you invoke whatever command runs this plugin. (This works because of [chalk](https://github.com/sindresorhus/chalk).)
|
||||
|
||||
## Standalone formatter
|
||||
|
||||
You can also use this module's formatter as a library, with following API:
|
||||
|
||||
```js
|
||||
var formatter = require('postcss-reporter/lib/formatter');
|
||||
var myFormatter = formatter(myOptions);
|
||||
// to use defaults, just pass no options: `formatter()`
|
||||
var warningLog = myFormatter({
|
||||
messages: someMessages,
|
||||
source: someSource
|
||||
});
|
||||
console.log(warningLog);
|
||||
```
|
||||
|
||||
These are the formatter's options:
|
||||
|
||||
- sortByPosition (boolean, default = `true`)
|
||||
- noIcon (boolean, default = `false`) - Do not print any warning exclamatory triangle icons
|
||||
- noPlugin (boolean, default = `false`) - Do not print plugin names
|
4
node_modules/colorguard/node_modules/postcss-reporter/index.js
generated
vendored
Normal file
4
node_modules/colorguard/node_modules/postcss-reporter/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var postcss = require('postcss');
|
||||
var reporter = require('./lib/reporter');
|
||||
|
||||
module.exports = postcss.plugin('postcss-reporter', reporter);
|
80
node_modules/colorguard/node_modules/postcss-reporter/lib/formatter.js
generated
vendored
Normal file
80
node_modules/colorguard/node_modules/postcss-reporter/lib/formatter.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
var chalk = require('chalk');
|
||||
var path = require('path');
|
||||
var symbols = require('log-symbols');
|
||||
var _ = require('lodash');
|
||||
var util = require('./util');
|
||||
|
||||
module.exports = function(opts) {
|
||||
var options = opts || {};
|
||||
var sortByPosition = (typeof options.sortByPosition !== 'undefined') ? options.sortByPosition : true;
|
||||
var positionless = options.positionless || 'first';
|
||||
|
||||
return function(input) {
|
||||
var messages = input.messages;
|
||||
var source = input.source;
|
||||
|
||||
if (!messages.length) return '';
|
||||
|
||||
var orderedMessages = _.sortBy(
|
||||
messages,
|
||||
function(m) {
|
||||
if (!m.line) return 1;
|
||||
if (positionless === 'any') return 1;
|
||||
if (positionless === 'first') return 2;
|
||||
if (positionless === 'last') return 0;
|
||||
},
|
||||
function(m) {
|
||||
if (!sortByPosition) return 1;
|
||||
return m.line;
|
||||
},
|
||||
function(m) {
|
||||
if (!sortByPosition) return 1;
|
||||
return m.column;
|
||||
}
|
||||
);
|
||||
|
||||
var output = '\n';
|
||||
|
||||
if (source) {
|
||||
output += chalk.bold.underline(logFrom(source)) + '\n';
|
||||
}
|
||||
|
||||
orderedMessages.forEach(function(w) {
|
||||
output += messageToString(w) + '\n';
|
||||
});
|
||||
|
||||
return output;
|
||||
|
||||
function messageToString(message) {
|
||||
var location = util.getLocation(message);
|
||||
var str = '';
|
||||
|
||||
if (location.line) {
|
||||
str += chalk.bold(location.line);
|
||||
}
|
||||
|
||||
if (location.column) {
|
||||
str += chalk.bold(':' + location.column)
|
||||
}
|
||||
|
||||
if (location.line || location.column) {
|
||||
str += '\t';
|
||||
}
|
||||
|
||||
if (!options.noIcon && message.type === 'warning') {
|
||||
str += chalk.yellow(symbols.warning + ' ');
|
||||
}
|
||||
|
||||
str += message.text;
|
||||
if (!options.noPlugin) {
|
||||
str += chalk.yellow(' [' + message.plugin + ']');
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function logFrom(fromValue) {
|
||||
if (fromValue.charAt(0) === '<') return fromValue;
|
||||
return path.relative(process.cwd(), fromValue).split(path.sep).join('/');
|
||||
}
|
||||
};
|
||||
};
|
75
node_modules/colorguard/node_modules/postcss-reporter/lib/reporter.js
generated
vendored
Normal file
75
node_modules/colorguard/node_modules/postcss-reporter/lib/reporter.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
var chalk = require('chalk');
|
||||
var _ = require('lodash');
|
||||
var defaultFormatter = require('./formatter');
|
||||
var util = require('./util');
|
||||
|
||||
module.exports = function(opts) {
|
||||
var options = opts || {};
|
||||
|
||||
var formatter = options.formatter || defaultFormatter({
|
||||
sortByPosition: (typeof options.sortByPosition !== 'undefined') ? options.sortByPosition : true,
|
||||
positionless: options.positionless || 'first',
|
||||
noIcon: options.noIcon,
|
||||
noPlugin: options.noPlugin,
|
||||
});
|
||||
|
||||
var pluginFilter;
|
||||
if (!options.plugins) {
|
||||
// Every plugin
|
||||
pluginFilter = function() { return true; };
|
||||
} else if (options.plugins.every(function(plugin) { return plugin[0] === '!'; })) {
|
||||
// Blacklist
|
||||
pluginFilter = function(message) {
|
||||
return options.plugins.indexOf('!' + message.plugin) === -1;
|
||||
};
|
||||
} else {
|
||||
// Whitelist
|
||||
pluginFilter = function(message) {
|
||||
return options.plugins.indexOf(message.plugin) !== -1;
|
||||
};
|
||||
}
|
||||
|
||||
var messageFilter = options.filter || function() { return true; };
|
||||
|
||||
return function(css, result) {
|
||||
var messagesToLog = result.messages
|
||||
.filter(pluginFilter)
|
||||
.filter(messageFilter);
|
||||
|
||||
var resultSource = (!result.root.source) ? ''
|
||||
: result.root.source.input.file || result.root.source.input.id
|
||||
|
||||
var sourceGroupedMessages = _.groupBy(messagesToLog, function(message) {
|
||||
return util.getLocation(message).file || resultSource;
|
||||
});
|
||||
|
||||
var report = '';
|
||||
_.forOwn(sourceGroupedMessages, function(messages, source) {
|
||||
report += formatter({
|
||||
messages: messages,
|
||||
source: source,
|
||||
});
|
||||
});
|
||||
|
||||
if (options.clearMessages) {
|
||||
result.messages = _.difference(result.messages, messagesToLog);
|
||||
}
|
||||
|
||||
if (!report) return;
|
||||
|
||||
console.log(report);
|
||||
|
||||
if (options.throwError && shouldThrowError()) {
|
||||
throw new Error(chalk.red.bold('\n** postcss-reporter: warnings or errors were found **'));
|
||||
}
|
||||
|
||||
function shouldThrowError() {
|
||||
return (
|
||||
messagesToLog.length
|
||||
&& messagesToLog.some(function(message) {
|
||||
return message.type === 'warning' || message.type === 'error';
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
20
node_modules/colorguard/node_modules/postcss-reporter/lib/util.js
generated
vendored
Normal file
20
node_modules/colorguard/node_modules/postcss-reporter/lib/util.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
var _ = require('lodash');
|
||||
|
||||
exports.getLocation = function(message) {
|
||||
var messageNode = message.node;
|
||||
|
||||
var location = {
|
||||
line: message.line,
|
||||
column: message.column,
|
||||
};
|
||||
|
||||
var messageInput = _.get(messageNode, 'source.input');
|
||||
|
||||
if (!messageInput) return location;
|
||||
|
||||
var originLocation = messageInput.origin && messageInput.origin(message.line, message.column)
|
||||
if (originLocation) return originLocation
|
||||
|
||||
location.file = messageInput.file || messageInput.id;
|
||||
return location;
|
||||
};
|
94
node_modules/colorguard/node_modules/postcss-reporter/package.json
generated
vendored
Normal file
94
node_modules/colorguard/node_modules/postcss-reporter/package.json
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"postcss-reporter@^1.2.1",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/colorguard"
|
||||
]
|
||||
],
|
||||
"_from": "postcss-reporter@>=1.2.1 <2.0.0",
|
||||
"_id": "postcss-reporter@1.4.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/colorguard/postcss-reporter",
|
||||
"_nodeVersion": "4.4.7",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-16-east.internal.npmjs.com",
|
||||
"tmp": "tmp/postcss-reporter-1.4.1.tgz_1467678653758_0.5163490162231028"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "david.dave.clark@gmail.com",
|
||||
"name": "davidtheclark"
|
||||
},
|
||||
"_npmVersion": "2.15.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "postcss-reporter",
|
||||
"raw": "postcss-reporter@^1.2.1",
|
||||
"rawSpec": "^1.2.1",
|
||||
"scope": null,
|
||||
"spec": ">=1.2.1 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/colorguard"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/postcss-reporter/-/postcss-reporter-1.4.1.tgz",
|
||||
"_shasum": "c136f0a5b161915f379dd3765c61075f7e7b9af2",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "postcss-reporter@^1.2.1",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/colorguard",
|
||||
"author": {
|
||||
"email": "david.dave.clark@gmail.com",
|
||||
"name": "David Clark",
|
||||
"url": "http://davidtheclark.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/postcss/postcss-reporter/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^1.0.0",
|
||||
"lodash": "^4.1.0",
|
||||
"log-symbols": "^1.0.2",
|
||||
"postcss": "^5.0.0"
|
||||
},
|
||||
"description": "Log PostCSS messages in the console",
|
||||
"devDependencies": {
|
||||
"eslint": "1.3.1",
|
||||
"less": "2.7.1",
|
||||
"source-map": "0.5.6",
|
||||
"stylelint": "6.8.0",
|
||||
"tape": "4.6.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "c136f0a5b161915f379dd3765c61075f7e7b9af2",
|
||||
"tarball": "https://registry.npmjs.org/postcss-reporter/-/postcss-reporter-1.4.1.tgz"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"gitHead": "24518056bcaebbd6252fecfdfa0ccca158a54797",
|
||||
"homepage": "https://github.com/postcss/postcss-reporter",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "davidtheclark",
|
||||
"email": "david.dave.clark@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "postcss-reporter",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/postcss/postcss-reporter.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "npm run lint && tape test",
|
||||
"visual": "node test/visual.js"
|
||||
},
|
||||
"version": "1.4.1"
|
||||
}
|
118
node_modules/colorguard/package.json
generated
vendored
Normal file
118
node_modules/colorguard/package.json
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"colorguard@^1.2.0",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint"
|
||||
]
|
||||
],
|
||||
"_from": "colorguard@>=1.2.0 <2.0.0",
|
||||
"_id": "colorguard@1.2.0",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/colorguard",
|
||||
"_nodeVersion": "5.4.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-16-east.internal.npmjs.com",
|
||||
"tmp": "tmp/colorguard-1.2.0.tgz_1462052518360_0.8823722924571484"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "beneb.info@gmail.com",
|
||||
"name": "beneb"
|
||||
},
|
||||
"_npmVersion": "3.3.12",
|
||||
"_phantomChildren": {
|
||||
"chalk": "1.1.3",
|
||||
"lodash": "4.17.4",
|
||||
"log-symbols": "1.0.2",
|
||||
"postcss": "5.2.15"
|
||||
},
|
||||
"_requested": {
|
||||
"name": "colorguard",
|
||||
"raw": "colorguard@^1.2.0",
|
||||
"rawSpec": "^1.2.0",
|
||||
"scope": null,
|
||||
"spec": ">=1.2.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/stylelint"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/colorguard/-/colorguard-1.2.0.tgz",
|
||||
"_shasum": "f3facaf5caaeba4ef54653d9fb25bb73177c0d84",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "colorguard@^1.2.0",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint",
|
||||
"author": {
|
||||
"email": "alexsexton@gmail.com",
|
||||
"name": "Alex Sexton"
|
||||
},
|
||||
"bin": {
|
||||
"colorguard": "./bin/colorguard"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/SlexAxton/css-colorguard/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.1",
|
||||
"color-diff": "^0.1.3",
|
||||
"log-symbols": "^1.0.2",
|
||||
"object-assign": "^4.0.1",
|
||||
"pipetteur": "^2.0.0",
|
||||
"plur": "^2.0.0",
|
||||
"postcss": "^5.0.4",
|
||||
"postcss-reporter": "^1.2.1",
|
||||
"text-table": "^0.2.0",
|
||||
"yargs": "^1.2.6"
|
||||
},
|
||||
"description": "Keep a watchful eye on your css colors",
|
||||
"devDependencies": {
|
||||
"jshint": "^2.9.1",
|
||||
"tap-spec": "^4.1.0",
|
||||
"tape": "^4.2.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "f3facaf5caaeba4ef54653d9fb25bb73177c0d84",
|
||||
"tarball": "https://registry.npmjs.org/colorguard/-/colorguard-1.2.0.tgz"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"gitHead": "12c5920fdfab140fd13f58df58422ddb9c35e42c",
|
||||
"homepage": "https://github.com/SlexAxton/css-colorguard",
|
||||
"keywords": [
|
||||
"colors",
|
||||
"css",
|
||||
"csslint",
|
||||
"lint",
|
||||
"postcss",
|
||||
"postcss-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "beneb",
|
||||
"email": "beneb.info@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "slexaxton",
|
||||
"email": "alexsexton@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "colorguard",
|
||||
"optionalDependencies": {},
|
||||
"preferGlobal": true,
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/SlexAxton/css-colorguard.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "jshint .",
|
||||
"test": "npm run lint && tape test/*.js | tap-spec"
|
||||
},
|
||||
"version": "1.2.0"
|
||||
}
|
Reference in New Issue
Block a user