diff --git a/.github/workflows/repository_dispatch.yml b/.github/workflows/repository_dispatch.yml index 3e9387effb0e..0321e2e2a412 100644 --- a/.github/workflows/repository_dispatch.yml +++ b/.github/workflows/repository_dispatch.yml @@ -39,7 +39,7 @@ jobs: run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build WASM module for the web - run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --profiling --scope biomejs crates/biome_wasm + run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --profiling --scope biomejs crates/biome_wasm --features experimental-html # https://github.com/actions/cache/issues/342 - name: Clear old wasm-pack cache diff --git a/crates/biome_cli/Cargo.toml b/crates/biome_cli/Cargo.toml index 21b26fcf35c4..06ad44b835e3 100644 --- a/crates/biome_cli/Cargo.toml +++ b/crates/biome_cli/Cargo.toml @@ -77,7 +77,8 @@ regex = { workspace = true } tokio = { workspace = true, features = ["io-util"] } [features] -docgen = ["bpaf/docgen"] +docgen = ["bpaf/docgen"] +experimental-html = ["biome_service/experimental-html"] [lints] workspace = true diff --git a/crates/biome_service/Cargo.toml b/crates/biome_service/Cargo.toml index fb3bb96f8035..1bb93d4567e7 100644 --- a/crates/biome_service/Cargo.toml +++ b/crates/biome_service/Cargo.toml @@ -66,6 +66,7 @@ slotmap = { workspace = true, features = ["serde"] } tracing = { workspace = true, features = ["attributes", "log"] } [features] +experimental-html = [] schema = [ "dep:schemars", "biome_js_analyze/schema", diff --git a/crates/biome_service/src/file_handlers/html.rs b/crates/biome_service/src/file_handlers/html.rs index 9d39e9714f15..45a4dee8bc00 100644 --- a/crates/biome_service/src/file_handlers/html.rs +++ b/crates/biome_service/src/file_handlers/html.rs @@ -1,3 +1,4 @@ +use biome_analyze::{AnalyzerConfiguration, AnalyzerOptions}; use biome_formatter::Printed; use biome_fs::BiomePath; use biome_html_formatter::{format_node, HtmlFormatOptions}; @@ -25,9 +26,9 @@ impl ServiceLanguage for HtmlLanguage { type EnvironmentSettings = (); fn lookup_settings( - _languages: &crate::settings::LanguageListSettings, + languages: &crate::settings::LanguageListSettings, ) -> &crate::settings::LanguageSettings { - todo!() + &languages.html } fn resolve_format_options( @@ -46,10 +47,13 @@ impl ServiceLanguage for HtmlLanguage { _linter: Option<&crate::settings::LinterSettings>, _overrides: Option<&crate::settings::OverrideSettings>, _language: Option<&Self::LinterSettings>, - _path: &biome_fs::BiomePath, + path: &biome_fs::BiomePath, _file_source: &super::DocumentFileSource, - ) -> biome_analyze::AnalyzerOptions { - todo!() + ) -> AnalyzerOptions { + AnalyzerOptions { + configuration: AnalyzerConfiguration::default(), + file_path: path.to_path_buf(), + } } } diff --git a/crates/biome_service/src/file_handlers/mod.rs b/crates/biome_service/src/file_handlers/mod.rs index 2da2abb62147..622940208ae2 100644 --- a/crates/biome_service/src/file_handlers/mod.rs +++ b/crates/biome_service/src/file_handlers/mod.rs @@ -144,9 +144,10 @@ impl DocumentFileSource { if let Ok(file_source) = GraphqlFileSource::try_from_extension(extension) { return Ok(file_source.into()); } - //if let Ok(file_source) = HtmlFileSource::try_from_extension(extension) { - // return Ok(file_source.into()); - //} + #[cfg(feature = "experimental-html")] + if let Ok(file_source) = HtmlFileSource::try_from_extension(extension) { + return Ok(file_source.into()); + } Err(FileSourceError::UnknownExtension) } @@ -170,9 +171,10 @@ impl DocumentFileSource { if let Ok(file_source) = GraphqlFileSource::try_from_language_id(language_id) { return Ok(file_source.into()); } - //if let Ok(file_source) = HtmlFileSource::try_from_language_id(language_id) { - // return Ok(file_source.into()); - //} + #[cfg(feature = "experimental-html")] + if let Ok(file_source) = HtmlFileSource::try_from_language_id(language_id) { + return Ok(file_source.into()); + } Err(FileSourceError::UnknownLanguageId) } @@ -314,7 +316,7 @@ impl DocumentFileSource { DocumentFileSource::Css(_) | DocumentFileSource::Graphql(_) | DocumentFileSource::Json(_) => true, - DocumentFileSource::Html(_) => false, + DocumentFileSource::Html(_) => cfg!(feature = "experimental-html"), DocumentFileSource::Unknown => false, } } diff --git a/crates/biome_service/src/settings.rs b/crates/biome_service/src/settings.rs index 7b3fb1cd0fa1..8eaf70178351 100644 --- a/crates/biome_service/src/settings.rs +++ b/crates/biome_service/src/settings.rs @@ -23,6 +23,7 @@ use biome_formatter::{ use biome_fs::BiomePath; use biome_graphql_formatter::context::GraphqlFormatOptions; use biome_graphql_syntax::GraphqlLanguage; +use biome_html_syntax::HtmlLanguage; use biome_js_formatter::context::JsFormatOptions; use biome_js_parser::JsParserOptions; use biome_js_syntax::{JsFileSource, JsLanguage}; @@ -560,6 +561,7 @@ pub struct LanguageListSettings { pub json: LanguageSettings, pub css: LanguageSettings, pub graphql: LanguageSettings, + pub html: LanguageSettings, } impl From for LanguageSettings { diff --git a/crates/biome_wasm/Cargo.toml b/crates/biome_wasm/Cargo.toml index 9e6672e74cbf..462dbbb6500a 100644 --- a/crates/biome_wasm/Cargo.toml +++ b/crates/biome_wasm/Cargo.toml @@ -16,7 +16,8 @@ version = "1.7.3" crate-type = ["cdylib", "rlib"] [features] -default = ["console_error_panic_hook"] +default = ["console_error_panic_hook"] +experimental-html = ["biome_service/experimental-html"] [dependencies] biome_console = { workspace = true }