mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-25 10:41:47 +03:00
Ignore fixes for the elm.json
file
This commit is contained in:
parent
bfade4d4c2
commit
0a811c5b43
@ -10,16 +10,20 @@ When creating a [`Review.Rule.Error`](./Review-Rule#Error), you can provide an a
|
|||||||
fix for the error using [`Review.Rule.withFixes`](./Review-Rule#withFixes) so that the
|
fix for the error using [`Review.Rule.withFixes`](./Review-Rule#withFixes) so that the
|
||||||
user doesn't need to fix the problem themselves.
|
user doesn't need to fix the problem themselves.
|
||||||
|
|
||||||
In the [CLI](https://github.com/jfmengels/node-elm-review), the user can ask to
|
In the [CLI], the user can ask to fix the errors automatically, and in doing so,
|
||||||
fix the errors automatically, and in doing so, they will be presented by a fix
|
they will be presented by a fix which they can accept or refuse. If the fix gets
|
||||||
which they can accept or refuse. If the fix gets refused, then the next fixable
|
refused, then the next fixable error will be presented. Otherwise, if the fix
|
||||||
error will be presented. Otherwise, if the fix gets accepted, the file will be
|
gets accepted, the file will be applied and the fixed file content get analyzed
|
||||||
applied and the fixed file content get analyzed again by the different rules in
|
again by the different rules in the user's configuration, and then another fix
|
||||||
the user's configuration, and then another fix will be presented. When there are
|
will be presented. When there are no more fixable errors, the remaining errors
|
||||||
no more fixable errors, the remaining errors will be reported, just like when
|
will be reported, just like when the user doesn't request errors to be automatically
|
||||||
the user doesn't request errors to be automatically fixed.
|
fixed.
|
||||||
|
|
||||||
In summary, errors will be presented one by one and the user will validate them.
|
In summary, errors will be presented one by one and the user will validate them.
|
||||||
|
The [CLI] also proposes an option to fix all the errors, which applies each fix
|
||||||
|
one by one and then asks the user to confirm the cummulated fix.
|
||||||
|
|
||||||
|
Automatic fixes for the `elm.json` are ignored and won't be applied.
|
||||||
|
|
||||||
|
|
||||||
# Guidelines
|
# Guidelines
|
||||||
@ -27,7 +31,7 @@ In summary, errors will be presented one by one and the user will validate them.
|
|||||||
An automatic fix, when applied, should resolve the reported error completely.
|
An automatic fix, when applied, should resolve the reported error completely.
|
||||||
This means that when the automatic fix is applied, the user should not have to
|
This means that when the automatic fix is applied, the user should not have to
|
||||||
think about the error anymore or have to do additional work. Imagine if the user
|
think about the error anymore or have to do additional work. Imagine if the user
|
||||||
applies a lot of automatic fixes all at once, we don't want them to have to
|
applies a lot of automatic fixes all at once. We don't want them to have to
|
||||||
remember having to do something, otherwise we may have just offloaded a lot of
|
remember having to do something, otherwise we may have just offloaded a lot of
|
||||||
work that they may forget to do. In that case, it is better not to provide a fix
|
work that they may forget to do. In that case, it is better not to provide a fix
|
||||||
at all, so that they keep a reminder and the details of how to fix the problem.
|
at all, so that they keep a reminder and the details of how to fix the problem.
|
||||||
@ -123,6 +127,8 @@ in the context of your rule.
|
|||||||
|
|
||||||
@docs FixResult, Problem, fix
|
@docs FixResult, Problem, fix
|
||||||
|
|
||||||
|
[CLI]: https://github.com/jfmengels/node-elm-review
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Array
|
import Array
|
||||||
|
@ -2237,6 +2237,8 @@ If you pass `withFixes` an empty list, the error will be considered as having no
|
|||||||
automatic fix available. Calling `withFixes` several times on an error will
|
automatic fix available. Calling `withFixes` several times on an error will
|
||||||
overwrite the previous fixes.
|
overwrite the previous fixes.
|
||||||
|
|
||||||
|
Fixes for the `elm.json` file will be ignored.
|
||||||
|
|
||||||
**Note**: Each fix applies on a location in the code, defined by a range. To avoid an
|
**Note**: Each fix applies on a location in the code, defined by a range. To avoid an
|
||||||
unpredictable result, those ranges may not overlap. The order of the fixes does
|
unpredictable result, those ranges may not overlap. The order of the fixes does
|
||||||
not matter.
|
not matter.
|
||||||
@ -2244,7 +2246,7 @@ not matter.
|
|||||||
-}
|
-}
|
||||||
withFixes : List Fix -> Error -> Error
|
withFixes : List Fix -> Error -> Error
|
||||||
withFixes fixes (Error err) =
|
withFixes fixes (Error err) =
|
||||||
if List.isEmpty fixes then
|
if List.isEmpty fixes || String.endsWith ".json" err.filePath then
|
||||||
Error { err | fixes = Nothing }
|
Error { err | fixes = Nothing }
|
||||||
|
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user