Backtestshugorun-20261002-200313#15169

Issue #15169 Merged fix PR # Run 2 Oct 2026 · run-20261002-200313 gohugoio/hugo

resources/jsconfig: Address VS Code linting notice in jsconfig.json

Better

Our patch was judged better than the merged fix.

In this judgment, Patch A = our agent, Patch B = the merged fix.

Patch A fixes the root cause. The lint fires because path entries in `paths` lack a `./` or `../` prefix when `baseUrl` is unset. Patch A normalizes every generated entry so it is explicitly relative. That turns `"*"` into `"./*"`, keeps the self-mapping that lets bare imports resolve to the assets dir in the editor, and also covers source roots nested under `dir` (e.g. `sub/*`). Those nested roots would trigger the same lint, and Patch B leaves them unfixed. Its test checks a sibling root (`../c/*`), the self root (`./*`) and a nested root (`./sub/*`). That test would fail before the change and pass after. Patch B instead drops the mapping for the current dir entirely. In the issue's exact scenario this makes `Build` return nil, so the self-mapping functionality is removed rather than corrected. It also still emits non-relative paths for nested source roots, and its `root == dir` string equality is brittle against path-form differences. Its test only asserts nil for the single-root case and does not check that the remaining paths are valid relative paths. One minor nit on A: on Windows it uses the OS separator (`.\`), but this matches the existing `filepath.Rel`-based behavior. Overall A is more correct, preserves functionality, and has a stronger test.

The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.

Solve

42m 41s

Wall-clock time in the container

Full test suite

No new failures

3,696 passed · 99 skipped · 3,804 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

31vs 11 merged

Changed lines, ours vs merged

When building a site that calls js.Build, the assets/jsconfig.json file looks like this:

{
 "compilerOptions": {
  "paths": {
   "*": [
    "*"
   ]
  }
 }
}

VS Code lints line 5 as follows:

Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?

The two patches

Our patch+30 −1
resources/jsconfig/jsconfig.goindex 4aabf69f7..8a9f038e0 100644@@ -16,6 +16,7 @@ package jsconfig import ( 	"path/filepath" 	"sort"+	"strings"  	"github.com/bep/helpers/maphelpers" )@@ -41,7 +42,7 @@ func (b *Builder) Build(dir string) *Config { 	for root := range b.sourceRoots.All() { 		rel, err := filepath.Rel(dir, filepath.Join(root, "*")) 		if err == nil {-			roots = append(roots, rel)+			roots = append(roots, toRelativePath(rel)) 		} 	} 	if len(roots) == 0 {@@ -53,6 +54,16 @@ func (b *Builder) Build(dir string) *Config { 	return conf } +// toRelativePath makes sure that rel starts with "./" or "../".+// Without baseUrl set, TypeScript (and editors such as VS Code) treat paths+// without such a prefix as non-relative and reject them.+func toRelativePath(rel string) string {+	if rel == ".." || strings.HasPrefix(rel, ".."+string(filepath.Separator)) || strings.HasPrefix(rel, "."+string(filepath.Separator)) {+		return rel+	}+	return "." + string(filepath.Separator) + rel+}+ // AddSourceRoot adds a new source root. // This method is thread safe. func (b *Builder) AddSourceRoot(root string) {resources/jsconfig/jsconfig_test.goindex ab9b739d1..a3458aaa8 100644@@ -38,3 +38,21 @@ func TestJsConfigBuilder(t *testing.T) {  	c.Assert(NewBuilder().Build("/a/b"), qt.IsNil) }++// Paths must be relative (start with ./ or ../) when baseUrl is not set,+// or VS Code complains with "Non-relative paths are not allowed when 'baseUrl' is not set".+func TestJsConfigBuilderRelativePaths(t *testing.T) {+	c := qt.New(t)++	b := NewBuilder()+	b.AddSourceRoot("/a/b")+	b.AddSourceRoot("/a/b/sub")+	b.AddSourceRoot("/a/c")++	conf := b.Build("/a/b")+	c.Assert(conf.CompilerOptions.Paths["*"], qt.DeepEquals, []string{+		filepath.FromSlash("../c/*"),+		filepath.FromSlash("./*"),+		filepath.FromSlash("./sub/*"),+	})+} 
Merged fix · PR #+11 −0
resources/jsconfig/jsconfig.goindex 4aabf69f7..d347cab19 100644@@ -39,6 +39,11 @@ func (b *Builder) Build(dir string) *Config { 	} 	var roots []string 	for root := range b.sourceRoots.All() {+		if root == dir {+			// We need mappings for other source roots (e.g. mounted modules), but not for the current one.+			// See issue 15169.+			continue+		} 		rel, err := filepath.Rel(dir, filepath.Join(root, "*")) 		if err == nil { 			roots = append(roots, rel)resources/jsconfig/jsconfig_test.goindex ab9b739d1..1fb8ef3cd 100644@@ -37,4 +37,10 @@ func TestJsConfigBuilder(t *testing.T) { 	c.Assert(string(data), qt.Not(qt.Contains), "baseUrl")  	c.Assert(NewBuilder().Build("/a/b"), qt.IsNil)++	// Issue 15169.+	b = NewBuilder()+	b.AddSourceRoot("/c/assets")+	conf = b.Build("/c/assets")+	c.Assert(conf, qt.IsNil) }