Skip to content

Commit

Permalink
Merge branch 'next' into support-promise-expression
Browse files Browse the repository at this point in the history
  • Loading branch information
kaykdm authored Jan 29, 2025
2 parents d65de62 + d76e8d3 commit 71696d7
Show file tree
Hide file tree
Showing 149 changed files with 1,276 additions and 364 deletions.
2 changes: 2 additions & 0 deletions .changeset/introduce_includes.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ The previous configuration must be updated as follows:
}
}
```

You can run `biome migrate` to automatically convert from `include` and `ignore` to `includes`.
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ allow_attributes = "deny"
cargo_common_metadata = "allow"
empty_docs = "allow" # there are some false positives inside biome_wasm
multiple_crate_versions = "allow"
needless_lifetimes = "allow"
unnecessary_map_or = "allow"

# pedantic
assigning_clones = "warn"
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ mod tests {
nodes: Vec<RawLanguageKind>,
}

impl<'a> QueryMatcher<RawLanguage> for &'a mut BufferMatcher {
impl QueryMatcher<RawLanguage> for &mut BufferMatcher {
fn match_query(&mut self, params: MatchQueryParams<RawLanguage>) {
self.nodes.push(
params
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_aria/src/roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ impl AriaRoles {
.find_attribute_by_name(|n| n == "type")
.as_ref()
.and_then(|attr| attr.value())
.map_or(false, |value| value.as_ref() == "hidden"),
.is_some_and(|value| value.as_ref() == "hidden"),
_ => self
.get_implicit_role(element)
.map_or(false, |implicit_role| implicit_role.is_non_interactive()),
.is_some_and(|implicit_role| implicit_role.is_non_interactive()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/src/commands/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub(crate) fn read_most_recent_log_file(

let most_recent = fs::read_dir(biome_log_path)?
.flatten()
.filter(|file| file.file_type().map_or(false, |ty| ty.is_file()))
.filter(|file| file.file_type().is_ok_and(|ty| ty.is_file()))
.filter_map(|file| {
match file
.file_name()
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ impl BiomeCommand {

pub fn is_verbose(&self) -> bool {
self.cli_options()
.map_or(false, |cli_options| cli_options.verbose)
.is_some_and(|cli_options| cli_options.verbose)
}

pub fn log_level(&self) -> LoggingLevel {
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/src/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl Execution {
// Ref: https://docs.github.com/actions/learn-github-actions/variables#default-environment-variables
let is_github = std::env::var("GITHUB_ACTIONS")
.ok()
.map_or(false, |value| value == "true");
.is_some_and(|value| value == "true");

Self {
report_mode: ReportMode::default(),
Expand Down
8 changes: 4 additions & 4 deletions crates/biome_configuration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ impl Configuration {
}

pub fn is_formatter_enabled(&self) -> bool {
self.formatter.as_ref().map_or(false, |f| f.is_enabled())
self.formatter.as_ref().is_some_and(|f| f.is_enabled())
}

pub fn is_linter_enabled(&self) -> bool {
self.linter.as_ref().map_or(false, |f| f.is_enabled())
self.linter.as_ref().is_some_and(|f| f.is_enabled())
}

pub fn is_assist_enabled(&self) -> bool {
self.assist.as_ref().map_or(false, |f| f.is_enabled())
self.assist.as_ref().is_some_and(|f| f.is_enabled())
}

pub fn get_linter_rules(&self) -> Rules {
Expand All @@ -266,7 +266,7 @@ impl Configuration {
}

pub fn is_vcs_enabled(&self) -> bool {
self.assist.as_ref().map_or(false, |f| f.is_enabled())
self.assist.as_ref().is_some_and(|f| f.is_enabled())
}

/// Whether Biome should check for `.editorconfig` file
Expand Down
7 changes: 4 additions & 3 deletions crates/biome_css_formatter/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ fn handle_declaration_name_comment(
) -> CommentPlacement<CssLanguage> {
match comment.preceding_node() {
Some(following_node) if AnyCssDeclarationName::can_cast(following_node.kind()) => {
if following_node.parent().map_or(false, |p| {
p.kind() == CssSyntaxKind::CSS_GENERIC_COMPONENT_VALUE_LIST
}) {
if following_node
.parent()
.is_some_and(|p| p.kind() == CssSyntaxKind::CSS_GENERIC_COMPONENT_VALUE_LIST)
{
CommentPlacement::Default(comment)
} else {
CommentPlacement::leading(following_node.clone(), comment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl FormatNodeRule<CssUnknownBlockAtRule> for FormatCssUnknownBlockAtRule {

write!(f, [name.format(), space(), components.format()])?;

if components.map_or(false, |components| components.items().next().is_some()) {
if components.is_ok_and(|components| components.items().next().is_some()) {
write!(f, [space()])?;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ where
name.as_css_identifier()
.map(|name| name.to_trimmed_string())
})
.map_or(false, |name| {
.is_some_and(|name| {
let name = name.to_ascii_lowercase_cow();

name.starts_with("grid-template") || name == "grid"
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_css_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ impl<'src> CssLexer<'src> {
// U+002E FULL STOP (.) followed by a digit...
if self
.current_byte()
.map_or(false, |byte| byte.is_ascii_digit())
.is_some_and(|byte| byte.is_ascii_digit())
{
// While the next input code point is a digit, consume it.
self.consume_number_sequence();
Expand Down Expand Up @@ -1244,7 +1244,7 @@ impl<'src> CssLexer<'src> {
Some(byte) if byte.is_ascii_digit() => true,
// Otherwise, if the second code point is a U+002E FULL STOP (.) and the
// third code point is a digit, return true.
Some(b'.') if self.byte_at(2).map_or(false, |byte| byte.is_ascii_digit()) => true,
Some(b'.') if self.byte_at(2).is_some_and(|byte| byte.is_ascii_digit()) => true,
_ => false,
},
Some(b'.') => match self.peek_byte() {
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_diagnostics/src/display/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl NativeBacktrace {
frame.symbols().iter().any(|symbol| {
symbol
.addr()
.map_or(false, |addr| addr as usize == self.top_frame)
.is_some_and(|addr| addr as usize == self.top_frame)
})
});

Expand All @@ -173,7 +173,7 @@ impl NativeBacktrace {
frame.symbols().iter().any(|symbol| {
symbol
.addr()
.map_or(false, |addr| addr as usize == self.bottom_frame)
.is_some_and(|addr| addr as usize == self.bottom_frame)
})
});

Expand Down
4 changes: 2 additions & 2 deletions crates/biome_diagnostics/src/display/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ pub(super) fn print_invisibles(

let next_char_is_whitespace = iter
.peek()
.map_or(false, |(_, char)| char.is_ascii_whitespace());
.is_some_and(|(_, char)| char.is_ascii_whitespace());

if prev_char_was_whitespace || next_char_is_whitespace {
show_invisible = false;
Expand All @@ -436,7 +436,7 @@ pub(super) fn print_invisibles(

// If we are a carriage return next to a \n then don't show the character as visible
if options.ignore_trailing_carriage_return && char == '\r' {
let next_char_is_line_feed = iter.peek().map_or(false, |(_, char)| *char == '\n');
let next_char_is_line_feed = iter.peek().is_some_and(|(_, char)| *char == '\n');
if next_char_is_line_feed {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_formatter/src/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ impl<Context> Format<Context> for LineSuffixBoundary {
///
/// let recorded = recording.stop();
///
/// let is_labelled = recorded.first().map_or(false, |element| element.has_label(LabelId::of(MyLabels::Main)));
/// let is_labelled = recorded.first().is_some_and(|element| element.has_label(LabelId::of(MyLabels::Main)));
///
/// if is_labelled {
/// write!(f, [text(" has label `Main`")])
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_formatter/src/format_element/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl Format<IrFormatContext> for &[FormatElement] {
_ => unreachable!(),
}

let is_next_text = iter.peek().map_or(false, |e| e.is_text() || e.is_space());
let is_next_text = iter.peek().is_some_and(|e| e.is_text() || e.is_space());

if !is_next_text {
write!(f, [text("\"")])?;
Expand Down Expand Up @@ -687,7 +687,7 @@ impl FormatElements for [FormatElement] {

fn has_label(&self, expected: LabelId) -> bool {
self.first()
.map_or(false, |element| element.has_label(expected))
.is_some_and(|element| element.has_label(expected))
}

fn start_tag(&self, kind: TagKind) -> Option<&Tag> {
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_formatter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,7 @@ mod tests {
}
}

impl<'a> std::fmt::Display for DiagnosticPrinter<'a> {
impl std::fmt::Display for DiagnosticPrinter<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for diagnostic in self.diagnostics {
diagnostic.description(f)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_formatter/src/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl TransformSourceMap {
// It can, therefore, be necessary to navigate backwards again.
// In this case, do a binary search for the index of the next deleted range (`O(log(n)`).
let out_of_order_marker =
previous_marker.map_or(false, |previous| previous.source > marker.source);
previous_marker.is_some_and(|previous| previous.source > marker.source);

if out_of_order_marker {
let index = self
Expand Down
10 changes: 5 additions & 5 deletions crates/biome_formatter/src/trivia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ where
match comment.lines_after() {
0 => {
let should_nestle =
leading_comments_iter.peek().map_or(false, |next_comment| {
leading_comments_iter.peek().is_some_and(|next_comment| {
should_nestle_adjacent_doc_comments(comment, next_comment)
});

Expand Down Expand Up @@ -138,7 +138,7 @@ where

let format_comment = FormatRefWithRule::new(comment, Context::CommentRule::default());

let should_nestle = previous_comment.map_or(false, |previous_comment| {
let should_nestle = previous_comment.is_some_and(|previous_comment| {
should_nestle_adjacent_doc_comments(previous_comment, comment)
});

Expand Down Expand Up @@ -169,7 +169,7 @@ where
// /**
// * docs
// */ /* still on the same line */
if previous_comment.map_or(false, |previous_comment| {
if previous_comment.is_some_and(|previous_comment| {
previous_comment.kind().is_line()
}) {
write!(f, [hard_line_break()])?;
Expand Down Expand Up @@ -315,7 +315,7 @@ where
let format_comment =
FormatRefWithRule::new(comment, Context::CommentRule::default());

let should_nestle = previous_comment.map_or(false, |previous_comment| {
let should_nestle = previous_comment.is_some_and(|previous_comment| {
should_nestle_adjacent_doc_comments(previous_comment, comment)
});

Expand All @@ -334,7 +334,7 @@ where
if matches!(self.indent(), DanglingIndentMode::Soft)
&& dangling_comments
.last()
.map_or(false, |comment| comment.kind().is_line())
.is_some_and(|comment| comment.kind().is_line())
{
write!(f, [hard_line_break()])?;
}
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_fs/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub trait FileSystem: Send + Sync + RefUnwindSafe {
/// [Self::path_is_symlink()] and this method to return `true` for the same
/// path.
fn path_is_file(&self, path: &Utf8Path) -> bool {
Self::path_kind(self, path).map_or(false, |kind| matches!(kind, PathKind::File { .. }))
Self::path_kind(self, path).is_ok_and(|kind| matches!(kind, PathKind::File { .. }))
}

/// Checks if the given path is a directory
Expand All @@ -104,12 +104,12 @@ pub trait FileSystem: Send + Sync + RefUnwindSafe {
/// [Self::path_is_symlink()] and this method to return `true` for the same
/// path.
fn path_is_dir(&self, path: &Utf8Path) -> bool {
Self::path_kind(self, path).map_or(false, |kind| matches!(kind, PathKind::Directory { .. }))
Self::path_kind(self, path).is_ok_and(|kind| matches!(kind, PathKind::Directory { .. }))
}

/// Checks if the given path is a symlink
fn path_is_symlink(&self, path: &Utf8Path) -> bool {
Self::path_kind(self, path).map_or(false, PathKind::is_symlink)
Self::path_kind(self, path).is_ok_and(PathKind::is_symlink)
}

/// Returns metadata about the path.
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_graphql_formatter/src/utils/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ where
let node = element.node();

if index != 0 {
if node.map_or(false, |node| node.syntax().has_leading_comments()) {
if node.is_ok_and(|node| node.syntax().has_leading_comments()) {
write!(f, [soft_line_break_or_space()])?;
} else {
write!(f, [space()])?;
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_graphql_syntax/src/string_value_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ impl GraphqlStringValue {
/// ```
pub fn is_block(&self) -> bool {
self.graphql_string_literal_token()
.map_or(false, |token| token.text_trimmed().starts_with("\"\"\""))
.is_ok_and(|token| token.text_trimmed().starts_with("\"\"\""))
}
}
4 changes: 2 additions & 2 deletions crates/biome_grit_patterns/src/grit_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ impl<'a> Binding<'a, GritQueryContext> for GritBinding<'a> {
Self::Empty(node2, sort2) => node1.kind() == node2.kind() && sort1 == sort2,
Self::Range(..) | Self::File(_) | Self::Node(..) | Self::Constant(_) => false,
},
Self::Constant(c1) => other.as_constant().map_or(false, |c2| *c1 == c2),
Self::Constant(c1) => other.as_constant().is_some_and(|c2| *c1 == c2),
Self::Range(range, source) => other
.text(language)
.is_ok_and(|t| t == source[range.start().into()..range.end().into()]),
Self::File(path1) => other.as_filename().map_or(false, |path2| *path1 == path2),
Self::File(path1) => other.as_filename().is_some_and(|path2| *path1 == path2),
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/biome_grit_patterns/src/grit_resolved_pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ impl<'a> ResolvedPattern<'a, GritQueryContext> for GritResolvedPattern<'a> {
language: &GritTargetLanguage,
) -> GritResult<bool> {
let truthiness = match self {
Self::Binding(bindings) => bindings.last().map_or(false, Binding::is_truthy),
Self::Binding(bindings) => bindings.last().is_some_and(Binding::is_truthy),
Self::List(elements) => !elements.is_empty(),
Self::Map(map) => !map.is_empty(),
Self::Constant(c) => c.is_truthy(),
Expand Down Expand Up @@ -532,7 +532,7 @@ impl<'a> ResolvedPattern<'a, GritQueryContext> for GritResolvedPattern<'a> {
Self::Binding(b) => b
.last()
.and_then(Binding::as_constant)
.map_or(false, Constant::is_undefined),
.is_some_and(Constant::is_undefined),
Self::Constant(Constant::Undefined) => true,
Self::Constant(_)
| Self::Snippets(_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl GritTargetLanguageImpl for CssTargetLanguage {

fn is_comment_kind(kind: GritTargetSyntaxKind) -> bool {
kind.as_css_kind()
.map_or(false, |kind| COMMENT_KINDS.matches(kind))
.is_some_and(|kind| COMMENT_KINDS.matches(kind))
}

fn metavariable_kind() -> Self::Kind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ impl GritTargetLanguageImpl for JsTargetLanguage {

fn is_comment_kind(kind: GritTargetSyntaxKind) -> bool {
kind.as_js_kind()
.map_or(false, |kind| COMMENT_KINDS.matches(kind))
.is_some_and(|kind| COMMENT_KINDS.matches(kind))
}

fn metavariable_kind() -> Self::Kind {
JsSyntaxKind::JS_METAVARIABLE
}

fn is_alternative_metavariable_kind(kind: GritTargetSyntaxKind) -> bool {
kind.as_js_kind().map_or(false, |kind| {
kind.as_js_kind().is_some_and(|kind| {
kind == JsSyntaxKind::JS_TEMPLATE_ELEMENT_LIST
|| kind == JsSyntaxKind::TS_TEMPLATE_ELEMENT_LIST
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::needless_lifetimes)]
use grit_pattern_matcher::pattern::VariableSource;
use grit_util::ByteRange;

Expand Down
5 changes: 4 additions & 1 deletion crates/biome_html_formatter/src/html/lists/attribute_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ pub(crate) struct FormatHtmlAttributeList;
impl FormatRule<HtmlAttributeList> for FormatHtmlAttributeList {
type Context = HtmlFormatContext;
fn fmt(&self, node: &HtmlAttributeList, f: &mut HtmlFormatter) -> FormatResult<()> {
let line_break = if f.options().attribute_position() == AttributePosition::Multiline {
let attribute_len = node.iter().len();
let line_break = if f.options().attribute_position() == AttributePosition::Multiline
&& attribute_len > 1
{
hard_line_break()
} else {
soft_line_break_or_space()
Expand Down
Loading

0 comments on commit 71696d7

Please sign in to comment.