Commit Graph
26 Commits
Author SHA1 Message Date
Samuel Degueldre 2add185ff5 [FIX] web: fix tooling not working in enterprise and autorefresh config
Previously, the pre-commit hook was modified to disallow commiting when
the config files were not up to date, the paths that were checked for
changes assumed that the hook was executed in the community repo which
breaks in enterprise and disallows commiting completely instead.

This commit fixes that, and also reloads or refreshes the tooling
automatically when it is not up to date before running prettier and
eslint instead of aborting the commit and asking the user to do it by
hand.

closes odoo/odoo#97404

Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-08-03 16:31:07 +02:00
Lucas Lefèvre 01e1b0fcc4 [IMP] web: add spreadsheet modules to web tooling
Enable automatic linting and formatting for spreadsheet modules.

`o_spreadsheet.js` lib file should not be checked since the file comes from
an external library (`o-spreadsheet`)

closes odoo/odoo#97393

Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-08-03 15:10:17 +02:00
Samuel Degueldre 1107e18234 [IMP] web: configure prefer-const eslint rule to be more lax
We recently added the prefer-const eslint rule, but the default
configuration of this rule disallows some things that we often do and
which we do not think are bad practice such as declaring a variable with
let so that it's available to a function defined below, but assign it
only once later, we also sometimes destructure variables with let where
some of the variables could be const but not all, in those cases we
accept that some variables will be mutable even though it's not strictly
necessary in favour of conciseness.

closes odoo/odoo#97384

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2022-08-03 15:10:04 +02:00
Lucas Perais f9434f6cf8 [FIX] web: tooling: refresh script executable.
Fixup b099b0cb35 where the new script was not made executable.

Part-of: odoo/odoo#97280
2022-08-03 06:34:11 +02:00
Dardenne Florent (dafl) 20369e46e1 [FIX] tooling,base_setup: fix whitelist syntax
closes odoo/odoo#97234

Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-08-02 15:49:50 +02:00
Dardenne Florent (dafl) 7b7ece114a [IMP] tooling,purchase: whitelist purchase module js
Part-of: odoo/odoo#97234
2022-08-02 15:49:50 +02:00
Samuel Degueldre b099b0cb35 [IMP] web: tooling: abort commit if tooling is outdated
Currently, if your tooling is not up to date, the pre-commit hook will
happily just format your code with the outdated config. This is
undesirable because the next person to touch the file with an up-to-date
config will introduce a bunch of linting noice in their commit.

This commit adds some basic checking by comparing the config files and
aborting the commit if they are out of date, and suggesting a refresh
when the eslint/prettier config files have changed or a full reload if
the package.json has changed.

closes odoo/odoo#97286

Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-08-02 11:49:17 +02:00
Samuel Degueldre 4d380f8753 [IMP] web: tooling: add a refresh script
This commit adds a refresh script which is a lightweight alternative to
the reload script in case the package.json hasn't changed but some
eslint/prettier files have been changed (new rules or ignored files).

Part-of: odoo/odoo#97286
2022-08-02 11:49:17 +02:00
Samuel Degueldre 4949829e20 [IMP] web: enable prefer-const and curly rules in eslint config
The prefer-const rule disallows using const on variables that are never
reassigned, this improves readability by allowing the reader to know in
advance that all variables that are declared with const are never
reassigned and all variables declared with let will eventually be
reassigned.

The curly rule disallows braceless if/else, for and while which is a
rule we have thus far been enforcing by hand.

Part-of: odoo/odoo#97286
2022-08-02 11:49:16 +02:00
Simon Genin (ges) 6ab02de109 [REF] base_setup: convert module to new js framework
convert res_config_dev_tool widget
convert res_config_edition widget
convert res_config_invite_users widget

closes odoo/odoo#96615

Related: odoo/enterprise#29804
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-07-28 08:10:45 +02:00
Géry Debongnie 3c782440ab [REF] board: rewrite board action in owl
This commit rewrites the board action in owl. Legacy actions are
still supported inside this new board thanks to a compatibility
layer.

Part-of: odoo/odoo#92475
2022-06-30 09:29:45 +02:00
Simon Genin (ges) c81c1ac6b1 [FIX] web: tooling -> cp -r doesn't copy symlink on macOS
closes odoo/odoo#94124

Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-06-21 11:20:26 +02:00
Pierre Rousseau aee53b0d48 [FIX] web: ensure realpath is installed
With this commit, if realpath is not available (for exemple on macos),
the script is directly stopped.

closes odoo/odoo#90522

X-original-commit: 7857c577948d55842a5697ca6d91bb6ea656ef6e
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
2022-05-04 19:17:45 +02:00
Pierre Rousseau 9e65c6a00b [FIX] web: fix tooling for enterprise repo
Since fcf2e2210a639adfcdb9236c24cfb31046b6dead, the path of enterprise
is derived from the tooling path instead of the community path.

X-original-commit: 4ff8f62aa1e10d27189ebbdd22a01711c700ea32
Part-of: odoo/odoo#90522
2022-05-04 19:17:44 +02:00
Samuel Degueldre 92497ed4f1 [FIX] web: fix tooling failing to run due to bash-specific syntax
In #86163 we added a check on the branch name to avoid running the
tooling on stable branches, however this check used bash-specific
syntax. While the hashbang in the pre-commit hook specifies that the
hook should be run using bash, we were using the npm module "husky" to
manage git hooks, which would ignore this hashbang and always run the
hook using sh, causing the hook to fail in all cases.

After some consideration, we have decided to stop using husky, as its
main purpose is to make hook management easier in npm-based projects.
Since we already need a script to enable the tooling, we can do
essentially the same thing that husky is doing but with more control
over the process with no drawbacks.

closes odoo/odoo#87436

X-original-commit: 3104ab16ecf88d4f7b1618db4d62e7f57df34e6c
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-03-29 12:00:11 +02:00
Jorge Pinna Puissant 42940aa6e9 [FIX] web: add the globals
On 19e775b3cc we added the same rules that
exists in test_lint on the tooling, but we didn't add the globals.

closes odoo/odoo#86649

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-03-18 13:18:34 +01:00
Samuel Degueldre 074b2c7be6 [FIX] web: run tooling only on branches starting with master
Previously, the tooling for web ran on all branches, this can cause
problems because it will automatically lint all files that have been
changed on commit, which can cause a lot of noise in the diff which is
undesirable in stable branches, as it makes forward ports more
difficult, among other things.

This commit adds a condition in the tooling so that it only runs on
branches whose name starts with master to fix this issue.

closes odoo/odoo#86200

X-original-commit: 5962b63f4ad1cfeccc0a80de2307300b50492668
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-03-11 08:44:37 +00:00
Samuel Degueldre 6d04d62117 [IMP] web: prevent committing files that will fail test_eslint
Currently, we lint and auto-format non-legacy files in web. The tool
that we use for this linting and formatting unfortunately does not
propagate any linting errors except for parsing errors. This means that
it's possible to commit files of which we know in advance that they will
break CI. This commit simply relints the files in a standalone manner
after they've been formatted, so that if there is a linting error, the
commit will be aborted.

It is still possible to commit non-conforming code (eg to save work in
progress before switching branches) by committing with the --no-verify
git flag

closes odoo/odoo#85727

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-03-03 10:07:49 +00:00
Jorge Pinna Puissant cac3ba62e5 [IMP] test_lint, *: add caughtErrors option to no-unused-vars
All named arguments on the catch block must be used. If for some motive
the named argument on the catch block is not used, its name must begin
with '_'.

closes odoo/odoo#85569

Related: odoo/enterprise#24867
Related: odoo/design-themes#552
Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-03-02 13:05:42 +00:00
Jorge Pinna Puissant bc20eb4790 [IMP] test_lint, *: enable no-unused-vars rule
Part-of: odoo/odoo#85569
2022-03-02 13:05:42 +00:00
Jorge Pinna Puissant 19e775b3cc [IMP] web: add the new test_lint eslint rules to the tooling
Part-of: odoo/odoo#85569
2022-03-02 13:05:42 +00:00
Julien Mougenot db63ff2259 [REF] web: Owl imports adaptation
In the next version of Owl, all exported terms are directly available
from the top level `owl` object. This commit aims to adapt existing
imports to this new system. This is done by importing any Owl property
used in files at the top, right after the `import` or `require`
statements.

closes odoo/odoo#82736

Related: odoo/enterprise#23609
Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-01-20 11:03:01 +00:00
Michael (mcm) 5fef288cdb [IMP] web: tooling: whitelist web_map
Part-of: odoo/odoo#76472
2021-11-02 10:45:15 +00:00
Lucas Perais (lpe) 2a784b7c88 [IMP] web: tooling: whitelist web_dashboard and web_cohort
Enable tooling (eslint, prettier) for new converted modules
web_dashboard and web_cohort

Part-of: odoo/odoo#73311
2021-09-07 10:04:39 +00:00
Simon Genin (ges) 9583c74e5f [FIX] web: make js tooling safe with paths with spaces
If $basepath in the tooling contained spaces, it could have dramatic
consequences on the rm -rf command.
We simply escape everything to avoid the problem.

closes odoo/odoo#73222

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-07-05 13:07:48 +00:00
Simon Genin (ges) 8d57a5cde9 [ADD] web: prettier and eslint tooling
Provide an opt in js tooling system by adding a node env with prettier and eslint configured.
3 bash scripts are provided: enable.sh, disable.sh and reload.sh.

Enable.sh: add to the community root (and optionaly to the enterprise root) the env.
Disable.sh: remove the env.
Reload.sh: disable then enable.
2021-06-18 21:31:27 +02:00