slim-lint icon indicating copy to clipboard operation
slim-lint copied to clipboard

Linter Idea: Check For Hard Coded Text

Open jaimerson opened this issue 8 years ago • 2 comments

I need to implement a linter that checks if there is any hard coded text (instead of i18n translations or method calls in general) for a project. So I wondered whether this project is a good place for this linter to live.

Here are some examples:

.foo
  | This is bad

.foo
  = t('.this_is_good')

.foo
  = this_is_also_ok(42)

jaimerson avatar May 19 '17 17:05 jaimerson

Hey @jaimerson,

This is doable with Slim-Lint, but I think you will find edge cases where static text is indeed what you want, which will lead you to do something silly like = 'My text'.

Open to a pull request that adds a linter checking this, but we'd have it disabled by default. Thanks!

sds avatar May 24 '17 16:05 sds

@sds Yeah, sure. There will be also some cases where it's impossible to detect whether static text is being used, like = link_to 'Untranslated text here' ..., but I think detecting the type I mentioned is a good start.

Thanks for the response!

jaimerson avatar May 24 '17 16:05 jaimerson