@woltapp/browserbug-core
Parser and core comparison utilities for the browserbug syntax.
This is useful if you want to recreate the ESLint and Stylelint rules, but in a
different linter.
Installation
npm install @woltapp/browserbug-core
Usage
import {
parseBrowserbug,
getBrowserSupportStatus,
type BrowserbugDescriptor,
} from '@woltapp/browserbug-core';
import browserslist from 'browserslist',
const targets = browserslist()
const parseResult = parseBrowserbug(
'@browserbug chrome equal 120 -- Some comment',
browserslist.data
);
if (!parseResult.success) {
console.error(parseResult.error.message);
}
for (const descriptor of parseResult.data) {
const supportStatus = getBrowserSupportStatus(data)
}
About the grammar
The grammar is currently written with
Ohm. Earlier versions of the grammar were built with
sticky RegExp and a stack, but that seemed a bit ad-hoc.
If you have a compelling case for alternatives, including speed and quality of
error messages, we would love to hear them!