fixhunt

biome correctness/useJsonImportAttributes

labelled safe
Runs / 2026-10-17T20-46-49-470Z-9ytj-biome-correctness_useJsonImportAttributesbiome 2.5.152026-10-17 20:46 UTC8 programs × 2 round(s)8 programs, 4 fired, 4 fixed, 0 findings, 4 rejectedmodel cost $0.0028

Analysis Nemotron 3 Super

Flags imports of .json files missing the 'type': "json" attribute in their import assertions.

Fix: Adds 'with { type: "json" }' to the import statement if no with/assert clause exists, or merges 'type': "json" into an existing with/assert clause while preserving other attributes.

12 hazards
  • Rewriting 'import data from "./data.json" with { some: "value" };' to include 'type': "json" may change behavior if the runtime relies on the absence of the type attribute for non-JSON interpretation.
  • If the import is inside a conditional block, adding the assertion could alter parsing timing and cause early errors in environments that statically reject unknown attributes.
  • In bundled environments where JSON imports are transformed via plugins, adding the assertion might conflict with plugin expectations that assume raw imports without assertions.
  • If the source file has trailing comments on the same line after the import, the autofix might incorrectly place them inside the with block or drop them during rewrite.
  • When multiple imports share the same line via commas, inserting the assertion could break syntactic validity if not applied per-import.
  • In TypeScript files, adding the assertion might interfere with type declaration merging if the module augmentation depends on the original import form.
  • If the import uses an assert clause instead of with (e.g., assert { ... }), the autofix might incorrectly convert it to with, which is not supported in older environments.
  • If the JSON file is actually a symlink or mapped to a non-JSON resource via server configuration, forcing the type attribute could cause the runtime to misparse the content.
  • In environments with custom loaders that inspect the import syntax for optimization, adding the assertion might disable those optimizations.
  • If the import is part of a larger expression (e.g., tagged template), inserting the assertion could break the surrounding syntax structure.
  • When the import is decorated with inline comments specifying loader instructions (e.g., webpack), adding the assertion might conflict with or override those comments.
  • If the import statement is generated by a macro or code-mod that expects a specific shape, the injected assertion could invalidate the macro's assumptions.

Programs

idresulttitlehazard
r1-p001fix okComments preserved after fixcomments attached to the removed or moved code
r1-p002invalidArrow function binding captured via closurethis binding: arrow vs function, methods extracted from objects, call/apply/bind
r1-p003invalidException in destructuring after fixexceptions thrown inside the code the fix removes or rewrites
r1-p004fix okNullish coalescing depends on imported valuenull/undefined distinction, optional chaining short-circuit, nullish vs falsy
r1-p005fix okClass field initialization uses imported JSONclass fields, static blocks, private names, super calls
r1-p006fix okASI hazard: import followed by leading parenASI and semicolon-less code, leading ( or [ on the next line
r1-p007invalidImport inside case block scopefunction declarations inside blocks, switch cases, labeled statements
r1-p008invalidMacro expects raw import shapeIf the import statement is generated by a macro or code-mod that expects a specific shape, the injected assertion could invalidate the macro's assumptions.

Sources

r1-p001 · Comments preserved after fix
1// comment before
2import config from './data.json'; // inline comment
3console.log(config.value);
--- orig.js	2026-10-17 16:46:59.727169612 -0400
+++ fixed.js	2026-10-17 16:47:00.014176574 -0400
@@ -1,3 +1,3 @@
 // comment before
-import config from './data.json'; // inline comment
+import config from './data.json' with { type: "json" }; // inline comment
 console.log(config.value);
r1-p002 · Arrow function binding captured via closure (generated program does not parse: /home/sun/dev/diaghunt/runs/2026-10-17T20-46-4)
1const getData = () => {
2 import obj from './data.json';
3 return () => obj.prop; // captures obj via closure
4};
5const fn = getData();
6console.log(fn());
r1-p003 · Exception in destructuring after fix (generated program does not parse: /home/sun/dev/diaghunt/runs/2026-10-17T20-46-4)
1try {
2 import { nonExistentProp } from './data.json';
3 console.log('unreachable');
4} catch (e) {
5 console.log(e.name + ': ' + e.message);
6}
r1-p004 · Nullish coalescing depends on imported value
1import settings from './data.json';
2const value = settings?.nested ?? 'default';
3console.log(value);
--- orig.js	2026-10-17 16:47:00.269182752 -0400
+++ fixed.js	2026-10-17 16:47:00.530189076 -0400
@@ -1,3 +1,3 @@
-import settings from './data.json';
+import settings from './data.json' with { type: "json" };
 const value = settings?.nested ?? 'default';
 console.log(value);
r1-p005 · Class field initialization uses imported JSON
1import cfg from './data.json';
2class C {
3 static field = cfg.value;
4 constructor() {
5 console.log(C.field);
6 }
7}
8new C();
--- orig.js	2026-10-17 16:47:00.696193098 -0400
+++ fixed.js	2026-10-17 16:47:00.965199616 -0400
@@ -1,4 +1,4 @@
-import cfg from './data.json';
+import cfg from './data.json' with { type: "json" };
 class C {
   static field = cfg.value;
   constructor() {
r1-p006 · ASI hazard: import followed by leading paren
1import data from './data.json'
2(function(){
3 console.log(data.prop);
4})()
--- orig.js	2026-10-17 16:47:01.136203755 -0400
+++ fixed.js	2026-10-17 16:47:01.416210532 -0400
@@ -1,4 +1,4 @@
-import data from './data.json'
+import data from './data.json' with { type: "json" }
 (function(){
   console.log(data.prop);
 })()
r1-p007 · Import inside case block scope (generated program does not parse: /home/sun/dev/diaghunt/runs/2026-10-17T20-46-4)
1switch (1) {
2 case 1:
3 import val from './data.json';
4 console.log(val.x);
5 break;
6}
r1-p008 · Macro expects raw import shape (generated program does not parse: /home/sun/dev/diaghunt/runs/2026-10-17T20-46-4)
1// Simulated macro: expects import without assertions
2const macroProcessed = (() => {
3 try {
4 import raw from './data.json';
5 return typeof raw === 'object' && raw !== null;
6 } catch (e) {
7 return false;
8 }
9})();
10console.log(macroProcessed);