Skip to content

Commit de2d6d3

Browse files
dannycolinflodolo
andauthored
Add prettier-plugin-jinja-template (#3959)
Signed-off-by: Danny Colin <contact@dannycolin.com> Co-authored-by: Francesco Lodolo <flod@lodolo.net>
1 parent 76f1c64 commit de2d6d3

114 files changed

Lines changed: 5682 additions & 4044 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/js-lint.yml‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
name: JavaScript linting
1+
name: JavaScript and Jinja linting
22

33
on:
44
push:
55
branches:
66
- main
77
paths:
8+
- '**.jinja'
89
- '**.js'
10+
- '**.html'
911
- '**.ts'
1012
- '**.tsx'
1113
- '**.css'
@@ -17,7 +19,9 @@ on:
1719
branches:
1820
- main
1921
paths:
22+
- '**.jinja'
2023
- '**.js'
24+
- '**.html'
2125
- '**.ts'
2226
- '**.tsx'
2327
- '**.css'
@@ -32,8 +36,8 @@ jobs:
3236
name: eslint
3337
runs-on: ubuntu-latest
3438
steps:
35-
- uses: actions/checkout@v5
36-
- uses: actions/setup-node@v5
39+
- uses: actions/checkout@v6
40+
- uses: actions/setup-node@v6
3741
with: { node-version: '22' }
3842
- name: Install dependencies
3943
run: npm ci
@@ -44,8 +48,8 @@ jobs:
4448
name: prettier
4549
runs-on: ubuntu-latest
4650
steps:
47-
- uses: actions/checkout@v5
48-
- uses: actions/setup-node@v5
51+
- uses: actions/checkout@v6
52+
- uses: actions/setup-node@v6
4953
with: { node-version: '22' }
5054
- name: Install dependencies
5155
run: npm ci

‎.prettierignore‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ venv/
1111
/media/
1212
/static/
1313

14-
# Jinja templates
15-
translate/public/translate.html
16-
**/templates/**/*.html
17-
1814
# Vendored code
1915
pontoon/base/static/css/boilerplate.css
2016
pontoon/base/static/css/fontawesome-all.css

‎package-lock.json‎

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
"globals": "^15.9.0",
7979
"identity-obj-proxy": "^3.0.0",
8080
"jsdom": "^27.4.0",
81-
"prettier": "^3.3.3",
81+
"prettier": "^3.8.1",
82+
"prettier-plugin-jinja-template": "^2.1.0",
8283
"react-intersection-observer": "9.11.0",
8384
"rollup": "^3.29.5",
8485
"rollup-plugin-css-only": "^4.3.0",
@@ -91,7 +92,21 @@
9192
"trailingComma": "all",
9293
"tabWidth": 2,
9394
"jsxSingleQuote": true,
94-
"singleQuote": true
95+
"singleQuote": true,
96+
"plugins": [
97+
"prettier-plugin-jinja-template"
98+
],
99+
"overrides": [
100+
{
101+
"files": [
102+
"**/*.html",
103+
"**/*.jinja"
104+
],
105+
"options": {
106+
"parser": "jinja-template"
107+
}
108+
}
109+
]
95110
},
96111
"engines": {
97112
"npm": ">= 7"

‎pontoon/administration/templates/admin.html‎

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,41 @@
2323
{% endblock %}
2424

2525
{% block bottom %}
26-
<section id="main" class="clearfix">
27-
<div class="container">
28-
<menu class="controls">
29-
<div class="search-wrapper big clearfix">
30-
<div class="icon fas fa-search"></div>
31-
<input class="table-filter" type="search" autocomplete="off" autofocus placeholder="Filter projects">
26+
<section id="main" class="clearfix">
27+
<div class="container">
28+
<menu class="controls">
29+
<div class="search-wrapper big clearfix">
30+
<div class="icon fas fa-search"></div>
31+
<input
32+
class="table-filter"
33+
type="search"
34+
autocomplete="off"
35+
autofocus
36+
placeholder="Filter projects"
37+
/>
38+
</div>
39+
<a
40+
class="add button small"
41+
href="{{ url('pontoon.admin.project.new') }}"
42+
>Add new project</a
43+
>
44+
<button
45+
class="button small request-toggle"
46+
id="toggle-projects"
47+
data-show-disabled="false"
48+
>
49+
<span class="fas fa-chevron-right"></span>
50+
</button>
51+
</menu>
52+
53+
<div class="project-list enabled-projects">
54+
{{ render_project_list(enabled_projects, project_stats) }}
55+
</div>
56+
<div class="project-list disabled-projects">
57+
{{ render_project_list(disabled_projects, project_stats) }}
3258
</div>
33-
<a class="add button small" href="{{ url('pontoon.admin.project.new') }}">Add new project</a>
34-
<button class="button small request-toggle"
35-
id="toggle-projects"
36-
data-show-disabled="false">
37-
<span class="fas fa-chevron-right"></span>
38-
</button>
39-
</menu>
40-
41-
<div class="project-list enabled-projects">
42-
{{ render_project_list(enabled_projects, project_stats) }}
43-
</div>
44-
<div class="project-list disabled-projects">
45-
{{ render_project_list(disabled_projects, project_stats) }}
4659
</div>
47-
</div>
48-
</section>
60+
</section>
4961
{% endblock %}
5062

5163
{% block extend_css %}
Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
11
{% macro render(title, type, formset) %}
2-
<h4>
2+
<h4>
33
<span>{{ title }}</span>
44
<a href="#" class="add-inline" data-type="{{ type }}">Add more</a>
5-
</h4>
5+
</h4>
66

7-
{{ formset.management_form }}
8-
{% for form in formset %}
7+
{{ formset.management_form }}
8+
{% for form in formset %}
99
{{ form.id }}
1010
<div class="{{ type }} inline controls clearfix">
11-
{{ form.name.label_tag(label_suffix='') }}
12-
{{ form.url.label_tag(label_suffix='') }}
13-
<span class="arrow">{{ form.name }}</span>
14-
{{ form.url }}
15-
<button title="Delete" class="button delete-inline far fa-trash-alt" tabindex="-1"></button>
16-
{{ form.DELETE }}
17-
{{ form.name.errors }}
18-
{{ form.url.errors }}
11+
{{ form.name.label_tag(label_suffix='') }}
12+
{{ form.url.label_tag(label_suffix='') }}
13+
<span class="arrow">{{ form.name }}</span>
14+
{{ form.url }}
15+
<button
16+
title="Delete"
17+
class="button delete-inline far fa-trash-alt"
18+
tabindex="-1"
19+
></button>
20+
{{ form.DELETE }}
21+
{{ form.name.errors }}
22+
{{ form.url.errors }}
1923
</div>
20-
{% endfor %}
24+
{% endfor %}
2125

22-
<div class="{{ type }} inline controls clearfix" data-count="{{ formset.total_form_count() }}">
26+
<div
27+
class="{{ type }} inline controls clearfix"
28+
data-count="{{ formset.total_form_count() }}"
29+
>
2330
{{ formset.empty_form.name.label_tag(label_suffix='') }}
2431
{{ formset.empty_form.url.label_tag(label_suffix='') }}
2532
<span class="arrow">{{ formset.empty_form.name }}</span>
2633
{{ formset.empty_form.url }}
27-
<button title="Delete" class="button delete-inline far fa-trash-alt" tabindex="-1"></button>
34+
<button
35+
title="Delete"
36+
class="button delete-inline far fa-trash-alt"
37+
tabindex="-1"
38+
></button>
2839
{{ formset.empty_form.DELETE }}
2940
{{ formset.empty_form.name.errors }}
3041
{{ formset.empty_form.url.errors }}
31-
</div>
42+
</div>
3243
{% endmacro %}

0 commit comments

Comments
 (0)