diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-07-14 20:58:54 +0300 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-07-14 20:58:54 +0300 |
commit | 2f85645d453ea67fac349325ff062735e758ddac (patch) | |
tree | 224d4a37d0b010937c30fc6016ef2ab5f15ab460 | |
parent | 0f393724e7de8d764577b6622ccf43964539cb2b (diff) |
Brought in HAML Linter changes from Winniehaml-inlinescript-linter
-rw-r--r-- | .haml-lint.yml | 3 | ||||
-rw-r--r-- | lib/haml_lint/inline_javascript.rb | 14 | ||||
-rw-r--r-- | lib/tasks/haml-lint.rake | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/.haml-lint.yml b/.haml-lint.yml index 528f99d08d2..09a11f4f7c1 100644 --- a/.haml-lint.yml +++ b/.haml-lint.yml @@ -38,6 +38,9 @@ linters: ImplicitDiv: enabled: true + InlineJavaScript: + enabled: true + LeadingCommentSpace: enabled: false diff --git a/lib/haml_lint/inline_javascript.rb b/lib/haml_lint/inline_javascript.rb new file mode 100644 index 00000000000..eef95cd95ef --- /dev/null +++ b/lib/haml_lint/inline_javascript.rb @@ -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. If needed, you can add this file to the list of exceptions in .haml-lint.yml.') + end + end +end diff --git a/lib/tasks/haml-lint.rake b/lib/tasks/haml-lint.rake index 609dfaa48e3..ad2d034b0b4 100644 --- a/lib/tasks/haml-lint.rake +++ b/lib/tasks/haml-lint.rake @@ -1,5 +1,6 @@ unless Rails.env.production? require 'haml_lint/rake_task' + require 'haml_lint/inline_javascript' HamlLint::RakeTask.new end |