diff options
author | Luke Bennett <lbennett@gitlab.com> | 2019-04-14 01:14:27 +0300 |
---|---|---|
committer | Luke Bennett <lbennett@gitlab.com> | 2019-04-14 01:14:27 +0300 |
commit | 95f522a159800997ee94b0f98c9fdefe78572140 (patch) | |
tree | 6ee2b1544926fdada94c594fb99a4e03e3584818 | |
parent | 44be329d59bc20598c2c2f310d4f3029c8dd25a9 (diff) |
beep boophaml_lint_plain_node
-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 |