Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
improv justfile
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Dec 3, 2022
1 parent a39b9bd commit 1a834d4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::use_exhaustive_dependencies::ReactExtensiveDependenciesOptions;
declare_rule! {
/// Enforce that all React hooks are being called from the Top Level
/// component functions.
///
///
/// To understand why this required see https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
///
/// ## Examples
Expand Down
8 changes: 6 additions & 2 deletions crates/rome_js_unicode_table/src/tables.rs

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

9 changes: 9 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ new-lintrule path name:
just codegen
just documentation

[unix]
touch file:
touch {{file}}

[windows]
touch file:
(gci {{file}}).LastWriteTime = Get-Date

test-lintrule name:
just touch crates/rome_js_analyze/tests/spec_tests.rs
cargo test -p rome_js_analyze -- {{snakecase(name)}}

check-ready:
Expand Down
12 changes: 4 additions & 8 deletions xtask/codegen/src/generate_new_lintrule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ use case::CaseExt;

pub fn generate_new_lintrule(path: &str, rule_name: &str) {
let rule_folder = PathBuf::from_str(path).unwrap();
match rule_folder.file_stem()
.and_then(|x| x.to_str()) {
Some("nursery") => {},
match rule_folder.file_stem().and_then(|x| x.to_str()) {
Some("nursery") => {}
_ => {
panic!("all new rules must be at a nursery folder");
},
}
}


let rule_name_upper_camel = rule_name.to_camel();
let rule_name_snake = rule_name.to_snake();
let rule_name_lower_camel = rule_name_snake.to_camel_lowercase();
Expand Down Expand Up @@ -65,7 +63,6 @@ None
let file_name = format!("{path}/{rule_name_snake}.rs");
std::fs::write(file_name, code).unwrap();


let categories_path = "crates/rome_diagnostics_categories/src/categories.rs";
let categories = std::fs::read_to_string(categories_path).unwrap();
let insertion_point = r#"
Expand All @@ -82,5 +79,4 @@ None
// General categories"#));
debug_assert!(categories.contains(&rule_name_lower_camel));
std::fs::write(categories_path, categories).unwrap();

}
}
2 changes: 1 addition & 1 deletion xtask/codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod css_kinds_src;
mod formatter;
mod generate_analyzer;
mod generate_macros;
pub mod generate_new_lintrule;
mod generate_node_factory;
mod generate_nodes;
mod generate_nodes_mut;
Expand All @@ -15,7 +16,6 @@ mod kinds_src;
mod parser_tests;
mod termcolorful;
mod unicode;
pub mod generate_new_lintrule;
use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use std::path::Path;
Expand Down
4 changes: 2 additions & 2 deletions xtask/codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ mod generate_aria;
mod generate_bindings;
#[cfg(feature = "configuration")]
mod generate_configuration;
mod generate_new_lintrule;
#[cfg(feature = "schema")]
mod generate_schema;
mod generate_new_lintrule;

use pico_args::Arguments;
use xtask::{project_root, pushd, Mode, Result};
Expand All @@ -19,10 +19,10 @@ use crate::generate_bindings::generate_workspace_bindings;
use crate::generate_configuration::generate_rules_configuration;
#[cfg(feature = "schema")]
use crate::generate_schema::generate_configuration_schema;
use generate_new_lintrule::*;
use xtask_codegen::{
generate_analyzer, generate_ast, generate_formatters, generate_parser_tests, generate_tables,
};
use generate_new_lintrule::*;

fn main() -> Result<()> {
let _d = pushd(project_root());
Expand Down
4 changes: 1 addition & 3 deletions xtask/codegen/src/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ pub fn generate_tables() -> Result<()> {
#(#ranges),*
];

pub fn #fn_ident(c: char) -> bool {
super::bsearch_range_table(c, #table_ident)
}
pub fn #fn_ident(c: char) -> bool { super::bsearch_range_table(c, #table_ident) }
})
})
.collect::<Result<Vec<_>, _>>()?;
Expand Down

0 comments on commit 1a834d4

Please sign in to comment.