Backtestshugorun-20260930-140149#15169
resources/jsconfig: Address VS Code linting notice in jsconfig.json
Our patch was judged better than the merged fix.
In this judgment, Patch A = our agent, Patch B = the merged fix.
The lint fires because the source root equal to `dir` produces the bare entry `"*"`. Without `baseUrl`, TypeScript and VS Code require `paths` entries to be relative. Correctness: Patch A fixes the entry itself by prefixing `./` when the path isn't already relative. The mapping becomes `"./*"`, which is valid without `baseUrl` and keeps the original meaning. Non-relative imports like `js/foo` still resolve against the assets directory in the editor. Entries for other roots already start with `../` and are left unchanged. Patch B silences the lint by dropping the current root from `paths` entirely. That removes a mapping that was doing useful work. When other roots exist, bare imports no longer fall back to the site's own assets directory. When the site's assets dir is the only root, `Build` returns nil and no jsconfig is produced at all. B masks the symptom by removing functionality, while A corrects the malformed value. Tests: Both add tests that would fail before their change. A's test checks the exact output: `./*` for the self root and `../../c/assets/*` for another root, using `filepath.FromSlash` so it works across platforms. It fails on the old code, which emitted `*`. B's test only asserts nil for a single self root, which tests the new skip behavior rather than validity of the output. Scope and craft: Both are small and focused. A's prefix check is simple and consistent with the existing `filepath` usage. B's comment is clear, but the behavioral regression outweighs that. Overall, A is the more faithful root-cause fix.
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
21m 26s9 turns
Wall-clock time in the container
Full test suite
No new failures
3,695 passed · 99 skipped · 3,803 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
13vs 11 merged
Changed lines, ours vs merged
The issue
View on GitHubWhen 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
resources/jsconfig/jsconfig.goindex 4aabf69f7..e2234e91a 100644@@ -16,6 +16,7 @@ package jsconfig import ( "path/filepath" "sort"+ "strings" "github.com/bep/helpers/maphelpers" )@@ -41,6 +42,10 @@ func (b *Builder) Build(dir string) *Config { for root := range b.sourceRoots.All() { rel, err := filepath.Rel(dir, filepath.Join(root, "*")) if err == nil {+ sep := string(filepath.Separator)+ if !strings.HasPrefix(rel, "."+sep) && !strings.HasPrefix(rel, ".."+sep) {+ rel = "." + sep + rel+ } roots = append(roots, rel) } }resources/jsconfig/jsconfig_test.goindex ab9b739d1..d043db258 100644@@ -37,4 +37,12 @@ func TestJsConfigBuilder(t *testing.T) { c.Assert(string(data), qt.Not(qt.Contains), "baseUrl") c.Assert(NewBuilder().Build("/a/b"), qt.IsNil)++ // Without baseUrl, every entry in paths must be relative (start with "./" or "../"),+ // including the source root that equals dir.+ b = NewBuilder()+ b.AddSourceRoot("/a/b")+ b.AddSourceRoot("/c/assets")+ conf = b.Build("/a/b")+ c.Assert(conf.CompilerOptions.Paths["*"], qt.DeepEquals, []string{filepath.FromSlash("../../c/assets/*"), filepath.FromSlash("./*")}) }
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) }
What the agent reported
The generated assets/jsconfig.json no longer triggers the VS Code notice. The regression test fails before the fix and passes after, but only when run directly with go test. ./bt-test never got as far as running tests.
What was wrong: An earlier commit (ff2903a93) removed the deprecated baseUrl setting from the generated file. Without baseUrl, TypeScript and VS Code require every entry under compilerOptions.paths to start with ./ or ../. When the source root is the folder holding jsconfig.json (the normal case, the project's own assets folder), Build in resources/jsconfig/jsconfig.go wrote a bare "*". That is the entry VS Code flagged on line 5.
What changed:
resources/jsconfig/jsconfig.go:Buildnow adds a./prefix to any path that doesn't already start with./or../, so"*"becomes"./*". Paths that already start with../are unchanged. It uses the same separator style as the rest of the code, and TypeScript accepts either slash.resources/jsconfig/jsconfig_test.go: I added a case toTestJsConfigBuilderwith source roots/a/band/c/assetsandBuild("/a/b"). It expects["../../c/assets/*", "./*"]. The existing checks are unchanged.
Test evidence:
./bt-testdid not produce a result. It exited 1 three times (once with the test only, twice after the fix) because the setup step couldn't downloadgithub.com/bep/helpers@v0.12.0: there is no network, and it doesn't use the local module cache at/bt/cache/go-mod. No tests ran, so these runs say nothing either way.- Direct runs against that cache, offline:
- Before the fix, the new check failed with
got []string{"*", "../../c/assets/*"},want []string{"../../c/assets/*", "./*"}. - After the fix,
./resources/jsconfig/passes, and the neighbouring./internal/js/esbuildtests also pass.
Blast radius: Build is only called from hugolib/hugo_sites_build.go:665, where the file is written, and no other tests check these paths. A read-only reviewer found the fix correct, including folder names that start with dots and Windows separators.
Requirements:
- Remove the VS Code notice "Non-relative paths are not allowed when 'baseUrl' is not set": done. The generated path is now
./*, shown by the new check failing before the fix and passing after. - Don't bring back
baseUrl: kept. The existing check that the output has nobaseUrlstill passes.
AGENTS.md and CLAUDE.md were already deleted in the working tree before I started. I left them alone. Nothing is committed.