Module renaming

This commit is contained in:
Jeroen Engels 2018-11-10 23:43:58 +01:00
parent c559bd94b8
commit 5236dea4d7
9 changed files with 84 additions and 84 deletions

View File

@ -1,38 +1,38 @@
module LintConfig exposing (config)
import Lint.Types exposing (Rule, Severity(..))
import Lint.Rules.DefaultPatternPosition
import Lint.Rules.NoConstantCondition
import Lint.Rules.NoDebug
import Lint.Rules.NoDuplicateImports
import Lint.Rules.NoExposingEverything
import Lint.Rules.NoImportingEverything
import Lint.Rules.NoNestedLet
import Lint.Rules.NoUnannotatedFunction
import Lint.Rules.NoUnusedVariables
import Lint.Rules.NoUselessIf
import Lint.Rules.NoUselessPatternMatching
import Lint.Rules.NoWarningComments
import Lint.Rules.SimplifyPiping
import Lint.Rules.SimplifyPropertyAccess
import Lint.Rules.ElmTest.NoDuplicateTestBodies
import Lint.Rule exposing (Rule, Severity(..))
import Lint.Rule.DefaultPatternPosition
import Lint.Rule.NoConstantCondition
import Lint.Rule.NoDebug
import Lint.Rule.NoDuplicateImports
import Lint.Rule.NoExposingEverything
import Lint.Rule.NoImportingEverything
import Lint.Rule.NoNestedLet
import Lint.Rule.NoUnannotatedFunction
import Lint.Rule.NoUnusedVariables
import Lint.Rule.NoUselessIf
import Lint.Rule.NoUselessPatternMatching
import Lint.Rule.NoWarningComments
import Lint.Rule.SimplifyPiping
import Lint.Rule.SimplifyPropertyAccess
import Lint.Rule.ElmTest.NoDuplicateTestBodies
config : List ( Severity, Rule )
config =
[ ( Critical, Lint.Rules.DefaultPatternPosition.rule { position = Lint.Rules.DefaultPatternPosition.Last } )
, ( Critical, Lint.Rules.NoConstantCondition.rule )
, ( Critical, Lint.Rules.NoDebug.rule )
, ( Critical, Lint.Rules.NoDuplicateImports.rule )
, ( Critical, Lint.Rules.NoExposingEverything.rule )
, ( Critical, Lint.Rules.NoImportingEverything.rule { exceptions = [ "Html", "Ast.Expression", "Ast.Statement" ] } )
, ( Critical, Lint.Rules.NoNestedLet.rule )
, ( Critical, Lint.Rules.NoUnannotatedFunction.rule )
, ( Critical, Lint.Rules.NoUnusedVariables.rule )
, ( Critical, Lint.Rules.NoUselessIf.rule )
, ( Critical, Lint.Rules.NoUselessPatternMatching.rule )
, ( Warning, Lint.Rules.NoWarningComments.rule )
, ( Critical, Lint.Rules.SimplifyPiping.rule )
, ( Critical, Lint.Rules.SimplifyPropertyAccess.rule )
, ( Critical, Lint.Rules.ElmTest.NoDuplicateTestBodies.rule )
[ ( Critical, Lint.Rule.DefaultPatternPosition.rule { position = Lint.Rule.DefaultPatternPosition.Last } )
, ( Critical, Lint.Rule.NoConstantCondition.rule )
, ( Critical, Lint.Rule.NoDebug.rule )
, ( Critical, Lint.Rule.NoDuplicateImports.rule )
, ( Critical, Lint.Rule.NoExposingEverything.rule )
, ( Critical, Lint.Rule.NoImportingEverything.rule { exceptions = [ "Html", "Ast.Expression", "Ast.Statement" ] } )
, ( Critical, Lint.Rule.NoNestedLet.rule )
, ( Critical, Lint.Rule.NoUnannotatedFunction.rule )
, ( Critical, Lint.Rule.NoUnusedVariables.rule )
, ( Critical, Lint.Rule.NoUselessIf.rule )
, ( Critical, Lint.Rule.NoUselessPatternMatching.rule )
, ( Warning, Lint.Rule.NoWarningComments.rule )
, ( Critical, Lint.Rule.SimplifyPiping.rule )
, ( Critical, Lint.Rule.SimplifyPropertyAccess.rule )
, ( Critical, Lint.Rule.ElmTest.NoDuplicateTestBodies.rule )
]

View File

@ -6,8 +6,8 @@
"version": "3.0.0",
"exposed-modules": [
"Lint",
"Lint.Types",
"Lint.Rules.NoDebug"
"Lint.Rule",
"Lint.Rule.NoDebug"
],
"elm-version": "0.19.0 <= v < 0.20.0",
"dependencies": {

View File

@ -8,7 +8,7 @@ import Html.Attributes exposing (class, id, style)
import Html.Events exposing (onInput)
import Lint exposing (Rule, Severity(..), lintSource)
import Lint.Error exposing (Error)
import Lint.Rules.NoDebug
import Lint.Rule.NoDebug
import Result exposing (Result)
@ -18,22 +18,22 @@ type Msg
config : List ( Severity, Rule )
config =
[ ( Critical, Lint.Rules.NoDebug.rule )
[ ( Critical, Lint.Rule.NoDebug.rule )
-- , ( Critical, Lint.Rules.DefaultPatternPosition.rule { position = Lint.Rules.DefaultPatternPosition.Last } )
-- , ( Critical, Lint.Rules.NoConstantCondition.rule )
-- , ( Critical, Lint.Rules.NoDuplicateImports.rule )
-- , ( Critical, Lint.Rules.NoExposingEverything.rule )
-- , ( Critical, Lint.Rules.NoImportingEverything.rule { exceptions = [ "Html" ] } )
-- , ( Critical, Lint.Rules.NoNestedLet.rule )
-- , ( Critical, Lint.Rules.NoUnannotatedFunction.rule )
-- , ( Critical, Lint.Rules.NoUnusedVariables.rule )
-- , ( Critical, Lint.Rules.NoUselessIf.rule )
-- , ( Critical, Lint.Rules.NoUselessPatternMatching.rule )
-- , ( Warning, Lint.Rules.NoWarningComments.rule )
-- , ( Critical, Lint.Rules.SimplifyPiping.rule )
-- , ( Critical, Lint.Rules.SimplifyPropertyAccess.rule )
-- , ( Critical, Lint.Rules.ElmTest.NoDuplicateTestBodies.rule )
-- , ( Critical, Lint.Rule.DefaultPatternPosition.rule { position = Lint.Rule.DefaultPatternPosition.Last } )
-- , ( Critical, Lint.Rule.NoConstantCondition.rule )
-- , ( Critical, Lint.Rule.NoDuplicateImports.rule )
-- , ( Critical, Lint.Rule.NoExposingEverything.rule )
-- , ( Critical, Lint.Rule.NoImportingEverything.rule { exceptions = [ "Html" ] } )
-- , ( Critical, Lint.Rule.NoNestedLet.rule )
-- , ( Critical, Lint.Rule.NoUnannotatedFunction.rule )
-- , ( Critical, Lint.Rule.NoUnusedVariables.rule )
-- , ( Critical, Lint.Rule.NoUselessIf.rule )
-- , ( Critical, Lint.Rule.NoUselessPatternMatching.rule )
-- , ( Warning, Lint.Rule.NoWarningComments.rule )
-- , ( Critical, Lint.Rule.SimplifyPiping.rule )
-- , ( Critical, Lint.Rule.SimplifyPropertyAccess.rule )
-- , ( Critical, Lint.Rule.ElmTest.NoDuplicateTestBodies.rule )
]

View File

@ -57,8 +57,8 @@ import Elm.Syntax.Expression exposing (Expression)
import Elm.Syntax.File exposing (File)
import Elm.Syntax.Node exposing (Node)
import Lint.Error exposing (Error)
import Lint.Types exposing (Direction, LintRuleImplementation, Visitor, initialContext)
import Lint.Visitor exposing (expressionToVisitors, transformDeclarationsIntoVisitors)
import Lint.NodeToVisitor exposing (declarationsIntoVisitors, expressionToVisitors)
import Lint.Rule exposing (Direction, Implementation, Visitor, initialContext)
{-| Shortcut to a lint rule
@ -122,7 +122,7 @@ parseSource source =
rule input =
lint input implementation
implementation : LintRuleImplementation Context
implementation : Implementation Context
implementation =
{ typeFn = doNothing
, visitExpression = visitExpression
@ -131,10 +131,10 @@ parseSource source =
}
-}
lint : File -> LintRuleImplementation context -> List Error
lint : File -> Implementation context -> List Error
lint file rule =
file.declarations
|> transformDeclarationsIntoVisitors
|> declarationsIntoVisitors
|> lintWithVisitors rule
@ -150,7 +150,7 @@ part of the implementation of complex rules much easier. It gives back a list of
_ ->
( [], ctx )
subimplementation : LintRuleImplementation Subcontext
subimplementation : Implementation Subcontext
subimplementation =
{ statementFn = doNothing
, typeFn = doNothing
@ -160,19 +160,19 @@ part of the implementation of complex rules much easier. It gives back a list of
}
-}
visitExpression : LintRuleImplementation context -> Node Expression -> ( List Error, context )
visitExpression : Implementation context -> Node Expression -> ( List Error, context )
visitExpression rule expression =
expressionToVisitors expression
|> List.foldl (visitAndAccumulate rule) ( [], initialContext rule )
visitAndAccumulate : LintRuleImplementation context -> Visitor context -> ( List Error, context ) -> ( List Error, context )
visitAndAccumulate : Implementation context -> Visitor context -> ( List Error, context ) -> ( List Error, context )
visitAndAccumulate rule visitor ( errors, ctx ) =
visitor rule ctx
|> Tuple.mapFirst (\errors_ -> errors ++ errors_)
lintWithVisitors : LintRuleImplementation context -> List (Visitor context) -> List Error
lintWithVisitors : Implementation context -> List (Visitor context) -> List Error
lintWithVisitors rule visitors =
visitors
|> List.foldl (visitAndAccumulate rule) ( [], initialContext rule )

View File

@ -1,10 +1,10 @@
module Lint.Visitor exposing (expressionToVisitors, transformDeclarationsIntoVisitors)
module Lint.NodeToVisitor exposing (declarationsIntoVisitors, expressionToVisitors)
import Elm.Syntax.Declaration exposing (Declaration(..))
import Elm.Syntax.Expression exposing (Expression(..), Function, FunctionImplementation, LetDeclaration(..))
import Elm.Syntax.Infix exposing (InfixDirection(..))
import Elm.Syntax.Node exposing (Node, value)
import Lint.Types exposing (Direction(..), Visitor, evaluateExpression, finalEvaluation)
import Lint.Rule exposing (Direction(..), Visitor, evaluateExpression, finalEvaluation)
createExitAndEnterWithChildren : (Direction -> nodeType -> Visitor context) -> nodeType -> List (Visitor context) -> List (Visitor context)
@ -134,8 +134,8 @@ declarationToVisitors declaration =
childrenVisitors
transformDeclarationsIntoVisitors : List (Node Declaration) -> List (Visitor context)
transformDeclarationsIntoVisitors declarations =
declarationsIntoVisitors : List (Node Declaration) -> List (Visitor context)
declarationsIntoVisitors declarations =
declarations
|> List.concatMap (value >> declarationToVisitors)
|> (\allVisitors -> List.append allVisitors [ moduleVisitor ])

View File

@ -1,6 +1,6 @@
module Lint.Types exposing
module Lint.Rule exposing
( Direction(..)
, LintRuleImplementation, createRule
, Implementation, createRule
, Visitor, LintResult
, evaluateExpression, finalEvaluation, initialContext
)
@ -15,7 +15,7 @@ module Lint.Types exposing
# Writing rules
@docs LintRuleImplementation, createRule
@docs Implementation, createRule
# Internal types
@ -56,7 +56,7 @@ type Direction
| Exit
{-| A LintRuleImplementation is the implementation of a rule. It is a record that contains:
{-| A Implementation is the implementation of a rule. It is a record that contains:
- initialContext: An initial context
@ -69,7 +69,7 @@ type Direction
rule input =
lint input implementation
implementation : LintRuleImplementation Context
implementation : Implementation Context
implementation =
{ expression = expression
, visitEnd = (\\ctx -> ( [], ctx ))
@ -77,8 +77,8 @@ type Direction
}
-}
type LintRuleImplementation context
= LintRuleImplementation
type Implementation context
= Implementation
{ initContext : context
, visitors : Visitors context
}
@ -90,9 +90,9 @@ type alias Visitors context =
}
createRule : context -> (Visitors context -> Visitors context) -> LintRuleImplementation context
createRule : context -> (Visitors context -> Visitors context) -> Implementation context
createRule initContext createVisitors =
LintRuleImplementation
Implementation
{ initContext = initContext
, visitors =
createVisitors
@ -102,18 +102,18 @@ createRule initContext createVisitors =
}
initialContext : LintRuleImplementation context -> context
initialContext (LintRuleImplementation { initContext }) =
initialContext : Implementation context -> context
initialContext (Implementation { initContext }) =
initContext
evaluateExpression : LintRuleImplementation context -> context -> Direction -> Node Expression -> ( List Error, context )
evaluateExpression (LintRuleImplementation { visitors }) =
evaluateExpression : Implementation context -> context -> Direction -> Node Expression -> ( List Error, context )
evaluateExpression (Implementation { visitors }) =
visitors.visitExpression
finalEvaluation : LintRuleImplementation context -> context -> ( List Error, context )
finalEvaluation (LintRuleImplementation { visitors }) =
finalEvaluation : Implementation context -> context -> ( List Error, context )
finalEvaluation (Implementation { visitors }) =
visitors.visitEnd
@ -130,4 +130,4 @@ Note: this is internal API, and will be removed in a future version.
-}
type alias Visitor context =
LintRuleImplementation context -> context -> ( List Error, context )
Implementation context -> context -> ( List Error, context )

View File

@ -1,4 +1,4 @@
module Lint.Rules.NoDebug exposing (rule)
module Lint.Rule.NoDebug exposing (rule)
{-|
@ -34,7 +34,7 @@ import Elm.Syntax.Expression exposing (Expression(..))
import Elm.Syntax.Node exposing (Node, range, value)
import Lint exposing (Rule, lint)
import Lint.Error exposing (Error)
import Lint.Types exposing (Direction(..), LintRuleImplementation, createRule)
import Lint.Rule exposing (Direction(..), Implementation, createRule)
type alias Context =
@ -53,7 +53,7 @@ rule input =
lint input implementation
implementation : LintRuleImplementation Context
implementation : Implementation Context
implementation =
createRule
Context

View File

@ -3,8 +3,8 @@ module NoDebugTest exposing (all)
import Elm.Syntax.Range exposing (Location, Range)
import Lint exposing (Rule)
import Lint.Error exposing (Error)
import Lint.Rules.NoDebug exposing (rule)
import Lint.Types exposing (LintResult)
import Lint.Rule exposing (LintResult)
import Lint.Rule.NoDebug exposing (rule)
import Test exposing (Test, describe, only, test)
import TestUtil exposing (expectErrors, ruleTester)

View File

@ -3,7 +3,7 @@ module TestUtil exposing (expectErrors, ruleTester)
import Expect
import Lint exposing (Rule, parseSource)
import Lint.Error exposing (Error)
import Lint.Types exposing (LintResult)
import Lint.Rule exposing (LintResult)
ruleTester : Rule -> String -> LintResult