gulp-polish
Advanced tools
Comparing version 2.4.2 to 3.0.0
70
index.js
@@ -1,23 +0,19 @@ | ||
var through = require('through2'); | ||
var path = require('path'); | ||
var _ = require('lodash'); | ||
var gutil = require('gulp-util'); | ||
var PluginError = gutil.PluginError; | ||
var polish = require('./lib/polish'); | ||
var reporter = require('./lib/polish-error-reporter'); | ||
var getRules = require('./lib/polish-get-rules'); | ||
var astHelpers = require('./lib/polish-ast-helpers'); | ||
var through = require('through2'); | ||
var path = require('path'); | ||
var chalk = require('chalk'); | ||
var logSymbols = require('log-symbols'); | ||
var polishcss = require('polishcss'); | ||
var reporter = polishcss.reporter; | ||
var astHelpers = polishcss.astHelpers; | ||
var PLUGIN_NAME = 'gulp-polish'; | ||
function gulpPolish (options){ | ||
if (!options || !options.rulesDirectory || typeof options.rulesDirectory !== 'string'){ | ||
throw new PluginError(PLUGIN_NAME, 'Rules directory not specified.'); | ||
} | ||
var rules = getRules(options.rulesDirectory); | ||
function polish (options){ | ||
return through.obj(function(file, enc, cb) { | ||
var stream = this; | ||
var contents = file.contents.toString('utf8'), | ||
results; | ||
@@ -28,4 +24,14 @@ if (!file.isBuffer() || file.contents.toString('utf8').length === 0) { | ||
polish(file, rules); | ||
results = polishcss(contents, file.path, { pluginsDirectory : options.pluginsDirectory, plugins : options.plugins }); | ||
file.polish = {}; | ||
if (results.length){ | ||
file.polish.success = false; | ||
file.polish.results = results; | ||
} else { | ||
file.polish.success = true; | ||
file.polish.results = []; | ||
} | ||
return cb(null, file); | ||
@@ -35,5 +41,31 @@ }); | ||
gulpPolish.reporter = reporter; | ||
gulpPolish.astHelpers = astHelpers; | ||
function gulpReporter (options){ | ||
options = options || {}; | ||
module.exports = gulpPolish; | ||
var results = 0; | ||
return through.obj(function (file, enc, cb) { | ||
if (!file.polish) { | ||
return cb(null, file); | ||
} | ||
if (file.polish && !file.polish.success) { | ||
reporter(file.path, file.polish.results); | ||
} | ||
results += file.polish.results.length; | ||
return cb(null, file); | ||
}) | ||
.on('end', function(){ | ||
if (options.reportTotal) { | ||
console.log(chalk.yellow(logSymbols.warning + ' Total warnings: ' + results + '\n')); | ||
} | ||
results = 0; | ||
}); | ||
} | ||
module.exports = polish; | ||
module.exports.astHelpers = astHelpers; | ||
module.exports.reporter = gulpReporter; |
{ | ||
"name": "gulp-polish", | ||
"version": "2.4.2", | ||
"version": "3.0.0", | ||
"description": "Make your stylesheets perfect. Add an extra coat of polish.", | ||
@@ -22,8 +22,5 @@ "main": "index.js", | ||
"chalk": "^1.1.0", | ||
"gonzales-pe": "git://github.com/brendanlacroix/gonzales-pe.git", | ||
"gulp-util": "^3.0.6", | ||
"lodash": "^3.10.1", | ||
"log-symbols": "^1.0.2", | ||
"require-dir": "^0.3.0", | ||
"text-table": "^0.2.0", | ||
"polish-css": "^1.0.0", | ||
"through2": "^2.0.0" | ||
@@ -30,0 +27,0 @@ }, |
@@ -7,5 +7,5 @@ # gulp-polish | ||
Spend less time reviewing pull requests. | ||
Make learning your rules simpler for new additions to the team. | ||
Keep your code more consistent and more reliable... | ||
Spend less time reviewing pull requests. | ||
Make learning your rules simpler for new additions to the team. | ||
Keep your code more consistent and more reliable... | ||
@@ -19,3 +19,3 @@ Or don't. You're the boss. | ||
## Install | ||
@@ -41,3 +41,3 @@ `npm install --save gulp-polish` | ||
You can write your own reporter (check out the Results section below), but if you want to just use the | ||
You can write your own reporter (check out the Results section below), but if you want to just use the | ||
default (which prints to the console), pipe it through `polish.reporter()` as well. | ||
@@ -87,3 +87,3 @@ | ||
name: 'your-stylesheet', | ||
cssDOM: { ... } | ||
ast: { ... } | ||
} | ||
@@ -94,6 +94,6 @@ ``` | ||
- **AST node-level failure** | ||
- **AST node-level failure** | ||
If you have found an issue with one of the AST nodes, make an object and shove that node under a `rule` key. | ||
``` | ||
@@ -107,12 +107,12 @@ { | ||
``` | ||
If you push this object to `test`'s returned array, it will be printed with a line | ||
If you push this object to `test`'s returned array, it will be printed with a line | ||
and column number for where that node starts. | ||
- **File-level failure** | ||
If you have found an issue with the whole file, make an object and shove the `file` | ||
- **File-level failure** | ||
If you have found an issue with the whole file, make an object and shove the `file` | ||
argument passed into your test function under a `file` key. | ||
``` | ||
@@ -126,7 +126,7 @@ { | ||
``` | ||
If you push this object to `test`'s returned array, it'll report without line and | ||
If you push this object to `test`'s returned array, it'll report without line and | ||
column numbers and simply say "File warning: " before your error message. | ||
## Sample rules | ||
@@ -145,3 +145,3 @@ | ||
file.cssDOM.traverseByType('ruleset', function(rule){ | ||
file.ast.traverseByType('ruleset', function(rule){ | ||
rule.forEach('block', function (block){ | ||
@@ -155,3 +155,3 @@ block.forEach('declaration', function (declaration){ | ||
} | ||
errors.push({ | ||
@@ -170,3 +170,3 @@ rule: rule | ||
**File-level failure** | ||
**File-level failure** | ||
``` | ||
@@ -184,3 +184,3 @@ var _ = require('lodash'); | ||
var filename = file.name.trim(), | ||
rule = file.cssDOM.contains('ruleset') && file.cssDOM.first('ruleset'), | ||
rule = file.ast.contains('ruleset') && file.ast.first('ruleset'), | ||
errors = [], | ||
@@ -218,7 +218,7 @@ className, | ||
## Configuring rules | ||
To configure which rules are applied on a per-directory basis, use `.polish.json` files. | ||
The config will inherit from its parents directories. Just create a simple JSON object | ||
To configure which rules are applied on a per-directory basis, use `.polish.json` files. | ||
The config will inherit from its parents directories. Just create a simple JSON object | ||
that specifies rules to include/exclude by filename. | ||
@@ -233,3 +233,3 @@ | ||
If a certain file needs to me configured differently from its directory, add a | ||
If a certain file needs to me configured differently from its directory, add a | ||
`fileConfigs` key to your `.polish.json` with a config object for that file: | ||
@@ -254,8 +254,8 @@ | ||
``` | ||
## Todo | ||
- Tests! | ||
## License | ||
@@ -262,0 +262,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
5
0
0
10193
5
51
1
+ Addedpolish-css@^1.0.0
+ Addedarr-diff@2.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarray-unique@0.2.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbraces@1.8.5(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconvert-source-map@1.9.0(transitive)
+ Addedduplexify@3.7.1(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexpand-brackets@0.1.5(transitive)
+ Addedexpand-range@1.8.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextend-shallow@2.0.1(transitive)
+ Addedextglob@0.3.2(transitive)
+ Addedfilename-regex@2.0.1(transitive)
+ Addedfill-range@2.2.4(transitive)
+ Addedfirst-chunk-stream@1.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedglob-base@0.3.0(transitive)
+ Addedglob-parent@2.0.03.1.0(transitive)
+ Addedglob-stream@5.3.5(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedgulp-sourcemaps@1.6.0(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-dotfile@1.0.3(transitive)
+ Addedis-equal-shallow@0.1.3(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedis-extglob@1.0.02.1.1(transitive)
+ Addedis-glob@2.0.13.1.0(transitive)
+ Addedis-number@2.1.04.0.0(transitive)
+ Addedis-posix-bracket@0.1.1(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedis-utf8@0.2.1(transitive)
+ Addedis-valid-glob@0.3.0(transitive)
+ Addedisobject@2.1.0(transitive)
+ Addedjson-stable-stringify-without-jsonify@1.0.1(transitive)
+ Addedkind-of@3.2.26.0.3(transitive)
+ Addedlazystream@1.0.1(transitive)
+ Addedlodash.isequal@4.5.0(transitive)
+ Addedmath-random@1.0.4(transitive)
+ Addedmerge-stream@1.0.1(transitive)
+ Addedmicromatch@2.3.11(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedordered-read-streams@0.3.0(transitive)
+ Addedparse-glob@3.0.4(transitive)
+ Addedpath-dirname@1.0.2(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpolish-css@1.2.1(transitive)
+ Addedpreserve@0.2.0(transitive)
+ Addedrandomatic@3.1.1(transitive)
+ Addedreadable-stream@1.0.343.6.2(transitive)
+ Addedregex-cache@0.4.4(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstream-shift@1.0.3(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-bom@2.0.0(transitive)
+ Addedstrip-bom-stream@1.0.0(transitive)
+ Addedthrough2@0.6.54.0.2(transitive)
+ Addedthrough2-filter@2.0.03.1.0(transitive)
+ Addedto-absolute-glob@0.1.1(transitive)
+ Addedunique-stream@2.3.1(transitive)
+ Addedvali-date@1.0.0(transitive)
+ Addedvinyl@1.2.0(transitive)
+ Addedvinyl-fs@2.4.4(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedgonzales-pe@git://github.com/brendanlacroix/gonzales-pe.git
- Removedlodash@^3.10.1
- Removedrequire-dir@^0.3.0
- Removedtext-table@^0.2.0