Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(html): add experimental-html feature flag to enable html file handler #3967

Merged
merged 1 commit into from
Sep 19, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/repository_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion crates/biome_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions crates/biome_service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 9 additions & 5 deletions crates/biome_service/src/file_handlers/html.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use biome_analyze::{AnalyzerConfiguration, AnalyzerOptions};
use biome_formatter::Printed;
use biome_fs::BiomePath;
use biome_html_formatter::{format_node, HtmlFormatOptions};
Expand Down Expand Up @@ -25,9 +26,9 @@ impl ServiceLanguage for HtmlLanguage {
type EnvironmentSettings = ();

fn lookup_settings(
_languages: &crate::settings::LanguageListSettings,
languages: &crate::settings::LanguageListSettings,
) -> &crate::settings::LanguageSettings<Self> {
todo!()
&languages.html
}

fn resolve_format_options(
Expand All @@ -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(),
}
}
}

Expand Down
16 changes: 9 additions & 7 deletions crates/biome_service/src/file_handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down Expand Up @@ -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,
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/biome_service/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -560,6 +561,7 @@ pub struct LanguageListSettings {
pub json: LanguageSettings<JsonLanguage>,
pub css: LanguageSettings<CssLanguage>,
pub graphql: LanguageSettings<GraphqlLanguage>,
pub html: LanguageSettings<HtmlLanguage>,
}

impl From<JavascriptConfiguration> for LanguageSettings<JsLanguage> {
Expand Down
3 changes: 2 additions & 1 deletion crates/biome_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down