From 6e3104e0b0a37ce7fd78790efcbab248a7bd5700 Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Fri, 16 Feb 2024 11:55:29 +0100 Subject: [PATCH] Technical/Add commit spellcheck linter * Added commit spellcheck linter, configuration * Updated lefthook config --- .../linter_configs/.commit_spellcheck.yml | 34 +++++++++++++++++++ .circleci/linter_configs/.lefthook.yml | 2 ++ .circleci/scripts/commit_spellcheck.sh | 22 ++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 .circleci/linter_configs/.commit_spellcheck.yml create mode 100755 .circleci/scripts/commit_spellcheck.sh diff --git a/.circleci/linter_configs/.commit_spellcheck.yml b/.circleci/linter_configs/.commit_spellcheck.yml new file mode 100644 index 0000000..0b06924 --- /dev/null +++ b/.circleci/linter_configs/.commit_spellcheck.yml @@ -0,0 +1,34 @@ +--- + +enableGlobDot: true + +patterns: + - name: GithubUser + pattern: /\[@.+\]/gmx + +languageSettings: + - languageId: markdown + ignoreRegExpList: + - Email + - GithubUser + +words: + - bestwebua + - codecov + - consts + - crtypto + - funcs + - golangci + - gomod + - gotestsum + - lefthook + - markdownlint + - multihomed + - punycode + - rubocop + - shellcheck + - shortcuting + - struct + - structs + - truemail + - yamlint diff --git a/.circleci/linter_configs/.lefthook.yml b/.circleci/linter_configs/.lefthook.yml index 6f978c3..e7e07c6 100644 --- a/.circleci/linter_configs/.lefthook.yml +++ b/.circleci/linter_configs/.lefthook.yml @@ -6,6 +6,8 @@ skip_output: linters: commands: + commit_spellcheck: + run: .circleci/scripts/commit_spellcheck.sh -c '.circleci/linter_configs/.commit_spellcheck.yml' cspell: run: cspell-cli lint -c '.circleci/linter_configs/.cspell.yml' '**/*.{txt,md}' golangci: diff --git a/.circleci/scripts/commit_spellcheck.sh b/.circleci/scripts/commit_spellcheck.sh new file mode 100755 index 0000000..d284cd0 --- /dev/null +++ b/.circleci/scripts/commit_spellcheck.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +configuration=$(if [ "$2" = "" ]; then echo "$2"; else echo " $1 $2"; fi) +latest_commit=$(git rev-parse HEAD) + +spellcheck_info() { + echo "Checking the spelling of the latest commit ($latest_commit) message..." +} + +compose_cspell_command() { + echo "cspell-cli lint stdin$configuration" +} + +cspell="$(compose_cspell_command)" + +spellcheck_latest_commit() { + git log -1 --pretty=%B | $cspell +} + +spellcheck_info +spellcheck_latest_commit