From 529061c9f0ed1fc86ac2bb3cc9a5d5129c933dfc Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Wed, 9 Oct 2024 12:14:11 +0000 Subject: [PATCH] build: add commitlint to pre-commit --- .commitlint.config.mjs | 17 ----------------- .devcontainer/Dockerfile | 4 ++++ .pre-commit-config.yaml | 5 +++++ commitlint.config.mjs | 6 ++++++ scripts/setup.sh | 3 +++ 5 files changed, 18 insertions(+), 17 deletions(-) delete mode 100644 .commitlint.config.mjs create mode 100644 commitlint.config.mjs diff --git a/.commitlint.config.mjs b/.commitlint.config.mjs deleted file mode 100644 index f2606949..00000000 --- a/.commitlint.config.mjs +++ /dev/null @@ -1,17 +0,0 @@ -import { RuleConfigSeverity } from "@commitlint/types"; - -const Configuration = { - /* - * Resolve and load @commitlint/config-conventional from node_modules. - * Referenced packages must be installed - */ - extends: ["@commitlint/config-conventional"], - /* - * Any rules defined here will override rules from @commitlint/config-conventional - */ - rules: { - "body-max-line-length": [RuleConfigSeverity.Error, "always", 300], - }, -}; - -export default Configuration; diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 720431a5..e714dec3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,9 @@ FROM mcr.microsoft.com/devcontainers/python:1-3.11 +# [Option] Install Node.js +ARG INSTALL_NODE="true" +ARG NODE_VERSION="lts/*" +RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi # Install Python dependencies from requirements COPY requirements*.txt /tmp/pip-tmp/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b340ae89..6ffdeb11 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,6 +32,11 @@ repos: hooks: - id: commitizen stages: [commit-msg] + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.18.0 + hooks: + - id: commitlint + stages: [commit-msg] - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 hooks: diff --git a/commitlint.config.mjs b/commitlint.config.mjs new file mode 100644 index 00000000..be77cf6e --- /dev/null +++ b/commitlint.config.mjs @@ -0,0 +1,6 @@ +export default { + extends: ["@commitlint/config-conventional"], + rules: { + "body-max-line-length": [2, "always", 300], + }, +}; diff --git a/scripts/setup.sh b/scripts/setup.sh index 43d671e4..d96b5b27 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -5,3 +5,6 @@ set -e pre-commit install +pre-commit install --hook-type commit-msg +cd +npm install @commitlint/config-conventional