Skip to content

Commit

Permalink
chore: revert LanguageKind
Browse files Browse the repository at this point in the history
  • Loading branch information
togami2864 committed Mar 27, 2024
1 parent 6ce3ddf commit a906118
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 65 deletions.
4 changes: 2 additions & 2 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ pub use crate::registry::{
RuleRegistry, RuleRegistryBuilder, RuleSuppressions,
};
pub use crate::rule::{
CategoryLanguage, FixKind, GroupCategory, GroupLanguage, LanguageKind, Rule, RuleAction,
RuleDiagnostic, RuleGroup, RuleMeta, RuleMetadata, RuleSource, RuleSourceKind, SuppressAction,
CategoryLanguage, FixKind, GroupCategory, GroupLanguage, Rule, RuleAction, RuleDiagnostic,
RuleGroup, RuleMeta, RuleMetadata, RuleSource, RuleSourceKind, SuppressAction,
};
pub use crate::services::{FromServices, MissingServicesDiagnostic, ServiceBag};
pub use crate::signals::{
Expand Down
30 changes: 0 additions & 30 deletions crates/biome_analyze/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ pub struct RuleMetadata {
pub recommended: bool,
/// The kind of fix
pub fix_kind: Option<FixKind>,
/// The target language
pub language_kind: Option<LanguageKind>,
/// The source URL of the rule
pub source: Option<RuleSource>,
/// The source kind of the rule
Expand Down Expand Up @@ -229,28 +227,6 @@ impl RuleSourceKind {
}
}

#[derive(Debug, Default, Clone)]
pub enum LanguageKind {
#[default]
Js,
Json,
Css,
}

impl LanguageKind {
pub const fn is_js(&self) -> bool {
matches!(self, Self::Js)
}

pub const fn is_json(&self) -> bool {
matches!(self, Self::Json)
}

pub const fn is_css(&self) -> bool {
matches!(self, Self::Css)
}
}

impl RuleMetadata {
pub const fn new(version: &'static str, name: &'static str, docs: &'static str) -> Self {
Self {
Expand All @@ -262,7 +238,6 @@ impl RuleMetadata {
fix_kind: None,
source: None,
source_kind: None,
language_kind: None,
}
}

Expand Down Expand Up @@ -293,11 +268,6 @@ impl RuleMetadata {
self.source_kind = Some(source_kind);
self
}

pub const fn language_kind(mut self, language_kind: LanguageKind) -> Self {
self.language_kind = Some(language_kind);
self
}
}

pub trait RuleMeta {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use biome_analyze::{context::RuleContext, declare_rule, Ast, LanguageKind, Rule, RuleDiagnostic};
use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use biome_console::markup;
use biome_css_syntax::CssDeclarationOrRuleBlock;
use biome_rowan::AstNode;
Expand Down Expand Up @@ -28,7 +28,6 @@ declare_rule! {
version: "next",
name: "noColorInvalidHex",
recommended: false,
language_kind: LanguageKind::Css,
}
}

Expand Down
35 changes: 4 additions & 31 deletions xtask/lintdoc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,32 +241,12 @@ fn generate_group(
writeln!(main_page_buffer)?;
write_markup_to_string(main_page_buffer, description)?;
writeln!(main_page_buffer)?;
if is_nursery {
writeln!(
main_page_buffer,
"| Rule name | Description | Properties | Language |"
)?;
writeln!(main_page_buffer, "| --- | --- | --- | --- |")?;
} else {
writeln!(main_page_buffer, "| Rule name | Description | Properties |")?;
writeln!(main_page_buffer, "| --- | --- | --- |")?;
}
writeln!(main_page_buffer, "| Rule name | Description | Properties |")?;
writeln!(main_page_buffer, "| --- | --- | --- |")?;

for (rule, meta) in rules {
let is_recommended = !is_nursery && meta.recommended;
let dashed_rule = Case::Kebab.convert(rule);
let lang_kind = meta.language_kind.unwrap_or_default();
let lang_icon = match lang_kind {
LanguageKind::Js => {
"<img alt=\"JavaScript logo\" src=\"/src/assets/svg/js-icon.svg\" />"
}
LanguageKind::Json => {
"<img alt=\"JavaScript logo\" src=\"/src/assets/svg/json-icon.svg\" />"
}
LanguageKind::Css => {
"<img alt=\"JavaScript logo\" src=\"/src/assets/svg/css-icon.svg\" />"
}
};
if is_recommended {
recommended_rules.push_str(&format!(
"\t<li><a href='/linter/rules/{dashed_rule}'>{rule}</a></li>\n"
Expand Down Expand Up @@ -301,17 +281,10 @@ fn generate_group(
let mut summary_html = Vec::new();
write_html(&mut summary_html, summary.into_iter())?;
let summary_html = String::from_utf8_lossy(&summary_html);
if is_nursery {
write!(
write!(
main_page_buffer,
"| [{rule}](/linter/rules/{dashed_rule}) | {summary_html} | {properties} | {lang_icon} |"
"| [{rule}](/linter/rules/{dashed_rule}) | {summary_html} | {properties} |"
)?;
} else {
write!(
main_page_buffer,
"| [{rule}](/linter/rules/{dashed_rule}) | {summary_html} | {properties} |"
)?;
}

writeln!(main_page_buffer)?;
}
Expand Down

0 comments on commit a906118

Please sign in to comment.