Skip to content

Commit cb1bad3

Browse files
committed
Merge pull request #1186 from elm-lang/pr/1184
Do not allow upper case letters in new project names
2 parents 1b1a899 + be9f59a commit cb1bad3

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/Elm/Package.hs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fromString string =
5757
Left "You did not provide a project name (user/project)"
5858

5959
else if all (/='/') project then
60-
Name user <$> validate project
60+
Name user <$> validateProjectName project
6161

6262
else
6363
Left "Expecting only one slash, separating the user and project name (user/project)"
@@ -66,14 +66,43 @@ fromString string =
6666
Left "There should be a slash separating the user and project name (user/project)"
6767

6868

69-
validate :: String -> Either String String
70-
validate str =
69+
whitelistedUppercaseName :: String -> Bool
70+
whitelistedUppercaseName name =
71+
-- These packages were uploaded to package.elm-lang.org before version 0.16,
72+
-- when uppercase letters were disallowed in package names.
73+
-- They should be considered deprecated and removed from this list once users
74+
-- migrate to using the lowercase versions of the names.
75+
List.elem name
76+
[ "Easing"
77+
, "LoadAssets"
78+
, "elm-MultiDimArray"
79+
, "elm-SafeLists"
80+
, "GraphicsEngine"
81+
, "Elm-Css"
82+
, "Elm-Test"
83+
, "DateOp"
84+
, "IO"
85+
, "Elm-Align-Distribute"
86+
, "Elm-Format-String"
87+
, "Elm-Multiset"
88+
, "Elm-Random-Sampling"
89+
, "ElmCache"
90+
, "ExternalStorage"
91+
, "IntRange"
92+
]
93+
94+
95+
validateProjectName :: String -> Either String String
96+
validateProjectName str =
7197
if elem ('-','-') (zip str (tail str)) then
7298
Left "There is a double dash -- in your package name. It must be a single dash."
7399

74100
else if elem '_' str then
75101
Left "Underscores are not allowed in package names."
76102

103+
else if any Char.isUpper str && not (whitelistedUppercaseName str) then
104+
Left "Upper case characters are not allowed in package names."
105+
77106
else if not (Char.isLetter (head str)) then
78107
Left "Package names must start with a letter."
79108

0 commit comments

Comments
 (0)