From 6fbb3b5130d84cf0c2fd7e835c978dee2892e52b Mon Sep 17 00:00:00 2001 From: Patrick Kollitsch Date: Fri, 21 Oct 2022 22:04:23 +0700 Subject: [PATCH] chore(config): update pre-commit configuration with commitlint setup --- .commitlintrc.js | 133 ++++++++++++++++++++-------------------- .pre-commit-config.yaml | 15 +++-- package.json | 5 -- 3 files changed, 79 insertions(+), 74 deletions(-) diff --git a/.commitlintrc.js b/.commitlintrc.js index 885945a4..0d4f3846 100644 --- a/.commitlintrc.js +++ b/.commitlintrc.js @@ -1,68 +1,71 @@ /** @type {import('cz-git').UserConfig} */ module.exports = { - rules: { - // @see: https://commitlint.js.org/#/reference-rules - }, - // https://cz-git.qbenben.com/guide/options-show.html - prompt: { - messages: { - type: "Select the type of change that you're committing:", - scope: "Denote the SCOPE of this change (optional):", - customScope: "Denote the SCOPE of this change:", - subject: "Write a SHORT, IMPERATIVE tense description of the change:\n", - body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n', - breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n', - footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):", - customFooterPrefixs: "Input ISSUES prefix:", - footer: "List any ISSUES by this change. E.g.: #31, #34:\n", - confirmCommit: "Are you sure you want to proceed with the commit above?" - }, - // https://github.com/sindresorhus/xterm-colors - themeColorCode: "38;5;160", - types: [ - { value: "feat", name: "feat: A new feature", emoji: ":sparkles:" }, - { value: "fix", name: "fix: A bug fix", emoji: ":bug:" }, - { value: "docs", name: "docs: Documentation only changes", emoji: ":memo:" }, - { value: "style", name: "style: Changes that do not affect the meaning of the code", emoji: ":lipstick:" }, - { value: "refactor", name: "refactor: A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" }, - { value: "perf", name: "perf: A code change that improves performance", emoji: ":zap:" }, - { value: "test", name: "test: Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" }, - { value: "build", name: "build: Changes that affect the build system or external dependencies", emoji: ":package:" }, - { value: "ci", name: "ci: Changes to our CI configuration files and scripts", emoji: ":ferris_wheel:" }, - { value: "chore", name: "chore: Other changes that don't modify src or test files", emoji: ":hammer:" }, - { value: "revert", name: "revert: Reverts a previous commit", emoji: ":rewind:" } - ], - useEmoji: false, - customScopesAlign: "bottom-top", - scopes: [], - allowCustomScopes: true, - allowEmptyScopes: true, - customScopesAlias: "custom", - emptyScopesAlias: "empty", - upperCaseSubject: false, - markBreakingChangeMode: true, - allowBreakingChanges: ['feat', 'fix'], - breaklineNumber: 100, - breaklineChar: "|", - skipQuestions: [], - issuePrefixs: [ - { value: "closed", name: "closed: ISSUE has been resolved" }, - { value: "see", name: "see: ISSUE is connected to this commit" } - ], - customIssuePrefixsAlign: "top", - emptyIssuePrefixsAlias: "skip", - customIssuePrefixsAlias: "custom", - allowCustomIssuePrefixs: true, - allowEmptyIssuePrefixs: true, - confirmColorize: true, - maxHeaderLength: Infinity, - maxSubjectLength: Infinity, - minSubjectLength: 0, - scopeOverrides: undefined, - defaultBody: "", - defaultIssues: "", - defaultScope: "", - defaultSubject: "", - // https://cz-git.qbenben.com/config/engineer.html - } + extends: [ + "@davidsneighbour/commitlint-config" + ], + rules: { + // @see: https://commitlint.js.org/#/reference-rules + }, + // https://cz-git.qbenben.com/guide/options-show.html + prompt: { + messages: { + type: "Select the type of change that you're committing:", + scope: "Denote the SCOPE of this change (optional):", + customScope: "Denote the SCOPE of this change:", + subject: "Write a SHORT, IMPERATIVE tense description of the change:\n", + body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n', + breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n', + footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):", + customFooterPrefixs: "Input ISSUES prefix:", + footer: "List any ISSUES by this change. E.g.: #31, #34:\n", + confirmCommit: "Are you sure you want to proceed with the commit above?" + }, + // https://github.com/sindresorhus/xterm-colors + themeColorCode: "38;5;160", + types: [ + { value: "feat", name: "feat: A new feature", emoji: ":sparkles:" }, + { value: "fix", name: "fix: A bug fix", emoji: ":bug:" }, + { value: "docs", name: "docs: Documentation only changes", emoji: ":memo:" }, + { value: "style", name: "style: Changes that do not affect the meaning of the code", emoji: ":lipstick:" }, + { value: "refactor", name: "refactor: A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" }, + { value: "perf", name: "perf: A code change that improves performance", emoji: ":zap:" }, + { value: "test", name: "test: Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" }, + { value: "build", name: "build: Changes that affect the build system or external dependencies", emoji: ":package:" }, + { value: "ci", name: "ci: Changes to our CI configuration files and scripts", emoji: ":ferris_wheel:" }, + { value: "chore", name: "chore: Other changes that don't modify src or test files", emoji: ":hammer:" }, + { value: "revert", name: "revert: Reverts a previous commit", emoji: ":rewind:" } + ], + useEmoji: false, + customScopesAlign: "bottom-top", + scopes: [], + allowCustomScopes: true, + allowEmptyScopes: true, + customScopesAlias: "custom", + emptyScopesAlias: "empty", + upperCaseSubject: false, + markBreakingChangeMode: true, + allowBreakingChanges: ['feat', 'fix'], + breaklineNumber: 100, + breaklineChar: "|", + skipQuestions: [], + issuePrefixs: [ + { value: "closed", name: "closed: ISSUE has been resolved" }, + { value: "see", name: "see: ISSUE is connected to this commit" } + ], + customIssuePrefixsAlign: "top", + emptyIssuePrefixsAlias: "skip", + customIssuePrefixsAlias: "custom", + allowCustomIssuePrefixs: true, + allowEmptyIssuePrefixs: true, + confirmColorize: true, + maxHeaderLength: Infinity, + maxSubjectLength: Infinity, + minSubjectLength: 0, + scopeOverrides: undefined, + defaultBody: "", + defaultIssues: "", + defaultScope: "", + defaultSubject: "", + // https://cz-git.qbenben.com/config/engineer.html + } } diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f71a09df..0065dae7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,15 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.1.0 + # install with `pre-commit install --hook-type commit-msg` + hooks: + - id: commitlint + stages: [commit-msg] + additional_dependencies: ['@davidsneighbour/commitlint-config'] - repo: 'https://github.com/pre-commit/pre-commit-hooks' - rev: v4.2.0 + rev: v4.3.0 hooks: - id: check-byte-order-marker #- forbids files which have a utf-8 byte-order marker. - id: check-case-conflict #- checks for files that would conflict in case-insensitive filesystems. @@ -46,14 +53,14 @@ repos: - id: blocklint - repo: 'https://github.com/adrienverge/yamllint' - rev: v1.26.3 + rev: v1.28.0 hooks: - id: yamllint args: [-c=tests/config/yamllint.yaml] exclude: ^(_vendor|.github/workflows|.pre-commit-config.yaml) - repo: 'https://github.com/jumanjihouse/pre-commit-hooks' - rev: 2.1.6 + rev: 3.0.0 hooks: - id: check-mailmap - id: script-must-have-extension @@ -66,7 +73,7 @@ repos: - id: shfmt - repo: 'https://github.com/zricethezav/gitleaks' - rev: v8.8.4 + rev: v8.15.0 hooks: - id: gitleaks diff --git a/package.json b/package.json index d442be0a..44a530e7 100644 --- a/package.json +++ b/package.json @@ -104,11 +104,6 @@ "not opera > 0", "not IE > 0" ], - "commitlint": { - "extends": [ - "@davidsneighbour/config/commitlint" - ] - }, "eslintConfig": { "extends": "@davidsneighbour/eslint-config" },