Reword the error message for the NoDebug rule

This commit is contained in:
Jeroen Engels 2019-07-23 00:16:02 +02:00
parent 661bee3ef3
commit 7dc2094ff8
5 changed files with 24 additions and 24 deletions

View File

@ -365,7 +365,7 @@ The following example forbids using the Debug module.
case Node.value node of
FunctionOrValue moduleName fnName ->
if List.member "Debug" moduleName then
[ Rule.error "Forbidden use of Debug" (Node.range node) ]
[ Rule.error "Remove the use of `Debug` before shipping to production" (Node.range node) ]
else
[]
@ -510,7 +510,7 @@ withInitialContext initialContext_ (Schema schema) =
[module definition](https://package.elm-lang.org/packages/stil4m/elm-syntax/latest/Elm-Syntax-Module) (`module SomeModuleName exposing (a, b)`), collect data in the `context` and/or report patterns.
The following example forbids the use of `Debug` except in some files, determined
by a configuration which could look like `( Critical, NoDebugExceptInSomeModules.rule ["Some.Module"] )`
by a configuration which could look like `( Critical, NoDebugExceptInSomeModules.rule [ "Some.Module" ] )`
import Elm.Syntax.Expression exposing (Expression(..))
import Elm.Syntax.Module as Module exposing (Module)
@ -548,7 +548,7 @@ by a configuration which could look like `( Critical, NoDebugExceptInSomeModules
case Node.value node of
FunctionOrValue moduleName fnName ->
if List.member "Debug" moduleName then
( [ Rule.error "Forbidden use of Debug" (Node.range node) ], context )
( [ Rule.error "Remove the use of `Debug` before shipping to production" (Node.range node) ], context )
else
( [], context )
@ -775,7 +775,7 @@ module Main exposing (Context(..), expressionVisitor, importVisitor, rule)
DebugLogWasImported ->
case ( direction, Node.value node ) of
( Rule.OnEnter, FunctionOrValue [] "log" ) ->
( [ Rule.error "Forbidden use of Debug.log" (Node.range node) ], context )
( [ Rule.error "Remove the use of `Debug` before shipping to production.log" (Node.range node) ], context )
_ ->
( [], context )
@ -860,7 +860,7 @@ In most cases, you can get it using [`Node.range`](https://package.elm-lang.org/
error : Node a -> Error
error node =
Rule.error "Forbidden use of Debug" (Node.range node)
Rule.error "Remove the use of `Debug` before shipping to production" (Node.range node)
-}
error : String -> Range -> Error

View File

@ -56,7 +56,7 @@ rule =
error : Node a -> Error
error node =
Rule.error "Forbidden use of Debug" (Node.range node)
Rule.error "Remove the use of `Debug` before shipping to production" (Node.range node)
importVisitor : Node Import -> List Error

View File

@ -28,7 +28,7 @@ module Lint.Test exposing
a = Debug.log "some" "message\""""
|> Lint.Test.expectErrors
[ Lint.Test.error
{ message = "Forbidden use of Debug"
{ message = "Remove the use of `Debug` before shipping to production"
, under = "Debug.log"
}
]
@ -181,7 +181,7 @@ an error at the end of the source code.
a = Debug.log "some" "message\""""
|> Lint.Test.expectErrors
[ Lint.Test.error
{ message = "Forbidden use of Debug"
{ message = "Remove the use of `Debug` before shipping to production"
, under = "Debug.log"
}
]
@ -215,7 +215,7 @@ lines will appear if the error appeared in an editor.
a = Debug.log "some" "message\""""
|> Lint.Test.expectErrors
[ Lint.Test.error
{ message = "Forbidden use of Debug"
{ message = "Remove the use of `Debug` before shipping to production"
, under = "Debug.log"
}
]

View File

@ -84,13 +84,13 @@ messageMismatchTest =
let
expectedError : ExpectedErrorData
expectedError =
{ message = "Forbidden use of Debug"
{ message = "Remove the use of `Debug` before shipping to production"
, under = "Debug.log"
}
error : Error
error =
Rule.error "Forbidden use of Debu" dummyRange
Rule.error "Some error message" dummyRange
in
ErrorMessage.messageMismatch expectedError error
|> expectMessageEqual """
@ -98,11 +98,11 @@ UNEXPECTED ERROR MESSAGE
I was looking for the error with the following message:
`Forbidden use of Debug`
`Remove the use of `Debug` before shipping to production`
but I found the following error message:
`Forbidden use of Debu`"""
`Some error message`"""
underMismatchTest : Test
@ -260,10 +260,10 @@ expectedMoreErrorsTest =
let
missingErrors : List ExpectedErrorData
missingErrors =
[ { message = "Forbidden use of Debug"
[ { message = "Remove the use of `Debug` before shipping to production"
, under = "Debug.log"
}
, { message = "Forbidden use of Debug"
, { message = "Remove the use of `Debug` before shipping to production"
, under = "Debug.log"
}
]
@ -274,8 +274,8 @@ RULE REPORTED LESS ERRORS THAN EXPECTED
I expected to see 2 more errors:
- `Forbidden use of Debug`
- `Forbidden use of Debug`
- `Remove the use of `Debug` before shipping to production`
- `Remove the use of `Debug` before shipping to production`
"""
@ -288,7 +288,7 @@ tooManyErrorsTest =
extraErrors : List Rule.Error
extraErrors =
[ Rule.error
"Forbidden use of Debug"
"Remove the use of `Debug` before shipping to production"
{ start = { row = 2, column = 1 }, end = { row = 2, column = 5 } }
]
in
@ -298,7 +298,7 @@ RULE REPORTED MORE ERRORS THAN EXPECTED
I found 1 error too many:
- `Forbidden use of Debug`
- `Remove the use of `Debug` before shipping to production`
at { start = { row = 2, column = 1 }, end = { row = 2, column = 5 } }
"""
, test "with multiple extra errors" <|
@ -307,10 +307,10 @@ I found 1 error too many:
extraErrors : List Rule.Error
extraErrors =
[ Rule.error
"Forbidden use of Debug"
"Remove the use of `Debug` before shipping to production"
{ start = { row = 2, column = 1 }, end = { row = 2, column = 5 } }
, Rule.error
"Forbidden use of Debug"
"Remove the use of `Debug` before shipping to production"
{ start = { row = 3, column = 1 }, end = { row = 3, column = 5 } }
]
in
@ -320,9 +320,9 @@ RULE REPORTED MORE ERRORS THAN EXPECTED
I found 2 errors too many:
- `Forbidden use of Debug`
- `Remove the use of `Debug` before shipping to production`
at { start = { row = 2, column = 1 }, end = { row = 2, column = 5 } }
- `Forbidden use of Debug`
- `Remove the use of `Debug` before shipping to production`
at { start = { row = 3, column = 1 }, end = { row = 3, column = 5 } }
"""
]

View File

@ -14,7 +14,7 @@ testRule string =
message : String
message =
"Forbidden use of Debug"
"Remove the use of `Debug` before shipping to production"
tests : List Test