diff options
-rw-r--r-- | .haml-lint.yml | 6 | ||||
-rw-r--r-- | unwrapped_plain_node.rb | 18 |
2 files changed, 24 insertions, 0 deletions
diff --git a/.haml-lint.yml b/.haml-lint.yml index bad918ef35d..dcd64eab561 100644 --- a/.haml-lint.yml +++ b/.haml-lint.yml @@ -5,7 +5,13 @@ exclude: - 'vendor/**/*' - 'spec/**/*' +require: + - './unwrapped_plain_node.rb' + linters: + UnwrappedPlainNode: + enabled: true + AltText: enabled: true diff --git a/unwrapped_plain_node.rb b/unwrapped_plain_node.rb new file mode 100644 index 00000000000..9525e830304 --- /dev/null +++ b/unwrapped_plain_node.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module HamlLint + # Checks for unwrapped text nodes. + # Useful for i18n helper methods. + # + # Fail: %tag Some text + # Pass: %tag= _('Some text') + class Linter::UnwrappedPlainNode < Linter + include LinterRegistry + + MESSAGE = '`= "..."` should be rewritten as `...`'.freeze + + def visit_plain(node) + record_lint(node, MESSAGE) + end + end +end |