biomejs/biome-vscode

Format-on-save doesn't respect ignores in biome.jsonc

Opened this issue · 3 comments

VS Code version

1.90.0

Extension version

2.3.0

Biome version

1.7.3

Operating system

  • Windows
  • macOS
  • Linux

Description

The VSCode format-on-save feature appears to not respect ignores configured in biome.jsonc.

Steps to reproduce

I have the following biome.jsonc:

{
  "$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true
  },
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineEnding": "lf",
    "lineWidth": 80,
    "attributePosition": "auto",
    "ignore": [
      "**/package.json"
    ]
  },
}

And the following VSCode settings:

{
  "[json]": {
    "editor.defaultFormatter": "biomejs.biome"
  }
}

When I save a package.json, it still gets formatted by Biome. This makes it not play well with yarnpkg/berry#2636

Expected behavior

Biome doesn't format when package.jsons are saved, because they're specified to ignore in the config file.

Does this issue occur when using the CLI directly?

No

Logs

[Trace - 11:46:32 PM] Sending request 'textDocument/codeAction - (66)'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json"
    },
    "range": {
        "start": {
            "line": 26,
            "character": 26
        },
        "end": {
            "line": 26,
            "character": 26
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 11:46:32 PM] Sending request 'textDocument/codeAction - (63)'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json"
    },
    "range": {
        "start": {
            "line": 26,
            "character": 26
        },
        "end": {
            "line": 26,
            "character": 26
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 11:46:32 PM] Received response 'textDocument/codeAction - (66)' in 0ms.
Result: []


[Trace - 11:46:32 PM] Received response 'textDocument/codeAction - (63)' in 0ms.
Result: []


[Trace - 11:46:33 PM] Sending request 'textDocument/formatting - (67)'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json"
    },
    "options": {
        "tabSize": 2,
        "insertSpaces": true
    }
}


[Trace - 11:46:33 PM] Received response 'textDocument/formatting - (67)' in 1ms.
Result: [
    {
        "range": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 311,
                "character": 0
            }
        },
        "newText": "<redacted>"
    }
]


[Trace - 11:46:33 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json",
        "version": 17
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 306,
                    "character": 16
                },
                "end": {
                    "line": 307,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 305,
                    "character": 16
                },
                "end": {
                    "line": 306,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 303,
                    "character": 16
                },
                "end": {
                    "line": 304,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 302,
                    "character": 12
                },
                "end": {
                    "line": 303,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 300,
                    "character": 16
                },
                "end": {
                    "line": 301,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 299,
                    "character": 16
                },
                "end": {
                    "line": 300,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 297,
                    "character": 16
                },
                "end": {
                    "line": 298,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 296,
                    "character": 19
                },
                "end": {
                    "line": 297,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 293,
                    "character": 15
                },
                "end": {
                    "line": 294,
                    "character": 2
                }
            },
            "rangeLength": 3,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 292,
                    "character": 19
                },
                "end": {
                    "line": 293,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 38,
                    "character": 33
                },
                "end": {
                    "line": 39,
                    "character": 2
                }
            },
            "rangeLength": 3,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 38,
                    "character": 1
                },
                "end": {
                    "line": 38,
                    "character": 4
                }
            },
            "rangeLength": 3,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 37,
                    "character": 21
                },
                "end": {
                    "line": 38,
                    "character": 0
                }
            },
            "rangeLength": 1,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 36,
                    "character": 13
                },
                "end": {
                    "line": 37,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 12,
                    "character": 7
                },
                "end": {
                    "line": 13,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 11,
                    "character": 18
                },
                "end": {
                    "line": 12,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 10,
                    "character": 7
                },
                "end": {
                    "line": 11,
                    "character": 8
                }
            },
            "rangeLength": 9,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 10,
                    "character": 1
                },
                "end": {
                    "line": 10,
                    "character": 6
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 9,
                    "character": 8
                },
                "end": {
                    "line": 10,
                    "character": 0
                }
            },
            "rangeLength": 1,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 8,
                    "character": 27
                },
                "end": {
                    "line": 9,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 7,
                    "character": 7
                },
                "end": {
                    "line": 8,
                    "character": 8
                }
            },
            "rangeLength": 9,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 6,
                    "character": 16
                },
                "end": {
                    "line": 7,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        }
    ]
}


[Trace - 11:46:33 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json",
        "version": 17
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 306,
                    "character": 16
                },
                "end": {
                    "line": 307,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 305,
                    "character": 16
                },
                "end": {
                    "line": 306,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 303,
                    "character": 16
                },
                "end": {
                    "line": 304,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 302,
                    "character": 12
                },
                "end": {
                    "line": 303,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 300,
                    "character": 16
                },
                "end": {
                    "line": 301,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 299,
                    "character": 16
                },
                "end": {
                    "line": 300,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 297,
                    "character": 16
                },
                "end": {
                    "line": 298,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 296,
                    "character": 19
                },
                "end": {
                    "line": 297,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 293,
                    "character": 15
                },
                "end": {
                    "line": 294,
                    "character": 2
                }
            },
            "rangeLength": 3,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 292,
                    "character": 19
                },
                "end": {
                    "line": 293,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 38,
                    "character": 33
                },
                "end": {
                    "line": 39,
                    "character": 2
                }
            },
            "rangeLength": 3,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 38,
                    "character": 1
                },
                "end": {
                    "line": 38,
                    "character": 4
                }
            },
            "rangeLength": 3,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 37,
                    "character": 21
                },
                "end": {
                    "line": 38,
                    "character": 0
                }
            },
            "rangeLength": 1,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 36,
                    "character": 13
                },
                "end": {
                    "line": 37,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 12,
                    "character": 7
                },
                "end": {
                    "line": 13,
                    "character": 4
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 11,
                    "character": 18
                },
                "end": {
                    "line": 12,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 10,
                    "character": 7
                },
                "end": {
                    "line": 11,
                    "character": 8
                }
            },
            "rangeLength": 9,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 10,
                    "character": 1
                },
                "end": {
                    "line": 10,
                    "character": 6
                }
            },
            "rangeLength": 5,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 9,
                    "character": 8
                },
                "end": {
                    "line": 10,
                    "character": 0
                }
            },
            "rangeLength": 1,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 8,
                    "character": 27
                },
                "end": {
                    "line": 9,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 7,
                    "character": 7
                },
                "end": {
                    "line": 8,
                    "character": 8
                }
            },
            "rangeLength": 9,
            "text": ""
        },
        {
            "range": {
                "start": {
                    "line": 6,
                    "character": 16
                },
                "end": {
                    "line": 7,
                    "character": 6
                }
            },
            "rangeLength": 7,
            "text": ""
        }
    ]
}


[Trace - 11:46:33 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "<redacted>/package.json",
    "diagnostics": [],
    "version": 17
}


[Trace - 11:46:33 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "<redacted>/package.json",
    "diagnostics": [],
    "version": 17
}


[Trace - 11:46:33 PM] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json"
    }
}


[Trace - 11:46:33 PM] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json"
    }
}


[Trace - 11:46:33 PM] Sending request 'textDocument/codeAction - (68)'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json"
    },
    "range": {
        "start": {
            "line": 19,
            "character": 26
        },
        "end": {
            "line": 19,
            "character": 26
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 11:46:33 PM] Sending request 'textDocument/codeAction - (64)'.
Params: {
    "textDocument": {
        "uri": "<redacted>/package.json"
    },
    "range": {
        "start": {
            "line": 19,
            "character": 26
        },
        "end": {
            "line": 19,
            "character": 26
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 11:46:33 PM] Received response 'textDocument/codeAction - (68)' in 1ms.
Result: []


[Trace - 11:46:33 PM] Received response 'textDocument/codeAction - (64)' in 1ms.
Result: []


Came here with a question about jsonc support. It seems to have been working and I came back to a project today to see it's formatting using the default settings. Changing jsonc back to json fixed the issue, but alludes to the extension not reading from that config and falling back to defaults(?)

Came here with a question about jsonc support. It seems to have been working and I came back to a project today to see it's formatting using the default settings. Changing jsonc back to json fixed the issue, but alludes to the extension not reading from that config and falling back to defaults(?)

Just to make sure, you're talking about biome.jsonc, not formatting .jsonc files, is that correct?

@Sec-ant yes, I have a biome.jsonc and VSCode formats with biome, but not with my configuration from the jsonc file