@@ -206,15 +206,15 @@ fn collectWarnStyleDiagnostics(
206206 const is_type_function = Analyser .isTypeFunction (tree , func );
207207
208208 const func_name = tree .tokenSlice (name_token );
209- if (! is_type_function and ! Analyser . isCamelCase (func_name )) {
209+ if (! is_type_function and ! isCamelCase (func_name )) {
210210 try diagnostics .append (arena , .{
211211 .range = offsets .tokenToRange (tree , name_token , offset_encoding ),
212212 .severity = .Hint ,
213213 .code = .{ .string = "bad_style" },
214214 .source = "zls" ,
215215 .message = "Functions should be camelCase" ,
216216 });
217- } else if (is_type_function and ! Analyser . isPascalCase (func_name )) {
217+ } else if (is_type_function and ! isPascalCase (func_name )) {
218218 try diagnostics .append (arena , .{
219219 .range = offsets .tokenToRange (tree , name_token , offset_encoding ),
220220 .severity = .Hint ,
@@ -231,6 +231,18 @@ fn collectWarnStyleDiagnostics(
231231 }
232232}
233233
234+ fn isCamelCase (name : []const u8 ) bool {
235+ return ! std .ascii .isUpper (name [0 ]) and ! isSnakeCase (name );
236+ }
237+
238+ fn isPascalCase (name : []const u8 ) bool {
239+ return std .ascii .isUpper (name [0 ]) and ! isSnakeCase (name );
240+ }
241+
242+ fn isSnakeCase (name : []const u8 ) bool {
243+ return std .mem .find (u8 , name , "_" ) != null ;
244+ }
245+
234246fn collectGlobalVarDiagnostics (
235247 tree : * const Ast ,
236248 arena : std.mem.Allocator ,
0 commit comments