github biomejs/biome @biomejs/js-api@6.1.0
JavaScript APIs v6.1.0

one hour ago

6.1.0

Minor Changes

  • #9940 1aefcb1 Thanks @regseb! - Added spanInBytesToSpanInCodeUnits helper function in subpath exports of @biomejs/js-api.

    import { spanInBytesToSpanInCodeUnits } from "@biomejs/js-api/nodejs";
    // Or:
    // import { spanInBytesToSpanInCodeUnits } from "@biomejs/js-api/bundler";
    // import { spanInBytesToSpanInCodeUnits } from "@biomejs/js-api/web";
    
    const [start, end] = spanInBytesToSpanInCodeUnits(
        diagnostic.location.span,
        content
    );
    const text = content.slice(start, end); // Correctly extracts the text
  • #8912 e9785d8 Thanks @dyc3! - Added GritQL search to @biomejs/js-api. Parse a pattern with parsePattern(), search content with searchContent(), and release the pattern with dropPattern(). Matches are returned as UTF-8 byte offsets; use spanInBytesToSpanInCodeUnits() to convert them before slicing the content.

    const patternId = biome.parsePattern("`console.log($message)`", {
      defaultLanguage: "js",
    });
    const { matches } = biome.searchContent(projectKey, content, {
      filePath: "example.js",
      patternId,
    });
    biome.dropPattern(patternId);

Patch Changes

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

What's Changed

  • feat(js-api): add spanInBytesToSpanInCodeUnits in subpath exports by @regseb in #9940
  • feat(useSortedAttributes): add sortFirst option by @thibaut-pro in #10631
  • chore: merge main into next by @ematipico in #11044
  • feat(plugins): add resolutionKind for object-syntax plugin entries by @soconnor-seeq in #10711
  • feat(cli): output files information via biome rage by default by @christymcgrory in #6886
  • feat: add partitionByNewLine option to useSortedInterfaceMembers by @LinusU in #10424
  • chore: main into next by @dyc3 in #11093
  • feat(html): support .htm files by @Punisheroot in #11126
  • chore: mege main into next by @ematipico in #11241
  • feat(cli): add profiler for type inference by @ematipico in #11244
  • feat(useSortedClasses): add support for html files by @gameroman in #11102
  • chore: merge main into next by @ematipico in #11380
  • feat(languages): support Google Apps Script (.gs) files by @JamBalaya56562 in #10837
  • chore: merge main to next by @ematipico in #11433
  • chore: merge main into next by @ematipico in #11490
  • feat(cli): inspect config command by @ematipico in #11432
  • feat(cli): enable Git VCS integration during init by @nhedger in #11477
  • feat(cli): add --git flag to init command by @nhedger in #11479
  • feat: enable markdown by @ematipico in #11394
  • feat(plugin): distribution and loading by @ematipico in #11408
  • chore: merge main into next by @ematipico in #11635
  • feat: enable YAML and Markdown embedding by @ematipico in #11451
  • feat(cli): biome inspect file command by @ematipico in #11709
  • feat(grit): support range patterns by @dyc3 in #11713
  • chore: marge main into next by @ematipico in #11811
  • feat: yaml quotes and bracket spacing by @ematipico in #11832
  • fix(cli): inspect plugins by @ematipico in #11634
  • chore: yaml linting by @Netail in #11804
  • chore: disable linting md code blocks by @ematipico in #12015
  • chore: add more clarity to needs-repro bot message by @dyc3 in #12046
  • chore: merge main into next by @ematipico in #12035
  • feat: biome migrate stylelint by @Netail in #11742
  • feat(npm): add Android (Termux) support to the npm distribution by @dlecan in #11133
  • fix(grit): backtrack into contains when later conditions fail by @dyc3 in #12063
  • feat(xtask): export unsupported rule metadata as JSON by @dyc3 in #12062
  • fix(js_analyze): don't apply noAdjacentSpacesInRegex fix inside character classes by @santichausis in #11563
  • fix(migrate): update upstream rule scope metadata by @dyc3 in #12066
  • feat(migrate): additional unsupported rule reasons by @dyc3 in #12069
  • docs: sync configuration rework by @yanthomasdev in #11629
  • feat(lint/js/vue): add noVueBooleanDefault by @dyc3 in #12052
  • fix(format/html): group snippet definitions so they only line break when necessary by @dyc3 in #12080
  • feat(lint/js): add useBigintLiterals by @dyc3 in #11967
  • fix(noUnknownAttribute): recognize React 19 transition events by @ternaus in #12089
  • feat(lint/js): add noZeroFractions by @dyc3 in #9817
  • fix(noDuplicateFontNames): allow monospace, monospace duplicate exception by @GreedyC in #12068
  • perf(noUnknownAttribute): use binary searches instead of linear scans by @dyc3 in #12091
  • fix(css_parser): distinguish legacy and modern if() syntax by @denbezrukov in #12047
  • feat(css): support expression-based at-root queries by @denbezrukov in #12048
  • fix(css_parser): parse unary and identifier-led SCSS list expressions by @denbezrukov in #12096
  • chore: add sass spec to coverage by @ematipico in #12097
  • ci: breakdown conformance job in groups by @ematipico in #12099
  • chore: improve docs skill by @ematipico in #12100
  • fix(migrate): support empty nested configuration by @tionway in #12075
  • feat(type_inference): support mapped keyof types by @dyc3 in #11854
  • chore: update rule metadata by @dyc3 in #12102
  • fix(useImportExtensions): take html modules into account by @dyc3 in #12104
  • docs: improve lint rules and code actions by @ematipico in #12101
  • feat(lint/js): add noIteratorProperty by @dyc3 in #12083
  • feat(lint/js/svelte): add noSvelteInspect by @dyc3 in #12067
  • feat(lint): add noProcessExit by @dyc3 in #12122
  • feat(lint/html): add noRestrictedElements to HTML by @dyc3 in #12084
  • feat: promote rules by @ematipico in #12108
  • chore: use agents all over by @ematipico in #12125
  • docs(lint): document the noImplicitReturns caveat of noUselessReturn by @ff1451 in #12054
  • feat(css): support dynamic supports heads by @denbezrukov in #12127
  • docs: improve docs for useButtonType by @dyc3 in #12051
  • chore(deps): update rust crate libc to 0.2.190 by @renovate[bot] in #12139
  • fix(css): support percentage steps in SCSS bodies by @denbezrukov in #12128
  • fix(migrate): apply upstream lint rule scope decisions by @dyc3 in #12141
  • revert: "feat(lint/js): add noIteratorProperty (#12083)" by @dyc3 in #12148
  • feat(migrate): new unsupported rule reasons by @dyc3 in #12142
  • feat(lint): update useLogicalProperties rule to include values by @Th3S4mur41 in #11953
  • fix(parse/tailwind): parse css selectors that start with [ by @dyc3 in #12152
  • feat(tailwind): add top-level detection configuration by @dyc3 in #11386
  • ci: disallow pr titles to end with … (one character, not 3) by @dyc3 in #12153
  • feat(lint): add ignoreElements option to noRedundantRoles by @dyc3 in #12033
  • feat(migrate): migrate noRestrictedElements options from react, vue, and svelte rules by @dyc3 in #12086
  • chore(deps): update github-actions by @renovate[bot] in #12138
  • feat(lint): add noTailwindRestyledComponents rule by @dyc3 in #11801
  • fix(lint): compare equivalent member names in noSelfAssign by @erenbati in #12155
  • chore: merge main into next by @ematipico in #12161
  • chore: next to main by @ematipico in #11046
  • feat(lint): add noNestedSwitch by @dyc3 in #12166
  • fix(parse/tailwind): parenthesized and unary expressions by @dyc3 in #12156
  • revert: fix(parse/tailwind): parenthesized and unary expressions by @dyc3 in #12173
  • refactor: extract common has_inner_comments helper into common function by @dyc3 in #12171
  • fix(parse/tailwind): parenthesized and unary expressions by @dyc3 in #12174
  • fix(lint/useConsistentObjectDefinitions): ignore named function expressions by @MustafaKemal0146 in #12178
  • fix(lint/noConfusingVoidType): allow unions of only void and never by @MustafaKemal0146 in #12177
  • fix(css_parser): accept leading digits in Tailwind custom variants by @dyc3 in #12180
  • feat(core): enable SASS, cover more caes in the analyzer by @ematipico in #12132
  • fix(loader): js plugins by @ematipico in #12188
  • feat(css_parser): support Sass values in attr() by @denbezrukov in #12190
  • feat(css): support Sass statements in keyframes by @denbezrukov in #12191
  • fix(parse/tailwind): tokenize binary minus in CSS values by @dyc3 in #12181
  • fix(parse/tailwind): parse CSS variable shorthands as parameter lists by @dyc3 in #12183
  • feat(lint): add noTailwindLegacyUtilities and add legacy basenames to tailwind parser by @dyc3 in #12185
  • fix(useImportExtensions): resolve configured extension mappings by @dyc3 in #12202
  • fix(type_inference): infer string types from template literals by @dyc3 in #12115
  • feat(lint/svelte): add useSvelteKitResolve by @dyc3 in #11957
  • feat(lint/html/vue): add noVueRootVIf by @dyc3 in #12077
  • fix(parse/css): support Grit metavariables in selectors and property names by @siketyan in #12199
  • refactor(parse): lex GritQL metavariables from source text ranges by @siketyan in #12200
  • fix(css_parser): correct variable-led SCSS media ranges by @denbezrukov in #12196
  • fix(css): preserve interpolated SCSS at-rule names by @denbezrukov in #12205
  • feat(lint): add noOctal by @dyc3 in #12110
  • chore: update rule metadata by @dyc3 in #12217
  • feat(lint/yaml): add noEmptySource to yaml by @dyc3 in #12214
  • feat(js-api): expose grit search to js-api by @dyc3 in #8912
  • ci: use nextest in CI for testing by @ematipico in #12222
  • ci: fix insta behaviour by @ematipico in #12220
  • fix(css): support Sass values in modern if() branches by @denbezrukov in #12209
  • fix(format/html/vue): format Vue directive values inside quotes by @dyc3 in #12131
  • chore: rename useSortedClasses to useTailwindSortedClasses by @dyc3 in #12157
  • feat(useSortedClasses): switch to tailwind v4 sorter by @dyc3 in #12149
  • chore(format): normalize spacing in OS matrix list by @dyc3 in #12227
  • fix(format/html/vue): format Vue event handlers that are statements by @dyc3 in #12218
  • fix(tailwind): read stylesheets imported from packages by @dyc3 in #12192
  • fix(cli): inspect plugins messages by @ematipico in #12230
  • fix(cli): inspect config without key by @ematipico in #12208
  • fix(css): collections of model rules by @ematipico in #12014
  • fix(fmt/md): prose wrap of cjk chars by @ematipico in #12232
  • fix(noTailwindArbitraryValues): don't flag modifiers, and add escape hatch options by @dyc3 in #12194
  • feat(lint/js/svelte): add noSvelteObjectInTextMustaches by @dyc3 in #12072
  • feat(lint/js/vue): add noVueRequiredPropWithDefault by @dyc3 in #12090
  • feat(lint/html/vue): add useVueConsistentEventHyphenation by @dyc3 in #12053
  • feat(lint/js): add useCapitalizedConstructors by @dyc3 in #12081
  • feat(lint/md): add noEmptySource to markdown by @dyc3 in #12221
  • fix(parse/css): fix parsing of tailwind @theme options by @dyc3 in #12203
  • fix(type_inference): detect inferred arrays correctly by @dyc3 in #12249
  • feat(html): move useScopedStyles to the suspicious group by @dyc3 in #12245
  • fix(lint/html/svelte): mark class: and style: shorthands as variable usages by @dyc3 in #12246
  • fix(cli): don't let script exit with 0 when child process exits by @dyc3 in #12251
  • fix(useVueConsistentDefinePropsDeclaration): only check calls to the defineProps macro by @dyc3 in #12242
  • feat(noTailwindRestyledComponents): let users supply their own advice messages by @dyc3 in #12252
  • feat(codegen): extract tailwind raw colors by @dyc3 in #12243
  • feat(css): support empty SCSS statements by @denbezrukov in #12253
  • feat(md): friendly cjk semantics by @ematipico in #12257
  • fix(biome_js_analyze): preserve JS number stringification semantics in noUselessStringConcat by @Athish2002 in #12211
  • fix(css): parse quoted interpolation in unknown SCSS at-rules by @denbezrukov in #12259
  • feat(lint/js): add useUnaryMinus by @dyc3 in #12093
  • fix(js_control_flow): resolve unlabeled break/continue inside labeled loops by @dyc3 in #12117
  • feat(lint/js): add useConsistentJsonFileRead by @dyc3 in #12109
  • feat(lint): add noNestedTemplateLiterals by @dyc3 in #12170
  • feat(lint): add noVueVHtml by @dyc3 in #12135
  • feat(lint/js): add noUnsafeUnaryMinus by @dyc3 in #12116
  • feat: add tanstack query rule source by @dyc3 in #12263
  • feat(lint): add noVueVText by @dyc3 in #12134
  • feat(lint): add useNamedFunction by @dyc3 in #12133
  • fix(js_control_flow): treat for loops with a truthy literal test as infinite by @latent-9 in #12240
  • feat(lint/js): add noExcessiveStatementsPerFunction by @dyc3 in #12061
  • feat(lint/html): add useConsistentBlockLang by @dyc3 in #12094
  • feat(lint/js): add noUselessAssignment by @dyc3 in #12107
  • feat(lint): add useMatchingFunctionName by @dyc3 in #12129
  • feat(lint/js): add noSvelteUselessDerivedBy by @dyc3 in #12092
  • fix(noVueDuplicateKeys): don't flag variables derived from withDefaults props by @dyc3 in #12244
  • feat(lint): add noAccidentalBitwiseOperators by @dyc3 in #12223
  • fix(migrate): use Prettier's defaults for semi and singleQuote by @JamBalaya56562 in #12266
  • feat(lint): add noPromiseExecutorReturn by @dyc3 in #12112
  • feat(lint): add noUselessDateGetTime by @dyc3 in #12186
  • feat(lint): add noDoubleComparison by @dyc3 in #12175
  • feat(lint): add noArgumentsCallerOrCallee by @dyc3 in #12114
  • feat(lint): add noObjectConstructor by @dyc3 in #12111
  • chore: update rule metadata by @dyc3 in #12281
  • fix(noUnusedImports): handle svelte stores by @dyc3 in #12280
  • chore(deps): update github-actions by @renovate[bot] in #12277
  • feat(css): parse computed SCSS media feature names by @denbezrukov in #12283
  • fix(css): support compound SCSS placeholder selectors by @denbezrukov in #12276
  • feat(noUnusedVariables): add ignoreUsingDeclarations to options by @dyc3 in #12206
  • fix: plugin includes globs resolve relative to config they are defined in by @dyc3 in #12264
  • feat(lint): add useTailwindStaticClassStrings by @dyc3 in #11961
  • feat(noTailwindRawColors): suggest actual colors from user's design system by @dyc3 in #12272
  • feat(md): configure embeds behaviour by @ematipico in #12262
  • feat(lint): add noInvalidThis by @dyc3 in #12120
  • feat(lint): add useVueMatchingComponentFileName by @dyc3 in #12137
  • feat(lint/js/svelte): add noSvelteAddEventListener by @dyc3 in #12070
  • feat(lint): add useSvelteShorthandDirective by @dyc3 in #12172
  • feat(lint): add useSimplifiedBooleanReturn by @dyc3 in #12169
  • feat(lint): add useLowercaseTestTitle by @dyc3 in #12154
  • chore: update rule metadata by @dyc3 in #12296
  • feat(lint): add useSvelteReactiveClasses by @dyc3 in #12235
  • refactor: move syntax helper to syntax crate by @dyc3 in #12303
  • fix(html): lex processing instructions in their own context by @ematipico in #12292
  • feat: change tailwind domain activation to v4 instead of v3 by @dyc3 in #12291
  • refactor(noProto): avoid possible allocations at all, use idiomatic apis by @dyc3 in #12288
  • fix(css): support computed SCSS @supports names by @denbezrukov in #12307
  • feat(graphql_analyze): implement useSortedVariables by @ff1451 in #12055
  • fix(analyze): update eslint-plugin-package-json rule docs url by @dyc3 in #12305
  • feat(lint): add noVueShadowNativeEvents by @dyc3 in #12136
  • feat(lint): add noVueLifecycleAfterAwait by @dyc3 in #12229
  • feat(graphql_analyze): implement useSortedArguments by @ff1451 in #12282
  • feat(lint/js): add noUselessCall by @dyc3 in #12082
  • fix: correct urls for eslint-plugin-package-json by @dyc3 in #12313
  • feat(css): support interpolation in modern if() conditions by @denbezrukov in #12312
  • feat(css): preserve non-color SCSS hash values by @denbezrukov in #12321
  • perf(service): skip re-parsing formatted code without syntax diagnostics by @dyc3 in #12322
  • perf(formatter): skip comment-free subtrees when collecting comments by @dyc3 in #12325
  • fix(css_formatter): preserve single-element SCSS list commas by @denbezrukov in #12330
  • feat(scss): accept Sass non-ASCII identifier characters by @denbezrukov in #12324
  • fix(useReactCompiler): analyze files with exported type, interface, and enum declarations by @maroKanatani in #12340
  • fix(lsp): empty messages in diagnostics by @ematipico in #12346
  • feat: improved diagnostics for some GraphQL rules by @Netail in #12350
  • feat: sorted GraphQL documents by @Netail in #12318
  • perf(analyze): read suppression comments from borrowed tokens by @dyc3 in #12339
  • perf(rowan): read a single syntax slot without a slot iterator by @dyc3 in #12331
  • perf(cli): skip dropping the workspace when the process exits by @dyc3 in #12327
  • chore(deps): update rust crate tokio to 1.53.3 by @renovate[bot] in #12140
  • fix: improve lint diagnostics by @Netail in #12353
  • feat(css): support at-root statements in keyframes by @denbezrukov in #12352
  • fix(deps): update rustls to 0.23.46 by @dyc3 in #12359
  • perf(lint): skip embedded lookups in files without embedded content by @dyc3 in #12341
  • feat(lint): add noSvelteClassDirective by @dyc3 in #12254
  • feat(scss): support interpolated at-rule prelude names by @denbezrukov in #12357
  • fix: improve more lint diagnostics by @Netail in #12354
  • test(yaml_formatter): update Prettier test suite by @dyc3 in #12364
  • chore: update rule metadata by @dyc3 in #12378
  • fix(js_formatter): parenthesize returned and thrown sequence expressions by @florian-lefebvre in #12379
  • fix: improve even more lint diagnostics by @Netail in #12355
  • fix(js_parser): accept any expression in Astro shorthand attributes by @florian-lefebvre in #12394
  • chore: remove unused advisory ignore by @Netail in #12396
  • refactor(inference): remove the legacy type engine by @ematipico in #12391
  • fix(core): domains and overrides by @ematipico in #12392
  • fix(fmt/html): svelte bindings by @ematipico in #12393
  • fix(css): preserve URL nodes in SCSS custom properties by @denbezrukov in #12398
  • fix(yaml_parser): exclude trailing blanks from plain scalar tokens by @dyc3 in #12365
  • fix(yaml_formatter): keep comments after flow mapping keys on the key's line by @dyc3 in #12366
  • perf(lint): scan borrowed tokens in noTsIgnore by @dyc3 in #12360
  • perf(lint): scan borrowed tokens in noIrregularWhitespace by @dyc3 in #12361
  • feat(css): accept computed dashed at-rule names in SCSS by @denbezrukov in #12406
  • feat(parse/css): extend lexing/parsing metavariables for CSS-in-JS by @siketyan in #12210
  • feat: parse and format CSS-in-JS snippets with interpolations by @siketyan in #12212
  • fix(format/css): improve compatibility with Prettier for formatting CSS-in-JS snippets by @siketyan in #12215
  • fix(css): preserve Tailwind theme wildcard property order by @latin-1 in #12411
  • perf(analyze): walk only the node kinds the visitors of a phase read by @dyc3 in #12362
  • fix(migrate): migrate eqeqeq null comparison options by @dyc3 in #12404
  • fix: mark useSingleVarDeclarator as inspired by @dyc3 in #12399
  • fix(useTailwindShorthandClasses): preserve Tailwind shorthand semantics by @dyc3 in #12401
  • fix(useVueDefineMacrosOrder): fix detection and reordering by @dyc3 in #12402
  • fix(yaml_formatter): keep comments between flow mapping keys and values in place by @dyc3 in #12367
  • fix(yaml_formatter): keep comments after directives in place by @dyc3 in #12368
  • chore: add changeset for gritMetavariables removal by @siketyan in #12424
  • chore: update sponsors by @ematipico in #12428
  • ci(bench): build all biome_service bench targets instead of naming them by @dyc3 in #12430
  • perf(js_control_flow): visit only statement and function nodes when building graphs by @dyc3 in #12425
  • feat(scss): support dynamic attr() units by @denbezrukov in #12429
  • chore(cli): upgrade self_update to v1, drop reqwest by @siketyan in #11550
  • fix(useNamingConvention): ignore declarations nested in ambient namespaces by @dfedoryshchev in #11888
  • perf(rowan): skip refcount traffic for cached children when building trees by @dyc3 in #12420
  • perf(rowan): compute trimmed node ranges from the green tree by @dyc3 in #12426
  • refactor(rowan): add named single-space and newline trivia helpers by @dyc3 in #12182
  • fix(vue): parse generic attribute of Vue setup scripts by @levrik in #12124
  • fix(lsp): make pull_actions handle embedded snippets by @dyc3 in #12440
  • test(noUndeclaredVariables): update Vue generic snapshot with new diagnostic notes by @dyc3 in #12442
  • feat(scss): support standalone percent values by @denbezrukov in #12435
  • fix(cli): search matches by @ematipico in #12444
  • chore: update rule metadata by @dyc3 in #12446
  • fix(daemon): various fixes by @dyc3 in #12441
  • fix(css): handle irregular whitespace in strings and trivia by @fe-dudu in #12434
  • fix(noTsIgnore): only report comments TypeScript treats as directives by @dyc3 in #12451
  • fix(grit): json query binding by @ematipico in #12461
  • ci: enable unstable releases by @ematipico in #12463
  • perf(lint): fix quadratic time in noUnknownFunction, noShorthandPropertyOverrides and useSingleTopLevelHeading by @dyc3 in #12462
  • test(analyze): remove the kind-filtered walk tests by @dyc3 in #12467
  • perf(js_analyze): decide noUnusedVariables usage from stored reference positions by @dyc3 in #12437
  • perf(search): use optimized Grit query execution by @dyc3 in #12468
  • chore(deps): replace actions/attest-build-provenance action with actions/attest v4.2.2 by @renovate[bot] in #11981
  • fix(css_formatter): keep wrapped selector indent below a rule comment by @dyc3 in #12474
  • feat(rowan): add skip_subtree() to preorder_of_kinds() iterator by @dyc3 in #12479
  • fix(format/js): don't duplicate comments of spread objects in JSX by @vidigoat in #12480
  • fix: advisory for tls vulnerability by @ematipico in #12490
  • ci: release by @github-actions[bot] in #12065

New Contributors

Full Changelog: https://github.com/biomejs/biome/compare/@biomejs/biome@2.5.15...@biomejs/js-api@6.1.0

Don't miss a new biome release

NewReleases is sending notifications on new releases.