Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 3 tasks
JavaScriptBach opened this issue Jun 7, 2024 · 6 comments
Closed
1 of 3 tasks

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

JavaScriptBach opened this issue Jun 7, 2024 · 6 comments
Labels
Needs reproduction Needs a reproduction Triage

Comments

@JavaScriptBach
Copy link

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: []


@josefaidt
Copy link

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(?)

@Sec-ant
Copy link
Member

Sec-ant commented Jun 13, 2024

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?

@josefaidt
Copy link

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

@nhedger
Copy link
Member

nhedger commented Jul 17, 2024

@josefaidt Sorry for the late reply. Would you be able to provide a minimal reproduction repository ?

@nhedger nhedger added Triage Needs reproduction Needs a reproduction and removed Triage labels Jul 17, 2024
@josefaidt
Copy link

Hey @nhedger no worries! I made a quick reproduction to find it's no longer occurring! Not sure if this was related to some other extension or my project itself but I'm good to go! https://github.com/josefaidt/repro-biome-jsonc

@nhedger
Copy link
Member

nhedger commented Jul 22, 2024

Ah! Thanks for taking the time!

@nhedger nhedger closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs reproduction Needs a reproduction Triage
Projects
None yet
Development

No branches or pull requests

4 participants