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 @@ -78,7 +78,10 @@ impl Rule for NoUnknownFunction {

fn run(ctx: &RuleContext<Self>) -> Option<Self::State> {
let node = ctx.query();
let binding = node.name().ok()?.value_token().ok()?;
let binding = node.name().ok().and_then(|name| {
name.as_css_identifier()
.and_then(|name| name.value_token().ok())
})?;
let function_name = binding.text_trimmed();

// We don't have a semantic model yet, so we can't determine if functions are defined elsewhere.
Expand Down
10 changes: 5 additions & 5 deletions crates/biome_css_analyze/src/lint/correctness/no_unknown_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ impl Rule for NoUnknownUnit {
match ancestor.kind() {
CssSyntaxKind::CSS_FUNCTION => {
let function_name_token = ancestor
.cast::<CssFunction>()?
.name()
.ok()?
.value_token()
.ok()?;
.cast::<CssFunction>()?
.name()
.ok()?
.as_css_identifier()
.and_then(|name| name.value_token().ok())?;
let function_name = function_name_token
.text_trimmed()
.to_ascii_lowercase_cow();
Expand Down
16 changes: 15 additions & 1 deletion 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.

35 changes: 34 additions & 1 deletion 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.

15 changes: 15 additions & 0 deletions crates/biome_css_formatter/src/css/any/function_name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

use crate::prelude::*;
use biome_css_syntax::AnyCssFunctionName;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyCssFunctionName;
impl FormatRule<AnyCssFunctionName> for FormatAnyCssFunctionName {
type Context = CssFormatContext;
fn fmt(&self, node: &AnyCssFunctionName, f: &mut CssFormatter) -> FormatResult<()> {
match node {
AnyCssFunctionName::CssIdentifier(node) => node.format().fmt(f),
AnyCssFunctionName::ScssQualifiedName(node) => node.format().fmt(f),
}
}
}
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/css/any/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub(crate) mod font_family_name;
pub(crate) mod font_feature_values_block;
pub(crate) mod font_feature_values_item;
pub(crate) mod function;
pub(crate) mod function_name;
pub(crate) mod function_parameter;
pub(crate) mod generic_component_value;
pub(crate) mod if_branch;
Expand Down
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/css/any/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl FormatRule<AnyCssValue> for FormatAnyCssValue {
AnyCssValue::CssString(node) => node.format().fmt(f),
AnyCssValue::CssUnicodeRange(node) => node.format().fmt(f),
AnyCssValue::ScssIdentifier(node) => node.format().fmt(f),
AnyCssValue::ScssQualifiedName(node) => node.format().fmt(f),
AnyCssValue::TwValueThemeReference(node) => node.format().fmt(f),
}
}
Expand Down
88 changes: 88 additions & 0 deletions crates/biome_css_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7072,6 +7072,44 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssNamespacedIdentifier
)
}
}
impl FormatRule<biome_css_syntax::ScssQualifiedName>
for crate::scss::auxiliary::qualified_name::FormatScssQualifiedName
{
type Context = CssFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_css_syntax::ScssQualifiedName,
f: &mut CssFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::ScssQualifiedName>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::ScssQualifiedName {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::ScssQualifiedName,
crate::scss::auxiliary::qualified_name::FormatScssQualifiedName,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::scss::auxiliary::qualified_name::FormatScssQualifiedName::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssQualifiedName {
type Format = FormatOwnedWithRule<
biome_css_syntax::ScssQualifiedName,
crate::scss::auxiliary::qualified_name::FormatScssQualifiedName,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::scss::auxiliary::qualified_name::FormatScssQualifiedName::default(),
)
}
}
impl FormatRule<biome_css_syntax::ScssVariableModifier>
for crate::scss::auxiliary::variable_modifier::FormatScssVariableModifier
{
Expand Down Expand Up @@ -10566,6 +10604,31 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::AnyCssFunction {
)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::AnyCssFunctionName {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::AnyCssFunctionName,
crate::css::any::function_name::FormatAnyCssFunctionName,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::css::any::function_name::FormatAnyCssFunctionName::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::AnyCssFunctionName {
type Format = FormatOwnedWithRule<
biome_css_syntax::AnyCssFunctionName,
crate::css::any::function_name::FormatAnyCssFunctionName,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::css::any::function_name::FormatAnyCssFunctionName::default(),
)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::AnyCssFunctionParameter {
type Format<'a> = FormatRefWithRule<
'a,
Expand Down Expand Up @@ -12159,6 +12222,31 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::AnyScssDeclarationName {
)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::AnyScssModuleMember {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::AnyScssModuleMember,
crate::scss::any::module_member::FormatAnyScssModuleMember,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::scss::any::module_member::FormatAnyScssModuleMember::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::AnyScssModuleMember {
type Format = FormatOwnedWithRule<
biome_css_syntax::AnyScssModuleMember,
crate::scss::any::module_member::FormatAnyScssModuleMember,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::scss::any::module_member::FormatAnyScssModuleMember::default(),
)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::AnyTwCustomVariantSelector {
type Format<'a> = FormatRefWithRule<
'a,
Expand Down
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/scss/any/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

pub(crate) mod declaration_name;
pub(crate) mod module_member;
15 changes: 15 additions & 0 deletions crates/biome_css_formatter/src/scss/any/module_member.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

use crate::prelude::*;
use biome_css_syntax::AnyScssModuleMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyScssModuleMember;
impl FormatRule<AnyScssModuleMember> for FormatAnyScssModuleMember {
type Context = CssFormatContext;
fn fmt(&self, node: &AnyScssModuleMember, f: &mut CssFormatter) -> FormatResult<()> {
match node {
AnyScssModuleMember::CssIdentifier(node) => node.format().fmt(f),
AnyScssModuleMember::ScssIdentifier(node) => node.format().fmt(f),
}
}
}
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/scss/auxiliary/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod declaration;
pub(crate) mod qualified_name;
pub(crate) mod variable_modifier;
17 changes: 17 additions & 0 deletions crates/biome_css_formatter/src/scss/auxiliary/qualified_name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::prelude::*;
use biome_css_syntax::{ScssQualifiedName, ScssQualifiedNameFields};
use biome_formatter::write;

#[derive(Debug, Clone, Default)]
pub(crate) struct FormatScssQualifiedName;
impl FormatNodeRule<ScssQualifiedName> for FormatScssQualifiedName {
fn fmt_fields(&self, node: &ScssQualifiedName, f: &mut CssFormatter) -> FormatResult<()> {
let ScssQualifiedNameFields {
module,
dot_token,
member,
} = node.as_fields();

write!(f, [module.format(), dot_token.format(), member.format()])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Trailing newline: true
$combined: green !default !global !global;

padding: $local-var;
margin: ns.$namespaced-var;
margin: ns.$namespaced-var;
}

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.test{

width:math.div(10px
,
2);

height:

math.ceil( 3.5px

);


value:map.get( $map
, a
);

variable:

map.$default ;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
assertion_line: 212
info: css/scss/expression/qualified-names.scss
---
# Input

```scss
.test{

width:math.div(10px
,
2);

height:

math.ceil( 3.5px

);


value:map.get( $map
, a
);

variable:

map.$default ;
}

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
Trailing newline: true
-----

```scss
.test {
width: math.div(10px, 2);

height: math.ceil(3.5px);

value: map.get($map, a);

variable: map.$default;
}

```
Loading