gulp-w3c-css

A Gulp plugin for CSS Validation

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
gulp-w3c-css
1012.0.04 years ago8 years agoMinified + gzip package size for gulp-w3c-css in KB

Readme

gulp-w3c-css Build Status
A Gulp plugin for CSS Validation using W3C CSS Validation Service
Depends on w3c-css package.

Installation

$ npm install gulp-w3c-css

Usage

Validate all *.css files in the /css directory and write results to the /build directory. If there are no errors or warnings in a file, the resulting file will be empty. Otherwise the file will contain errors and warnings as JSON object:
{ "errors":[ /* ... */ ],"warnings":[ /* ... */ ] }

var validate = require('gulp-w3c-css');

var path = require('path');
var gulp = require('gulp');

var srcPath = path.join(__dirname, './css/*.css');
var dstPath = path.join(__dirname, './build');

gulp.src(srcPath)
  .pipe(validate())
  .pipe(gulp.dest(dstPath));

OR
var validate = require('gulp-w3c-css');

var path = require('path');
var gulp = require('gulp');
var ListStream = require('list-stream');

var srcPath = path.join(__dirname, './css/*.css');

gulp.src(srcPath)
  .pipe(validate())
  .pipe(ListStream.obj(function(err, files) {
    // err - an error encountered
    // files - array of validation results
    // files[i].contents is empty if there are no errors or warnings found
  }));

Arguments

The first argument to the validate function can be an options object with the following properties:
  • sleep - time to sleep between the requests, milliseconds default: 1500 -- 1.5 seconds. This option is required if you intend to validate several CSS files at once. Make sure its value is greater than 1 second. Otherwise, consider using a Private CSS Validator that doesn't have any request-frequency limitations.
  • profile - the CSS profile used for the validation: css1, css2, css21, css3 default: 'css3'
  • usermedium - the medium used for the validation: screen, print, ... default: 'all'
  • server - the "IP:PORT" string or the URL object of a custom validation server, e.g, '172.17.0.2:8080' or { host: '172.17.0.2:8080' }.

Contact

Grigoriy Chudnov (mailto:g.chudnov@gmail.com)

License

Distributed under the The MIT License (MIT).