There are a couple of utilities included with lesshint which can be used when creating custom linters.
const utils = require('lesshint').utils;Check if a string is a absolute URL.
utils.isAbsoluteURL('http://example.com'); // true
utils.isAbsoluteURL('file.less'); // falseCheck if a value is a Less variable.
utils.isVariable('@foo'); // true
utils.isVariable('blue'); // falseCheck if a string is enclosed in quotes.
style values |
Description |
|---|---|
any |
Check for any kind of quotes (default). |
double |
Check for double quotes. |
single |
Check for single quotes. |
utils.hasQuotes'"foo"', 'any'); // true
utils.hasQuotes('foo', 'any'); // false
utils.hasQuotes('"foo"', 'double'); // true
utils.hasQuotes("'foo'", 'double'); // false
utils.hasQuotes("'foo'", 'single'); // true
utils.hasQuotes('"foo"', 'single'); // falseParse a selector using postcss-selector-parser. Accepts a selector string or a PostCSS Rule node.
utils.parseSelector('.foo'); // Parser tree
utils.parseSelector(ruleNode); // Parser treeParse a value using postcss-values-parser.
options is any valid postcss-values-parser options. The default values are:
{
loose: true
}utils.parseValue('10px', {
loose: false
}); // Parser tree