Skip to content

Latest commit

 

History

History
44 lines (27 loc) · 3.13 KB

File metadata and controls

44 lines (27 loc) · 3.13 KB

Contributing guide

Thanks for lending a hand 👋

To understand how the code is structured, start with src/index.js, which exports the public API including toRegExp. If you have questions before starting development, feel free to open an issue.

Setup

  • pnpm is used to manage dependencies. Install it with npm install --global pnpm.
  • Install dependencies with pnpm install.
  • Build the package with pnpm build.

Testing

  • Jasmine is used to test the codebase. Run pnpm test to start the test runner.
  • Tests live in ./spec.
  • Please include tests alongside changes and new features.

Testing in Shiki

This library receives extensive additional test coverage prior to new releases via Shiki, a syntax highlighter that provides 220+ TextMate grammars (that include ~55k Oniguruma regexes). Shiki includes both Oniguruma and JavaScript regex engines, and its JavaScript engine is powered by this library.

Shiki also provides a "compatibility report" that's created by comparing the highlighting results for its Oniguruma and JavaScript engines for all of the languages that Shiki provides. Given the huge number of real world regexes that Shiki tests against its language samples, the compatibility report serves as an extremely robust test for a large set of features and edge cases, ensuring that the syntax and behavior relied on by those regexes is behaving exactly as it would in Oniguruma. As a result, if you're making sensitive changes to this library, it might be beneficial to also ensure that it doesn't negatively impact Shiki's report.

Demo page

A demo REPL is included with this library and available online. It shows results as you type and can be helpful for quick manual testing. It also allows trying out all of this library's options. Library functions can be tested on the demo page via the developer console.

Important

The demo uses the latest published version of the library. To use local changes, you currently have to uncomment the relevant <script> tags in ./demo/index.html. Run pnpm build to include your changes in the local bundle.

Comparing results with Oniguruma

A simple command line script is included with this library for testing Oniguruma results (using vscode-oniguruma). It also automatically compares results from Oniguruma with a JavaScript regex generated by this library.

node scripts/onig-match.js '\w' 'a'

See more details and options in the comment at the top of the script.