Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-polish

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-polish - npm Package Compare versions

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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc