Fix the router and stub out a number of crates to get compiling
This commit is contained in:
226 files changed
+1057
-1482
No files matched your search
+38
-38
@@ -279,7 +279,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_no_hooks() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
rsx! {
|
||||
p { "Hello World" }
|
||||
}
|
||||
@@ -294,8 +294,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_hook_correctly_used_inside_component() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
let count = use_state(cx, || 0);
|
||||
fn App() -> Element {
|
||||
let count = use_state(|| 0);
|
||||
rsx! {
|
||||
p { "Hello World: {count}" }
|
||||
}
|
||||
@@ -310,8 +310,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_hook_correctly_used_inside_hook_fn() {
|
||||
let contents = indoc! {r#"
|
||||
fn use_thing(cx: Scope) -> UseState<i32> {
|
||||
use_state(cx, || 0)
|
||||
fn use_thing() -> UseState<i32> {
|
||||
use_state(|| 0)
|
||||
}
|
||||
"#};
|
||||
|
||||
@@ -323,9 +323,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_hook_correctly_used_inside_hook_closure() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
let use_thing = || {
|
||||
use_state(cx, || 0)
|
||||
use_state(|| 0)
|
||||
};
|
||||
let count = use_thing();
|
||||
rsx! {
|
||||
@@ -342,9 +342,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_conditional_hook_if() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
if you_are_happy && you_know_it {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
}
|
||||
@@ -357,7 +357,7 @@ mod tests {
|
||||
vec![Issue::HookInsideConditional(
|
||||
HookInfo::new(
|
||||
Span::new_from_str(
|
||||
r#"use_state(cx, || "hands")"#,
|
||||
r#"use_state(|| "hands")"#,
|
||||
LineColumn { line: 3, column: 24 },
|
||||
),
|
||||
Span::new_from_str(
|
||||
@@ -368,7 +368,7 @@ mod tests {
|
||||
),
|
||||
ConditionalInfo::If(IfInfo::new(
|
||||
Span::new_from_str(
|
||||
"if you_are_happy && you_know_it {\n let something = use_state(cx, || \"hands\");\n println!(\"clap your {something}\")\n }",
|
||||
"if you_are_happy && you_know_it {\n let something = use_state(|| \"hands\");\n println!(\"clap your {something}\")\n }",
|
||||
LineColumn { line: 2, column: 4 },
|
||||
),
|
||||
Span::new_from_str(
|
||||
@@ -383,10 +383,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_conditional_hook_match() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
match you_are_happy && you_know_it {
|
||||
true => {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
false => {}
|
||||
@@ -400,13 +400,13 @@ mod tests {
|
||||
report.issues,
|
||||
vec![Issue::HookInsideConditional(
|
||||
HookInfo::new(
|
||||
Span::new_from_str(r#"use_state(cx, || "hands")"#, LineColumn { line: 4, column: 28 }),
|
||||
Span::new_from_str(r#"use_state(|| "hands")"#, LineColumn { line: 4, column: 28 }),
|
||||
Span::new_from_str(r#"use_state"#, LineColumn { line: 4, column: 28 }),
|
||||
"use_state".to_string()
|
||||
),
|
||||
ConditionalInfo::Match(MatchInfo::new(
|
||||
Span::new_from_str(
|
||||
"match you_are_happy && you_know_it {\n true => {\n let something = use_state(cx, || \"hands\");\n println!(\"clap your {something}\")\n }\n false => {}\n }",
|
||||
"match you_are_happy && you_know_it {\n true => {\n let something = use_state(|| \"hands\");\n println!(\"clap your {something}\")\n }\n false => {}\n }",
|
||||
LineColumn { line: 2, column: 4 },
|
||||
),
|
||||
Span::new_from_str("match you_are_happy && you_know_it", LineColumn { line: 2, column: 4 })
|
||||
@@ -418,9 +418,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_for_loop_hook() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
for _name in &names {
|
||||
let is_selected = use_state(cx, || false);
|
||||
let is_selected = use_state(|| false);
|
||||
println!("selected: {is_selected}");
|
||||
}
|
||||
}
|
||||
@@ -433,7 +433,7 @@ mod tests {
|
||||
vec![Issue::HookInsideLoop(
|
||||
HookInfo::new(
|
||||
Span::new_from_str(
|
||||
"use_state(cx, || false)",
|
||||
"use_state(|| false)",
|
||||
LineColumn { line: 3, column: 26 },
|
||||
),
|
||||
Span::new_from_str(
|
||||
@@ -444,7 +444,7 @@ mod tests {
|
||||
),
|
||||
AnyLoopInfo::For(ForInfo::new(
|
||||
Span::new_from_str(
|
||||
"for _name in &names {\n let is_selected = use_state(cx, || false);\n println!(\"selected: {is_selected}\");\n }",
|
||||
"for _name in &names {\n let is_selected = use_state(|| false);\n println!(\"selected: {is_selected}\");\n }",
|
||||
LineColumn { line: 2, column: 4 },
|
||||
),
|
||||
Span::new_from_str(
|
||||
@@ -459,9 +459,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_while_loop_hook() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
while true {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
}
|
||||
@@ -474,7 +474,7 @@ mod tests {
|
||||
vec![Issue::HookInsideLoop(
|
||||
HookInfo::new(
|
||||
Span::new_from_str(
|
||||
r#"use_state(cx, || "hands")"#,
|
||||
r#"use_state(|| "hands")"#,
|
||||
LineColumn { line: 3, column: 24 },
|
||||
),
|
||||
Span::new_from_str(
|
||||
@@ -485,7 +485,7 @@ mod tests {
|
||||
),
|
||||
AnyLoopInfo::While(WhileInfo::new(
|
||||
Span::new_from_str(
|
||||
"while true {\n let something = use_state(cx, || \"hands\");\n println!(\"clap your {something}\")\n }",
|
||||
"while true {\n let something = use_state(|| \"hands\");\n println!(\"clap your {something}\")\n }",
|
||||
LineColumn { line: 2, column: 4 },
|
||||
),
|
||||
Span::new_from_str(
|
||||
@@ -500,9 +500,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_loop_hook() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
loop {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
}
|
||||
@@ -515,7 +515,7 @@ mod tests {
|
||||
vec![Issue::HookInsideLoop(
|
||||
HookInfo::new(
|
||||
Span::new_from_str(
|
||||
r#"use_state(cx, || "hands")"#,
|
||||
r#"use_state(|| "hands")"#,
|
||||
LineColumn { line: 3, column: 24 },
|
||||
),
|
||||
Span::new_from_str(
|
||||
@@ -525,7 +525,7 @@ mod tests {
|
||||
"use_state".to_string()
|
||||
),
|
||||
AnyLoopInfo::Loop(LoopInfo::new(Span::new_from_str(
|
||||
"loop {\n let something = use_state(cx, || \"hands\");\n println!(\"clap your {something}\")\n }",
|
||||
"loop {\n let something = use_state(|| \"hands\");\n println!(\"clap your {something}\")\n }",
|
||||
LineColumn { line: 2, column: 4 },
|
||||
)))
|
||||
)],
|
||||
@@ -535,8 +535,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_conditional_okay() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
let something = use_state(cx, || "hands");
|
||||
fn App() -> Element {
|
||||
let something = use_state(|| "hands");
|
||||
if you_are_happy && you_know_it {
|
||||
println!("clap your {something}")
|
||||
}
|
||||
@@ -551,9 +551,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_closure_hook() {
|
||||
let contents = indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
let _a = || {
|
||||
let b = use_state(cx, || 0);
|
||||
let b = use_state(|| 0);
|
||||
b.get()
|
||||
};
|
||||
}
|
||||
@@ -566,7 +566,7 @@ mod tests {
|
||||
vec![Issue::HookInsideClosure(
|
||||
HookInfo::new(
|
||||
Span::new_from_str(
|
||||
"use_state(cx, || 0)",
|
||||
"use_state(|| 0)",
|
||||
LineColumn {
|
||||
line: 3,
|
||||
column: 16
|
||||
@@ -582,7 +582,7 @@ mod tests {
|
||||
"use_state".to_string()
|
||||
),
|
||||
ClosureInfo::new(Span::new_from_str(
|
||||
"|| {\n let b = use_state(cx, || 0);\n b.get()\n }",
|
||||
"|| {\n let b = use_state(|| 0);\n b.get()\n }",
|
||||
LineColumn {
|
||||
line: 2,
|
||||
column: 13
|
||||
@@ -595,8 +595,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_hook_outside_component() {
|
||||
let contents = indoc! {r#"
|
||||
fn not_component_or_hook(cx: Scope) {
|
||||
let _a = use_state(cx, || 0);
|
||||
fn not_component_or_hook() {
|
||||
let _a = use_state(|| 0);
|
||||
}
|
||||
"#};
|
||||
|
||||
@@ -606,7 +606,7 @@ mod tests {
|
||||
report.issues,
|
||||
vec![Issue::HookOutsideComponent(HookInfo::new(
|
||||
Span::new_from_str(
|
||||
"use_state(cx, || 0)",
|
||||
"use_state(|| 0)",
|
||||
LineColumn {
|
||||
line: 2,
|
||||
column: 13
|
||||
@@ -627,8 +627,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_hook_inside_hook() {
|
||||
let contents = indoc! {r#"
|
||||
fn use_thing(cx: Scope) {
|
||||
let _a = use_state(cx, || 0);
|
||||
fn use_thing() {
|
||||
let _a = use_state(|| 0);
|
||||
}
|
||||
"#};
|
||||
|
||||
|
||||
@@ -230,9 +230,9 @@ mod tests {
|
||||
let issue_report = check_file(
|
||||
"src/main.rs".into(),
|
||||
indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
if you_are_happy && you_know_it {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ mod tests {
|
||||
error: hook called conditionally: `use_state` (inside `if`)
|
||||
--> src/main.rs:3:25
|
||||
|
|
||||
3 | let something = use_state(cx, || "hands");
|
||||
3 | let something = use_state(|| "hands");
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `if you_are_happy && you_know_it { … }` is the conditional
|
||||
@@ -258,10 +258,10 @@ mod tests {
|
||||
let issue_report = check_file(
|
||||
"src/main.rs".into(),
|
||||
indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
match you_are_happy && you_know_it {
|
||||
true => {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
_ => {}
|
||||
@@ -274,7 +274,7 @@ mod tests {
|
||||
error: hook called conditionally: `use_state` (inside `match`)
|
||||
--> src/main.rs:4:29
|
||||
|
|
||||
4 | let something = use_state(cx, || "hands");
|
||||
4 | let something = use_state(|| "hands");
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `match you_are_happy && you_know_it { … }` is the conditional
|
||||
@@ -289,9 +289,9 @@ mod tests {
|
||||
let issue_report = check_file(
|
||||
"src/main.rs".into(),
|
||||
indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
for i in 0..10 {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ mod tests {
|
||||
error: hook called in a loop: `use_state` (inside `for` loop)
|
||||
--> src/main.rs:3:25
|
||||
|
|
||||
3 | let something = use_state(cx, || "hands");
|
||||
3 | let something = use_state(|| "hands");
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `for i in 0..10 { … }` is the loop
|
||||
@@ -317,9 +317,9 @@ mod tests {
|
||||
let issue_report = check_file(
|
||||
"src/main.rs".into(),
|
||||
indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
while check_thing() {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ mod tests {
|
||||
error: hook called in a loop: `use_state` (inside `while` loop)
|
||||
--> src/main.rs:3:25
|
||||
|
|
||||
3 | let something = use_state(cx, || "hands");
|
||||
3 | let something = use_state(|| "hands");
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `while check_thing() { … }` is the loop
|
||||
@@ -345,9 +345,9 @@ mod tests {
|
||||
let issue_report = check_file(
|
||||
"src/main.rs".into(),
|
||||
indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
loop {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ mod tests {
|
||||
error: hook called in a loop: `use_state` (inside `loop`)
|
||||
--> src/main.rs:3:25
|
||||
|
|
||||
3 | let something = use_state(cx, || "hands");
|
||||
3 | let something = use_state(|| "hands");
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `loop { … }` is the loop
|
||||
@@ -373,9 +373,9 @@ mod tests {
|
||||
let issue_report = check_file(
|
||||
"src/main.rs".into(),
|
||||
indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
let something = || {
|
||||
let something = use_state(cx, || "hands");
|
||||
let something = use_state(|| "hands");
|
||||
println!("clap your {something}")
|
||||
};
|
||||
}
|
||||
@@ -386,7 +386,7 @@ mod tests {
|
||||
error: hook called in a closure: `use_state`
|
||||
--> src/main.rs:3:25
|
||||
|
|
||||
3 | let something = use_state(cx, || "hands");
|
||||
3 | let something = use_state(|| "hands");
|
||||
| ^^^^^^^^^
|
||||
"#};
|
||||
|
||||
@@ -399,9 +399,9 @@ mod tests {
|
||||
let issue_report = check_file(
|
||||
"src/main.rs".into(),
|
||||
indoc! {r#"
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
if you_are_happy && you_know_it {
|
||||
let something = use_state(cx, || {
|
||||
let something = use_state(|| {
|
||||
"hands"
|
||||
});
|
||||
println!("clap your {something}")
|
||||
@@ -414,7 +414,7 @@ mod tests {
|
||||
error: hook called conditionally: `use_state` (inside `if`)
|
||||
--> src/main.rs:3:25
|
||||
|
|
||||
3 | let something = use_state(cx, || {
|
||||
3 | let something = use_state(|| {
|
||||
| ^^^^^^^^^
|
||||
4 | "hands"
|
||||
5 | });
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
pub struct HookInfo {
|
||||
/// The name of the hook, e.g. `use_state`.
|
||||
pub name: String,
|
||||
/// The span of the hook, e.g. `use_state(cx, || 0)`.
|
||||
/// The span of the hook, e.g. `use_state(|| 0)`.
|
||||
pub span: Span,
|
||||
/// The span of the name, e.g. `use_state`.
|
||||
pub name_span: Span,
|
||||
|
||||
Reference in new issue
Block a user