Skip to content

Commit adffd9d

Browse files
committed
fix: feedback
1 parent 8cb0b33 commit adffd9d

File tree

9 files changed

+148
-88
lines changed

9 files changed

+148
-88
lines changed

.changeset/chubby-bottles-lick.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"@biomejs/biome": patch
33
---
44

5-
Added the rule [`useDescriptionStyle`](https://biomejs.dev/linter/rules/use-description-style/), requiring all descriptions to follow the same style (either block or inline).
5+
Added the nursery rule [`useConsistentGraphqlDescriptions`](https://biomejs.dev/linter/rules/use-consistent-graphql-descriptions/), requiring all descriptions to follow the same style (either block or inline) inside GraphQL files.
66

7-
##### Invalid
7+
**Invalid example:**
88

99
```graphql
1010
enum EnumValue {
@@ -13,7 +13,7 @@ enum EnumValue {
1313
}
1414
```
1515

16-
##### Valid
16+
**Valid example:**
1717

1818
```graphql
1919
enum EnumValue {

crates/biome_configuration/src/analyzer/linter/rules.rs

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/biome_diagnostics_categories/src/categories.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ define_categories! {
192192
"lint/nursery/useConsistentArrowReturn": "https://biomejs.dev/linter/rules/use-consistent-arrow-return",
193193
"lint/nursery/useConsistentObjectDefinition": "https://biomejs.dev/linter/rules/use-consistent-object-definition",
194194
"lint/nursery/useConsistentTypeDefinitions": "https://biomejs.dev/linter/rules/use-consistent-type-definitions",
195-
"lint/nursery/useDescriptionStyle": "https://biomejs.dev/linter/rules/use-description-style",
195+
"lint/nursery/useConsistentGraphqlDescriptions": "https://biomejs.dev/linter/rules/use-consistent-graphql-descriptions",
196196
"lint/nursery/useExhaustiveSwitchCases": "https://biomejs.dev/linter/rules/use-exhaustive-switch-cases",
197197
"lint/nursery/useExplicitFunctionReturnType": "https://biomejs.dev/linter/rules/use-explicit-type",
198198
"lint/nursery/useExplicitType": "https://biomejs.dev/linter/rules/use-explicit-type",

crates/biome_graphql_analyze/src/lint/nursery.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
//! Generated file, do not edit by hand, see `xtask/codegen`
44
55
use biome_analyze::declare_lint_group;
6-
pub mod use_description_style;
7-
declare_lint_group! { pub Nursery { name : "nursery" , rules : [self :: use_description_style :: UseDescriptionStyle ,] } }
6+
pub mod use_consistent_graphql_descriptions;
7+
declare_lint_group! { pub Nursery { name : "nursery" , rules : [self :: use_consistent_graphql_descriptions :: UseConsistentGraphqlDescriptions ,] } }

crates/biome_graphql_analyze/src/lint/nursery/use_description_style.rs renamed to crates/biome_graphql_analyze/src/lint/nursery/use_consistent_graphql_descriptions.rs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ use biome_analyze::{
44
use biome_console::markup;
55
use biome_graphql_syntax::GraphqlDescription;
66
use biome_rowan::AstNode;
7-
use biome_rule_options::use_description_style::{Style, UseDescriptionStyleOptions};
7+
use biome_rule_options::use_consistent_graphql_descriptions::{
8+
Style, UseConsistentGraphqlDescriptionsOptions,
9+
};
810

911
declare_lint_rule! {
1012
/// Require all descriptions to follow the same style (either block or inline)
1113
///
1214
/// ## Examples
1315
///
14-
/// ### Invalid
16+
/// ### style: `block`
17+
///
18+
/// #### Invalid
1519
///
1620
/// ```graphql,expect_diagnostic
1721
/// enum EnumValue {
@@ -20,7 +24,7 @@ declare_lint_rule! {
2024
/// }
2125
/// ```
2226
///
23-
/// ### Valid
27+
/// #### Valid
2428
///
2529
/// ```graphql
2630
/// enum EnumValue {
@@ -31,20 +35,50 @@ declare_lint_rule! {
3135
/// }
3236
/// ```
3337
///
34-
pub UseDescriptionStyle {
38+
/// ### style: `inline`
39+
///
40+
/// #### Invalid
41+
///
42+
/// ```graphql,expect_diagnostic
43+
/// enum EnumValue {
44+
/// """
45+
/// this is a description
46+
/// """
47+
/// DEFAULT
48+
/// }
49+
/// ```
50+
///
51+
/// #### Valid
52+
///
53+
/// ```graphql
54+
/// enum EnumValue {
55+
/// "this is a description"
56+
/// DEFAULT
57+
/// }
58+
/// ```
59+
///
60+
/// ## Options
61+
///
62+
/// ### style
63+
///
64+
/// Use the `style` option to specify the required description style:
65+
/// - `"block"` (default): Requires triple-quoted block descriptions (`"""..."""`)
66+
/// - `"inline"`: Requires single-quoted inline descriptions (`"..."`)
67+
///
68+
pub UseConsistentGraphqlDescriptions {
3569
version: "next",
36-
name: "useDescriptionStyle",
70+
name: "useConsistentGraphqlDescriptions",
3771
language: "graphql",
3872
sources: &[RuleSource::EslintGraphql("description-style").same()],
3973
recommended: false,
4074
}
4175
}
4276

43-
impl Rule for UseDescriptionStyle {
77+
impl Rule for UseConsistentGraphqlDescriptions {
4478
type Query = Ast<GraphqlDescription>;
4579
type State = ();
4680
type Signals = Option<Self::State>;
47-
type Options = UseDescriptionStyleOptions;
81+
type Options = UseConsistentGraphqlDescriptionsOptions;
4882

4983
fn run(ctx: &RuleContext<Self>) -> Option<Self::State> {
5084
let node = ctx.query();

crates/biome_rule_options/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ pub mod use_consistent_array_type;
265265
pub mod use_consistent_arrow_return;
266266
pub mod use_consistent_builtin_instantiation;
267267
pub mod use_consistent_curly_braces;
268+
pub mod use_consistent_graphql_descriptions;
268269
pub mod use_consistent_member_accessibility;
269270
pub mod use_consistent_object_definitions;
270271
pub mod use_consistent_type_definitions;
@@ -274,7 +275,6 @@ pub mod use_default_parameter_last;
274275
pub mod use_default_switch_clause;
275276
pub mod use_default_switch_clause_last;
276277
pub mod use_deprecated_reason;
277-
pub mod use_description_style;
278278
pub mod use_enum_initializers;
279279
pub mod use_error_message;
280280
pub mod use_exhaustive_dependencies;

crates/biome_rule_options/src/use_description_style.rs renamed to crates/biome_rule_options/src/use_consistent_graphql_descriptions.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ use std::str::FromStr;
66
#[derive(Default, Clone, Debug, Deserialize, Deserializable, Eq, PartialEq, Serialize)]
77
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
88
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
9-
pub struct UseDescriptionStyleOptions {
9+
pub struct UseConsistentGraphqlDescriptionsOptions {
10+
/// The description style to enforce. Default to "block"
1011
pub style: Style,
1112
}
1213

1314
#[derive(Clone, Copy, Debug, Default, Deserialize, Deserializable, Eq, PartialEq, Serialize)]
1415
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1516
#[serde(rename_all = "camelCase")]
1617
pub enum Style {
18+
/// Requires triple-quoted block descriptions (`"""..."""`)
1719
#[default]
1820
Block,
21+
/// Requires single-quoted inline descriptions (`"..."`)
1922
Inline,
2023
}
2124

packages/@biomejs/backend-jsonrpc/src/workspace.ts

Lines changed: 23 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)