Skip to content

Commit d97fffe

Browse files
authored
fix(cli): scss shouldn't be enabled (#10807)
1 parent 74c1a51 commit d97fffe

4 files changed

Lines changed: 42 additions & 5 deletions

File tree

.changeset/fluffy-heads-wash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed an issue where `.scss` files were incorrectly analyzed when running `biome check`.

crates/biome_cli/tests/commands/format.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::snap_test::{SnapshotPayload, assert_file_contents, markup_to_string};
66
use crate::{
77
CUSTOM_FORMAT_BEFORE, FORMATTED, LINT_ERROR, UNFORMATTED, assert_cli_snapshot, run_cli,
88
};
9+
use biome_cli::CliDiagnostic;
910
use biome_console::{BufferConsole, MarkupBuf, markup};
1011
use biome_fs::{FileSystemExt, MemoryFileSystem};
1112
use bpaf::Args;
@@ -4103,7 +4104,7 @@ fn trailing_newline_html_via_cli() {
41034104
}
41044105

41054106
#[test]
4106-
fn harness_scss() {
4107+
fn harness_scss_format() {
41074108
let fs = MemoryFileSystem::default();
41084109
let mut console = BufferConsole::default();
41094110

@@ -4116,10 +4117,33 @@ fn harness_scss() {
41164117
Args::from(["format", file_path.as_str()].as_slice()),
41174118
);
41184119

4120+
let result = result.expect_err("This test will fail once SCSS support is officially added");
4121+
41194122
assert!(
4120-
result.is_err(),
4121-
"This test will fail once SCSS support is officially added"
4123+
matches!(result, CliDiagnostic::NoFilesWereProcessed(_)),
4124+
"Found: {result:?}"
4125+
)
4126+
}
4127+
4128+
#[test]
4129+
fn harness_scss_lint() {
4130+
let fs = MemoryFileSystem::default();
4131+
let mut console = BufferConsole::default();
4132+
4133+
let file_path = Utf8Path::new("format.scss");
4134+
fs.insert(file_path.into(), "$fff".as_bytes());
4135+
4136+
let (_, result) = run_cli(
4137+
fs,
4138+
&mut console,
4139+
Args::from(["lint", file_path.as_str()].as_slice()),
41224140
);
4141+
let result = result.expect_err("This test will fail once SCSS support is officially added");
4142+
4143+
assert!(
4144+
matches!(result, CliDiagnostic::NoFilesWereProcessed(_)),
4145+
"Found: {result:?}"
4146+
)
41234147
}
41244148

41254149
#[test]

crates/biome_css_formatter/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ name = "css_formatter"
2525
biome_css_syntax = { workspace = true }
2626
biome_diagnostics = { workspace = true }
2727
biome_formatter = { workspace = true }
28-
biome_languages = { workspace = true, features = ["scss"] }
28+
biome_languages = { workspace = true, features = ["lang_css"] }
2929
biome_rowan = { workspace = true }
3030
biome_string_case = { workspace = true }
3131
biome_suppression = { workspace = true }
@@ -37,6 +37,7 @@ biome_css_syntax = { path = "../biome_css_syntax", features = ["scss"] }
3737
biome_formatter = { path = "../biome_formatter", features = ["countme"] }
3838
biome_formatter_test = { path = "../biome_formatter_test", features = ["lang_css"] }
3939
biome_fs = { path = "../biome_fs" }
40+
biome_languages = { path = "../biome_languages" }
4041
biome_parser = { path = "../biome_parser" }
4142
biome_service = { path = "../biome_service", features = ["lang_css"] }
4243
biome_test_utils = { path = "../biome_test_utils", features = ["lang_css"] }

crates/biome_css_formatter/tests/spec_test.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use biome_configuration::css::CssFormatterConfiguration;
22
use biome_configuration::{Configuration, CssConfiguration};
33
use biome_formatter_test::spec::{SpecSnapshot, SpecTestFile};
4+
use biome_languages::{CssFileSource, DocumentFileSource};
45
use camino::Utf8Path;
56

67
pub fn run(spec_input_file: &str, _expected_file: &str, test_directory: &str, _file_type: &str) {
@@ -21,7 +22,13 @@ pub fn run(spec_input_file: &str, _expected_file: &str, test_directory: &str, _f
2122
..Default::default()
2223
};
2324

24-
let snapshot = SpecSnapshot::new(test_file, test_directory, config);
25+
let is_scss = test_file.file_name().ends_with(".scss");
26+
let mut snapshot = SpecSnapshot::new(test_file, test_directory, config);
27+
28+
if is_scss {
29+
snapshot =
30+
snapshot.with_document_file_source(DocumentFileSource::Css(CssFileSource::scss()));
31+
}
2532

2633
snapshot.test()
2734
}

0 commit comments

Comments
 (0)