mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Add template linting via djlint (#25212)
So I found this [linter](https://github.com/Riverside-Healthcare/djlint) which features a mode for go templates, so I gave it a try and it did find a number of valid issue, like unbalanced tags etc. It also has a number of bugs, I had to disable/workaround many issues. Given that this linter is written in python, this does add a dependency on `python` >= 3.8 and `poetry` to the development environment to be able to run this linter locally. - `e.g.` prefixes on placeholders are removed because the linter had a false-positive on `placeholder="e.g. cn=Search"` for the `attr=value` syntax and it's not ideal anyways to write `e.g.` into a placeholder because a placeholder is meant to hold a sample value. - In `templates/repo/settings/options.tmpl` I simplified the logic to not conditionally create opening tags without closing tags because this stuff confuses the linter (and possibly the reader as well).
This commit is contained in:
parent
a0eaf08812
commit
e24f651c86
50 changed files with 520 additions and 171 deletions
|
@ -249,7 +249,7 @@
|
|||
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}}
|
||||
<span class="text grey muted-links">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{$.locale.Tr "repo.issues.start_tracking_history" $createdStr | Safe}}
|
||||
{{$.locale.Tr "repo.issues.start_tracking_history" $createdStr | Safe}}
|
||||
</span>
|
||||
</div>
|
||||
{{else if eq .Type 13}}
|
||||
|
@ -258,7 +258,7 @@
|
|||
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}}
|
||||
<span class="text grey muted-links">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{$.locale.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}}
|
||||
{{$.locale.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}}
|
||||
</span>
|
||||
{{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}}
|
||||
<div class="detail">
|
||||
|
@ -272,7 +272,7 @@
|
|||
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}}
|
||||
<span class="text grey muted-links">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{$.locale.Tr "repo.issues.add_time_history" $createdStr | Safe}}
|
||||
{{$.locale.Tr "repo.issues.add_time_history" $createdStr | Safe}}
|
||||
</span>
|
||||
{{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}}
|
||||
<div class="detail">
|
||||
|
@ -286,7 +286,7 @@
|
|||
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}}
|
||||
<span class="text grey muted-links">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{$.locale.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}}
|
||||
{{$.locale.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}}
|
||||
</span>
|
||||
</div>
|
||||
{{else if eq .Type 16}}
|
||||
|
@ -672,7 +672,7 @@
|
|||
<span class="text grey muted-links">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
|
||||
{{$.locale.Tr "repo.issues.del_time_history" $createdStr | Safe}}
|
||||
{{$.locale.Tr "repo.issues.del_time_history" $createdStr | Safe}}
|
||||
</span>
|
||||
<div class="detail">
|
||||
{{svg "octicon-clock"}}
|
||||
|
@ -719,7 +719,7 @@
|
|||
<span class="text grey muted-links">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{if .IsForcePush}}
|
||||
{{$.locale.Tr "repo.issues.force_push_codes" ($.Issue.PullRequest.HeadBranch|Escape) (ShortSha .OldCommit) (($.Issue.Repo.CommitLink .OldCommit)|Escape) (ShortSha .NewCommit) (($.Issue.Repo.CommitLink .NewCommit)|Escape) $createdStr | Safe}}
|
||||
{{$.locale.Tr "repo.issues.force_push_codes" ($.Issue.PullRequest.HeadBranch|Escape) (ShortSha .OldCommit) (($.Issue.Repo.CommitLink .OldCommit)|Escape) (ShortSha .NewCommit) (($.Issue.Repo.CommitLink .NewCommit)|Escape) $createdStr | Safe}}
|
||||
{{else}}
|
||||
{{$.locale.TrN (len .Commits) "repo.issues.push_commit_1" "repo.issues.push_commits_n" (len .Commits) $createdStr | Safe}}
|
||||
{{end}}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{{if (or .ctxData.IsAdmin (and .ctxData.IsSigned (eq .ctxData.SignedUserID .comment.PosterID)))}}
|
||||
<span class="ui float right">
|
||||
<div class="ui mini modal issue-delete-time-modal" data-id="{{.comment.Time.ID}}">
|
||||
<form method="POST" class="delete-time-form" action="{{.ctxData.RepoLink}}/issues/{{.ctxData.Issue.Index}}/times/{{.comment.TimeID}}/delete">
|
||||
<form method="post" class="delete-time-form" action="{{.ctxData.RepoLink}}/issues/{{.ctxData.Issue.Index}}/times/{{.comment.TimeID}}/delete">
|
||||
{{.ctxData.CsrfTokenHtml}}
|
||||
</form>
|
||||
<div class="header">{{.ctxData.locale.Tr "repo.issues.del_time"}}</div>
|
||||
|
|
|
@ -270,7 +270,7 @@
|
|||
<div class="ui watching">
|
||||
<span class="text"><strong>{{.locale.Tr "notification.notifications"}}</strong></span>
|
||||
<div class="gt-mt-3">
|
||||
<form method="POST" action="{{.Issue.Link}}/watch">
|
||||
<form method="post" action="{{.Issue.Link}}/watch">
|
||||
<input type="hidden" name="watch" value="{{if $.IssueWatch.IsWatching}}0{{else}}1{{end}}">
|
||||
{{$.CsrfTokenHtml}}
|
||||
<button class="fluid ui button">
|
||||
|
@ -292,13 +292,13 @@
|
|||
<div class="ui timetrack">
|
||||
<span class="text"><strong>{{.locale.Tr "repo.issues.tracker"}}</strong></span>
|
||||
<div class="gt-mt-3">
|
||||
<form method="POST" action="{{.Issue.Link}}/times/stopwatch/toggle" id="toggle_stopwatch_form">
|
||||
<form method="post" action="{{.Issue.Link}}/times/stopwatch/toggle" id="toggle_stopwatch_form">
|
||||
{{$.CsrfTokenHtml}}
|
||||
</form>
|
||||
<form method="POST" action="{{.Issue.Link}}/times/stopwatch/cancel" id="cancel_stopwatch_form">
|
||||
<form method="post" action="{{.Issue.Link}}/times/stopwatch/cancel" id="cancel_stopwatch_form">
|
||||
{{$.CsrfTokenHtml}}
|
||||
</form>
|
||||
{{if $.IsStopwatchRunning}}
|
||||
{{if $.IsStopwatchRunning}}
|
||||
<button class="ui fluid button issue-stop-time">{{.locale.Tr "repo.issues.stop_tracking"}}</button>
|
||||
<button class="ui fluid negative button issue-cancel-time gt-mt-3">{{.locale.Tr "repo.issues.cancel_tracking"}}</button>
|
||||
{{else}}
|
||||
|
@ -311,7 +311,7 @@
|
|||
<div class="ui mini modal issue-start-time-modal">
|
||||
<div class="header">{{.locale.Tr "repo.issues.add_time"}}</div>
|
||||
<div class="content">
|
||||
<form method="POST" id="add_time_manual_form" action="{{.Issue.Link}}/times/add" class="ui action input fluid">
|
||||
<form method="post" id="add_time_manual_form" action="{{.Issue.Link}}/times/add" class="ui action input fluid">
|
||||
{{$.CsrfTokenHtml}}
|
||||
<input placeholder='{{.locale.Tr "repo.issues.add_time_hours"}}' type="number" name="hours">
|
||||
<input placeholder='{{.locale.Tr "repo.issues.add_time_minutes"}}' type="number" name="minutes" class="ui compact">
|
||||
|
@ -330,7 +330,7 @@
|
|||
{{if gt (len .WorkingUsers) 0}}
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui comments">
|
||||
<span class="text"><strong>{{.locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}}</strong></span>
|
||||
<span class="text"><strong>{{.locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}}</strong></span>
|
||||
<div>
|
||||
{{range $user, $trackedtime := .WorkingUsers}}
|
||||
<div class="comment gt-mt-3">
|
||||
|
@ -498,7 +498,7 @@
|
|||
|
||||
{{if and .CanCreateIssueDependencies (not .Repository.IsArchived)}}
|
||||
<div>
|
||||
<form method="POST" action="{{.Issue.Link}}/dependency/add" id="addDependencyForm">
|
||||
<form method="post" action="{{.Issue.Link}}/dependency/add" id="addDependencyForm">
|
||||
{{$.CsrfTokenHtml}}
|
||||
<div class="ui fluid action input">
|
||||
<div class="ui search selection dropdown" id="new-dependency-drop-list" data-issue-id="{{.Issue.ID}}">
|
||||
|
@ -525,7 +525,7 @@
|
|||
{{.locale.Tr "repo.issues.dependency.remove_header"}}
|
||||
</div>
|
||||
<div class="content">
|
||||
<form method="POST" action="{{.Issue.Link}}/dependency/delete" id="removeDependencyForm">
|
||||
<form method="post" action="{{.Issue.Link}}/dependency/delete" id="removeDependencyForm">
|
||||
{{$.CsrfTokenHtml}}
|
||||
<input type="hidden" value="" name="removeDependencyID" id="removeDependencyID">
|
||||
<input type="hidden" value="" name="dependencyType" id="dependencyType">
|
||||
|
@ -556,7 +556,7 @@
|
|||
<div class="ui divider"></div>
|
||||
|
||||
{{if or .PinEnabled .Issue.IsPinned}}
|
||||
<form class="gt-mt-2" method="POST" {{if $.NewPinAllowed}}action="{{.Issue.Link}}/pin"{{else}}data-tooltip-content="{{.locale.Tr "repo.issues.max_pinned"}}"{{end}}>
|
||||
<form class="gt-mt-2" method="post" {{if $.NewPinAllowed}}action="{{.Issue.Link}}/pin"{{else}}data-tooltip-content="{{.locale.Tr "repo.issues.max_pinned"}}"{{end}}>
|
||||
{{$.CsrfTokenHtml}}
|
||||
<button class="fluid ui button {{if not $.NewPinAllowed}}disabled{{end}}">
|
||||
{{if not .Issue.IsPinned}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue