elm-format

This commit is contained in:
Jeroen Engels 2018-11-05 18:59:42 +01:00
parent e2161f8388
commit a16c660048

View File

@ -1,5 +1,7 @@
module Main exposing (main) module Main exposing (main)
-- Rules
import Ast import Ast
import Ast.Expression exposing (..) import Ast.Expression exposing (..)
import Ast.Statement exposing (..) import Ast.Statement exposing (..)
@ -9,14 +11,8 @@ import Html.Attributes exposing (class, id)
import Html.Events exposing (on, targetValue) import Html.Events exposing (on, targetValue)
import Json.Decode as JD import Json.Decode as JD
import Lint exposing (lintSource) import Lint exposing (lintSource)
import Lint.Types exposing (LintRule, Severity(..))
import Regex exposing (escape, regex)
import Result
-- Rules
import Lint.Rules.DefaultPatternPosition import Lint.Rules.DefaultPatternPosition
import Lint.Rules.ElmTest.NoDuplicateTestBodies
import Lint.Rules.NoConstantCondition import Lint.Rules.NoConstantCondition
import Lint.Rules.NoDebug import Lint.Rules.NoDebug
import Lint.Rules.NoDuplicateImports import Lint.Rules.NoDuplicateImports
@ -30,7 +26,9 @@ import Lint.Rules.NoUselessPatternMatching
import Lint.Rules.NoWarningComments import Lint.Rules.NoWarningComments
import Lint.Rules.SimplifyPiping import Lint.Rules.SimplifyPiping
import Lint.Rules.SimplifyPropertyAccess import Lint.Rules.SimplifyPropertyAccess
import Lint.Rules.ElmTest.NoDuplicateTestBodies import Lint.Types exposing (LintRule, Severity(..))
import Regex exposing (escape, regex)
import Result
type Msg type Msg
@ -151,24 +149,24 @@ statement s =
defaultDisplay = defaultDisplay =
li [] [ pre [] [ text <| toString s ] ] li [] [ pre [] [ text <| toString s ] ]
in in
case s of case s of
FunctionDeclaration _ _ body -> FunctionDeclaration _ _ body ->
displayElementAndExpressions s [ body ] displayElementAndExpressions s [ body ]
FunctionTypeDeclaration _ body -> FunctionTypeDeclaration _ body ->
displayElementAndAnyChild s [ body ] displayElementAndAnyChild s [ body ]
ModuleDeclaration _ exportSet -> ModuleDeclaration _ exportSet ->
displayElementAndAnyChild s [ exportSet ] displayElementAndAnyChild s [ exportSet ]
PortModuleDeclaration _ exportSet -> PortModuleDeclaration _ exportSet ->
displayElementAndAnyChild s [ exportSet ] displayElementAndAnyChild s [ exportSet ]
ImportStatement _ _ exportSet -> ImportStatement _ _ exportSet ->
displayElementAndAnyChild s [ exportSet ] displayElementAndAnyChild s [ exportSet ]
s -> s ->
defaultDisplay defaultDisplay
tree : Result (Combine.ParseErr ()) ( b, c, List Statement ) -> Html Msg tree : Result (Combine.ParseErr ()) ( b, c, List Statement ) -> Html Msg
@ -195,14 +193,15 @@ lint source =
Ok errors -> Ok errors ->
if List.isEmpty errors then if List.isEmpty errors then
[ "No errors." ] [ "No errors." ]
else else
List.map (Tuple.second >> .message) errors List.map (Tuple.second >> .message) errors
in in
div [] div []
(List.map (List.map
(\message -> p [] [ text message ]) (\message -> p [] [ text message ])
messages messages
) )
view : String -> Html Msg view : String -> Html Msg