2018-10-08 10:50:39 -04:00
|
|
|
# rubocop:disable Naming/FileName
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
unless Rails.env.production?
|
2017-08-08 03:19:44 -04:00
|
|
|
require 'haml_lint/haml_visitor'
|
|
|
|
require 'haml_lint/linter'
|
|
|
|
require '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
|
|
|
|
include 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
|