mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-24 04:12:09 +03:00
Add another elm-review rule.
This commit is contained in:
parent
7ac4ceecde
commit
1b19d8e22e
@ -38,8 +38,8 @@ config : List Rule
|
||||
config =
|
||||
([ NoExposingEverything.rule
|
||||
, NoPrematureLetComputation.rule
|
||||
|
||||
--NoImportingEverything.rule []
|
||||
, NoImportingEverything.rule []
|
||||
|> ignoreInTest
|
||||
, NoInconsistentAliases.config
|
||||
[ ( "Html.Attributes", "Attr" )
|
||||
|
||||
|
@ -1,81 +1,81 @@
|
||||
module CookieParser exposing (parse)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Parser exposing (..)
|
||||
import Parser exposing ((|.), (|=), Parser, Step(..))
|
||||
import Url
|
||||
|
||||
|
||||
parse : String -> Dict String String
|
||||
parse input =
|
||||
run parser input
|
||||
Parser.run parser input
|
||||
|> Result.withDefault Dict.empty
|
||||
|
||||
|
||||
parser : Parser (Dict String String)
|
||||
parser =
|
||||
loop [] keyValuePair
|
||||
|> map Dict.fromList
|
||||
Parser.loop [] keyValuePair
|
||||
|> Parser.map Dict.fromList
|
||||
|
||||
|
||||
keyValuePair : List ( String, String ) -> Parser (Step (List ( String, String )) (List ( String, String )))
|
||||
keyValuePair revChunks =
|
||||
oneOf
|
||||
[ end
|
||||
|> map (\_ -> Done (List.reverse revChunks))
|
||||
, succeed (Loop revChunks)
|
||||
|. chompIf isSpace
|
||||
|. chompWhile isSpace
|
||||
, succeed Tuple.pair
|
||||
Parser.oneOf
|
||||
[ Parser.end
|
||||
|> Parser.map (\_ -> Done (List.reverse revChunks))
|
||||
, Parser.succeed (Loop revChunks)
|
||||
|. Parser.chompIf isSpace
|
||||
|. Parser.chompWhile isSpace
|
||||
, Parser.succeed Tuple.pair
|
||||
|= parseKey
|
||||
|= oneOf
|
||||
[ succeed Nothing
|
||||
|. token ";"
|
||||
, succeed Just
|
||||
|. token "="
|
||||
|= Parser.oneOf
|
||||
[ Parser.succeed Nothing
|
||||
|. Parser.token ";"
|
||||
, Parser.succeed Just
|
||||
|. Parser.token "="
|
||||
|= valueParser
|
||||
|. oneOf
|
||||
[ token ";"
|
||||
, succeed ()
|
||||
|. Parser.oneOf
|
||||
[ Parser.token ";"
|
||||
, Parser.succeed ()
|
||||
]
|
||||
]
|
||||
|> andThen
|
||||
|> Parser.andThen
|
||||
(\( key, maybeValue ) ->
|
||||
case maybeValue of
|
||||
Just value ->
|
||||
succeed (Loop (( key, value ) :: revChunks))
|
||||
Parser.succeed (Loop (( key, value ) :: revChunks))
|
||||
|
||||
Nothing ->
|
||||
succeed (Loop revChunks)
|
||||
Parser.succeed (Loop revChunks)
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
valueParser : Parser String
|
||||
valueParser =
|
||||
succeed identity
|
||||
|. chompWhile isSpace
|
||||
|= oneOf
|
||||
[ succeed ""
|
||||
|. token ";"
|
||||
, succeed identity
|
||||
|. token "\""
|
||||
|= (chompUntil "\""
|
||||
|> getChompedString
|
||||
Parser.succeed identity
|
||||
|. Parser.chompWhile isSpace
|
||||
|= Parser.oneOf
|
||||
[ Parser.succeed ""
|
||||
|. Parser.token ";"
|
||||
, Parser.succeed identity
|
||||
|. Parser.token "\""
|
||||
|= (Parser.chompUntil "\""
|
||||
|> Parser.getChompedString
|
||||
)
|
||||
|. token "\""
|
||||
, chompWhile (\c -> c /= ';')
|
||||
|> getChompedString
|
||||
|. Parser.token "\""
|
||||
, Parser.chompWhile (\c -> c /= ';')
|
||||
|> Parser.getChompedString
|
||||
]
|
||||
|> map String.trim
|
||||
|> map (\value -> value |> Url.percentDecode |> Maybe.withDefault "")
|
||||
|> Parser.map String.trim
|
||||
|> Parser.map (\value -> value |> Url.percentDecode |> Maybe.withDefault "")
|
||||
|
||||
|
||||
parseKey : Parser String
|
||||
parseKey =
|
||||
succeed identity
|
||||
|= (chompWhile (\c -> c /= '=' && c /= ';')
|
||||
|> getChompedString
|
||||
|> map String.trim
|
||||
Parser.succeed identity
|
||||
|= (Parser.chompWhile (\c -> c /= '=' && c /= ';')
|
||||
|> Parser.getChompedString
|
||||
|> Parser.map String.trim
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user