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

This commit is contained in:
winniehell 2017-03-06 20:46:52 +01:00 committed by winh
parent 95b232f2cc
commit c6bf292efb
4 changed files with 22 additions and 0 deletions

View file

@ -41,6 +41,9 @@ linters:
ImplicitDiv:
enabled: true
InlineJavaScript:
enabled: true
InlineStyles:
enabled: false

View file

@ -0,0 +1,4 @@
---
title: Add custom linter for inline JavaScript to haml_lint
merge_request: 9742
author: winniehell

View file

@ -0,0 +1,14 @@
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

View file

@ -1,5 +1,6 @@
unless Rails.env.production?
require 'haml_lint/rake_task'
require 'haml_lint/inline_javascript'
HamlLint::RakeTask.new
end