Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use biome_analyze::{
Ast, Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule,
};
use biome_console::markup;
use biome_css_syntax::{CssFunction, CssParameter};
use biome_css_syntax::{AnyCssExpression, CssFunction};
use biome_diagnostics::Severity;
use biome_rowan::AstNode;
use biome_rowan::AstSeparatedList;
Expand Down Expand Up @@ -72,7 +72,7 @@ pub static DIRECTION_WITHOUT_TO: LazyLock<Regex> = LazyLock::new(|| {

impl Rule for NoInvalidDirectionInLinearGradient {
type Query = Ast<CssFunction>;
type State = CssParameter;
type State = AnyCssExpression;
type Signals = Option<Self::State>;
type Options = NoInvalidDirectionInLinearGradientOptions;

Expand All @@ -89,32 +89,31 @@ impl Rule for NoInvalidDirectionInLinearGradient {
if !linear_gradient_property.contains(&node_name.to_ascii_lowercase_cow().as_ref()) {
return None;
}
let css_parameter = node.items();

let first_css_parameter = css_parameter.first()?.ok()?;
let first_css_parameter_text = first_css_parameter.to_trimmed_text();
if IN_KEYWORD.is_match(&first_css_parameter_text) {
let arguments = node.items();
let first_expression = arguments.first()?.ok()?;
let first_expression_text = first_expression.to_trimmed_text();
if IN_KEYWORD.is_match(&first_expression_text) {
return None;
}
if let Some(first_byte) = first_css_parameter_text.bytes().next()
if let Some(first_byte) = first_expression_text.bytes().next()
&& first_byte.is_ascii_digit()
{
if ANGLE.is_match(&first_css_parameter_text) {
if ANGLE.is_match(&first_expression_text) {
return None;
}
return Some(first_css_parameter);
return Some(first_expression);
}
let direction_property = ["top", "left", "bottom", "right"];
if !direction_property.iter().any(|&keyword| {
first_css_parameter_text
first_expression_text
.to_ascii_lowercase_cow()
.contains(keyword)
}) {
return None;
}
let has_prefix = vendor_prefixed(&node_name);
if !is_standdard_direction(&first_css_parameter_text, has_prefix) {
return Some(first_css_parameter);
if !is_standdard_direction(&first_expression_text, has_prefix) {
return Some(first_expression);
}
None
}
Expand Down
8 changes: 1 addition & 7 deletions crates/biome_css_factory/src/generated/node_factory.rs

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

21 changes: 1 addition & 20 deletions crates/biome_css_factory/src/generated/syntax_factory.rs

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

1 change: 0 additions & 1 deletion crates/biome_css_formatter/src/css/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ pub(crate) mod nested_qualified_rule;
pub(crate) mod nth_offset;
pub(crate) mod number_declarator;
pub(crate) mod page_at_rule_block;
pub(crate) mod parameter;
pub(crate) mod parenthesized_expression;
pub(crate) mod position_try_at_rule_declarator;
pub(crate) mod property_at_rule_declarator;
Expand Down
13 changes: 0 additions & 13 deletions crates/biome_css_formatter/src/css/auxiliary/parameter.rs

This file was deleted.

34 changes: 0 additions & 34 deletions crates/biome_css_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4032,40 +4032,6 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssPageSelectorPseudo {
)
}
}
impl FormatRule<biome_css_syntax::CssParameter>
for crate::css::auxiliary::parameter::FormatCssParameter
{
type Context = CssFormatContext;
#[inline(always)]
fn fmt(&self, node: &biome_css_syntax::CssParameter, f: &mut CssFormatter) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::CssParameter>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::CssParameter {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssParameter,
crate::css::auxiliary::parameter::FormatCssParameter,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::css::auxiliary::parameter::FormatCssParameter::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssParameter {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssParameter,
crate::css::auxiliary::parameter::FormatCssParameter,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::parameter::FormatCssParameter::default(),
)
}
}
impl FormatRule<biome_css_syntax::CssParenthesizedExpression>
for crate::css::auxiliary::parenthesized_expression::FormatCssParenthesizedExpression
{
Expand Down
6 changes: 2 additions & 4 deletions crates/biome_css_parser/src/syntax/value/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,11 @@ pub(crate) fn parse_parameter(p: &mut CssParser) -> ParsedSyntax {
return Absent;
}

let param = p.start();
if CssSyntaxFeatures::Scss.is_supported(p) {
parse_scss_expression_in_args_until(p, token_set![T![,], T![')'], T![;], T!['}']]).ok();
parse_scss_expression_in_args_until(p, token_set![T![,], T![')'], T![;], T!['}']])
} else {
parse_any_expression(p).ok();
parse_any_expression(p)
}
Present(param.complete(p, CSS_PARAMETER))
}

/// Determines if the current position in the CSS parser is at the start of any CSS expression.
Expand Down
Loading
Loading