From 70542df7066b5a38cf689fd6ba3a667951b6fbba Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 25 Oct 2024 13:17:01 +0100 Subject: [PATCH] feat(workspace): make types camel case (#4368) Co-authored-by: Arend van Beelen jr --- .changeset/use_new_workspace_apis.md | 8 ++ crates/biome_analyze/src/categories.rs | 15 ++- crates/biome_css_syntax/src/file_source.rs | 2 + crates/biome_diagnostics/src/suggestion.rs | 1 + crates/biome_formatter/src/lib.rs | 3 +- crates/biome_fs/src/path.rs | 10 +- .../biome_graphql_syntax/src/file_source.rs | 2 + crates/biome_js_syntax/src/file_source.rs | 4 + crates/biome_json_syntax/src/file_source.rs | 1 + crates/biome_service/src/workspace.rs | 42 ++++++- knope.toml | 3 + .../@biomejs/backend-jsonrpc/src/workspace.ts | 116 +++++++++--------- .../backend-jsonrpc/tests/workspace.test.mjs | 12 +- packages/@biomejs/js-api/src/index.ts | 22 ++-- .../@biomejs/js-api/tests/lintContent.test.ts | 8 +- .../js-api/tests/printDiagnostics.test.ts | 4 +- packages/@biomejs/wasm-nodejs/package.json | 7 +- 17 files changed, 164 insertions(+), 96 deletions(-) create mode 100644 .changeset/use_new_workspace_apis.md diff --git a/.changeset/use_new_workspace_apis.md b/.changeset/use_new_workspace_apis.md new file mode 100644 index 000000000000..bdd37b3a6dfa --- /dev/null +++ b/.changeset/use_new_workspace_apis.md @@ -0,0 +1,8 @@ +--- +js-api: minor +cli: minor +--- + +# Use new Workspace APIs + +The package now requires `v2` of the WebAssembly packages. The internal APIs of Workspace are now `camelCase`. diff --git a/crates/biome_analyze/src/categories.rs b/crates/biome_analyze/src/categories.rs index 749a04203151..c70505e7200d 100644 --- a/crates/biome_analyze/src/categories.rs +++ b/crates/biome_analyze/src/categories.rs @@ -4,7 +4,8 @@ use std::borrow::Cow; #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[cfg_attr( feature = "serde", - derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) + derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema), + serde(rename_all = "camelCase") )] pub enum RuleCategory { /// This rule checks the syntax according to the language specification @@ -32,7 +33,8 @@ pub const SUPPRESSION_TOP_LEVEL_ACTION_CATEGORY: &str = "quickfix.suppressRule.t #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr( feature = "serde", - derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) + derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema), + serde(rename_all = "camelCase") )] pub enum ActionCategory { /// Base kind for quickfix actions: 'quickfix'. @@ -55,7 +57,8 @@ pub enum ActionCategory { #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr( feature = "serde", - derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) + derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema), + serde(rename_all = "camelCase") )] pub enum OtherActionCategory { /// Base kind for inline suppressions actions: `quickfix.suppressRule.inline.biome` @@ -139,7 +142,8 @@ impl ActionCategory { #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr( feature = "serde", - derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) + derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema), + serde(rename_all = "camelCase") )] pub enum RefactorKind { /// This action describes a refactor with no particular sub-category @@ -179,7 +183,8 @@ pub enum RefactorKind { #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr( feature = "serde", - derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) + derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema), + serde(rename_all = "camelCase") )] pub enum SourceActionKind { /// This action describes a source action with no particular sub-category diff --git a/crates/biome_css_syntax/src/file_source.rs b/crates/biome_css_syntax/src/file_source.rs index 03818ad50bf3..37f2acb4d6b7 100644 --- a/crates/biome_css_syntax/src/file_source.rs +++ b/crates/biome_css_syntax/src/file_source.rs @@ -6,6 +6,7 @@ use std::{ffi::OsStr, path::Path}; #[derive( Debug, Clone, Default, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, )] +#[serde(rename_all = "camelCase")] pub struct CssFileSource { // Unused until we potentially support postcss/less/sass #[allow(unused)] @@ -20,6 +21,7 @@ pub struct CssFileSource { #[derive( Debug, Clone, Default, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, )] +#[serde(rename_all = "camelCase")] enum CssVariant { #[default] Standard, diff --git a/crates/biome_diagnostics/src/suggestion.rs b/crates/biome_diagnostics/src/suggestion.rs index bf34945690ea..14110ad00645 100644 --- a/crates/biome_diagnostics/src/suggestion.rs +++ b/crates/biome_diagnostics/src/suggestion.rs @@ -6,6 +6,7 @@ use biome_text_edit::TextEdit; /// Indicates how a tool should manage this suggestion. #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub enum Applicability { /// The suggestion is definitely what the user intended. /// This suggestion should be automatically applied. diff --git a/crates/biome_formatter/src/lib.rs b/crates/biome_formatter/src/lib.rs index 685e285eb1fe..0d2f343ecd7e 100644 --- a/crates/biome_formatter/src/lib.rs +++ b/crates/biome_formatter/src/lib.rs @@ -837,7 +837,8 @@ pub type PrintResult = Result; #[derive(Debug, Clone, Eq, PartialEq)] #[cfg_attr( feature = "serde", - derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) + derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema), + serde(rename_all = "camelCase") )] pub struct Printed { code: String, diff --git a/crates/biome_fs/src/path.rs b/crates/biome_fs/src/path.rs index 041b03986713..a6bc6bc49f56 100644 --- a/crates/biome_fs/src/path.rs +++ b/crates/biome_fs/src/path.rs @@ -20,7 +20,8 @@ use std::{fs::File, io, io::Write, ops::Deref, path::PathBuf}; #[bitflags] #[cfg_attr( feature = "serde", - derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) + derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema), + serde(rename_all = "camelCase") )] // NOTE: The order of the variants is important, the one on the top has the highest priority pub enum FileKind { @@ -92,7 +93,8 @@ impl From for FileKinds { #[derive(Debug, Clone, Eq, PartialEq, Hash, Default)] #[cfg_attr( feature = "serde", - derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema) + derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema), + serde(rename_all = "camelCase") )] pub struct BiomePath { /// The path to the file @@ -400,7 +402,7 @@ mod test { #[test] #[cfg(feature = "serde")] fn deserialize_file_kind_from_str() { - let result = serde_json::from_str::("[\"Config\"]"); + let result = serde_json::from_str::("[\"config\"]"); assert!(result.is_ok()); let file_kinds = result.unwrap(); assert!(file_kinds.contains(FileKind::Config)); @@ -412,6 +414,6 @@ mod test { let file_kinds = FileKinds::from(FileKind::Config); let result = serde_json::to_string(&file_kinds); assert!(result.is_ok()); - assert_eq!(result.unwrap(), "[\"Config\"]"); + assert_eq!(result.unwrap(), "[\"config\"]"); } } diff --git a/crates/biome_graphql_syntax/src/file_source.rs b/crates/biome_graphql_syntax/src/file_source.rs index 87f6885dc8fc..00086acd1969 100644 --- a/crates/biome_graphql_syntax/src/file_source.rs +++ b/crates/biome_graphql_syntax/src/file_source.rs @@ -7,6 +7,7 @@ use std::path::Path; #[derive( Debug, Clone, Default, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, )] +#[serde(rename_all = "camelCase")] pub struct GraphqlFileSource { #[allow(unused)] variant: GraphqlVariant, @@ -17,6 +18,7 @@ pub struct GraphqlFileSource { #[derive( Debug, Clone, Default, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, )] +#[serde(rename_all = "camelCase")] enum GraphqlVariant { #[default] Standard, diff --git a/crates/biome_js_syntax/src/file_source.rs b/crates/biome_js_syntax/src/file_source.rs index 7d7bfd220c5a..1b7dcf329d1c 100644 --- a/crates/biome_js_syntax/src/file_source.rs +++ b/crates/biome_js_syntax/src/file_source.rs @@ -8,6 +8,7 @@ use std::{borrow::Cow, ffi::OsStr, path::Path}; /// Defaults to the latest stable ECMAScript standard. #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)] +#[serde(rename_all = "camelCase")] pub enum LanguageVersion { ES2022, @@ -34,6 +35,7 @@ impl Default for LanguageVersion { #[derive( Debug, Clone, Default, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, )] +#[serde(rename_all = "camelCase")] pub enum ModuleKind { /// An ECMAScript [Script](https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#sec-scripts) Script, @@ -56,6 +58,7 @@ impl ModuleKind { #[derive( Debug, Copy, Clone, Eq, PartialEq, Hash, Default, serde::Serialize, serde::Deserialize, )] +#[serde(rename_all = "camelCase")] pub enum LanguageVariant { /// Standard JavaScript or TypeScript syntax without any extensions #[default] @@ -84,6 +87,7 @@ impl LanguageVariant { #[derive( Debug, Copy, Clone, Eq, PartialEq, Default, Hash, serde::Serialize, serde::Deserialize, )] +#[serde(rename_all = "camelCase")] pub enum Language { #[default] JavaScript, diff --git a/crates/biome_json_syntax/src/file_source.rs b/crates/biome_json_syntax/src/file_source.rs index 14d6a198d283..3f3e0fa735a3 100644 --- a/crates/biome_json_syntax/src/file_source.rs +++ b/crates/biome_json_syntax/src/file_source.rs @@ -10,6 +10,7 @@ use std::{ #[derive( Debug, Clone, Default, Copy, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, )] +#[serde(rename_all = "camelCase")] pub struct JsonFileSource { allow_trailing_commas: bool, allow_comments: bool, diff --git a/crates/biome_service/src/workspace.rs b/crates/biome_service/src/workspace.rs index 2bd069861d36..9703c476c232 100644 --- a/crates/biome_service/src/workspace.rs +++ b/crates/biome_service/src/workspace.rs @@ -95,6 +95,7 @@ pub struct SupportsFeatureResult { #[derive(Debug, serde::Serialize, serde::Deserialize, Default, Clone, Eq, PartialEq)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct FileFeaturesResult { pub features_supported: HashMap, } @@ -373,6 +374,7 @@ impl SupportsFeatureResult { #[derive(Debug, serde::Serialize, serde::Deserialize, Eq, PartialEq, Clone)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub enum SupportKind { /// The feature is enabled for the file Supported, @@ -408,6 +410,7 @@ impl SupportKind { #[bitflags] #[repr(u8)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub enum FeatureKind { Format, Lint, @@ -420,7 +423,8 @@ pub enum FeatureKind { #[derive(Debug, Copy, Clone, Hash, serde::Serialize, serde::Deserialize, Eq, PartialEq)] #[serde( from = "smallvec::SmallVec<[FeatureKind; 6]>", - into = "smallvec::SmallVec<[FeatureKind; 6]>" + into = "smallvec::SmallVec<[FeatureKind; 6]>", + rename_all = "camelCase" )] pub struct FeatureName(BitFlags); @@ -505,6 +509,7 @@ impl FeaturesBuilder { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct UpdateSettingsParams { pub configuration: PartialConfiguration, // @ematipico TODO: have a better data structure for this @@ -516,6 +521,7 @@ pub struct UpdateSettingsParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct ProjectFeaturesParams { pub manifest_path: BiomePath, } @@ -526,6 +532,7 @@ pub struct ProjectFeaturesResult {} #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct OpenFileParams { pub path: BiomePath, pub content: String, @@ -534,6 +541,7 @@ pub struct OpenFileParams { } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct SetManifestForProjectParams { pub manifest_path: BiomePath, pub content: String, @@ -552,12 +560,14 @@ impl From<(BiomePath, String)> for SetManifestForProjectParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct GetSyntaxTreeParams { pub path: BiomePath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct GetSyntaxTreeResult { pub cst: String, pub ast: String, @@ -565,6 +575,7 @@ pub struct GetSyntaxTreeResult { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct GetControlFlowGraphParams { pub path: BiomePath, pub cursor: TextSize, @@ -578,12 +589,14 @@ pub struct GetFormatterIRParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct GetFileContentParams { pub path: BiomePath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct ChangeFileParams { pub path: BiomePath, pub content: String, @@ -592,12 +605,14 @@ pub struct ChangeFileParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct CloseFileParams { pub path: BiomePath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct PullDiagnosticsParams { pub path: BiomePath, pub categories: RuleCategories, @@ -608,6 +623,7 @@ pub struct PullDiagnosticsParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct PullDiagnosticsResult { pub diagnostics: Vec, pub errors: usize, @@ -616,6 +632,7 @@ pub struct PullDiagnosticsResult { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct PullActionsParams { pub path: BiomePath, pub range: Option, @@ -625,12 +642,14 @@ pub struct PullActionsParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct PullActionsResult { pub actions: Vec, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct CodeAction { pub category: ActionCategory, pub rule_name: Option<(Cow<'static, str>, Cow<'static, str>)>, @@ -639,12 +658,14 @@ pub struct CodeAction { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct FormatFileParams { pub path: BiomePath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct FormatRangeParams { pub path: BiomePath, pub range: TextRange, @@ -652,6 +673,7 @@ pub struct FormatRangeParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct FormatOnTypeParams { pub path: BiomePath, pub offset: TextSize, @@ -659,6 +681,7 @@ pub struct FormatOnTypeParams { #[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] /// Which fixes should be applied during the analyzing phase pub enum FixFileMode { /// Applies [safe](biome_diagnostics::Applicability::Always) fixes @@ -671,6 +694,7 @@ pub enum FixFileMode { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct FixFileParams { pub path: BiomePath, pub fix_file_mode: FixFileMode, @@ -682,6 +706,7 @@ pub struct FixFileParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct FixFileResult { /// New source code for the file with all fixes applied pub code: String, @@ -706,6 +731,7 @@ pub struct FixAction { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct RenameParams { pub path: BiomePath, pub symbol_at: TextSize, @@ -714,6 +740,7 @@ pub struct RenameParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct RenameResult { /// Range of source code modified by this rename operation pub range: TextRange, @@ -723,6 +750,7 @@ pub struct RenameResult { #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct ServerInfo { /// The name of the server as defined by the server. pub name: String, @@ -734,16 +762,19 @@ pub struct ServerInfo { #[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct RageParams {} #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct RageResult { pub entries: Vec, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub enum RageEntry { Section(String), Pair { name: String, value: MarkupBuf }, @@ -752,12 +783,14 @@ pub enum RageEntry { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct OrganizeImportsParams { pub path: BiomePath, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct OrganizeImportsResult { pub code: String, } @@ -785,18 +818,21 @@ impl RageEntry { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct ParsePatternParams { pub pattern: String, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct ParsePatternResult { pub pattern_id: PatternId, } #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct SearchPatternParams { pub path: BiomePath, pub pattern: PatternId, @@ -804,6 +840,7 @@ pub struct SearchPatternParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct SearchResults { pub file: BiomePath, pub matches: Vec, @@ -811,12 +848,14 @@ pub struct SearchResults { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct DropPatternParams { pub pattern: PatternId, } #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct PatternId(String); impl std::fmt::Display for PatternId { @@ -845,6 +884,7 @@ impl From<&str> for PatternId { #[derive(Debug, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] pub struct IsPathIgnoredParams { pub biome_path: BiomePath, pub features: FeatureName, diff --git a/knope.toml b/knope.toml index c6bea5437b69..1009dce90d99 100644 --- a/knope.toml +++ b/knope.toml @@ -22,6 +22,9 @@ versioned_files = [ "packages/@biomejs/backend-jsonrpc/package.json", ] +[packages.js-api] +changelog = "packages/@biomejs/js-api/CHANGELOG.md" +versioned_files = ["packages/@biomejs/js-api/package.json"] # Special crate. This is the main binary that we are going to release. [packages.biome_cli] diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index 6bb564b4dd23..8d190ff71636 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -17,33 +17,33 @@ export interface BiomePath { /** * Whether this path (usually a file) was fixed as a result of a format/lint/check command with the `--write` filag. */ - was_written: boolean; + wasWritten: boolean; } export type FeatureKind = - | "Format" - | "Lint" - | "OrganizeImports" - | "Search" - | "Assists" - | "Debug"; + | "format" + | "lint" + | "organizeImports" + | "search" + | "assists" + | "debug"; export type FileKind = FileKind2[]; /** * The priority of the file */ export type FileKind2 = - | "Config" - | "Manifest" - | "Ignore" - | "Inspectable" - | "Handleable"; + | "config" + | "manifest" + | "ignore" + | "inspectable" + | "handleable"; export interface FileFeaturesResult { - features_supported: {}; + featuresSupported: {}; } export interface UpdateSettingsParams { configuration: PartialConfiguration; - gitignore_matches: string[]; - vcs_base_path?: string; - workspace_directory?: string; + gitignoreMatches: string[]; + vcsBasePath?: string; + workspaceDirectory?: string; } /** * The configuration that is contained inside the file `biome.json` @@ -2668,12 +2668,12 @@ export interface RegisterProjectFolderParams { export type ProjectKey = string; export interface SetManifestForProjectParams { content: string; - manifest_path: BiomePath; + manifestPath: BiomePath; version: number; } export interface OpenFileParams { content: string; - document_file_source?: DocumentFileSource; + documentFileSource?: DocumentFileSource; path: BiomePath; version: number; } @@ -2696,8 +2696,8 @@ export interface JsFileSource { version: LanguageVersion; } export interface JsonFileSource { - allow_comments: boolean; - allow_trailing_commas: boolean; + allowComments: boolean; + allowTrailingCommas: boolean; } export interface CssFileSource { variant: CssVariant; @@ -2713,29 +2713,29 @@ export interface GritFileSource { } export type EmbeddingKind = "Astro" | "Vue" | "Svelte" | "None"; export type Language = - | "JavaScript" - | { TypeScript: { definition_file: boolean } }; + | "javaScript" + | { typeScript: { definition_file: boolean } }; /** * Is the source file an ECMAScript Module or Script. Changes the parsing semantic. */ -export type ModuleKind = "Script" | "Module"; -export type LanguageVariant = "Standard" | "StandardRestricted" | "Jsx"; +export type ModuleKind = "script" | "module"; +export type LanguageVariant = "standard" | "standardRestricted" | "jsx"; /** * Enum of the different ECMAScript standard versions. The versions are ordered in increasing order; The newest version comes last. Defaults to the latest stable ECMAScript standard. */ -export type LanguageVersion = "ES2022" | "ESNext"; +export type LanguageVersion = "eS2022" | "eSNext"; /** * The style of CSS contained in the file. Currently, Biome only supports plain CSS, and aims to be compatible with the latest Recommendation level standards. */ -export type CssVariant = "Standard"; +export type CssVariant = "standard"; /** * The style of GraphQL contained in the file. */ -export type GraphqlVariant = "Standard"; +export type GraphqlVariant = "standard"; export type HtmlVariant = "Standard" | "Astro"; export type GritVariant = "Standard"; export interface ChangeFileParams { @@ -2772,18 +2772,18 @@ export interface GetFormatterIRParams { } export interface PullDiagnosticsParams { categories: RuleCategories; - max_diagnostics: number; + maxDiagnostics: number; only: RuleCode[]; path: BiomePath; skip: RuleCode[]; } export type RuleCategories = RuleCategory[]; export type RuleCode = string; -export type RuleCategory = "Syntax" | "Lint" | "Action" | "Transformation"; +export type RuleCategory = "syntax" | "lint" | "action" | "transformation"; export interface PullDiagnosticsResult { diagnostics: Diagnostic[]; errors: number; - skipped_diagnostics: number; + skippedDiagnostics: number; } /** * Serializable representation for a [Diagnostic](super::Diagnostic). @@ -3266,7 +3266,7 @@ export interface PullActionsResult { } export interface CodeAction { category: ActionCategory; - rule_name?: [string, string]; + ruleName?: [string, string]; suggestion: CodeSuggestion; } /** @@ -3275,10 +3275,10 @@ export interface CodeAction { [CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind */ export type ActionCategory = - | "QuickFix" - | { Refactor: RefactorKind } - | { Source: SourceActionKind } - | { Other: OtherActionCategory }; + | "quickFix" + | { refactor: RefactorKind } + | { source: SourceActionKind } + | { other: OtherActionCategory }; /** * A Suggestion that is provided by Biome's linter, and can be reported to the user, and can be automatically applied if it has the right [`Applicability`]. */ @@ -3295,27 +3295,27 @@ export interface CodeSuggestion { [Check the LSP spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind) for more information: */ export type RefactorKind = - | "None" - | "Extract" - | "Inline" - | "Rewrite" - | { Other: string }; + | "none" + | "extract" + | "inline" + | "rewrite" + | { other: string }; /** * The sub-category of a source code action */ export type SourceActionKind = - | "FixAll" - | "None" - | "OrganizeImports" - | { Other: string }; + | "fixAll" + | "none" + | "organizeImports" + | { other: string }; export type OtherActionCategory = - | "InlineSuppression" - | "ToplevelSuppression" - | { Generic: string }; + | "inlineSuppression" + | "toplevelSuppression" + | { generic: string }; /** * Indicates how a tool should manage this suggestion. */ -export type Applicability = "Always" | "MaybeIncorrect"; +export type Applicability = "always" | "maybeIncorrect"; export interface FormatFileParams { path: BiomePath; } @@ -3323,7 +3323,7 @@ export interface Printed { code: string; range?: TextRange; sourcemap: SourceMarker[]; - verbatim_ranges: TextRange[]; + verbatimRanges: TextRange[]; } /** * Lightweight sourcemap marker between source and output tokens @@ -3347,20 +3347,20 @@ export interface FormatOnTypeParams { path: BiomePath; } export interface FixFileParams { - fix_file_mode: FixFileMode; + fixFileMode: FixFileMode; only: RuleCode[]; path: BiomePath; - rule_categories: RuleCategories; - should_format: boolean; + ruleCategories: RuleCategories; + shouldFormat: boolean; skip: RuleCode[]; } /** * Which fixes should be applied during the analyzing phase */ export type FixFileMode = - | "SafeFixes" - | "SafeAndUnsafeFixes" - | "ApplySuppressions"; + | "safeFixes" + | "safeAndUnsafeFixes" + | "applySuppressions"; export interface FixFileResult { /** * List of all the code actions applied to the file @@ -3377,7 +3377,7 @@ export interface FixFileResult { /** * number of skipped suggested fixes */ - skipped_suggested_fixes: number; + skippedSuggestedFixes: number; } export interface FixAction { /** @@ -3390,9 +3390,9 @@ export interface FixAction { rule_name?: [string, string]; } export interface RenameParams { - new_name: string; + newName: string; path: BiomePath; - symbol_at: TextSize; + symbolAt: TextSize; } export interface RenameResult { /** diff --git a/packages/@biomejs/backend-jsonrpc/tests/workspace.test.mjs b/packages/@biomejs/backend-jsonrpc/tests/workspace.test.mjs index 71022ff0f7b1..0d8222222c9a 100644 --- a/packages/@biomejs/backend-jsonrpc/tests/workspace.test.mjs +++ b/packages/@biomejs/backend-jsonrpc/tests/workspace.test.mjs @@ -20,8 +20,8 @@ describe("Workspace API", () => { await workspace.openFile({ path: { path: "test.js", - was_written: false, - kind: ["Handleable"], + wasWritten: false, + kind: ["handleable"], }, content: "statement()", version: 0, @@ -30,8 +30,8 @@ describe("Workspace API", () => { const printed = await workspace.formatFile({ path: { path: "test.js", - was_written: false, - kind: ["Handleable"], + wasWritten: false, + kind: ["handleable"], }, }); @@ -40,8 +40,8 @@ describe("Workspace API", () => { await workspace.closeFile({ path: { path: "test.js", - was_written: false, - kind: ["Handleable"], + wasWritten: false, + kind: ["handleable"], }, }); diff --git a/packages/@biomejs/js-api/src/index.ts b/packages/@biomejs/js-api/src/index.ts index 78c6c3efcbed..c78ad1b852bd 100644 --- a/packages/@biomejs/js-api/src/index.ts +++ b/packages/@biomejs/js-api/src/index.ts @@ -126,8 +126,8 @@ export class Biome { try { this.workspace.updateSettings({ configuration, - gitignore_matches: [], - workspace_directory: "./", + gitignoreMatches: [], + workspaceDirectory: "./", }); } catch (e) { throw wrapError(e); @@ -158,8 +158,8 @@ export class Biome { return this.tryCatchWrapper(() => { const biomePath: BiomePath = { path, - was_written: false, - kind: ["Handleable"], + wasWritten: false, + kind: ["handleable"], }; this.workspace.openFile({ @@ -199,8 +199,8 @@ export class Biome { const { diagnostics } = this.workspace.pullDiagnostics({ path, - categories: ["Syntax"], - max_diagnostics: Number.MAX_SAFE_INTEGER, + categories: ["syntax"], + maxDiagnostics: Number.MAX_SAFE_INTEGER, only: [], skip: [], }); @@ -258,11 +258,11 @@ export class Biome { const result = this.workspace.fixFile({ path, - fix_file_mode: fixFileMode, - should_format: false, + fixFileMode: fixFileMode, + shouldFormat: false, only: [], skip: [], - rule_categories: ["Syntax", "Lint"], + ruleCategories: ["syntax", "lint"], }); code = result.code; @@ -274,8 +274,8 @@ export class Biome { return this.withFile(filePath, maybeFixedContent, (path) => { const { diagnostics } = this.workspace.pullDiagnostics({ path, - categories: ["Syntax", "Lint"], - max_diagnostics: Number.MAX_SAFE_INTEGER, + categories: ["syntax", "lint"], + maxDiagnostics: Number.MAX_SAFE_INTEGER, only: [], skip: [], }); diff --git a/packages/@biomejs/js-api/tests/lintContent.test.ts b/packages/@biomejs/js-api/tests/lintContent.test.ts index d73700873866..66eeb31a2f51 100644 --- a/packages/@biomejs/js-api/tests/lintContent.test.ts +++ b/packages/@biomejs/js-api/tests/lintContent.test.ts @@ -43,7 +43,7 @@ describe("Biome WebAssembly lintContent", () => { it("should emit diagnotics", () => { const result = biome.lintContent(inputCode, { filePath: "example.js", - fixFileMode: "SafeFixes", + fixFileMode: "safeFixes", }); expect(result.diagnostics).toMatchObject([ { category: "lint/style/useTemplate" }, @@ -52,7 +52,7 @@ describe("Biome WebAssembly lintContent", () => { it("should fix the SafeFixes only", () => { const result = biome.lintContent(inputCode, { filePath: "example.js", - fixFileMode: "SafeFixes", + fixFileMode: "safeFixes", }); expect(result.content).toMatchSnapshot(); }); @@ -62,14 +62,14 @@ describe("Biome WebAssembly lintContent", () => { it("should emit diagnotics", () => { const result = biome.lintContent(inputCode, { filePath: "example.js", - fixFileMode: "SafeAndUnsafeFixes", + fixFileMode: "safeAndUnsafeFixes", }); expect(result.diagnostics).toHaveLength(0); }); it("should fix the code", () => { const result = biome.lintContent(inputCode, { filePath: "example.js", - fixFileMode: "SafeAndUnsafeFixes", + fixFileMode: "safeAndUnsafeFixes", }); expect(result.content).toMatchSnapshot(); }); diff --git a/packages/@biomejs/js-api/tests/printDiagnostics.test.ts b/packages/@biomejs/js-api/tests/printDiagnostics.test.ts index 0e9461a749a4..a1d7ae2538d9 100644 --- a/packages/@biomejs/js-api/tests/printDiagnostics.test.ts +++ b/packages/@biomejs/js-api/tests/printDiagnostics.test.ts @@ -42,7 +42,7 @@ if(expr()) { ], severity: "error", tags: [], - verbose_advices: { + verboseAdvices: { advices: [], }, }, @@ -66,7 +66,7 @@ if(expr()) { ], severity: "error", tags: [], - verbose_advices: { + verboseAdvices: { advices: [], }, }, diff --git a/packages/@biomejs/wasm-nodejs/package.json b/packages/@biomejs/wasm-nodejs/package.json index 046c304451a1..f612aa43ae8a 100644 --- a/packages/@biomejs/wasm-nodejs/package.json +++ b/packages/@biomejs/wasm-nodejs/package.json @@ -1,5 +1,5 @@ { - "name": "@biomejs/wasm-nodejs", + "name": "@biomejs/biome_wasm", "collaborators": [ "Biome Developers and Contributors" ], @@ -8,8 +8,7 @@ "license": "MIT OR Apache-2.0", "repository": { "type": "git", - "url": "git+https://github.com/biomejs/biome.git", - "directory": "packages/@biomejs/biome/wasm-nodejs" + "url": "https://github.com/biomejs/biome" }, "files": [ "biome_wasm_bg.wasm", @@ -25,4 +24,4 @@ "formatter", "wasm" ] -} +} \ No newline at end of file