CSScomb can be used in Node.js projects: inside a plugin or as a dev tool.
Workflow can look like this:
// Require:
var Comb = require('csscomb');
var config = require('path/to/config');
// Configure:
var comb = new Comb(config);
// Use:
comb.processPath('style.css');Create instance's prototype.
Parameters:
{String|Object} config— config that should be used after creating instance. Should be JSON or one of predefined config's name. Optional.
Example: Create CSScomb instance and configure it using predefined yandex sort
order
var comb = new Comb('yandex');
// This is shortcut for:
var comb = new Comb();
var config = Comb.getConfig('yandex');
comb.configure(config);Example: Create CSScomb instance and configure it using config object
var config = require('path/to/config');
var comb = new Comb(config);
// This is shortcut for:
var comb = new Comb();
comb.configure(config);Get one of predefined configs.
Note that this is a static method.
Parameters:
{String} name— config's name. Should be one of the following:csscomb,zenoryandex.
Example: Configure CSScomb using predefined zen sort order that is slightly
modified.
var config = Comb.getConfig('zen');
config['always-semicolon'] = true;
comb.configure(config);Get config options that can be detected in a file.
Note that this is a static method.
Parameters:
{String} path— path to stylesheet{Array} options— list of options to detect. Optional. By default tries to detect all available options.
Example: Configure CSScomb using template file
var config = comb.detectInFile('template.css');
comb.configure(config);Get config options that can be detected in a string.
Note that this is a static method.
Parameters:
{String} string— stylesheet{Array} options— list of options to detect. Optional. By default tries to detect all available options.
Example: Configure CSScomb using template stylesheet
var css = 'a {top: 0; left: 0}';
var config = comb.detectInString(css);
comb.configure(config);For the list of public methods and examples of their usage, see CSScomb Core docs.