File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,12 @@ fn check_name(
258
258
name
259
259
) ) ?;
260
260
}
261
+ let name_in_lowercase = name. to_lowercase ( ) ;
262
+ if name != name_in_lowercase {
263
+ shell. warn ( format ! (
264
+ "the name `{name}` is not snake_case or kebab-case which is recommended for package names, consider `{name_in_lowercase}`"
265
+ ) ) ?;
266
+ }
261
267
262
268
Ok ( ( ) )
263
269
}
Original file line number Diff line number Diff line change @@ -451,6 +451,7 @@ fn non_ascii_name() {
451
451
"\
452
452
[WARNING] the name `Привет` contains non-ASCII characters
453
453
Non-ASCII crate names are not supported by Rust.
454
+ [WARNING] the name `Привет` is not snake_case or kebab-case which is recommended for package names, consider `привет`
454
455
[CREATED] binary (application) `Привет` package
455
456
" ,
456
457
)
@@ -501,6 +502,29 @@ or change the name in Cargo.toml with:
501
502
. run ( ) ;
502
503
}
503
504
505
+ #[ cargo_test]
506
+ fn non_snake_case_name ( ) {
507
+ cargo_process ( "new UPPERcase_name" )
508
+ . with_stderr (
509
+ "\
510
+ [WARNING] the name `UPPERcase_name` is not snake_case or kebab-case which is recommended for package names, consider `uppercase_name`
511
+ [CREATED] binary (application) `UPPERcase_name` package
512
+ " ,
513
+ )
514
+ . run ( ) ;
515
+ }
516
+
517
+ #[ cargo_test]
518
+ fn kebab_case_name_is_accepted ( ) {
519
+ cargo_process ( "new kebab-case-is-valid" )
520
+ . with_stderr (
521
+ "\
522
+ [CREATED] binary (application) `kebab-case-is-valid` package
523
+ " ,
524
+ )
525
+ . run ( ) ;
526
+ }
527
+
504
528
#[ cargo_test]
505
529
fn git_default_branch ( ) {
506
530
// Check for init.defaultBranch support.
You can’t perform that action at this time.
0 commit comments