Commit c6bf292e authored by winniehell's avatar winniehell Committed by winh

Add custom linter for inline JavaScript to haml_lint (!9742)

parent 95b232f2
...@@ -41,6 +41,9 @@ linters: ...@@ -41,6 +41,9 @@ linters:
ImplicitDiv: ImplicitDiv:
enabled: true enabled: true
InlineJavaScript:
enabled: true
InlineStyles: InlineStyles:
enabled: false enabled: false
......
---
title: Add custom linter for inline JavaScript to haml_lint
merge_request: 9742
author: winniehell
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
unless Rails.env.production? unless Rails.env.production?
require 'haml_lint/rake_task' require 'haml_lint/rake_task'
require 'haml_lint/inline_javascript'
HamlLint::RakeTask.new HamlLint::RakeTask.new
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment