diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/haml_lint/inline_javascript.rb | 14 | ||||
-rw-r--r-- | lib/tasks/haml-lint.rake | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/haml_lint/inline_javascript.rb b/lib/haml_lint/inline_javascript.rb new file mode 100644 index 00000000000..f3ddcbb9c95 --- /dev/null +++ b/lib/haml_lint/inline_javascript.rb @@ -0,0 +1,14 @@ +require 'haml_lint/haml_visitor' +require 'haml_lint/linter' +require 'haml_lint/linter_registry' + +module HamlLint + class Linter::InlineJavaScript < Linter + include LinterRegistry + + def visit_filter(node) + return unless node.filter_type == 'javascript' + record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)') + end + end +end diff --git a/lib/tasks/haml-lint.rake b/lib/tasks/haml-lint.rake index 609dfaa48e3..ad2d034b0b4 100644 --- a/lib/tasks/haml-lint.rake +++ b/lib/tasks/haml-lint.rake @@ -1,5 +1,6 @@ unless Rails.env.production? require 'haml_lint/rake_task' + require 'haml_lint/inline_javascript' HamlLint::RakeTask.new end |