on master help sign in
Merge pull request #1186 from elm-lang/pr/1184
cb1bad3Evan Czaplicki
src/Elm/Package.hs+32−3
@@ -57,7 +57,7 @@ fromString string =
57 Left "You did not provide a project name (user/project)"
57 Left "You did not provide a project name (user/project)"
58
58
59 else if all (/='/') project then
59 else if all (/='/') project then
60− Name user <$> validate project
60+ Name user <$> validateProjectName project
61
61
62 else
62 else
63 Left "Expecting only one slash, separating the user and project name (user/project)"
63 Left "Expecting only one slash, separating the user and project name (user/project)"
@@ -66,14 +66,43 @@ fromString string =
66 Left "There should be a slash separating the user and project name (user/project)"
66 Left "There should be a slash separating the user and project name (user/project)"
67
67
68
68
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+
69−validate :: String -> Either String String
95+validateProjectName :: String -> Either String String
70−validate str =
96+validateProjectName str =
71 if elem ('-','-') (zip str (tail str)) then
97 if elem ('-','-') (zip str (tail str)) then
72 Left "There is a double dash -- in your package name. It must be a single dash."
98 Left "There is a double dash -- in your package name. It must be a single dash."
73
99
74 else if elem '_' str then
100 else if elem '_' str then
75 Left "Underscores are not allowed in package names."
101 Left "Underscores are not allowed in package names."
76
102
103+ else if any Char.isUpper str && not (whitelistedUppercaseName str) then
104+ Left "Upper case characters are not allowed in package names."
105+
77 else if not (Char.isLetter (head str)) then
106 else if not (Char.isLetter (head str)) then
78 Left "Package names must start with a letter."
107 Left "Package names must start with a letter."
79
108