This rule is useful to stop the spread of the usage of deprecated values and types.
This rule is recommended to be used with elm-review's suppression system (see elm-review suppress --help).
That way, current uses of deprecated elements won't be reported, but the rule will report new usages, in practice
allowing you to stop the bleed.
An additional benefit is that the suppressed errors will make it easy to have an overview of the number of times
deprecated elements are used and where they are located. Looking at the error reports (using elm-review --unsuppress
for instance) will give you the more precise problems and locations.
I recommend making it extra explicit when deprecating elements in your application code, for instance by renaming deprecated elements to include "deprecated" in their name, or in their module name for modules.
That way, it will be very explicit for you and your teammates when you're using something that is deprecated, even in Git diffs.
For packages, renaming something is a breaking chance so that is not a viable option (if it is, remove the function and
release a new major version). Instead, what you can do is to start a line in your module/value/type's documentation
with @deprecated. There is no official nor conventional approach around deprecation in the Elm community, but this may
be a good start. But definitely pitch in the discussion around making a standard!
(I'll put a link here soon. If I haven't, please remind me!)
For both application and packages, when you deprecate something, I highly recommend documenting (in the most appropriate location) why it is deprecate but especially what alternatives should be used or explored. It can be frustrating to learn that something is deprecated without an explanation or any guidance what to use instead.
Configuration for the rule.
Create one using defaults, then change it using functions like dependencies and
withExceptionsForElements.
Default configuration.
By default are considered as deprecated:
Configure this further using functions like dependencies and
withExceptionsForElements.
Mark one or more dependencies as deprecated.
config =
[ NoDeprecated.defaults
|> NoDeprecated.dependencies [ "jfmengels/some-deprecated-dependency" ]
|> NoDeprecated.rule
]Every usage of something defined in that dependency in the project's code wil be reported.
Add exceptions for the reporting elements. This can for instance be used for values and that contain "deprecated" in their name without actually being deprecated.
config =
[ NoDeprecated.defaults
|> NoDeprecated.withExceptionsForElements [ "SomeModule.listOfDeprecatedFunctions" ]
|> NoDeprecated.rule
]import DeprecatedModule
a =
DeprecatedModule.view "..."
b =
Button.view_DEPRECATED "Click me!" OnClickIf you do not have deprecated elements in your project, this rule won't be useful.
You can try this rule out by running the following command:
elm-review --template jfmengels/elm-review-common/example --rules NoDeprecated
Reports usages of deprecated values and types.