Skip to content

leojpod/review-no-empty-html-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

No-empty-html-text

What is it?

This is a simple rule for the elm-review tool that will flag the use of the Html.text function as a mean to show nothing. It is quite often the case that we see the following pattern in elm code:

if a then
  viewA a
else
  text ""

However, there is the quite nice elm-community/html-extra package that provide utility functions to "replace" those text "" by an alias nothing or by some other utility functions (e.g viewIf, viewMaybe, ...)

Why should you use it?

  • if you've just installed html-extra on an already existing project chances are that you've plenty of text "" dispersed across many files. Setting up elm-review and using this rule would be a good way to find and fix them all.
  • if you are already got the habit of using the function from html-extra but you'd like to make sure that newcomers will get directed to the proper doc when they start on your project, this is also a good option.

Why should you not use it?

  • if you do not mind text "" in your code.
  • if you do not want to use html-extra.
  • if you do not want to setup elm-review.
  • ...

Example configuration

import NoEmptyText
import Review.Rule exposing (Rule)

config : List Rule
config =
  [ NoEmptyText.rule
  ]

About

elm-review rule to forbid the use of `Html.text ""`

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages