mirror of
https://github.com/jfmengels/elm-review.git
synced 2025-01-07 02:09:35 +03:00
Report stray classes
This commit is contained in:
parent
7c2a0ff76b
commit
076884b912
@ -329,10 +329,37 @@ expressionVisitor cssFunctions node context =
|
||||
Expression.OperatorApplication "<|" _ (Node fnRange (Expression.FunctionOrValue _ name)) firstArg ->
|
||||
reportClasses cssFunctions context fnRange name firstArg []
|
||||
|
||||
Expression.FunctionOrValue _ name ->
|
||||
( reportStrayCssFunction cssFunctions context (Node.range node) name
|
||||
, context
|
||||
)
|
||||
|
||||
_ ->
|
||||
( [], context )
|
||||
|
||||
|
||||
reportStrayCssFunction : CssFunctions -> ModuleContext -> Range -> String -> List (Rule.Error {})
|
||||
reportStrayCssFunction cssFunctions context range name =
|
||||
if RangeDict.member range context.functionOrValuesToIgnore then
|
||||
[]
|
||||
|
||||
else
|
||||
case
|
||||
ModuleNameLookupTable.moduleNameAt context.lookupTable range
|
||||
|> Maybe.andThen (\moduleName -> Dict.get ( moduleName, name ) cssFunctions)
|
||||
of
|
||||
Just _ ->
|
||||
[ Rule.error
|
||||
{ message = "Class using function is used without all of its class arguments"
|
||||
, details = [ "REPLACEME" ]
|
||||
}
|
||||
range
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
[]
|
||||
|
||||
|
||||
type alias CssFunctions =
|
||||
Dict
|
||||
( ModuleName, String )
|
||||
|
@ -252,7 +252,7 @@ classListWithoutErrorsBeingReported =
|
||||
|> Review.Test.run (cssFiles [ "*.css" ] |> rule)
|
||||
|> Review.Test.expectErrors
|
||||
[ Review.Test.error
|
||||
{ message = "Class using function is used without all of its class functions"
|
||||
{ message = "Class using function is used without all of its class arguments"
|
||||
, details = [ "REPLACEME" ]
|
||||
, under = "Html.Attributes.classList"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user