Skip to content

Commit

Permalink
feat(useNamingConvention): add options for cutsom conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos committed May 8, 2024
1 parent b9f90b7 commit 5a3a996
Show file tree
Hide file tree
Showing 73 changed files with 2,233 additions and 1,192 deletions.
31 changes: 31 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ bpaf = { version = "0.9.9", features = ["derive"] }
countme = "3.0.1"
crossbeam = "0.8.4"
dashmap = "5.4.0"
enumflags2 = "0.7.3"
getrandom = "0.2.14"
ignore = "0.4.21"
indexmap = { version = "2.2.6", features = ["serde"] }
Expand All @@ -170,12 +171,12 @@ quote = "1.0.36"
rayon = "1.8.1"
regex = "1.10.4"
rustc-hash = "1.1.0"
schemars = "0.8.17"
schemars = { version = "0.8.17", features = ["indexmap2", "smallvec"] }
serde = { version = "1.0.200", features = ["derive"] }
serde_json = "1.0.116"
similar = "2.5.0"
slotmap = "1.0.7"
smallvec = { version = "1.10.0", features = ["union", "const_new"] }
smallvec = { version = "1.10.0", features = ["union", "const_new", "serde"] }
syn = "1.0.109"
termcolor = "1.4.1"
tokio = "1.36.0"
Expand Down
7 changes: 4 additions & 3 deletions crates/biome_cli/src/execute/migrate/eslint_typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,18 @@ impl From<NamingConventionOptions> for use_naming_convention::NamingConventionOp
Some(NamingConventionCase::StrictCamel | NamingConventionCase::StrictPascal)
),
require_ascii: false,
custom: Vec::new(),
enum_member_case: enum_member_format
.and_then(|format| {
match format {
NamingConventionCase::Camel | NamingConventionCase::StrictCamel => {
Some(use_naming_convention::EnumMemberCase::Camel)
Some(use_naming_convention::Format::Camel)
}
NamingConventionCase::Pascal | NamingConventionCase::StrictPascal => {
Some(use_naming_convention::EnumMemberCase::Pascal)
Some(use_naming_convention::Format::Pascal)
}
NamingConventionCase::Upper => {
Some(use_naming_convention::EnumMemberCase::Constant)
Some(use_naming_convention::Format::Constant)
}
// Biome doesn't support `snake_case` for enum member
NamingConventionCase::Snake => None,
Expand Down
1 change: 1 addition & 0 deletions crates/biome_deserialize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bitflags = { workspace = true }
indexmap = { workspace = true, features = ["serde"] }
schemars = { workspace = true, optional = true }
serde = { workspace = true }
smallvec = { workspace = true }

[features]
schema = ["schemars", "schemars/indexmap"]
Expand Down
29 changes: 29 additions & 0 deletions crates/biome_deserialize/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::{
num::{NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize},
ops::Deref,
path::PathBuf,
u8,
};

/// Type that allows deserializing a string without heap-allocation.
Expand Down Expand Up @@ -531,6 +532,34 @@ impl<T: Deserializable> Deserializable for Vec<T> {
}
}

impl<T: Deserializable, const L: usize> Deserializable for smallvec::SmallVec<[T; L]> {
fn deserialize(
value: &impl DeserializableValue,
name: &str,
diagnostics: &mut Vec<DeserializationDiagnostic>,
) -> Option<Self> {
struct Visitor<T, const L: usize>(PhantomData<T>);
impl<T: Deserializable, const L: usize> DeserializationVisitor for Visitor<T, L> {
type Output = smallvec::SmallVec<[T; L]>;
const EXPECTED_TYPE: VisitableType = VisitableType::ARRAY;
fn visit_array(
self,
values: impl Iterator<Item = Option<impl DeserializableValue>>,
_range: TextRange,
_name: &str,
diagnostics: &mut Vec<DeserializationDiagnostic>,
) -> Option<Self::Output> {
Some(
values
.filter_map(|value| Deserializable::deserialize(&value?, "", diagnostics))
.collect(),
)
}
}
value.deserialize(Visitor(PhantomData), name, diagnostics)
}
}

impl<T: Deserializable + Eq + Hash, S: BuildHasher + Default> Deserializable for HashSet<T, S> {
fn deserialize(
value: &impl DeserializableValue,
Expand Down
3 changes: 3 additions & 0 deletions crates/biome_js_analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ biome_rowan = { workspace = true }
biome_string_case = { workspace = true }
biome_suppression = { workspace = true }
biome_unicode_table = { workspace = true }
bitflags = { workspace = true }
enumflags2 = { workspace = true }
lazy_static = { workspace = true }
natord = "1.0.9"
regex = { workspace = true }
roaring = "0.10.4"
rustc-hash = { workspace = true }
schemars = { workspace = true, optional = true }
Expand Down
Loading

0 comments on commit 5a3a996

Please sign in to comment.