Skip to content

Commit 2089ba6

Browse files
authored
Tune up project linting (#1317)
- move lints configuration to `Cargo.toml` - omit using `#[deny]` for rustc lints for better future compatibility - use `#[expect]` instead of `#[allow]` asap
1 parent 9f12fe3 commit 2089ba6

File tree

80 files changed

+355
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+355
-139
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
resolver = "1" # unifying Cargo features asap for Book tests
33
members = [
44
"benches",
5+
"book",
56
"juniper_codegen",
67
"juniper",
78
"juniper_hyper",

benches/Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@ authors = ["Christoph Herzog <chris@theduke.at>"]
66
publish = false
77

88
[dependencies]
9-
dataloader = "0.18" # for Book only
10-
futures = "0.3"
119
juniper = { path = "../juniper" }
1210

1311
[dev-dependencies]
1412
criterion = "0.5"
1513
tokio = { version = "1.0", features = ["rt-multi-thread"] }
1614

15+
[lints.clippy]
16+
allow_attributes = "warn"
17+
allow_attributes_without_reason = "warn"
18+
[lints.rust]
19+
closure_returning_async_block = "warn"
20+
future_incompatible = { level = "warn", priority = -1 }
21+
impl_trait_redundant_captures = "warn"
22+
non_ascii_idents = "forbid"
23+
unsafe_code = "forbid"
24+
unused_crate_dependencies = "warn"
25+
1726
[[bench]]
1827
name = "benchmark"
1928
harness = false

benches/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#[cfg(test)]
2+
mod for_benches_only {
3+
use criterion as _;
4+
use tokio as _;
5+
}
6+
17
use juniper::{
28
DefaultScalarValue, EmptyMutation, EmptySubscription, ExecutionError, FieldError, GraphQLEnum,
39
GraphQLObject, RootNode, Value, Variables, graphql_object,

book/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "juniper_book"
3+
version = "0.0.0"
4+
edition = "2024"
5+
authors = ["Kai Ren <tyranron@gmail.com>"]
6+
publish = false
7+
8+
[dependencies]
9+
dataloader = "0.18" # for Book only
10+
11+
[lints.clippy]
12+
allow_attributes = "warn"
13+
allow_attributes_without_reason = "warn"
14+
[lints.rust]
15+
closure_returning_async_block = "warn"
16+
future_incompatible = { level = "warn", priority = -1 }
17+
impl_trait_redundant_captures = "warn"
18+
non_ascii_idents = "forbid"
19+
unsafe_code = "forbid"
20+
unused_crate_dependencies = "warn"

book/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Crate keeping dependencies for running Book tests.
2+
3+
use dataloader as _;

book/src/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Exposing simple enums and structs as [GraphQL] types is just a matter of adding
2727
For more advanced mappings, [Juniper] provides multiple macros to map your [Rust] types to a [GraphQL schema][schema]. The most important one is the [`#[graphql_object]` attribute][2] that is used for declaring a [GraphQL object] with resolvers (typically used for declaring [`Query` and `Mutation` roots][1]).
2828

2929
```rust
30-
# # ![allow(unused_variables)]
30+
# #![expect(unused_variables, reason = "example")]
3131
# extern crate juniper;
3232
#
3333
# use std::fmt::Display;

book/src/types/enums.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ enum StarWarsEpisode {
112112

113113
By default, all [enum][3] variants are included in the generated [GraphQL enum][0] type as values. To prevent including a specific variant, annotate it with the `#[graphql(ignore)]` attribute:
114114
```rust
115-
# #![allow(dead_code)]
115+
# #![expect(dead_code, reason = "example")]
116116
# extern crate juniper;
117117
# use juniper::GraphQLEnum;
118118
#

book/src/types/input_objects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Input objects
77
88
In [Juniper], defining a [GraphQL input object][0] is quite straightforward and similar to how [trivial GraphQL objects are defined](objects/index.md) - by using the [`#[derive(GraphQLInputObject)]` attribute][2] on a [Rust struct][struct]:
99
```rust
10-
# #![allow(unused_variables)]
10+
# #![expect(unused_variables, reason = "example")]
1111
# extern crate juniper;
1212
# use juniper::{GraphQLInputObject, GraphQLObject, graphql_object};
1313
#

book/src/types/interfaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ trait Person {
356356

357357
By default, all [struct][24] fields or [trait][20] methods are considered as [GraphQL fields][4]. If a helper method is needed, or it should be ignored for some reason, then it should be marked with the `#[graphql(ignore)]` attribute:
358358
```rust
359-
# #![allow(dead_code)]
359+
# #![expect(dead_code, reason = "example")]
360360
# extern crate juniper;
361361
# use std::marker::PhantomPinned;
362362
# use juniper::{graphql_interface, GraphQLInterface};

book/src/types/objects/complex_fields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl Person {
165165

166166
By default, all methods of an [`impl` block][6] are exposed as [GraphQL fields][4]. If a method should not be exposed as a [GraphQL field][4], it should be defined in a separate [`impl` block][6] or marked with the `#[graphql(ignore)]` attribute:
167167
```rust
168-
# #![allow(dead_code)]
168+
# #![expect(dead_code, reason = "example")]
169169
# extern crate juniper;
170170
# use juniper::graphql_object;
171171
#

0 commit comments

Comments
 (0)