JavaScript APIs v6.0.0

6.0.0

Minor Changes

  • #8944 8cd3da1 Thanks @ash1day! - Added a new spanInBytesToSpanInCodeUnits helper function to convert byte-based spans from Biome diagnostics to UTF-16 code unit spans. Biome internally uses UTF-8 byte offsets for spans, but JavaScript strings use UTF-16 code units. This causes incorrect text extraction when using string.slice() with non-ASCII content. The new helper function correctly handles this conversion, including surrogate pairs and unpaired surrogates.
    import { spanInBytesToSpanInCodeUnits } from "@biomejs/js-api";
    
    const [start, end] = spanInBytesToSpanInCodeUnits(
      diagnostic.location.span,
      content,
    );
    const text = content.slice(start, end); // Correctly extracts the text

Patch Changes

  • Updated dependencies []:
    • @biomejs/wasm-web@2.5.0
    • @biomejs/wasm-bundler@2.5.0
    • @biomejs/wasm-nodejs@2.5.0

What's Changed

New Contributors

Full Changelog: https://github.com/biomejs/biome/compare/@biomejs/biome@2.4.16...@biomejs/js-api@6.0.0

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论