<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ashok Ram's Open Source Notes]]></title><description><![CDATA[Write ups of merged fixes in Tauri, Biome, oxc, Turso, Grafana and more. The bug, the cause, and what the maintainers taught me in review.]]></description><link>https://ashokramsi.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6aff595d1016fbd689bd31d5/cde50b22-305f-4936-8eb0-68036f846f8a.png</url><title>Ashok Ram&apos;s Open Source Notes</title><link>https://ashokramsi.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 21 Nov 2026 14:33:58 GMT</lastBuildDate><atom:link href="https://ashokramsi.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[A minus sign before an SCSS interpolation that Biome read as math]]></title><description><![CDATA[Why Biome turned a list of negative SCSS interpolations into a subtraction, and the small parser check that fixed it.]]></description><link>https://ashokramsi.hashnode.dev/biome-scss-negative-interpolation</link><guid isPermaLink="true">https://ashokramsi.hashnode.dev/biome-scss-negative-interpolation</guid><category><![CDATA[Rust]]></category><category><![CDATA[CSS]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Ashok Ram]]></dc:creator><pubDate>Fri, 20 Nov 2026 03:40:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aff595d1016fbd689bd31d5/2c2014ef-6797-4f74-8461-49a3db599742.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Minus signs in SCSS are a little tricky. <code>$a - $b</code> is a subtraction, <code>-$b</code> is a negative value, and <code>1px 2px</code> is a list. A formatter has to read every minus sign exactly the way Sass does, or it quietly changes your CSS.</p>
<p>That's what <a href="https://github.com/biomejs/biome/issues/12957">issue #12957</a> was about. The reporter had this:</p>
<pre><code class="language-scss">$s: 8px;
.a {
  margin: -#{$s} -#{$s} -#{$s} auto;
}
</code></pre>
<p>and Biome formatted the value as <code>-#{$s} - #{$s} - #{$s} auto</code>. Looks like a spacing tweak. It isn't. The reporter checked with Dart Sass: the original compiles to <code>margin: -8px -8px -8px auto;</code>, the formatted file to <code>margin: -8px-8px-8px auto;</code>. That's invalid CSS, so the browser drops the whole declaration.</p>
<p>I picked it up, and the fix was merged in <a href="https://github.com/biomejs/biome/pull/12983">biomejs/biome#12983</a>.</p>
<h2>Why it happened</h2>
<p>The formatter wasn't really the problem. It prints the tree the parser gives it. The SCSS parser decides what counts as a binary operator in <code>crates/biome_css_parser/src/syntax/scss/expression/precedence.rs</code>, and its <code>scss_binary_precedence</code> function took every <code>-</code> after a value as subtraction. So <code>-#{$s} -#{$s}</code> became "negative <code>#{$s}</code>, minus <code>#{$s}</code>". Once the tree says subtraction, the formatter prints spaces around the operator.</p>
<p>Sass reads it differently. A <code>-</code> written directly against <code>#{</code> starts an interpolated identifier. With a space before it, that's simply the next item in the list. Only <code>$a - #{$s}</code>, with a space on both sides, subtracts.</p>
<h2>The fix</h2>
<p>Both <code>parse_scss_binary_tail</code> and <code>is_at_scss_binary_operator</code> go through <code>scss_binary_precedence</code>, so one check there covers both. I added a small helper:</p>
<pre><code class="language-rust">/// Returns whether the current `-` starts the next item of a space-separated
/// list instead of subtracting: it follows whitespace and is written directly
/// against an interpolation.
///
/// Sass reads a `-` followed by `#{` as the start of an interpolated
/// identifier, so `-#{$s} -#{$s}` is a two-item list (`-8px -8px`), while
/// `$a - #{$b}` subtracts.
///
/// Docs: https://sass-lang.com/documentation/operators/numeric/#unary-operators
#[inline]
fn is_at_scss_negated_interpolation_list_item(p: &amp;mut CssParser) -&gt; bool {
    p.at(T![-])
        &amp;&amp; (p.has_nth_preceding_whitespace(0) || p.has_nth_preceding_line_break(0))
        &amp;&amp; is_nth_at_scss_interpolation(p, 1)
        &amp;&amp; is_nth_source_tight(p, 1)
}
</code></pre>
<p>In words: a minus, with a space or a line break before it, followed by <code>#{</code> with nothing in between. When that's true, it's not a binary operator:</p>
<pre><code class="language-rust">if !p.at_ts(SCSS_BINARY_OPERATOR_TOKEN_SET) || is_at_scss_negated_interpolation_list_item(p) {
    return None;
}
</code></pre>
<p>I kept it narrow on purpose. It only looks at <code>#{</code>, so <code>height: 1 -$s;</code> still parses as a subtraction, same as before.</p>
<h2>Tests, and two snapshots that moved</h2>
<p>I added the same input as a parser spec and a formatter spec:</p>
<pre><code class="language-scss">$s: 8px;

.a {
  margin: -#{$s} -#{$s} -#{$s} auto;
  padding: 1px -#{$s};
  width: $a - #{$s};
  height: 1 -$s;
  inset: -#{$s}
    -#{$s};
}
</code></pre>
<p>The formatter now leaves <code>margin</code> and <code>padding</code> as written, keeps <code>$a - #{$s}</code> as a subtraction, prints <code>height</code> as <code>1 - $s</code> like it always did, and joins the two line <code>inset</code> into <code>-#{$s} -#{$s}</code>. Both specs fail without the parser change.</p>
<p>Two existing snapshots changed too. In the Prettier compatibility snapshot <code>parens.scss</code>, the line <code>prop25-4</code> used to come out as <code>#{$width} - #{$width}</code> where Prettier keeps <code>#{$width} -#{$width}</code>. Now Biome matches Prettier on that pair.</p>
<p>The bigger one showed up when I ran the whole parser suite. The <code>ok/scss/value/minus-operator.scss</code> snapshot, a matrix of subtraction cases, had 17 cases recorded as subtractions, all of the same shape: a space before, the minus tight against <code>#{</code>, like <code>10 -#{10}</code> and <code>#{10} -#{10}</code>. I checked them against Sass's own conformance tests in <code>sass/sass-spec</code>, and Sass's expected output keeps every one of them as separate values. So I updated that snapshot as well.</p>
<p>ematipico merged it on 6 November 2026, the same day I opened it, with no changes asked. Thanks!</p>
<h2>What I'm keeping from this one</h2>
<p>When a formatter changes what your code means, look at the parser first. The formatter here did exactly what the tree told it to.</p>
<p>The reporter's compiled output was the best part of the issue. <code>-8px-8px-8px</code> next to <code>-8px -8px -8px</code> made the bug obvious in one line.</p>
<p>And run the whole suite, not only your new tests. Those 17 cases sat in an existing snapshot.</p>
<p>Do you write negative interpolations like this in your SCSS, or do you wrap them in parentheses to be safe? I'd like to hear what your team does.</p>
]]></content:encoded></item><item><title><![CDATA[One /* in .taurignore and tauri dev watched nothing]]></title><description><![CDATA[A Tauri CLI bug where .taurignore ignored its own folder, the fix I sent first, and the simpler one that got merged after review.]]></description><link>https://ashokramsi.hashnode.dev/one-in-taurignore-and-tauri-dev-watched-nothing</link><guid isPermaLink="true">https://ashokramsi.hashnode.dev/one-in-taurignore-and-tauri-dev-watched-nothing</guid><category><![CDATA[Rust]]></category><category><![CDATA[Tauri]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[debugging]]></category><dc:creator><![CDATA[Ashok Ram]]></dc:creator><pubDate>Thu, 19 Nov 2026 20:41:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aff595d1016fbd689bd31d5/74afb74c-afa4-4fb4-ad39-c498d548e875.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><code>tauri dev</code> is one of those things you stop thinking about. You save a Rust file, it rebuilds, the app comes back. So when it quietly stops rebuilding, it takes a while to even notice.</p>
<p>That's what <a href="https://github.com/tauri-apps/tauri/issues/9163">issue #9163</a> was about. It had been open since March 2024. The reporter wanted <code>tauri dev</code> to watch only a few things, so they wrote their <code>.taurignore</code> as an allow list. Trimmed a little (their file also kept <code>icons/</code>), it looked like this:</p>
<pre><code class="language-gitignore">/*
!/*.toml
!/*.rs
!/src
</code></pre>
<p>Ignore everything at the top, then bring back the <code>.toml</code> files, the <code>.rs</code> files and <code>src/</code>. Same file as a <code>.gitignore</code>? Works fine. As a <code>.taurignore</code>? <code>tauri dev</code> stopped watching the app completely. Edit <code>src/main.rs</code>, nothing happens.</p>
<p>I picked it up, and the fix got merged in <a href="https://github.com/tauri-apps/tauri/pull/16398">tauri-apps/tauri#16398</a>. The fix that got merged is not the one I sent first, though, and that part is honestly the most useful bit of this story.</p>
<h2>Reproducing it</h2>
<p>Tauri's repo has a tiny app in <code>bench/tests/helloworld</code>. I dropped the <code>.taurignore</code> into its <code>src-tauri</code> folder and ran <code>tauri dev</code>. The CLI prints every folder it's watching, and the app folder just wasn't in the list.</p>
<h2>Why it happened</h2>
<p>The dev watcher lives in <code>crates/tauri-cli/src/interface/rust.rs</code>. Before my change it did roughly this:</p>
<pre><code class="language-rust">for path in watch_folders {
  if !ignore_matcher.is_ignore(&amp;path, true) {
    // watch every entry of `path`
  }
}
</code></pre>
<p>So before watching a folder, it asked the ignore matcher: is this folder itself ignored? For the app folder, that's the same folder the <code>.taurignore</code> sits in.</p>
<p>The matcher comes from the <a href="https://crates.io/crates/ignore"><code>ignore</code></a> crate (the one ripgrep uses). Patterns in an ignore file are relative to the file's own folder, so the crate strips that folder off the path before matching. Ask it about the folder itself and you're left with an empty path. And <code>/*</code> matches the empty path too.</p>
<p>So the app folder counted as ignored and got skipped. The <code>!/src</code> lines never had a chance, because they bring back things <em>inside</em> the folder, and the watcher never looked inside.</p>
<p>Git doesn't have this problem because it never applies a <code>.gitignore</code> to the folder the file lives in. Only to what's below it. That one difference was the whole bug.</p>
<h2>My first fix</h2>
<p>Since git was the behaviour everyone expected, I copied it. In <code>IgnoreMatcher::is_ignore</code>, skip an ignore file when the path you're asking about is that file's own folder. Everything inside the app matched exactly like before, and a <code>.taurignore</code> in a parent folder could still ignore a child folder.</p>
<p>I wrote the test first, using the <code>.taurignore</code> above, and watched it fail on the old code. Then the fix, and the test passed. <code>tauri dev</code> on the bench app showed the app folder in the "Watching … for changes" log again. Then I opened the PR.</p>
<h2>The review</h2>
<p>Legend-Master from the Tauri team requested changes. His point was that negative patterns are tricky to support, and treating <code>/*</code> at the root as a special case didn't really make sense. Then he asked whether we should just always watch the folders and filter the change events instead.</p>
<p>He was right, and when I thought about it, it was a better way to see the problem. My fix answered "is this folder ignored?" more carefully. His idea was to stop asking that question about the watch folders at all. A watch folder is something you told Tauri to watch. The ignore rules are about what's <em>in</em> it.</p>
<h2>The fix that got merged</h2>
<p>I reworked the PR around that. A new helper, <code>watch_targets</code>, lists what to watch: every entry of every watch folder that isn't ignored.</p>
<pre><code class="language-rust">fn watch_targets(watch_folders: &amp;[PathBuf]) -&gt; Vec&lt;(PathBuf, RecursiveMode)&gt; {
  let mut targets = Vec::new();
  for path in watch_folders {
    lookup(path, |file_type, p| {
      if p != *path {
        let mode = if file_type.is_dir() {
          RecursiveMode::Recursive
        } else {
          RecursiveMode::NonRecursive
        };
        targets.push((p, mode));
      }
    });
  }
  targets
}
</code></pre>
<p><code>lookup</code> already existed. It walks one level of the folder with the <code>ignore</code> crate's <code>WalkBuilder</code>, set up to read <code>.taurignore</code> (plus the watcher rules Tauri ships with), so ignored entries never come back from it. The walk also hands back the folder itself, which is what the <code>p != *path</code> check skips.</p>
<p>The watch loop then stops asking about the folder:</p>
<pre><code class="language-rust">// logging lines left out
for (path, mode) in watch_targets(&amp;watch_folders) {
  let _ = watcher.watch(&amp;path, mode);
}
</code></pre>
<p>Change events are still filtered by <code>IgnoreMatcher::is_ignore</code>, same as before, so touching an ignored file doesn't trigger a rebuild.</p>
<p>Two tests cover it, both with the <code>.taurignore</code> from the issue. The first, <code>watch_targets_watch_a_folder_whose_taurignore_matches_it</code>, checks that the watched entries are exactly <code>Cargo.toml</code> and <code>src</code>. The second, <code>ignore_matcher_filters_events_under_a_root_wide_pattern</code>, checks that the matcher the event loop uses keeps <code>src/</code>, <code>src/main.rs</code> and <code>Cargo.toml</code>, and ignores <code>README.md</code> and <code>assets/</code>.</p>
<p>And the real check: with that file, editing <code>README.md</code> triggers no rebuild, and editing <code>src/main.rs</code> triggers one.</p>
<p>Legend-Master approved it. He mentioned that from his experience with <a href="https://github.com/parcel-bundler/watcher">parcel's watcher</a> (the one VS Code uses), it seemed to watch the whole folder and match ignore patterns before events reach the app, and this change basically matches that. FabianLars approved too. It was merged on 12 November 2026 and shipped in <code>tauri-cli</code> and <code>@tauri-apps/cli</code> 2.12.5.</p>
<h2>What I'm keeping from this one</h2>
<p>The reporter's file was the best test fixture I could have asked for. I barely changed it.</p>
<p>When something works as a <code>.gitignore</code> and not as your file, ask what git does differently. That question is what pointed me at the root folder.</p>
<p>And the big one for me: my first fix passed its tests, but it added a special case. The maintainer's version deleted the question that caused the bug, and the code got simpler. I'll take that trade every time.</p>
<p>Thanks Legend-Master and FabianLars for the reviews. If you've hit this before, or you do file watching differently in your project, I'd really like to hear how. Drop a comment.</p>
]]></content:encoded></item></channel></rss>