File: javascript-practices.rst

package info (click to toggle)
debusine 0.14.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,056 kB
  • sloc: python: 193,072; sh: 848; javascript: 335; makefile: 116
file content (58 lines) | stat: -rw-r--r-- 1,870 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
.. _javascript-practices:

====================
JavaScript practices
====================

While JavaScript is useful to make complex data entry and interaction tasks
easier, there is value in maintaining a functional plain HTML interface, and in
modern browsers, HTML plus CSS interfaces can go a long way.

When there is a UI task, like sorting a list, which would have a significantly
better UI with the help of JavaScript, we can do it via incremental
improvement, with a basic HTML interface that is hidden when JavaScript is
enabled, and replaced with a different scripted one.

Data submitted from data entry enhanced with JavaScript should match the form
data submitted with the HTML-only form inputs, so that server-side validation
and handling can be reused for both.

In those cases where a UI task is not at all possible without JavaScript, we
can make its support mandatory as long as the same goal can be otherwise
achieved using the ``debusine`` client command.


Target browsers
---------------

We target the main browsers shipped in Debian stable, and oldstable as long as
it's still officially supported by Debian.

As of September 2025, this means ``firefox-esr 115`` and ``chrome 135``.

We are therefore allowed to use:

* The full ECMAScript 2015 featureset
* CSS3, with the ``attr()`` function limited to the ``content`` property


Modules
-------

We use `JavaScript modules <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules>`
to structure our code. The ``web/_base.html`` base template defines an
``importmap`` that can be extended by other templates.



Linting and formatting
----------------------

We do not yet have infrastructure to lint and format JavaScript code.


Testing
-------

We do not yet have infrastructure to perform unit testing and functional
testing of JavaScript code, and we rely on manual testing.