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

🐛 Biome applies unsafe fixes inside liveshares #119

Open
gustaferiksson opened this issue Feb 8, 2024 · 4 comments
Open

🐛 Biome applies unsafe fixes inside liveshares #119

gustaferiksson opened this issue Feb 8, 2024 · 4 comments
Labels
Bug confirmed Report has been confirmed as a valid bug Help wanted External contributions are welcome

Comments

@gustaferiksson
Copy link

It seems that biome applies unsafe fixes when working in virtual workspaces, at least when working inside liveshares.

Here is a reproducible example. https://github.com/gustaferiksson/biome-unsafe

If I start a liveshare in that repo and share it with myself (in a new vscode window), and save index.ts, biome will apply the unsafe fixes.

My vscode settings has the following related to biome

  "editor.formatOnSave": true,
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "editor.codeActionsOnSave": {
    "quickfix.biome": "explicit",
    "source.organizeImports.biome": "explicit"
  },
  "biome.lspBin": "./node_modules/@biomejs/biome/bin/biome",

Here is the Output from the Biome Trace that applies the unsafe fixes

[Trace - 10:55:20 AM] Sending request 'textDocument/codeAction - (24)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 15
                    },
                    "end": {
                        "line": 2,
                        "character": 35
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "'unused' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "only": [
            "quickfix.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/codeAction - (24)' in 2ms.
Result: []


[Trace - 10:55:20 AM] Sending request 'textDocument/codeAction - (25)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 15
                    },
                    "end": {
                        "line": 2,
                        "character": 35
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "'unused' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "only": [
            "source.organizeImports.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/codeAction - (25)' in 2ms.
Result: []


[Trace - 10:55:20 AM] Sending request 'textDocument/formatting - (26)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "options": {
        "tabSize": 2,
        "insertSpaces": true
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/formatting - (26)' in 1ms.
Result: [
    {
        "newText": "// const unused = `hello`\n\nconst unused = `hellothereklajsdjk`\n",
        "range": {
            "end": {
                "character": 0,
                "line": 4
            },
            "start": {
                "character": 0,
                "line": 0
            }
        }
    }
]


[Trace - 10:55:20 AM] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    }
}


[Trace - 10:55:20 AM] Sending request 'textDocument/codeAction - (27)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 15
                    },
                    "end": {
                        "line": 2,
                        "character": 35
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "'unused' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "triggerKind": 1
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/codeAction - (27)' in 3ms.
Result: [
    {
        "diagnostics": [
            {
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "range": {
                    "end": {
                        "character": 35,
                        "line": 2
                    },
                    "start": {
                        "character": 15,
                        "line": 2
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts": [
                    {
                        "newText": "\"",
                        "range": {
                            "end": {
                                "character": 16,
                                "line": 2
                            },
                            "start": {
                                "character": 15,
                                "line": 2
                            }
                        }
                    },
                    {
                        "newText": "\"",
                        "range": {
                            "end": {
                                "character": 35,
                                "line": 2
                            },
                            "start": {
                                "character": 34,
                                "line": 2
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.biome.style.noUnusedTemplateLiteral",
        "title": "Replace with string literal"
    },
    {
        "diagnostics": [
            {
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "range": {
                    "end": {
                        "character": 35,
                        "line": 2
                    },
                    "start": {
                        "character": 15,
                        "line": 2
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts": [
                    {
                        "newText": "// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>\n",
                        "range": {
                            "end": {
                                "character": 0,
                                "line": 2
                            },
                            "start": {
                                "character": 0,
                                "line": 2
                            }
                        }
                    },
                    {
                        "newText": "  ",
                        "range": {
                            "end": {
                                "character": 6,
                                "line": 2
                            },
                            "start": {
                                "character": 5,
                                "line": 2
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.suppressRule.biome.style.noUnusedTemplateLiteral",
        "title": "Suppress rule lint/style/noUnusedTemplateLiteral"
    },
    {
        "diagnostics": [
            {
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "message": "This variable is unused.",
                "range": {
                    "end": {
                        "character": 12,
                        "line": 2
                    },
                    "start": {
                        "character": 6,
                        "line": 2
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts": [
                    {
                        "newText": "_unused",
                        "range": {
                            "end": {
                                "character": 12,
                                "line": 2
                            },
                            "start": {
                                "character": 6,
                                "line": 2
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.biome.correctness.noUnusedVariables",
        "title": "If this is intentional, prepend unused with an underscore."
    },
    {
        "diagnostics": [
            {
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "message": "This variable is unused.",
                "range": {
                    "end": {
                        "character": 12,
                        "line": 2
                    },
                    "start": {
                        "character": 6,
                        "line": 2
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts": [
                    {
                        "newText": "// biome-ignore lint/correctness/noUnusedVariables: <explanation>\n",
                        "range": {
                            "end": {
                                "character": 0,
                                "line": 2
                            },
                            "start": {
                                "character": 0,
                                "line": 2
                            }
                        }
                    },
                    {
                        "newText": "  ",
                        "range": {
                            "end": {
                                "character": 6,
                                "line": 2
                            },
                            "start": {
                                "character": 5,
                                "line": 2
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.suppressRule.biome.correctness.noUnusedVariables",
        "title": "Suppress rule lint/correctness/noUnusedVariables"
    }
]


[Trace - 10:55:20 AM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts",
        "version": 14
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 34
                },
                "end": {
                    "line": 2,
                    "character": 35
                }
            },
            "rangeLength": 1,
            "text": "\""
        },
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 15
                },
                "end": {
                    "line": 2,
                    "character": 16
                }
            },
            "rangeLength": 1,
            "text": "\""
        }
    ]
}


[Trace - 10:55:20 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [
        {
            "code": "lint/correctness/noUnusedVariables",
            "codeDescription": {
                "href": "https://biomejs.dev/linter/rules/no-unused-variables"
            },
            "message": "This variable is unused.",
            "range": {
                "end": {
                    "character": 12,
                    "line": 2
                },
                "start": {
                    "character": 6,
                    "line": 2
                }
            },
            "severity": 1,
            "source": "biome"
        }
    ],
    "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts",
    "version": 14
}


[Trace - 10:55:20 AM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts",
        "version": 15
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 6
                },
                "end": {
                    "line": 2,
                    "character": 6
                }
            },
            "rangeLength": 0,
            "text": "_"
        }
    ]
}


[Trace - 10:55:20 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [],
    "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts",
    "version": 15
}


[Trace - 10:55:20 AM] Sending request 'textDocument/codeAction - (28)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/gustaf/Repos/Gustaf/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 3,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 6
                    },
                    "end": {
                        "line": 2,
                        "character": 12
                    }
                },
                "message": "'unused' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "triggerKind": 1
    }
}


[Trace - 10:55:20 AM] Received response 'textDocument/codeAction - (28)' in 1ms.
Result: []

@ematipico
Copy link
Member

Can you share the output of biome rage --daemon-logs?

Check the logs first, make sure there's no sensitive information you don't want to share.

Also, does that mean Biome works as expected when you don't do a live share of the project?

@gustaferiksson
Copy link
Author

I will get back to you during the day with the logs

Yes biome works as expected when I don't have a liveshare active, it also seems to work when a liveshare is started and no one has joined yet.

@gustaferiksson
Copy link
Author

@ematipico here is the logs

biome logs.txt

@nhedger
Copy link
Member

nhedger commented Feb 11, 2024

I was able to reproduce the issue.

When both you and the remote participant are connected to the live share session, the host saving the file does not apply the unsafe fixes, as expected. However, as soon as the guest participant saves the file, now both participants will trigger unsafe fixes when saving.

Terminating the liveshare session stops the issue from happening.


Comparing the trace output between a standard session and a liveshare session shows that liveshare session use context.triggerKind = 1, while standard session use context.triggerKind = 2. Not exactly sure what it means at this point, but I'll dig in.

From the LSP docs:

/**
 * The reason why code actions were requested.
 *
 * @since 3.17.0
 */
export namespace [CodeActionTriggerKind](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionTriggerKind) {
	/**
	 * Code actions were explicitly requested by the user or by an extension.
	 */
	export const Invoked: 1 = 1;

	/**
	 * Code actions were requested automatically.
	 *
	 * This typically happens when current selection in a file changes, but can
	 * also be triggered when file content changes.
	 */
	export const Automatic: 2 = 2;
}

export type [CodeActionTriggerKind](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionTriggerKind) = 1 | 2;
liveshare off
[Trace - 11:12:51] Sending request 'textDocument/codeAction - (70)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 1,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "'a' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            },
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 10
                    },
                    "end": {
                        "line": 0,
                        "character": 13
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "only": [
            "quickfix.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 11:12:51] Received response 'textDocument/codeAction - (70)' in 3ms.
Result: []


[Trace - 11:12:51] Sending request 'textDocument/codeAction - (71)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 1,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "'a' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            },
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 10
                    },
                    "end": {
                        "line": 0,
                        "character": 13
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "only": [
            "source.organizeImports.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 11:12:51] Received response 'textDocument/codeAction - (71)' in 2ms.
Result: []


[Trace - 11:12:51] Sending request 'textDocument/formatting - (72)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "options": {
        "tabSize": 4,
        "insertSpaces": true
    }
}


[Trace - 11:12:51] Received response 'textDocument/formatting - (72)' in 0ms.
Result: [
    {
        "newText": "const a = `b`\n",
        "range": {
            "end": {
                "character": 0,
                "line": 2
            },
            "start": {
                "character": 0,
                "line": 0
            }
        }
    }
]


[Trace - 11:12:51] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    }
}


[Trace - 11:12:52] Sending request 'textDocument/codeAction - (73)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}
liveshare on
[Trace - 11:11:44] Sending request 'textDocument/codeAction - (50)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 1,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "'a' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            },
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 10
                    },
                    "end": {
                        "line": 0,
                        "character": 13
                    }
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "severity": 1,
                "source": "biome"
            },
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "This variable is unused.",
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "triggerKind": 1
    }
}


[Trace - 11:11:44] Received response 'textDocument/codeAction - (50)' in 6ms.
Result: [
    {
        "diagnostics": [
            {
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "range": {
                    "end": {
                        "character": 13,
                        "line": 0
                    },
                    "start": {
                        "character": 10,
                        "line": 0
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/nicolas/code/repro/biome-unsafe/index.ts": [
                    {
                        "newText": "\"",
                        "range": {
                            "end": {
                                "character": 11,
                                "line": 0
                            },
                            "start": {
                                "character": 10,
                                "line": 0
                            }
                        }
                    },
                    {
                        "newText": "\"",
                        "range": {
                            "end": {
                                "character": 13,
                                "line": 0
                            },
                            "start": {
                                "character": 12,
                                "line": 0
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.biome.style.noUnusedTemplateLiteral",
        "title": "Replace with string literal"
    },
    {
        "diagnostics": [
            {
                "code": "lint/style/noUnusedTemplateLiteral",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-template-literal"
                },
                "message": "Do not use template literals if interpolation and special-character handling are not needed.",
                "range": {
                    "end": {
                        "character": 13,
                        "line": 0
                    },
                    "start": {
                        "character": 10,
                        "line": 0
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/nicolas/code/repro/biome-unsafe/index.ts": [
                    {
                        "newText": "// biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>\n",
                        "range": {
                            "end": {
                                "character": 0,
                                "line": 0
                            },
                            "start": {
                                "character": 0,
                                "line": 0
                            }
                        }
                    },
                    {
                        "newText": "  ",
                        "range": {
                            "end": {
                                "character": 6,
                                "line": 0
                            },
                            "start": {
                                "character": 5,
                                "line": 0
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.suppressRule.biome.style.noUnusedTemplateLiteral",
        "title": "Suppress rule lint/style/noUnusedTemplateLiteral"
    },
    {
        "diagnostics": [
            {
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "message": "This variable is unused.",
                "range": {
                    "end": {
                        "character": 7,
                        "line": 0
                    },
                    "start": {
                        "character": 6,
                        "line": 0
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/nicolas/code/repro/biome-unsafe/index.ts": [
                    {
                        "newText": "_a",
                        "range": {
                            "end": {
                                "character": 7,
                                "line": 0
                            },
                            "start": {
                                "character": 6,
                                "line": 0
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.biome.correctness.noUnusedVariables",
        "title": "If this is intentional, prepend a with an underscore."
    },
    {
        "diagnostics": [
            {
                "code": "lint/correctness/noUnusedVariables",
                "codeDescription": {
                    "href": "https://biomejs.dev/linter/rules/no-unused-variables"
                },
                "message": "This variable is unused.",
                "range": {
                    "end": {
                        "character": 7,
                        "line": 0
                    },
                    "start": {
                        "character": 6,
                        "line": 0
                    }
                },
                "severity": 1,
                "source": "biome"
            }
        ],
        "edit": {
            "changes": {
                "file:///Users/nicolas/code/repro/biome-unsafe/index.ts": [
                    {
                        "newText": "// biome-ignore lint/correctness/noUnusedVariables: <explanation>\n",
                        "range": {
                            "end": {
                                "character": 0,
                                "line": 0
                            },
                            "start": {
                                "character": 0,
                                "line": 0
                            }
                        }
                    },
                    {
                        "newText": "  ",
                        "range": {
                            "end": {
                                "character": 6,
                                "line": 0
                            },
                            "start": {
                                "character": 5,
                                "line": 0
                            }
                        }
                    }
                ]
            }
        },
        "kind": "quickfix.suppressRule.biome.correctness.noUnusedVariables",
        "title": "Suppress rule lint/correctness/noUnusedVariables"
    }
]


[Trace - 11:11:44] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts",
        "version": 33
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 12
                },
                "end": {
                    "line": 0,
                    "character": 13
                }
            },
            "rangeLength": 1,
            "text": "\""
        },
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 10
                },
                "end": {
                    "line": 0,
                    "character": 11
                }
            },
            "rangeLength": 1,
            "text": "\""
        }
    ]
}


[Trace - 11:11:44] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [
        {
            "code": "lint/correctness/noUnusedVariables",
            "codeDescription": {
                "href": "https://biomejs.dev/linter/rules/no-unused-variables"
            },
            "message": "This variable is unused.",
            "range": {
                "end": {
                    "character": 7,
                    "line": 0
                },
                "start": {
                    "character": 6,
                    "line": 0
                }
            },
            "severity": 1,
            "source": "biome"
        }
    ],
    "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts",
    "version": 33
}


[Trace - 11:11:44] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts",
        "version": 34
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 6
                },
                "end": {
                    "line": 0,
                    "character": 6
                }
            },
            "rangeLength": 0,
            "text": "_"
        }
    ]
}


[Trace - 11:11:44] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [],
    "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts",
    "version": 34
}


[Trace - 11:11:44] Sending request 'textDocument/codeAction - (51)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 1,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "'a' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "triggerKind": 1
    }
}


[Trace - 11:11:44] Received response 'textDocument/codeAction - (51)' in 3ms.
Result: []


[Trace - 11:11:44] Sending request 'textDocument/codeAction - (52)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 1,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "'a' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "only": [
            "quickfix.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 11:11:44] Received response 'textDocument/codeAction - (52)' in 1ms.
Result: []


[Trace - 11:11:44] Sending request 'textDocument/codeAction - (53)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 1,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 6
                    },
                    "end": {
                        "line": 0,
                        "character": 7
                    }
                },
                "message": "'a' is declared but its value is never read.",
                "code": 6133,
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "ts"
            }
        ],
        "only": [
            "source.organizeImports.biome"
        ],
        "triggerKind": 2
    }
}


[Trace - 11:11:44] Received response 'textDocument/codeAction - (53)' in 1ms.
Result: []


[Trace - 11:11:44] Sending request 'textDocument/formatting - (54)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "options": {
        "tabSize": 4,
        "insertSpaces": true
    }
}


[Trace - 11:11:44] Received response 'textDocument/formatting - (54)' in 1ms.
Result: [
    {
        "newText": "const _a = \"b\"\n",
        "range": {
            "end": {
                "character": 0,
                "line": 2
            },
            "start": {
                "character": 0,
                "line": 0
            }
        }
    }
]


[Trace - 11:11:44] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    }
}


[Trace - 11:11:44] Sending request 'textDocument/codeAction - (55)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 1
    }
}


[Trace - 11:11:44] Received response 'textDocument/codeAction - (55)' in 3ms.
Result: []


[Trace - 11:11:45] Sending request 'textDocument/codeAction - (56)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/nicolas/code/repro/biome-unsafe/index.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 1
    }
}


[Trace - 11:11:45] Received response 'textDocument/codeAction - (56)' in 5ms.
Result: []

@nhedger nhedger added Bug confirmed Report has been confirmed as a valid bug Help wanted External contributions are welcome labels Feb 11, 2024
@nhedger nhedger changed the title Biome applies unsafe fixes inside liveshares 🐛 Biome applies unsafe fixes inside liveshares Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug confirmed Report has been confirmed as a valid bug Help wanted External contributions are welcome
Projects
None yet
Development

No branches or pull requests

3 participants