Skip to content

Commit

Permalink
feat(migrate): migrate nursery rules (#2382)
Browse files Browse the repository at this point in the history
Co-authored-by: Victorien Elvinger <[email protected]>
  • Loading branch information
ematipico and Conaclos authored May 14, 2024
1 parent e486b7f commit 99d5f63
Show file tree
Hide file tree
Showing 16 changed files with 623 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ indent_size = 2

# YAML doesn't support hard tabs 🙃
# Templates that will be weird with hard tabs in the website editor
[{**.yml,**.md,**.rs,**.mdx,justfile}]
[{**.yml,**.md,**.rs,**.mdx,justfile,**.json}]
indent_style = space

[*.rs]
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions crates/biome_json_factory/src/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,22 @@ pub use crate::generated::node_factory::*;
pub fn ident(text: &str) -> JsonSyntaxToken {
JsonSyntaxToken::new_detached(JsonSyntaxKind::IDENT, text, [], [])
}

/// Create a new token with the specified syntax kind and no attached trivia
pub fn token(kind: JsonSyntaxKind) -> JsonSyntaxToken {
if let Some(text) = kind.to_string() {
JsonSyntaxToken::new_detached(kind, text, [], [])
} else {
panic!("token kind {kind:?} cannot be transformed to text")
}
}

/// Create a new string literal token with no attached trivia
pub fn json_string_literal(text: &str) -> JsonSyntaxToken {
JsonSyntaxToken::new_detached(
JsonSyntaxKind::JSON_STRING_LITERAL,
&format!("\"{text}\""),
[],
[],
)
}
1 change: 1 addition & 0 deletions crates/biome_migrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ biome_json_factory = { workspace = true }
biome_json_syntax = { workspace = true }
biome_rowan = { workspace = true }
lazy_static = { workspace = true }
rustc-hash = { workspace = true }

[dev-dependencies]
biome_json_factory = { path = "../biome_json_factory" }
Expand Down
6 changes: 5 additions & 1 deletion crates/biome_migrate/src/analyzers.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::analyzers::indent_size::IndentSize;
use crate::analyzers::nursery_rules::NurseryRules;
use crate::analyzers::schema::Schema;
use biome_analyze::{GroupCategory, RegistryVisitor, RuleCategory, RuleGroup};
use biome_json_syntax::JsonLanguage;

mod indent_size;
mod nursery_rules;
mod schema;

pub(crate) struct MigrationGroup;
Expand All @@ -19,7 +21,9 @@ impl RuleGroup for MigrationGroup {
// v1.3.0
registry.record_rule::<IndentSize>();
// v1.5.0
registry.record_rule::<Schema>()
registry.record_rule::<Schema>();
// v1.8.0
registry.record_rule::<NurseryRules>();
}
}

Expand Down
Loading

0 comments on commit 99d5f63

Please sign in to comment.