JSPM

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

CSS Validation using W3C CSS Validation Service

Package Exports

  • 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 (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

w3c-css

CSS Validation using W3C CSS Validation Service

Usage

'use strict';

var validator = require('w3c-css');

validator.validate('https://github.com/', function(err, data) {
  if(err) {
    // an error happened
    console.error(err);
  } else {
    // validation errors
    console.log('validation errors', data.errors);

    // validation warnings
    console.log('validation warnings', data.warnings);
  }

});

OR listen for events

'use strict';

var validator = require('w3c-css');

validator.validate('https://github.com/')
  .on('error', function(err) {
    // an error happened
    console.error(err);
  })
  .on('validation-error', function(data) {
    // validation error
    console.log(data);
  })
  .on('validation-warning', function(data) {
    // validation warning
    console.log(data);
  })
  .on('end', function() {
    // validation complete
  });

Arguments

The first argument to the validate function can be either a url or an options object. The only required option is uri; all others are optional.

  • uri || url - the URL of the document to validate
  • 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']
  • callback - [optional] callback to invoke on completion

The callback argument gets 2 arguments:

  1. err - an error
  2. data - a result object with errors and warnings properties. data.errors and data.warnings are the arrays on objects:
{
  line: '...',
  message: '...'
}