Skip to content

Commit 11ec086

Browse files
author
Mike
committed
[INFRA] Update pre-commit actions and config files
1 parent d0f22a8 commit 11ec086

File tree

11 files changed

+177
-179
lines changed

11 files changed

+177
-179
lines changed

.eslintrc

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,34 @@
77
"moment": false,
88
"odoo": false,
99
"openerp": false,
10-
"self": false
11-
},
12-
"env": {
13-
"browser": true
10+
"self": false,
11+
"odoo": "readonly",
12+
"$": "readonly",
13+
"jQuery": "readonly",
14+
"Chart": "readonly",
15+
"fuzzy": "readonly",
16+
"StackTrace": "readonly",
17+
"QUnit": "readonly",
18+
"luxon": "readonly",
19+
"py": "readonly",
20+
"FullCalendar": "readonly",
21+
"globalThis": "readonly",
22+
"ScrollSpy": "readonly",
23+
"module": "readonly",
24+
"chai": "readonly",
25+
"describe": "readonly",
26+
"it": "readonly",
27+
"mocha": "readonly",
28+
"DOMPurify": "readonly",
29+
"Alert": "readonly",
30+
"Collapse": "readonly",
31+
"Dropdown": "readonly",
32+
"Modal": "readonly",
33+
"Offcanvas": "readonly",
34+
"Popover": "readonly",
35+
"Tooltip": "readonly"
1436
},
37+
1538
"rules": {
1639
"no-alert": "warn",
1740
"no-array-constructor": "warn",
@@ -285,7 +308,13 @@
285308
"yield-star-spacing": "off",
286309
"yoda": "warn"
287310
},
288-
"parserOptions": {
289-
"ecmaVersion": 2017
290-
}
311+
312+
"env": {
313+
"browser": true,
314+
"es2022": true
315+
},
316+
"parserOptions": {
317+
"ecmaVersion": 2022,
318+
"sourceType": "module"
319+
},
291320
}

.eslintrc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ env:
44

55
# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449
66
parserOptions:
7-
ecmaVersion: 2019
7+
ecmaVersion: 2022
88

99
overrides:
1010
- files:
1111
- "**/*.esm.js"
12+
- "**/*.js"
1213
parserOptions:
1314
sourceType: module
1415

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Pre-Commit PR
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.11"
16+
- name: Get python version
17+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
18+
- uses: actions/cache@v4
19+
with:
20+
path: ~/.cache/pre-commit
21+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
22+
- name: Install pre-commit
23+
run: pip install pre-commit
24+
- name: Run pre-commit
25+
run: pre-commit run --all-files --show-diff-on-failure --color=always --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Pre-Commit Push
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.11"
16+
- name: Get python version
17+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
18+
- uses: actions/cache@v4
19+
with:
20+
path: ~/.cache/pre-commit
21+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
22+
- name: Install pre-commit
23+
run: pip install pre-commit
24+
- name: Run pre-commit
25+
run: pre-commit run --all-files --show-diff-on-failure --color=always

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
exclude: |
22
(?x)
3+
# Project Specific
4+
# OSI Template Specific
5+
^helm/|
6+
^odoo/legacy/|
7+
^odoo/src/paid-addons|
8+
^odoo/tests/|
9+
^odoo/src/patches|
10+
# Odoo source code
11+
^odoo/odoo/|
312
# NOT INSTALLABLE ADDONS
413
# END NOT INSTALLABLE ADDONS
514
# Files and folders generated by bots, to avoid loops
@@ -8,13 +17,13 @@ exclude: |
817
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
918
# Maybe reactivate this when all README files include prettier ignore tags?
1019
^README\.md$|
20+
^README\.rst$|
1121
# Library files can have extraneous formatting (even minimized)
1222
/static/(src/)?lib/|
1323
# Repos using Sphinx to generate docs don't need prettying
1424
^docs/_templates/.*\.html$|
1525
# You don't usually want a bot to modify your legal texts
16-
(LICENSE.*|COPYING.*)|
17-
helm/odoo/templates
26+
(LICENSE.*|COPYING.*)
1827
default_language_version:
1928
python: python3
2029
node: "16.17.0"
@@ -28,29 +37,35 @@ repos:
2837
entry: found forbidden files; remove them
2938
language: fail
3039
files: "\\.rej$"
40+
- id: en-po-files
41+
name: en.po files cannot exist
42+
entry: found a en.po file
43+
language: fail
44+
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
3145
- repo: https://github.com/oca/maintainer-tools
32-
rev: 451de41fa3e8aa81d077c804322d48632eb5ff74
46+
rev: 4cd2b852214dead80822e93e6749b16f2785b2fe
3347
hooks:
3448
# update the NOT INSTALLABLE ADDONS section above
3549
- id: oca-update-pre-commit-excluded-addons
3650
- id: oca-fix-manifest-website
3751
args: ["https://github.com/ursais/odoo-template"]
38-
- id: oca-gen-addon-readme
52+
- repo: https://github.com/myint/autoflake
53+
rev: v1.6.1
54+
hooks:
55+
- id: autoflake
3956
args:
40-
- --addons-dir=.
41-
- --branch=17.0
42-
- --org-name=ursais
43-
- --repo-name=odoo-template
44-
- --if-source-changed
45-
- --keep-source-digest
46-
- --convert-fragments-to-markdown
47-
- repo: https://github.com/OCA/odoo-pre-commit-hooks
48-
rev: v0.0.25
57+
- --expand-star-imports
58+
- --ignore-init-module-imports
59+
- --in-place
60+
- --remove-all-unused-imports
61+
- --remove-duplicate-keys
62+
- --remove-unused-variables
63+
- repo: https://github.com/psf/black
64+
rev: 22.8.0
4965
hooks:
50-
- id: oca-checks-odoo-module
51-
- id: oca-checks-po
66+
- id: black
5267
- repo: https://github.com/pre-commit/mirrors-prettier
53-
rev: v4.0.0-alpha.8
68+
rev: v2.7.1
5469
hooks:
5570
- id: prettier
5671
name: prettier (with plugin-xml)
@@ -61,15 +76,15 @@ repos:
6176
- --plugin=@prettier/plugin-xml
6277
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
6378
- repo: https://github.com/pre-commit/mirrors-eslint
64-
rev: v9.0.0-beta.1
79+
rev: v8.24.0
6580
hooks:
6681
- id: eslint
6782
verbose: true
6883
args:
6984
- --color
7085
- --fix
7186
- repo: https://github.com/pre-commit/pre-commit-hooks
72-
rev: v4.5.0
87+
rev: v4.3.0
7388
hooks:
7489
- id: trailing-whitespace
7590
# exclude autogenerated files
@@ -91,20 +106,30 @@ repos:
91106
- id: mixed-line-ending
92107
args: ["--fix=lf"]
93108
- repo: https://github.com/asottile/pyupgrade
94-
rev: v3.15.1
109+
rev: v2.38.2
95110
hooks:
96111
- id: pyupgrade
97112
args: ["--keep-percent-format"]
98113
- repo: https://github.com/PyCQA/isort
99-
rev: 5.13.2
114+
rev: 5.12.0
100115
hooks:
101116
- id: isort
102117
name: isort except __init__.py
103118
args:
104119
- --settings=.
105120
exclude: /__init__\.py$
121+
- repo: https://github.com/acsone/setuptools-odoo
122+
rev: 3.1.8
123+
hooks:
124+
- id: setuptools-odoo-make-default
125+
- repo: https://github.com/PyCQA/flake8
126+
rev: 3.9.2
127+
hooks:
128+
- id: flake8
129+
name: flake8
130+
additional_dependencies: ["flake8-bugbear==21.9.2"]
106131
- repo: https://github.com/OCA/pylint-odoo
107-
rev: v9.0.5
132+
rev: 7.0.2
108133
hooks:
109134
- id: pylint_odoo
110135
name: pylint with optional checks

.pylintrc

Lines changed: 20 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -13,106 +13,47 @@ valid-odoo-versions=17.0
1313
[MESSAGES CONTROL]
1414
disable=all
1515

16-
# This .pylintrc contains optional AND mandatory checks and is meant to be
17-
# loaded in an IDE to have it check everything, in the hope this will make
18-
# optional checks more visible to contributors who otherwise never look at a
19-
# green travis to see optional checks that failed.
16+
# This .pylintrc contains optional checks only
2017
# .pylintrc-mandatory containing only mandatory checks is used the pre-commit
2118
# config as a blocking check.
2219

23-
enable=anomalous-backslash-in-string,
24-
api-one-deprecated,
25-
api-one-multi-together,
26-
assignment-from-none,
27-
attribute-deprecated,
28-
class-camelcase,
29-
dangerous-default-value,
30-
dangerous-view-replace-wo-priority,
31-
development-status-allowed,
32-
duplicate-id-csv,
33-
duplicate-key,
34-
duplicate-xml-fields,
35-
duplicate-xml-record-id,
36-
eval-referenced,
37-
eval-used,
38-
incoherent-interpreter-exec-perm,
39-
license-allowed,
40-
manifest-author-string,
41-
manifest-deprecated-key,
42-
manifest-required-author,
43-
manifest-required-key,
44-
manifest-version-format,
45-
method-compute,
46-
method-inverse,
47-
method-required-super,
48-
method-search,
49-
openerp-exception-warning,
50-
pointless-statement,
51-
pointless-string-statement,
52-
print-used,
53-
redundant-keyword-arg,
54-
redundant-modulename-xml,
55-
reimported,
56-
relative-import,
57-
return-in-init,
58-
rst-syntax-error,
59-
sql-injection,
60-
too-few-format-args,
61-
translation-field,
62-
translation-required,
63-
unreachable,
64-
use-vim-comment,
65-
wrong-tabs-instead-of-spaces,
66-
xml-syntax-error,
67-
attribute-string-redundant,
20+
enable=api-one-deprecated,
6821
character-not-valid-in-resource-link,
22+
class-camelcase,
6923
consider-merging-classes-inherited,
70-
context-overridden,
7124
create-user-wo-reset-password,
7225
dangerous-filter-wo-user,
7326
dangerous-qweb-replace-wo-priority,
7427
deprecated-data-xml-node,
28+
deprecated-module,
7529
deprecated-openerp-xml-node,
76-
duplicate-po-message-definition,
77-
except-pass,
7830
file-not-used,
7931
invalid-commit,
32+
license-allowed,
33+
manifest-author-string,
34+
manifest-deprecated-key,
8035
manifest-maintainers-list,
81-
missing-newline-extrafiles,
82-
missing-readme,
83-
missing-return,
84-
odoo-addons-relative-import,
85-
old-api7-method-defined,
86-
po-msgstr-variables,
87-
po-syntax-error,
88-
renamed-field-parameter,
89-
resource-not-exist,
90-
str-format-used,
91-
test-folder-imported,
92-
translation-contains-variable,
93-
translation-positional-used,
94-
unnecessary-utf8-coding-comment,
95-
website-manifest-key-not-valid-uri,
96-
xml-attribute-translatable,
97-
xml-deprecated-qweb-directive,
98-
xml-deprecated-tree-attribute,
99-
external-request-timeout,
100-
# messages that do not cause the lint step to fail
101-
consider-merging-classes-inherited,
102-
create-user-wo-reset-password,
103-
dangerous-filter-wo-user,
104-
deprecated-module,
105-
file-not-used,
106-
invalid-commit,
36+
manifest-required-author,
37+
manifest-required-key,
38+
manifest-version-format,
10739
missing-manifest-dependency,
10840
missing-newline-extrafiles,
10941
missing-readme,
11042
no-utf8-coding-comment,
11143
odoo-addons-relative-import,
11244
old-api7-method-defined,
45+
pointless-statement,
46+
pointless-string-statement,
11347
redefined-builtin,
48+
rst-syntax-error,
11449
too-complex,
115-
unnecessary-utf8-coding-comment
50+
translation-field,
51+
translation-required,
52+
unnecessary-utf8-coding-comment,
53+
use-vim-comment,
54+
website-manifest-key-not-valid-uri,
55+
xml-deprecated-qweb-directive,
56+
xml-deprecated-tree-attribute
11657

11758

11859
[REPORTS]

0 commit comments

Comments
 (0)