From f4a073d3d5362795ae112429bfa009f40267b7d8 Mon Sep 17 00:00:00 2001 From: Alexander Nickel Date: Tue, 9 Mar 2021 17:16:48 +0100 Subject: [PATCH] feat: Add config, workflows, tools and README Release-As: 1.0.0 [FBTLOPS-159] --- .github/workflows | 1 + .gitignore | 1 + Makefile | 6 ++++++ README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++ index.js | 36 +++++++++++++++++++++++++++++++ package.json | 9 ++++++++ yarn.lock | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 160 insertions(+) create mode 160000 .github/workflows create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 index.js create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.github/workflows b/.github/workflows new file mode 160000 index 0000000..0fd09eb --- /dev/null +++ b/.github/workflows @@ -0,0 +1 @@ +Subproject commit 0fd09eb0ecb1d6b3ab1830a0b61188d8a10fdb4a diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c2636af --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +.DEFAULT_GOAL := lint +GITHUB_BASE_REF ?= master + +.PHONY: lint +lint: + commitlint -g index.js --from=$$(git rev-parse remotes/origin/$(GITHUB_BASE_REF)) diff --git a/README.md b/README.md new file mode 100644 index 0000000..8abf8f9 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# Config Commitlint + +Commitlint configuration used at flagbit + +## How can I use this in my project? + +Create a new file named `commitlint.config.js` in your projects root directory, +including this content: + +```javascript +module.exports = { + extends: ["@flagbit/config-commitlint"], + parserPreset: { + parserOpts: { + issuePrefixes: ["FBTLOPS-"], + }, + }, +}; +``` + +...add (or extend an existing) Makefile to include a `lint` target: + +```makefile +.DEFAULT_GOAL := lint +GITHUB_BASE_REF ?= master + +.PHONY: lint +lint: + commitlint -g index.js --from=$$(git rev-parse remotes/origin/$(GITHUB_BASE_REF)) +``` + +...and finally add a github-workflow to your project by placing a file named +`commitlint.yml` to the `.github/workflows/`-directory in your project. If this +directory is not existing, then you can simply create it. The `commitlint.yml` +needs to include this content: + +```yml +name: commitlint +on: pull_request + +jobs: + commitlint: + name: Lint Commit Messages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - run: | + yarn global add @commitlint/cli @flagbit/config-commitlint + echo "$(yarn global bin)" >> $GITHUB_PATH + - run: make lint +``` diff --git a/index.js b/index.js new file mode 100644 index 0000000..a2da839 --- /dev/null +++ b/index.js @@ -0,0 +1,36 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'body-case': [2, 'always', 'sentence-case'], + 'body-leading-blank': [2, 'always'], + 'body-max-line-length': [2, 'always', 72], + 'footer-leading-blank': [2, 'always'], + 'footer-max-line-length': [2, 'always', 72], + 'header-max-length': [2, 'always', 72], + 'header-min-length': [2, 'always', 30], + 'references-empty': [2, 'never'], + 'scope-case': [2, 'always', 'lower-case'], + 'subject-case': [2, 'always', 'sentence-case'], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], + 'type-enum': [ + 2, + 'always', + [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test', + ], + ], + }, +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..78a3bab --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "@flagbit/config-commitlint", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "dependencies": { + "@commitlint/config-conventional": "^12.0.1" + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..6f225ee --- /dev/null +++ b/yarn.lock @@ -0,0 +1,54 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@commitlint/config-conventional@^12.0.1": + version "12.0.1" + resolved "https://registry.yarnpkg.com/@commitlint/config-conventional/-/config-conventional-12.0.1.tgz#7bf3bbf68bda967c5165135ebe8f2055decf1a83" + integrity sha512-1ZhB135lh47zVmf1orwcjxuKuam11fJIH/bdVxW9XiQv8XPwC6iIp19knfl8FcOT78AVBnes1z6EVxgUeP2/4Q== + dependencies: + conventional-changelog-conventionalcommits "^4.3.1" + +array-ify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" + integrity sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4= + +compare-func@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-2.0.0.tgz#fb65e75edbddfd2e568554e8b5b05fff7a51fcb3" + integrity sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA== + dependencies: + array-ify "^1.0.0" + dot-prop "^5.1.0" + +conventional-changelog-conventionalcommits@^4.3.1: + version "4.5.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.5.0.tgz#a02e0b06d11d342fdc0f00c91d78265ed0bc0a62" + integrity sha512-buge9xDvjjOxJlyxUnar/+6i/aVEVGA7EEh4OafBCXPlLUQPGbRUBhBUveWRxzvR8TEjhKEP4BdepnpG2FSZXw== + dependencies: + compare-func "^2.0.0" + lodash "^4.17.15" + q "^1.5.1" + +dot-prop@^5.1.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.3.0.tgz#90ccce708cd9cd82cc4dc8c3ddd9abdd55b20e88" + integrity sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q== + dependencies: + is-obj "^2.0.0" + +is-obj@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982" + integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w== + +lodash@^4.17.15: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + +q@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" + integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=