Skip to content
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
10 changes: 8 additions & 2 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,23 @@ extend-ignore-identifiers-re = [
"prev",
"normalises",
"goes",
"Bare",
"inout",
"ba",
"ede",
"Bare",
]

[default.extend-words]
Bare = "Bare"
Supress = "Supress"
teh = "teh"
Teh = "Teh"

[files]
ignore-hidden = false
ignore-files = true
extend-exclude = [
"./CHANGELOG.md",
"CHANGELOG.md",
"/usr/**/*",
"/tmp/**/*",
"/**/node_modules/**",
Expand Down
6 changes: 3 additions & 3 deletions crates/language/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,17 +1721,17 @@ pub fn from_extension(path: &Path) -> Option<SupportLang> {
}

// Handle extensionless files or files with unknown extensions
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
if let Some(_file_name) = path.file_name().and_then(|n| n.to_str()) {
// 1. Check if the full filename matches a known extension (e.g. .bashrc)
#[cfg(any(feature = "bash", feature = "all-parsers"))]
if constants::BASH_EXTS.contains(&file_name) {
if constants::BASH_EXTS.contains(&_file_name) {
return Some(SupportLang::Bash);
}

// 2. Check known extensionless file names
#[cfg(any(feature = "bash", feature = "all-parsers", feature = "ruby"))]
for (name, lang) in constants::LANG_RELATIONSHIPS_WITH_NO_EXTENSION {
if *name == file_name {
if *name == _file_name {
return Some(*lang);
}
}
Expand Down
23 changes: 22 additions & 1 deletion crates/rule-engine/src/transform/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,5 +551,26 @@ if (true) {
Ok(())
}

// TODO: add a symbolic test for Rewrite
#[test]
fn test_rewrite() -> R {
let trans = parse(
r#"
rewrite:
source: "$A"
rewriters: ["re1", "re2"]
joinBy: ", "
"#,
)?;
let parsed = trans.parse(&TypeScript::Tsx).expect("should parse");
match &parsed {
Trans::Rewrite(r) => {
assert_eq!(r.rewriters, vec!["re1", "re2"]);
assert_eq!(r.join_by, Some(", ".to_string()));
}
_ => panic!("should be rewrite"),
}
assert_eq!(parsed.used_rewriters(), &["re1", "re2"]);
assert_eq!(parsed.used_vars(), "A");
Ok(())
}
}
Loading