mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-22 22:33:13 +03:00
Remove unused code
This commit is contained in:
parent
7e4d767923
commit
0ff71b2c84
@ -51,7 +51,7 @@ import Elm.Syntax.Node as Node
|
||||
import Review.Dependencies
|
||||
import Review.Project.Dependency as Dependency exposing (Dependency)
|
||||
import Review.Project.Internal as Internal exposing (Project)
|
||||
import Vendor.Graph as Graph exposing (Graph)
|
||||
import Vendor.Graph exposing (Graph)
|
||||
|
||||
|
||||
|
||||
@ -246,22 +246,8 @@ precomputeModuleGraph ((Internal.Project p) as project) =
|
||||
moduleGraph : Graph ModuleName ()
|
||||
moduleGraph =
|
||||
Internal.buildModuleGraph <| Dict.values p.modules
|
||||
|
||||
projectWithGraph =
|
||||
{ p | moduleGraph = Just moduleGraph }
|
||||
|
||||
nodeContexts : List (Graph.NodeContext ModuleName ())
|
||||
nodeContexts =
|
||||
moduleGraph
|
||||
|> Graph.checkAcyclic
|
||||
|> Result.map Graph.topologicalSort
|
||||
|> Result.withDefault []
|
||||
in
|
||||
Internal.Project
|
||||
{ projectWithGraph
|
||||
| moduleNameLookupTables =
|
||||
Just (Internal.computeModuleNameLookupTables (Internal.Project projectWithGraph) nodeContexts)
|
||||
}
|
||||
Internal.Project { p | moduleGraph = Just moduleGraph }
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@ module Review.Project.Internal exposing
|
||||
( Project(..)
|
||||
, ProjectModule
|
||||
, buildModuleGraph
|
||||
, computeModuleNameLookupTables
|
||||
, getModuleName
|
||||
, moduleGraph
|
||||
, moduleNameLookupTables
|
||||
@ -20,7 +19,6 @@ import Elm.Syntax.Module
|
||||
import Elm.Syntax.ModuleName exposing (ModuleName)
|
||||
import Elm.Syntax.Node as Node
|
||||
import Review.ModuleNameLookupTable exposing (ModuleNameLookupTable)
|
||||
import Review.ModuleNameLookupTable.Internal as ModuleNameLookupTableInternal
|
||||
import Review.Project.Dependency exposing (Dependency)
|
||||
import Vendor.Graph as Graph exposing (Graph)
|
||||
|
||||
@ -150,15 +148,3 @@ getModuleName module_ =
|
||||
module_.ast.moduleDefinition
|
||||
|> Node.value
|
||||
|> Elm.Syntax.Module.moduleName
|
||||
|
||||
|
||||
computeModuleNameLookupTables : Project -> List (Graph.NodeContext ModuleName ()) -> Dict ModuleName ModuleNameLookupTable
|
||||
computeModuleNameLookupTables project nodeContexts =
|
||||
nodeContexts
|
||||
|> List.map (\nodeContext -> ( nodeContext.node.label, computeModuleNameLookupTable project nodeContext ))
|
||||
|> Dict.fromList
|
||||
|
||||
|
||||
computeModuleNameLookupTable : Project -> Graph.NodeContext ModuleName () -> ModuleNameLookupTable
|
||||
computeModuleNameLookupTable (Project project) { node, incoming } =
|
||||
ModuleNameLookupTableInternal.empty
|
||||
|
1531
tests/Scope.elm
1531
tests/Scope.elm
File diff suppressed because it is too large
Load Diff
@ -1,50 +0,0 @@
|
||||
module ScopeExample exposing (rule)
|
||||
|
||||
import Elm.Syntax.Expression as Expression exposing (Expression)
|
||||
import Elm.Syntax.Node as Node exposing (Node)
|
||||
import Review.ModuleNameLookupTable as ModuleNameLookupTable exposing (ModuleNameLookupTable)
|
||||
import Review.Rule as Rule exposing (Direction, Error, Rule)
|
||||
|
||||
|
||||
rule : Rule
|
||||
rule =
|
||||
Rule.newModuleRuleSchemaUsingContextCreator "NoHtmlButton" initialContext
|
||||
|> Rule.withExpressionEnterVisitor expressionVisitor
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|> Rule.ignoreErrorsForFiles [ "src/Button.elm" ]
|
||||
|
||||
|
||||
type alias Context =
|
||||
{ lookupTable : ModuleNameLookupTable
|
||||
}
|
||||
|
||||
|
||||
initialContext : Rule.ContextCreator () Context
|
||||
initialContext =
|
||||
Rule.initContextCreator
|
||||
(\lookupTable () ->
|
||||
{ lookupTable = lookupTable
|
||||
}
|
||||
)
|
||||
|> Rule.withModuleNameLookupTable
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> Context -> ( List (Error {}), Context )
|
||||
expressionVisitor node context =
|
||||
case Node.value node of
|
||||
Expression.FunctionOrValue _ "button" ->
|
||||
if ModuleNameLookupTable.moduleNameFor context.lookupTable node == Just [ "Html" ] then
|
||||
( [ Rule.error
|
||||
{ message = "Do not use `Html.button` directly"
|
||||
, details = [ "At fruits.com, we've built a nice `Button` module that suits our needs better. Using this module instead of `Html.button` ensures we have a consistent button experience across the website." ]
|
||||
}
|
||||
(Node.range node)
|
||||
]
|
||||
, context
|
||||
)
|
||||
|
||||
else
|
||||
( [], context )
|
||||
|
||||
_ ->
|
||||
( [], context )
|
Loading…
Reference in New Issue
Block a user