@bhsd/stylelint-browserify v16.20.0
Stylelint-browserify
API
The stylelint global variable has a lint() method.
const result = await stylelint.lint(options);Options
config
code
A string to lint.
The returned promise
stylelint.lint() returns a Promise that resolves with an object containing the following properties:
code
A string that contains the autofixed code, if the fix option is set to true. Otherwise, it is undefined.
errored
Boolean. If true, at least one rule with an "error"-level severity registered a problem.
report
A JSON string that contains the formatted problems.
results
An array containing all the Stylelint result objects (the objects that formatters consume).
Edit info
When the computeEditInfo option is enabled, a warning may include a fix property that provides information about suggested fixes:
range([number, number]) - the pair of 0-based indices in source code text to removetext(string) - the text to add
For example, to change a { opacity: 10%; } to a { opacity: 0.1; }, the EditInfo might look like:
{
// "line", "column", "rule", ...
"fix": {
"range": [13, 16], // Indices of "10%"
"text": "0.1" // Replacement text
}
}Only a single EditInfo will be recorded for a specific region in source code. If multiple report ranges overlap, only the first will contain EditInfo.
Syntax errors
stylelint.lint() does not reject the Promise when your CSS contains syntax errors.
It resolves with an object (see the returned promise) that contains information about the syntax error.