Skip to content

Commit

Permalink
chore: change LSP and VSCode extension diagnostics (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Aug 18, 2023
1 parent cfef948 commit 0edaece
Show file tree
Hide file tree
Showing 136 changed files with 1,243 additions and 992 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/website_deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ jobs:
working-directory: website
run: pnpm build:js
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod
working-directory: website
26 changes: 15 additions & 11 deletions crates/rome_analyze/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,34 @@ impl ActionCategory {
/// Returns the representation of this [ActionCategory] as a `CodeActionKind` string
pub fn to_str(&self) -> Cow<'static, str> {
match self {
ActionCategory::QuickFix => Cow::Borrowed("quickfix.rome"),
ActionCategory::QuickFix => Cow::Borrowed("quickfix.biome"),

ActionCategory::Refactor(RefactorKind::None) => Cow::Borrowed("refactor.rome"),
ActionCategory::Refactor(RefactorKind::None) => Cow::Borrowed("refactor.biome"),
ActionCategory::Refactor(RefactorKind::Extract) => {
Cow::Borrowed("refactor.extract.rome")
Cow::Borrowed("refactor.extract.biome")
}
ActionCategory::Refactor(RefactorKind::Inline) => {
Cow::Borrowed("refactor.inline.biome")
}
ActionCategory::Refactor(RefactorKind::Inline) => Cow::Borrowed("refactor.inline.rome"),
ActionCategory::Refactor(RefactorKind::Rewrite) => {
Cow::Borrowed("refactor.rewrite.rome")
Cow::Borrowed("refactor.rewrite.biome")
}
ActionCategory::Refactor(RefactorKind::Other(tag)) => {
Cow::Owned(format!("refactor.{tag}.rome"))
Cow::Owned(format!("refactor.{tag}.biome"))
}

ActionCategory::Source(SourceActionKind::None) => Cow::Borrowed("source.rome"),
ActionCategory::Source(SourceActionKind::FixAll) => Cow::Borrowed("source.fixAll.rome"),
ActionCategory::Source(SourceActionKind::None) => Cow::Borrowed("source.biome"),
ActionCategory::Source(SourceActionKind::FixAll) => {
Cow::Borrowed("source.fixAll.biome")
}
ActionCategory::Source(SourceActionKind::OrganizeImports) => {
Cow::Borrowed("source.organizeImports.rome")
Cow::Borrowed("source.organizeImports.biome")
}
ActionCategory::Source(SourceActionKind::Other(tag)) => {
Cow::Owned(format!("source.{tag}.rome"))
Cow::Owned(format!("source.{tag}.biome"))
}

ActionCategory::Other(tag) => Cow::Owned(format!("{tag}.rome")),
ActionCategory::Other(tag) => Cow::Owned(format!("{tag}.biome")),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_cli/src/commands/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) {

impl LoggingFilter {
fn is_enabled(&self, meta: &Metadata<'_>) -> bool {
let filter = if meta.target().starts_with("rome") {
let filter = if meta.target().starts_with("biome") {
SELF_FILTER
} else {
LevelFilter::INFO
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_cli/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn command_name() -> String {
current_exe()
.ok()
.and_then(|path| Some(path.file_name()?.to_str()?.to_string()))
.unwrap_or_else(|| String::from("rome"))
.unwrap_or_else(|| String::from("biome"))
}

/// A diagnostic that is emitted when running rome via CLI.
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_cli/tests/snap_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn redact_snapshot(input: &str) -> Cow<'_, str> {
.and_then(|path| Some(path.file_name()?.to_str()?.to_string()));

if let Some(current_exe) = current_exe {
replace(&mut output, &current_exe, "rome");
replace(&mut output, &current_exe, "biome");
}

output = replace_temp_dir(output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ flags/invalid ━━━━━━━━━━━━━━━━━━━━━━
i Type the following command for more information
$ rome format --help
$ biome format --help
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_lsp/src/extension_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use serde_json::{Error, Value};
use tracing::trace;

pub(crate) const CONFIGURATION_SECTION: &str = "rome";
pub(crate) const CONFIGURATION_SECTION: &str = "biome";

#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_lsp/src/handlers/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub(crate) fn code_actions(
.actions
.into_iter()
.filter_map(|action| {
if action.category.matches("source.organizeImports.rome")
if action.category.matches("source.organizeImports.biome")
&& !file_features.supports_for(&FeatureName::OrganizeImports)
{
return None;
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_lsp/src/requests/syntax_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use tower_lsp::lsp_types::{TextDocumentIdentifier, Url};
use tracing::info;

pub const SYNTAX_TREE_REQUEST: &str = "rome_lsp/syntaxTree";
pub const SYNTAX_TREE_REQUEST: &str = "biome_lsp/syntaxTree";

#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_lsp/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub(crate) fn diagnostic_to_lsp<D: Diagnostic>(
span,
Some(severity),
code,
Some("rome".into()),
Some("biome".into()),
message,
related_information,
tags,
Expand Down
14 changes: 7 additions & 7 deletions crates/rome_lsp/tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ async fn pull_diagnostics() -> Result<()> {
code_description: Some(CodeDescription {
href: Url::parse("https://biomejs.dev/lint/rules/noDoubleEquals").unwrap()
}),
source: Some(String::from("rome")),
source: Some(String::from("biome")),
message: String::from(
"Use === instead of ==.\n== is only allowed when comparing against `null`",
),
Expand Down Expand Up @@ -636,7 +636,7 @@ fn fixable_diagnostic(line: u32) -> Result<lsp::Diagnostic> {
"lint/suspicious/noCompareNegZero",
))),
code_description: None,
source: Some(String::from("rome")),
source: Some(String::from("biome")),
message: String::from("Do not use the === operator to compare against -0."),
related_information: None,
tags: None,
Expand Down Expand Up @@ -714,7 +714,7 @@ async fn pull_quick_fixes() -> Result<()> {
let expected_code_action = lsp::CodeActionOrCommand::CodeAction(lsp::CodeAction {
title: String::from("Replace -0 with 0"),
kind: Some(lsp::CodeActionKind::new(
"quickfix.rome.suspicious.noCompareNegZero",
"quickfix.biome.suspicious.noCompareNegZero",
)),
diagnostics: Some(vec![fixable_diagnostic(0)?]),
edit: Some(lsp::WorkspaceEdit {
Expand Down Expand Up @@ -751,7 +751,7 @@ async fn pull_quick_fixes() -> Result<()> {
let expected_suppression_action = lsp::CodeActionOrCommand::CodeAction(lsp::CodeAction {
title: String::from("Suppress rule lint/suspicious/noCompareNegZero"),
kind: Some(lsp::CodeActionKind::new(
"quickfix.suppressRule.rome.suspicious.noCompareNegZero",
"quickfix.suppressRule.biome.suspicious.noCompareNegZero",
)),
diagnostics: Some(vec![fixable_diagnostic(0)?]),
edit: Some(lsp::WorkspaceEdit {
Expand Down Expand Up @@ -824,7 +824,7 @@ async fn pull_diagnostics_for_rome_json() -> Result<()> {
severity: Some(lsp::DiagnosticSeverity::ERROR),
code: Some(lsp::NumberOrString::String(String::from("deserialize",))),
code_description: None,
source: Some(String::from("rome")),
source: Some(String::from("biome")),
message: String::from("Found an unknown value `magic`.",),
related_information: None,
tags: None,
Expand Down Expand Up @@ -1014,7 +1014,7 @@ async fn pull_refactors() -> Result<()> {
let _expected_action = lsp::CodeActionOrCommand::CodeAction(lsp::CodeAction {
title: String::from("Inline variable"),
kind: Some(lsp::CodeActionKind::new(
"refactor.inline.rome.correctness.inlineVariable",
"refactor.inline.biome.correctness.inlineVariable",
)),
diagnostics: None,
edit: Some(lsp::WorkspaceEdit {
Expand Down Expand Up @@ -1114,7 +1114,7 @@ async fn pull_fix_all() -> Result<()> {

let expected_action = lsp::CodeActionOrCommand::CodeAction(lsp::CodeAction {
title: String::from("Fix all auto-fixable issues"),
kind: Some(lsp::CodeActionKind::new("source.fixAll.rome")),
kind: Some(lsp::CodeActionKind::new("source.fixAll.biome")),
diagnostics: Some(vec![
fixable_diagnostic(0)?,
fixable_diagnostic(1)?,
Expand Down
36 changes: 18 additions & 18 deletions editors/vscode/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rome VS Code Extension
# Biome VS Code Extension

[Rome](https://biome.tools/) unifies your development stack by combining the functionality of separate tools. It uses a single configuration file, has fantastic performance, and works with any stack. This extension brings Rome to your editor so that you can:
[Biome](https://biome.tools/) unifies your development stack by combining the functionality of separate tools. It uses a single configuration file, has fantastic performance, and works with any stack. This extension brings Biome to your editor so that you can:

- Format files *on save* or when issuing the *Format Document* command
- See lints while you type and apply code fixes
Expand All @@ -17,14 +17,14 @@ You can install the code extension by heading to the extension's [Visual Studio

### Default Formatter

Configure Rome as the default formatter for supported files to ensure that VS Code uses Rome over other formatters that you may have installed. You can do so by opening a JavaScript or TypeScript and then:
Configure Biome as the default formatter for supported files to ensure that VS Code uses Biome over other formatters that you may have installed. You can do so by opening a JavaScript or TypeScript and then:

- Open the Command Palette (<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd> or View → Command Palette)
- Select _Format Document With…_
- Select _Configure Default Formatter…_
- Select Rome
- Select Biome

You can also enable Rome for specific languages only:
You can also enable Biome for specific languages only:

- [Open the `settings.json`](https://code.visualstudio.com/docs/getstarted/settings#_settingsjson): open the _Command Palette_(<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd>) and select _Preferences: Open User Settings (JSON)_
- And set the `editor.defaultFormatter` to `biomejs.biome` for the desired language
Expand All @@ -38,19 +38,19 @@ You can also enable Rome for specific languages only:
}
```

This configuration sets Rome as the default formatter for JavaScript files. All other files will be formatted using `<other formatter>`
This configuration sets Biome as the default formatter for JavaScript files. All other files will be formatted using `<other formatter>`

## Configuration Resolution

The extension automatically loads the `rome.json` file from the workspace’s root directory.
The extension automatically loads the `Biome.json` file from the workspace’s root directory.

## Rome Resolution
## Biome Resolution

The extension tries to use Rome from your project's local dependencies (`node_modules/rome`). We recommend adding Rome as a project dependency to ensure that NPM scripts and the extension use the same Rome version.
The extension tries to use Biome from your project's local dependencies (`node_modules/Biome`). We recommend adding Biome as a project dependency to ensure that NPM scripts and the extension use the same Biome version.

You can also explicitly specify the `rome` binary the extension should use by configuring the `biome.lspBin` setting in your editor options.
You can also explicitly specify the `Biome` binary the extension should use by configuring the `biome.lspBin` setting in your editor options.

If the project has no dependency on Rome and no explicit path is configured, the extension uses the Rome version included in its bundle.
If the project has no dependency on Biome and no explicit path is configured, the extension uses the Biome version included in its bundle.

## Usage

Expand All @@ -62,22 +62,22 @@ To format a text range, select the text you want to format, open the _Command Pa

### Format on save

Rome respects VS Code's _Format on Save_ setting. To enable format on save, open the settings (_File_ -> _Preferences_ -> _Settings_), search for `editor.formatOnSave`, and enable the option.
Biome respects VS Code's _Format on Save_ setting. To enable format on save, open the settings (_File_ -> _Preferences_ -> _Settings_), search for `editor.formatOnSave`, and enable the option.

### Fix on save

Rome respects VS Code's _Code Actions On Save_ setting. To enable fix on save, add `"editor.codeActionsOnSave": { "quickfix.rome": true }` in vscode settings.json.
Biome respects VS Code's _Code Actions On Save_ setting. To enable fix on save, add `"editor.codeActionsOnSave": { "quickfix.Biome": true }` in vscode settings.json.

### Imports Sorting [Experimental]

The Rome VS Code extension has experimental support for imports sorting through the "Organize Imports" code action. By default this action can be run using the <kbd title="Shift">⇧</kbd>+<kbd>Alt</kbd>+<kbd>O</kbd> keyboard shortcut, or is accessible through the _Command Palette_ (<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd>) by selecting _Organize Imports_.
The Biome VS Code extension has experimental support for imports sorting through the "Organize Imports" code action. By default this action can be run using the <kbd title="Shift">⇧</kbd>+<kbd>Alt</kbd>+<kbd>O</kbd> keyboard shortcut, or is accessible through the _Command Palette_ (<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd>) by selecting _Organize Imports_.

You can add the following to your editor configuration if you want the action to run automatically on save instead of calling it manually:

```json
{
"editor.codeActionsOnSave":{
"source.organizeImports.rome": true
"source.organizeImports.Biome": true
}
}
```
Expand All @@ -86,15 +86,15 @@ You can add the following to your editor configuration if you want the action to

### `biome.lspBin`

The `biome.lspBin` option overrides the Rome binary used by the extension. The workspace folder is used as the base path if the path is relative.
The `biome.lspBin` option overrides the Biome binary used by the extension. The workspace folder is used as the base path if the path is relative.

### `biome.rename`

Enables Rome to handle renames in the workspace (experimental).
Enables Biome to handle renames in the workspace (experimental).

### `biome.requireConfiguration`

Disables formatting, linting, and syntax errors for projects without a `rome.json` file. Requires Rome 12 or newer.
Disables formatting, linting, and syntax errors for projects without a `Biome.json` file. Requires Biome 12 or newer.
Enabled by default.

## Versioning
Expand Down
Binary file modified editors/vscode/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0edaece

Please sign in to comment.