2018-05-09 12:01:36 +05:30
|
|
|
unless Rails.env.production? # rubocop:disable Naming/FileName
|
2017-09-10 17:25:29 +05:30
|
|
|
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'
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
def visit_tag(node)
|
|
|
|
return unless node.tag_name == 'script'
|
|
|
|
|
|
|
|
record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|