Skip to content

Commit

Permalink
feat(workspace): make types camel case (#4368)
Browse files Browse the repository at this point in the history
Co-authored-by: Arend van Beelen jr <arendjr@gmail.com>
  • Loading branch information
ematipico and arendjr authored Oct 25, 2024
1 parent f5f38dc commit 70542df
Show file tree
Hide file tree
Showing 17 changed files with 164 additions and 96 deletions.
8 changes: 8 additions & 0 deletions .changeset/use_new_workspace_apis.md
Original file line number Diff line number Diff line change
@@ -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`.
15 changes: 10 additions & 5 deletions crates/biome_analyze/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'.
Expand All @@ -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`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions crates/biome_css_syntax/src/file_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/biome_diagnostics/src/suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion crates/biome_formatter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,8 @@ pub type PrintResult<T> = Result<T, PrintError>;
#[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,
Expand Down
10 changes: 6 additions & 4 deletions crates/biome_fs/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -92,7 +93,8 @@ impl From<FileKind> 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
Expand Down Expand Up @@ -400,7 +402,7 @@ mod test {
#[test]
#[cfg(feature = "serde")]
fn deserialize_file_kind_from_str() {
let result = serde_json::from_str::<FileKinds>("[\"Config\"]");
let result = serde_json::from_str::<FileKinds>("[\"config\"]");
assert!(result.is_ok());
let file_kinds = result.unwrap();
assert!(file_kinds.contains(FileKind::Config));
Expand All @@ -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\"]");
}
}
2 changes: 2 additions & 0 deletions crates/biome_graphql_syntax/src/file_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions crates/biome_js_syntax/src/file_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,
Expand All @@ -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]
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/biome_json_syntax/src/file_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 70542df

Please sign in to comment.