mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-23 17:53:35 +03:00
Move LintResult from Lint.Error to TestUtil
This commit is contained in:
parent
b324066736
commit
fbbb70749b
@ -11,7 +11,7 @@ If you are familiar with [ESLint](http://eslint.org/) from JavaScript, this is p
|
||||
The idea is to improve your Elm source code base, after it passes compilation and [elm-format](https://github.com/avh4/elm-format) has been run on it.
|
||||
|
||||
This packages offers a few rules that you can pick and configure to improve your code base, but you can also create your own rules, to enforce rules specific to your project or team. A few cases:
|
||||
- You noticed a bad pattern in your codebase, wrote a nice module to handle the pattern better, and want to prevent your team from writing that pattern from now on. You can then write a rule to detect that pattern and have it suggest using your module instead.
|
||||
- You noticed a bad pattern in your codebase, wrote a nice module to handle the pattern better, and want to prevent your team from writing that pattern from now on. You can then write a rule to detect that pattern and have it suggest using your module instead. If you don't, you need to communicate this well to all your
|
||||
- When using the [core HTML package](https://package.elm-lang.org/packages/elm/html/latest/), you may style your tags using the [style function](https://package.elm-lang.org/packages/elm/html/latest/Html-Attributes#style). When using [elm-css](https://package.elm-lang.org/packages/rtfeldman/elm-css), you probably want to avoid using that function (or the core HTML package altogether) and can write a rule for it.
|
||||
- You published a library in the Elm package registry, and notice some pitfalls that users can fall in, that all your research for a better API do not prevent. You can then publish a separate package (or even in the same package) with rules preventing those pitfalls, should the user use `elm-lint` in their project.
|
||||
- You often notice that strings in your codebase contain very common typos, or bad use of punctuation (like a missing space after `;`).
|
||||
|
@ -1,5 +1,5 @@
|
||||
module Lint.Error exposing
|
||||
( Error, LintResult
|
||||
( Error
|
||||
, create
|
||||
, message, range
|
||||
)
|
||||
@ -13,7 +13,7 @@ module Lint.Error exposing
|
||||
|
||||
# Definition
|
||||
|
||||
@docs Error, LintResult
|
||||
@docs Error
|
||||
|
||||
|
||||
# CONSTRUCTOR
|
||||
@ -41,12 +41,6 @@ type Error
|
||||
}
|
||||
|
||||
|
||||
{-| Shortcut to the result of a lint rule
|
||||
-}
|
||||
type alias LintResult =
|
||||
Result (List String) (List Error)
|
||||
|
||||
|
||||
|
||||
-- CONSTRUCTOR
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
module DefaultPatternPositionTest exposing (all)
|
||||
|
||||
import Elm.Syntax.Range exposing (Location, Range)
|
||||
import Lint.Error as Error exposing (Error, LintResult)
|
||||
import Lint.Error as Error exposing (Error)
|
||||
import Lint.Rule exposing (Rule)
|
||||
import Lint.Rule.DefaultPatternPosition exposing (PatternPosition(..), rule)
|
||||
import Test exposing (Test, describe, test)
|
||||
import TestUtil
|
||||
import TestUtil exposing (LintResult)
|
||||
|
||||
|
||||
testRule : PatternPosition -> String -> LintResult
|
||||
|
@ -1,11 +1,11 @@
|
||||
module NoDebugTest exposing (all)
|
||||
|
||||
import Elm.Syntax.Range exposing (Location, Range)
|
||||
import Lint.Error as Error exposing (Error, LintResult)
|
||||
import Lint.Error as Error exposing (Error)
|
||||
import Lint.Rule exposing (Rule)
|
||||
import Lint.Rule.NoDebug exposing (rule)
|
||||
import Test exposing (Test, describe, test)
|
||||
import TestUtil
|
||||
import TestUtil exposing (LintResult)
|
||||
|
||||
|
||||
testRule : String -> LintResult
|
||||
|
@ -1,11 +1,11 @@
|
||||
module NoExtraBooleanComparisonTest exposing (all)
|
||||
|
||||
import Elm.Syntax.Range exposing (Location, Range)
|
||||
import Lint.Error as Error exposing (Error, LintResult)
|
||||
import Lint.Error as Error exposing (Error)
|
||||
import Lint.Rule exposing (Rule)
|
||||
import Lint.Rule.NoExtraBooleanComparison exposing (rule)
|
||||
import Test exposing (Test, describe, test)
|
||||
import TestUtil
|
||||
import TestUtil exposing (LintResult)
|
||||
|
||||
|
||||
testRule : String -> LintResult
|
||||
|
@ -1,11 +1,11 @@
|
||||
module NoImportingEverythingTest exposing (all)
|
||||
|
||||
import Elm.Syntax.Range exposing (Location, Range)
|
||||
import Lint.Error as Error exposing (Error, LintResult)
|
||||
import Lint.Error as Error exposing (Error)
|
||||
import Lint.Rule exposing (Rule)
|
||||
import Lint.Rule.NoImportingEverything exposing (Configuration, rule)
|
||||
import Test exposing (Test, describe, test)
|
||||
import TestUtil
|
||||
import TestUtil exposing (LintResult)
|
||||
|
||||
|
||||
testRule : Configuration -> String -> LintResult
|
||||
|
@ -1,11 +1,11 @@
|
||||
module NoUnusedVariablesTest exposing (all)
|
||||
|
||||
import Elm.Syntax.Range exposing (Location, Range)
|
||||
import Lint.Error as Error exposing (Error, LintResult)
|
||||
import Lint.Error as Error exposing (Error)
|
||||
import Lint.Rule exposing (Rule)
|
||||
import Lint.Rule.NoUnusedVariables exposing (rule)
|
||||
import Test exposing (Test, describe, test)
|
||||
import TestUtil
|
||||
import TestUtil exposing (LintResult)
|
||||
|
||||
|
||||
testRule : String -> LintResult
|
||||
|
@ -1,12 +1,18 @@
|
||||
module TestUtil exposing (errorWithoutRange, expectErrors, expectErrorsWithoutRange, location, ruleTester)
|
||||
module TestUtil exposing (LintResult, errorWithoutRange, expectErrors, expectErrorsWithoutRange, location, ruleTester)
|
||||
|
||||
import Elm.Syntax.Range exposing (Range)
|
||||
import Expect
|
||||
import Lint exposing (Severity(..), lintSource)
|
||||
import Lint.Error as Error exposing (Error, LintResult)
|
||||
import Lint.Error as Error exposing (Error)
|
||||
import Lint.Rule exposing (Rule)
|
||||
|
||||
|
||||
{-| Result of a lint rule being applied on a string containing Elm code.
|
||||
-}
|
||||
type alias LintResult =
|
||||
Result (List String) (List Error)
|
||||
|
||||
|
||||
ruleTester : Rule -> String -> Result (List String) (List Error)
|
||||
ruleTester rule str =
|
||||
lintSource [ ( Critical, rule ) ] str
|
||||
|
Loading…
Reference in New Issue
Block a user