Skip to content

Commit

Permalink
Improve HTML rules & add one more HTML test
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Dec 15, 2024
1 parent 201b802 commit a79c4bd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/eslint.test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ module.exports = [
},
{
// HTML linting (aside from erb_lint)
files: ["**/*.html", "**/*.html.erb"],
processor: plugin.processors["processorHtml"],
...html.configs["flat/recommended"],
files: ["**/*.html", "**/*.html.erb"],
plugins: {
"@html-eslint": html,
"@stylistic": stylistic,
},
rules: {
"@stylistic/eol-last": ["error", "always"],
"@stylistic/no-trailing-spaces": "error",
"@stylistic/no-multiple-empty-lines": ["error", { max: 1, maxEOF: 0 }],
...html.configs["flat/recommended"].rules,
// 🎈 Best Practices
"@html-eslint/no-extra-spacing-text": "error",
Expand Down
16 changes: 16 additions & 0 deletions tests/fixtures/if-else.expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="card-body scrollable">
<% if current_user.admin? %>
<div id="new-course-area" class="bg-green-lighten-4 p-3 mb-3 rounded" style="display: none;">
<%= render partial: 'courses/new',
locals: { course: Course.new } %>
</div>
<% end %>
<% if current_user.edited_courses.any? %>
<%= render partial: 'administration/index/courses_card',
locals: { courses:
current_user.edited_courses
.natural_sort_by(&:title) } %>
<% else %>
<%= t('admin.main.no_edited_courses') %>
<% end %>
</div>
18 changes: 18 additions & 0 deletions tests/fixtures/if-else.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="card-body scrollable">
<% if current_user.admin? %>
<div id="new-course-area"
class="bg-green-lighten-4 p-3 mb-3 rounded"
style="display: none;">
<%= render partial: 'courses/new',
locals: { course: Course.new } %>
</div>
<% end %>
<% if current_user.edited_courses.any? %>
<%= render partial: 'administration/index/courses_card',
locals: { courses:
current_user.edited_courses
.natural_sort_by(&:title) } %>
<% else %>
<%= t('admin.main.no_edited_courses') %>
<% end %>
</div>
2 changes: 2 additions & 0 deletions tests/fixtures/multiple-attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
data-id="<%= lecture.id %>">
<%= t("buttons.discard") %>
</button>


0 comments on commit a79c4bd

Please sign in to comment.