File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,12 @@ fn check_name(
258258 name
259259 ) ) ?;
260260 }
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+ }
261267
262268 Ok ( ( ) )
263269}
Original file line number Diff line number Diff line change @@ -451,6 +451,7 @@ fn non_ascii_name() {
451451 "\
452452 [WARNING] the name `Привет` contains non-ASCII characters
453453Non-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 `привет`
454455[CREATED] binary (application) `Привет` package
455456" ,
456457 )
@@ -501,6 +502,29 @@ or change the name in Cargo.toml with:
501502 . run ( ) ;
502503}
503504
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+
504528#[ cargo_test]
505529fn git_default_branch ( ) {
506530 // Check for init.defaultBranch support.
You can’t perform that action at this time.
0 commit comments