JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 55
  • Score
    100M100P100Q71366F
  • License MIT

A Gulp plugin for CSS Validation

Package Exports

  • gulp-w3c-css

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-w3c-css) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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).