From 046aab04631f66119385926ebf6bce9756725b29 Mon Sep 17 00:00:00 2001 From: Pablo Esteban Date: Tue, 8 Oct 2024 13:18:07 +0200 Subject: [PATCH] [IMP] pre-commmit: Run prettier and eslint as local hooks and update versions in v18 --- .prettierrc.yml | 2 +- src/.pre-commit-config.yaml.jinja | 32 +++++++++++-------- ...version < 18 %}.prettierrc.yml{% endif %}} | 0 ...version >= 18 %}.prettierrc.cjs{% endif %} | 12 +++++++ 4 files changed, 32 insertions(+), 14 deletions(-) rename src/{{% if odoo_version > 12 %}.prettierrc.yml{% endif %} => {% if 12 < odoo_version < 18 %}.prettierrc.yml{% endif %}} (100%) create mode 100644 src/{% if odoo_version >= 18 %}.prettierrc.cjs{% endif %} diff --git a/.prettierrc.yml b/.prettierrc.yml index 5094c31..49faf19 120000 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -1 +1 @@ -./src/{% if odoo_version > 12 %}.prettierrc.yml{% endif %} \ No newline at end of file +src/{% if 12 < odoo_version < 18 %}.prettierrc.yml{% endif %} \ No newline at end of file diff --git a/src/.pre-commit-config.yaml.jinja b/src/.pre-commit-config.yaml.jinja index 0ec619c..66a33d6 100644 --- a/src/.pre-commit-config.yaml.jinja +++ b/src/.pre-commit-config.yaml.jinja @@ -5,7 +5,7 @@ {%- if odoo_version < 15 %} {%- set repo_rev.autoflake = "v1.4" %} {%- set repo_rev.black = "22.3.0" %} - {%- set repo_rev.eslint = "v7.8.1" %} + {%- set repo_rev.eslint = "7.8.1" %} {%- set repo_rev.flake8 = "3.8.3" %} {%- set repo_rev.flake8_bugbear = "20.1.4" %} {%- set repo_rev.isort = "5.12.0" %} @@ -23,7 +23,7 @@ {%- elif odoo_version < 16 %} {%- set repo_rev.autoflake = "v1.4" %} {%- set repo_rev.black = "22.3.0" %} - {%- set repo_rev.eslint = "v7.32.0" %} + {%- set repo_rev.eslint = "7.32.0" %} {%- set repo_rev.flake8 = "3.9.2" %} {%- set repo_rev.flake8_bugbear = "21.9.2" %} {%- set repo_rev.isort = "5.12.0" %} @@ -41,7 +41,7 @@ {%- elif odoo_version < 18 %} {%- set repo_rev.autoflake = "v1.6.1" %} {%- set repo_rev.black = "22.8.0" %} - {%- set repo_rev.eslint = "v8.24.0" %} + {%- set repo_rev.eslint = "8.24.0" %} {%- set repo_rev.flake8 = "3.9.2" %} {%- set repo_rev.flake8_bugbear = "21.9.2" %} {%- set repo_rev.isort = "5.12.0" %} @@ -58,7 +58,7 @@ {%- else %} {%- set repo_rev.autoflake = "v1.6.1" %} {%- set repo_rev.black = "22.8.0" %} - {%- set repo_rev.eslint = "v8.24.0" %} + {%- set repo_rev.eslint = "9.12.0" %} {%- set repo_rev.flake8 = "3.9.2" %} {%- set repo_rev.flake8_bugbear = "21.9.2" %} {%- set repo_rev.isort = "5.12.0" %} @@ -66,8 +66,8 @@ {%- set repo_rev.nodejs = "16.17.0" %} {%- set repo_rev.odoo_pre_commit_hooks = "v0.0.33" %} {%- set repo_rev.pre_commit_hooks = "v4.6.0" %} - {%- set repo_rev.prettier = "2.7.1" %} - {%- set repo_rev.prettier_xml = "2.2.0" %} + {%- set repo_rev.prettier = "3.3.3" %} + {%- set repo_rev.prettier_xml = "3.4.1" %} {%- set repo_rev.pylint_odoo = "v9.1.2" %} {%- set repo_rev.pyupgrade = "v2.38.2" %} {%- set repo_rev.ruff = "v0.6.8" %} @@ -178,25 +178,31 @@ repos: hooks: - id: black {%- endif %} - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v{{ repo_rev.prettier }} + - repo: local hooks: - id: prettier name: prettier (with plugin-xml) - additional_dependencies: - - "prettier@{{ repo_rev.prettier }}" - - "@prettier/plugin-xml@{{ repo_rev.prettier_xml }}" + entry: prettier --write --list-different --ignore-unknown + language: node + types: [text] args: - --plugin=@prettier/plugin-xml files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ - - repo: https://github.com/pre-commit/mirrors-eslint - rev: {{ repo_rev.eslint }} + additional_dependencies: + - "prettier@{{ repo_rev.prettier }}" + - "@prettier/plugin-xml@{{ repo_rev.prettier_xml }}" + - repo: local hooks: - id: eslint + name: eslint + entry: eslint + language: node + types: [javascript] verbose: true args: - --color - --fix + additional_dependencies: ["eslint@{{ repo_rev.eslint }}"] - repo: https://github.com/pre-commit/pre-commit-hooks rev: {{ repo_rev.pre_commit_hooks }} hooks: diff --git a/src/{% if odoo_version > 12 %}.prettierrc.yml{% endif %} b/src/{% if 12 < odoo_version < 18 %}.prettierrc.yml{% endif %} similarity index 100% rename from src/{% if odoo_version > 12 %}.prettierrc.yml{% endif %} rename to src/{% if 12 < odoo_version < 18 %}.prettierrc.yml{% endif %} diff --git a/src/{% if odoo_version >= 18 %}.prettierrc.cjs{% endif %} b/src/{% if odoo_version >= 18 %}.prettierrc.cjs{% endif %} new file mode 100644 index 0000000..a90fa9c --- /dev/null +++ b/src/{% if odoo_version >= 18 %}.prettierrc.cjs{% endif %} @@ -0,0 +1,12 @@ +/** @type {import('prettier').Config} */ +const config = { + plugins: [require.resolve("@prettier/plugin-xml")], + bracketSpacing: false, + printWidth: 88, + proseWrap: "always", + semi: true, + trailingComma: "es5", + xmlWhitespaceSensitivity: "preserve", +}; + +module.exports = config;