Skip to content

Commit 116ecd3

Browse files
authored
Fix unexpected_cfgs warnings and add a troubleshooting note (#783)
* add `sycamore_force_ssr` to the list of accepted cfg * enable workspace lints on all examples crates * add `rust_analyzer` to valid cfg * enable workspace lints on all packages * doc: add a troubleshooting note
1 parent b0aa222 commit 116ecd3

File tree

34 files changed

+140
-7
lines changed

34 files changed

+140
-7
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ sycamore-web = { path = "packages/sycamore-web", version = "0.9.1" }
5858

5959
[profile.bench]
6060
debug = true
61+
62+
[workspace.lints.rust]
63+
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(sycamore_force_ssr)", "cfg(rust_analyzer)"] }

docs/next/troubleshooting.md

+15
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,18 @@ console_error_panic_hook::set_once();
1818
## Debugging using DWARF + WASM
1919

2020
> Note: This section is a stub. Help us write this section!
21+
22+
## unexpected `cfg` condition name: `sycamore_force_ssr`
23+
24+
Sycamore uses a custom cfg (`sycamore_force_ssr`) to force the SSR mode. Because
25+
the compiler doesn't know about custom cfg it will emit warnings. To disables
26+
those warnings, add the following lints configuration in the `Cargo.toml` file
27+
of your project.
28+
29+
```toml
30+
[lints.rust]
31+
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(sycamore_force_ssr)"] }
32+
```
33+
34+
More information here:
35+
<https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html#check-cfg-in-lintsrust-table>

examples/attributes-passthrough/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/components/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/context/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/counter/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/hello-builder/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ edition = "2021"
88
[dependencies]
99
console_error_panic_hook = "0.1.7"
1010
sycamore = { path = "../../packages/sycamore" }
11+
12+
13+
[lints]
14+
workspace = true

examples/hello-world/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/higher-order-components/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/http-request-builder/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ console_error_panic_hook = "0.1.7"
1010
gloo-net = { version = "0.6.0", features = ["http"] }
1111
serde = { version = "1.0.147", features = ["derive"] }
1212
sycamore = { path = "../../packages/sycamore", features = ["suspense"] }
13+
14+
15+
[lints]
16+
workspace = true

examples/http-request/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ console_error_panic_hook = "0.1.7"
1010
gloo-net = { version = "0.6.0", features = ["http"] }
1111
serde = { version = "1.0.147", features = ["derive"] }
1212
sycamore = { path = "../../packages/sycamore", features = ["suspense"] }
13+
14+
15+
[lints]
16+
workspace = true

examples/hydrate/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ edition = "2021"
99
console_error_panic_hook = "0.1.7"
1010
sycamore = { path = "../../packages/sycamore", features = ["hydrate"] }
1111
wasm-bindgen = "0.2.83"
12+
13+
[lints]
14+
workspace = true

examples/iteration/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/js-framework-benchmark/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ console_error_panic_hook = "0.1.7"
1010
getrandom = { version = "0.2.8", features = ["js"] }
1111
rand = "0.8.5"
1212
sycamore = { path = "../../packages/sycamore" }
13+
14+
15+
[lints]
16+
workspace = true

examples/js-snippets/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ edition = "2021"
88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
1010
wasm-bindgen = "0.2.83"
11+
12+
13+
[lints]
14+
workspace = true

examples/motion/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ edition = "2021"
88
[dependencies]
99
console_error_panic_hook = "0.1.7"
1010
sycamore = { path = "../../packages/sycamore" }
11+
12+
13+
[lints]
14+
workspace = true

examples/number-binding/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/router/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ edition = "2021"
88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
1010
sycamore-router = { path = "../../packages/sycamore-router" }
11+
12+
13+
[lints]
14+
workspace = true

examples/ssr-streaming/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ sycamore = { path = "../../packages/sycamore", features = [
99
"hydrate",
1010
] }
1111

12+
[lints]
13+
workspace = true
14+
1215
[target.'cfg(all(target_arch = "wasm32", not(sycamore_force_ssr)))'.dependencies]
1316
console_error_panic_hook = "0.1.7"
1417

examples/ssr-suspense/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ sycamore = { path = "../../packages/sycamore", features = [
99
"hydrate",
1010
] }
1111

12+
[lints]
13+
workspace = true
14+
1215
[target.'cfg(all(target_arch = "wasm32", not(sycamore_force_ssr)))'.dependencies]
1316
console_error_panic_hook = "0.1.7"
1417

examples/ssr/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/svg/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
sycamore = { path = "../../packages/sycamore" }
10+
11+
12+
[lints]
13+
workspace = true

examples/timer/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ edition = "2021"
88
[dependencies]
99
gloo-timers = { version = "0.2.4", features = ["futures"] }
1010
sycamore = { path = "../../packages/sycamore", features = ["suspense"] }
11+
12+
13+
[lints]
14+
workspace = true

examples/todomvc/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ uuid = { version = "1.2.2", features = ["serde", "v4", "js"] }
1515
[dependencies.web-sys]
1616
features = ["Location", "Storage", "HtmlInputElement"]
1717
version = "0.3.60"
18+
19+
20+
[lints]
21+
workspace = true

examples/transitions/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ getrandom = { version = "0.2.8", features = ["js"] }
1111
gloo-timers = { version = "0.2.4", features = ["futures"] }
1212
rand = "0.8.5"
1313
sycamore = { path = "../../packages/sycamore", features = ["suspense"] }
14+
15+
16+
[lints]
17+
workspace = true

packages/sycamore-core/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ sycamore = { path = "../sycamore" }
2222
[features]
2323
default = []
2424
suspense = ["sycamore-futures"]
25+
26+
27+
[lints]
28+
workspace = true

packages/sycamore-futures/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ tokio = { version = "1.22.0", features = ["rt"] }
2626
tokio = { version = "1.22.0", features = ["rt", "macros"] }
2727
tokio-test = "0.4.4"
2828

29-
[lints.rust]
30-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(sycamore_force_ssr)'] }
29+
[lints]
30+
workspace = true

packages/sycamore-macro/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ trybuild = "1.0.71"
2727

2828
[features]
2929
default = []
30+
31+
32+
[lints]
33+
workspace = true

packages/sycamore-reactive/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ default = []
2424
nightly = []
2525
serde = ["dep:serde"]
2626
wasm-bindgen = ["dep:wasm-bindgen"]
27+
28+
29+
[lints]
30+
workspace = true

packages/sycamore-router-macro/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ syn = "2.0.10"
2424
expect-test = "1.4.0"
2525
sycamore-router = { path = "../sycamore-router" }
2626
trybuild = "1.0.71"
27+
28+
29+
[lints]
30+
workspace = true

packages/sycamore-router/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ features = [
3232
"UrlSearchParams",
3333
]
3434
version = "0.3.60"
35+
36+
37+
[lints]
38+
workspace = true

packages/sycamore-view-parser/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ version.workspace = true
1414
proc-macro2 = "1.0.47"
1515
quote = "1.0.21"
1616
syn = { version = "2.0.10", features = ["extra-traits", "full"] }
17+
18+
19+
[lints]
20+
workspace = true

packages/sycamore-web/Cargo.toml

+3-5
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ hydrate = []
8282
suspense = ["dep:sycamore-futures", "dep:futures", "dep:async-stream"]
8383
wasm-bindgen-interning = ["wasm-bindgen/enable-interning"]
8484

85-
[lints.rust]
86-
unexpected_cfgs = { level = "warn", check-cfg = [
87-
"cfg(sycamore_force_ssr)",
88-
"cfg(rust_analyzer)",
89-
] }
85+
86+
[lints]
87+
workspace = true

packages/sycamore/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ required-features = ["hydrate"]
5656
[package.metadata.docs.rs]
5757
all-features = true
5858
default-target = "wasm32-unknown-unknown"
59+
60+
61+
[lints]
62+
workspace = true

0 commit comments

Comments
 (0)