2018-10-08 10:50:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
unless Rails.env.production?
|
2018-10-17 18:39:12 -04:00
|
|
|
require_dependency 'haml_lint/haml_visitor'
|
|
|
|
require_dependency 'haml_lint/linter'
|
|
|
|
require_dependency 'haml_lint/linter_registry'
|
2017-03-06 14:46:52 -05:00
|
|
|
|
2017-08-08 03:19:44 -04:00
|
|
|
module HamlLint
|
|
|
|
class Linter::InlineJavaScript < Linter
|
2019-05-21 20:28:28 -04:00
|
|
|
include ::HamlLint::LinterRegistry
|
2018-02-28 17:58:12 -05: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 16:42:34 -05:00
|
|
|
def visit_tag(node)
|
2018-02-28 16:23:58 -05:00
|
|
|
return unless node.tag_name == 'script'
|
2017-11-14 04:02:39 -05:00
|
|
|
|
2017-08-08 03:19:44 -04: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 14:46:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|