Add and run elm-review

This commit is contained in:
Dan Neumann 2022-05-26 16:54:34 -05:00
parent 72bf7575c7
commit 3cf97c0cbb
7 changed files with 1918 additions and 19 deletions

1795
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
"private": true,
"devDependencies": {
"elm-doc-preview": "^5.0.5",
"elm-review": "^2.7.2",
"elm-test": "^0.19.1-revision7"
},
"scripts": {

41
review/elm.json Normal file
View File

@ -0,0 +1,41 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/core": "1.0.5",
"elm/json": "1.1.3",
"elm/project-metadata-utils": "1.0.2",
"jfmengels/elm-review": "2.7.2",
"jfmengels/elm-review-code-style": "1.0.0",
"jfmengels/elm-review-common": "1.2.0",
"jfmengels/elm-review-debug": "1.0.6",
"jfmengels/elm-review-documentation": "2.0.1",
"jfmengels/elm-review-simplify": "2.0.15",
"jfmengels/elm-review-unused": "1.1.22",
"stil4m/elm-syntax": "7.2.9"
},
"indirect": {
"elm/html": "1.0.0",
"elm/parser": "1.1.0",
"elm/random": "1.0.0",
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.3",
"elm-community/list-extra": "8.5.2",
"elm-explorations/test": "1.2.2",
"miniBill/elm-unicode": "1.0.2",
"rtfeldman/elm-hex": "1.0.0",
"stil4m/structured-writer": "1.0.3"
}
},
"test-dependencies": {
"direct": {
"elm-explorations/test": "1.2.2"
},
"indirect": {}
}
}

View File

@ -0,0 +1,68 @@
module ReviewConfig exposing (config)
{-| Do not rename the ReviewConfig module or the config function, because
`elm-review` will look for these.
To add packages that contain rules, add them to this review project using
`elm install author/packagename`
when inside the directory containing this file.
-}
import Docs.NoMissing exposing (exposedModules, onlyExposed)
import Docs.ReviewAtDocs
import Docs.ReviewLinksAndSections
import Docs.UpToDateReadmeLinks
import NoDebug.Log
import NoDebug.TodoOrToString
import NoExposingEverything
import NoImportingEverything
import NoMissingTypeAnnotation
import NoMissingTypeAnnotationInLetIn
import NoMissingTypeExpose
import NoPrematureLetComputation
import NoSimpleLetBody
import NoUnused.CustomTypeConstructorArgs
import NoUnused.CustomTypeConstructors
import NoUnused.Dependencies
import NoUnused.Exports
import NoUnused.Modules
import NoUnused.Parameters
import NoUnused.Patterns
import NoUnused.Variables
import Review.Rule as Rule exposing (Rule)
import Simplify
config : List Rule
config =
[ Docs.NoMissing.rule
{ document = onlyExposed
, from = exposedModules
}
, Docs.ReviewLinksAndSections.rule
, Docs.ReviewAtDocs.rule
, Docs.UpToDateReadmeLinks.rule
, NoDebug.Log.rule
, NoDebug.TodoOrToString.rule
|> Rule.ignoreErrorsForDirectories [ "tests/" ]
, NoExposingEverything.rule
, NoImportingEverything.rule []
, NoMissingTypeAnnotation.rule
, NoMissingTypeAnnotationInLetIn.rule
, NoMissingTypeExpose.rule
, NoSimpleLetBody.rule
, NoPrematureLetComputation.rule
, NoUnused.CustomTypeConstructors.rule []
, NoUnused.CustomTypeConstructorArgs.rule
, NoUnused.Dependencies.rule
, NoUnused.Exports.rule
, NoUnused.Modules.rule
, NoUnused.Parameters.rule
, NoUnused.Patterns.rule
, NoUnused.Variables.rule
, Simplify.rule Simplify.defaults
]

View File

@ -276,6 +276,7 @@ mergeText n nodes =
{-| Chomps zero or more space characters or html comments.
-}
ws : Parser ()
ws =
loop 0 <|
ifProgress <|
@ -287,7 +288,7 @@ ws =
isSpace : Char -> Bool
isSpace c =
c == ' ' || c == '\n' || c == '\u{000D}' || c == '\n' || c == '\t' || c == '\u{000C}' || c == '\u{00A0}'
c == ' ' || c == '\n' || c == '\u{000D}' || c == '\t' || c == '\u{000C}' || c == '\u{00A0}'
@ -306,7 +307,7 @@ attributeValueUnquoted cfg =
, characterReference cfg
]
|> oneOrMore "attribute value"
|> map (String.join "")
|> map String.concat
attributeValueQuoted : Config -> Char -> Parser String
@ -323,7 +324,7 @@ attributeValueQuoted cfg quote =
, characterReference cfg
]
|> zeroOrMore
|> map (String.join "")
|> map String.concat
)
|. chompIf ((==) quote)
@ -512,8 +513,7 @@ element cfg =
else if isAutoclosingTag tag then
-- Autoclosing tag is automatically closed by an opening tag of the same name
succeed (Element tag attrs)
|= oneOf
[ succeed identity
|= (succeed identity
|= zeroOrMore
(if tag == "head" then
notNode cfg [ tag, "body" ]
@ -525,7 +525,7 @@ element cfg =
[ backtrackable (closeTag tag)
, succeed ()
]
]
)
else
-- Normal elements parse all nodes as children until their closing tag
@ -877,7 +877,7 @@ nodeToString node_ =
else
openTagToString tag attrs
++ (List.map nodeToString kids
|> String.join ""
|> String.concat
)
++ "</"
++ tag
@ -896,7 +896,7 @@ nodeToString node_ =
nodesToString : List Node -> String
nodesToString nodes =
List.map nodeToString nodes
|> String.join ""
|> String.concat
{-| Turn a single node into an Elm html node that Elm can render.
@ -977,7 +977,7 @@ prettyNode_ indent node_ =
Element tag attrs kids ->
String.trim <|
String.join ""
String.concat
(List.concat
[ [ "\n" ++ pad ++ openTagToString tag attrs ]
, List.map (prettyNode_ (indent + 1)) kids
@ -986,8 +986,7 @@ prettyNode_ indent node_ =
else
"\n"
]
, [ (if List.isEmpty kids then
, (if List.isEmpty kids then
""
else

View File

@ -1,11 +1,8 @@
module LocTests exposing (..)
module LocTests exposing (Dir(..), DirCase, config, testTraversals, zipperTests)
import Expect exposing (Expectation)
import Fuzz exposing (Fuzzer, int, list, string)
import Html.CharRefs
import Expect
import Html.Loc as Q exposing (Loc)
import Html.Parser exposing (Document, Node(..))
import Parser exposing (DeadEnd)
import Html.Parser exposing (Node(..))
import Test exposing (..)

View File

@ -1,8 +1,6 @@
module ParserTests exposing (..)
import Expect exposing (Expectation)
import Fuzz exposing (Fuzzer, int, list, string)
import Html.CharRefs
import Html.Parser exposing (Document, Node(..))
import Parser exposing (DeadEnd)
import Test exposing (..)