@woltapp/browserbug-core
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@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',

// Read targets from environment
const targets = browserslist()

const parseResult = parseBrowserbug(
  '@browserbug chrome equal 120 -- Some comment',
  browserslist.data // used to validate the list and available versions of browsers
);

if (!parseResult.success) {
  // Do something with the error here :)
  console.error(parseResult.error.message);
}

// Do something with data here
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!

Readme

Keywords

Package Sidebar

Install

npm i @woltapp/browserbug-core

Weekly Downloads

5,249

Version

0.1.0

License

MIT

Unpacked Size

54.4 kB

Total Files

18

Last publish

Collaborators

  • fpapado
  • vluoto
  • thisen
  • waha.06x36
  • nyde
  • omahlama