2018-10-08 14:50:39 +00:00
|
|
|
# rubocop:disable Naming/FileName
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
unless Rails.env.production?
|
2018-10-17 22:39:12 +00:00
|
|
|
require_dependency 'haml_lint/haml_visitor'
|
|
|
|
require_dependency 'haml_lint/linter'
|
|
|
|
require_dependency 'haml_lint/linter_registry'
|
2017-03-06 19:46:52 +00:00
|
|
|
|
2017-08-08 07:19:44 +00:00
|
|
|
module HamlLint
|
|
|
|
class Linter::InlineJavaScript < Linter
|
|
|
|
include LinterRegistry
|
2018-02-28 22:58:12 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-02-28 21:42:34 +00:00
|
|
|
def visit_tag(node)
|
2018-02-28 21:23:58 +00:00
|
|
|
return unless node.tag_name == 'script'
|
2017-11-14 09:02:39 +00:00
|
|
|
|
2017-08-08 07:19:44 +00:00
|
|
|
record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
|
|
|
|
end
|
2017-03-06 19:46:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|