@@ -8,7 +8,7 @@ use biome_graphql_syntax::{
88 GraphqlSyntaxToken ,
99} ;
1010use biome_rowan:: { AstNode , TextRange } ;
11- use biome_rule_options:: use_input_name:: UseInputNameOptions ;
11+ use biome_rule_options:: use_input_name:: { CheckInputType , UseInputNameOptions } ;
1212
1313declare_lint_rule ! {
1414 /// Require mutation argument to be always called "input"
@@ -37,15 +37,16 @@ declare_lint_rule! {
3737 ///
3838 /// ### `checkInputType`
3939 ///
40- /// When the option `checkInputType` is enabled, the input type requires to be called `<mutation name>Input`.
40+ /// With the option `checkInputType` on, the input type name requires to be called `<mutation name>Input`.
41+ /// This can either be "loose" (case-insensitive) or "strict" (case-sensitive).
4142 /// Using the name of the mutation in the input type name will make it easier to find the mutation that the input type belongs to.
4243 ///
43- /// Default `false `
44+ /// Default `"off" `
4445 ///
4546 /// ```json,options
4647 /// {
4748 /// "options": {
48- /// "checkInputType": true
49+ /// "checkInputType": "loose"
4950 /// }
5051 /// }
5152 /// ```
@@ -56,27 +57,45 @@ declare_lint_rule! {
5657 /// }
5758 /// ```
5859 ///
59- /// ### `caseSensitiveInputType`
60+ /// ```graphql,use_options
61+ /// type Mutation {
62+ /// SetMessage(input: setMessageInput): String
63+ /// }
64+ /// ```
6065 ///
61- /// Treat input type names as case-sensitive.
66+ /// ```graphql,use_options
67+ /// type Mutation {
68+ /// SetMessage(input: SetMessageInput): String
69+ /// }
70+ /// ```
6271 ///
63- /// Default `true`
6472 ///
6573 /// ```json,options
6674 /// {
6775 /// "options": {
68- /// "checkInputType": true,
69- /// "caseSensitiveInputType": false
76+ /// "checkInputType": "strict"
7077 /// }
7178 /// }
7279 /// ```
7380 ///
74- /// ```graphql,use_options
81+ /// ```graphql,expect_diagnostic,use_options
82+ /// type Mutation {
83+ /// SetMessage(input: InputMessage): String
84+ /// }
85+ /// ```
86+ ///
87+ /// ```graphql,expect_diagnostic,use_options
7588 /// type Mutation {
7689 /// SetMessage(input: setMessageInput): String
7790 /// }
7891 /// ```
7992 ///
93+ /// ```graphql,use_options
94+ /// type Mutation {
95+ /// SetMessage(input: SetMessageInput): String
96+ /// }
97+ /// ```
98+ ///
8099 pub UseInputName {
81100 version: "next" ,
82101 name: "useInputName" ,
@@ -131,10 +150,10 @@ impl Rule for UseInputName {
131150 ) ) ;
132151 }
133152
134- let check_input_type = ctx. options ( ) . check_input_type ( ) ;
135- if check_input_type {
136- let is_case_sensitive_input_type = ctx . options ( ) . case_sensitive_input_type ( ) ;
137-
153+ let check_input_type = ctx. options ( ) . check_input_type ;
154+ if let Some ( check_input_type) = check_input_type
155+ && check_input_type != CheckInputType :: Off
156+ {
138157 let any_type = argument. ty ( ) . ok ( ) ?;
139158
140159 let ty = find_input_type ( any_type) ?;
@@ -144,8 +163,8 @@ impl Rule for UseInputName {
144163 let def_value_token = def_name. value_token ( ) . ok ( ) ?;
145164
146165 let valid_str = format ! ( "{}Input" , def_value_token. text_trimmed( ) ) ;
147- if ( is_case_sensitive_input_type && ty_string != valid_str)
148- || ( !is_case_sensitive_input_type
166+ if ( check_input_type == CheckInputType :: Strict && ty_string != valid_str)
167+ || ( check_input_type == CheckInputType :: Loose
149168 && !ty_string. eq_ignore_ascii_case ( & valid_str) )
150169 {
151170 return Some ( UseInputNameState :: InvalidTypeName (
0 commit comments