Skip to content
代码片段 群组 项目
提交 114b688a 编辑于 作者: Sincheol (David) Kim's avatar Sincheol (David) Kim
浏览文件

Merge branch 'pl-haml-linter-inline-javascript' into 'master'

Move HAML linter InlineJavaScript into haml_lint/linter

See merge request gitlab-org/gitlab!86547
No related branches found
No related tags found
无相关合并请求
......@@ -8,8 +8,9 @@ exclude:
- 'spec/**/*'
- 'ee/spec/**/*'
require:
- './haml_lint/linter/no_plain_nodes.rb'
- './haml_lint/linter/documentation_links.rb'
- './haml_lint/linter/inline_javascript.rb'
- './haml_lint/linter/no_plain_nodes.rb'
linters:
AltText:
......
# frozen_string_literal: true
unless Rails.env.production?
require 'haml_lint/haml_visitor'
require 'haml_lint/linter'
require 'haml_lint/linter_registry'
module HamlLint
class Linter::InlineJavaScript < Linter
module HamlLint
class Linter
class InlineJavaScript < Linter
include ::HamlLint::LinterRegistry
MSG = 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)'
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)')
record_lint(node, MSG)
end
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)')
record_lint(node, MSG)
end
end
end
......
......@@ -2,7 +2,6 @@
unless Rails.env.production?
require 'haml_lint/rake_task'
require Rails.root.join('haml_lint/inline_javascript')
HamlLint::RakeTask.new
end
# frozen_string_literal: true
require 'spec_helper'
require 'fast_spec_helper'
require 'haml_lint'
require 'haml_lint/spec'
require Rails.root.join('haml_lint/linter/documentation_links')
require_relative '../../../haml_lint/linter/documentation_links'
RSpec.describe HamlLint::Linter::DocumentationLinks do
include_context 'linter'
......
# frozen_string_literal: true
require 'fast_spec_helper'
require 'haml_lint'
require 'haml_lint/spec'
require 'rspec-parameterized'
require_relative '../../../haml_lint/linter/inline_javascript'
RSpec.describe HamlLint::Linter::InlineJavaScript do # rubocop:disable RSpec/FilePath
using RSpec::Parameterized::TableSyntax
include_context 'linter'
let(:message) { described_class::MSG }
where(:haml, :should_report) do
'%script' | true
'%javascript' | false
':javascript' | true
':markdown' | false
end
with_them do
if params[:should_report]
it { is_expected.to report_lint message: message }
else
it { is_expected.not_to report_lint }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
require 'fast_spec_helper'
require 'haml_lint'
require 'haml_lint/spec'
require Rails.root.join('haml_lint/linter/no_plain_nodes')
require_relative '../../../haml_lint/linter/no_plain_nodes'
RSpec.describe HamlLint::Linter::NoPlainNodes do
include_context 'linter'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册