Skip to content

Commit

Permalink
Fix nested forbidden engine not being detected (#173)
Browse files Browse the repository at this point in the history
Co-authored-by: Shane da Silva <shane@dasilva.io>
  • Loading branch information
jclusso and sds committed Apr 1, 2024
1 parent d165c9b commit cb9b8ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/slim_lint/linter/embedded_engines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Linter::EmbeddedEngines < Linter
dummy_node = Struct.new(:line)
document.source_lines.each_with_index do |line, index|
forbidden_engines.each do |forbidden_engine|
next unless line =~ /^#{forbidden_engine}.*:\s*$/
next unless line =~ /^\s*#{forbidden_engine}.*:\s*$/

report_lint(dummy_node.new(index + 1), MESSAGE % forbidden_engine)
end
Expand Down
23 changes: 23 additions & 0 deletions spec/slim_lint/linter/embedded_engines_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,27 @@
it { should report_lint line: 3 }
it { should report_lint line: 6 }
end

context 'when a file contains nested forbidden embedded engine' do
let(:config) do
{ 'forbidden_engines' => %w[javascript css] }
end

let(:slim) { <<-SLIM }
html
head
javascript:
alert('foo')
css:
h1 {
font-size: 10px;
}
body
h1 Test
SLIM

it { should report_lint line: 3 }
it { should report_lint line: 6 }
end
end

0 comments on commit cb9b8ef

Please sign in to comment.