From b0eea7f59d6fa4b7a068937778d76a8913e32648 Mon Sep 17 00:00:00 2001 From: Elizabeth Mitchell Date: Thu, 14 Dec 2023 15:01:40 -0800 Subject: [PATCH] chore: add commitlint config for scopes PiperOrigin-RevId: 591061701 --- .github/workflows/commitlint.yml | 6 +++-- .gitignore | 3 ++- commitlint.config.js | 45 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 commitlint.config.js diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 6d2235790b..dd04345460 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -7,11 +7,13 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 18 + cache: npm - - run: npm install -g commitlint @commitlint/config-conventional - - run: 'echo "${PR_TITLE}" | commitlint -x @commitlint/config-conventional' + - run: npm install -g @commitlint/cli @commitlint/config-conventional + - run: 'echo "${PR_TITLE}" | commitlint' env: PR_TITLE: ${{ github.event.pull_request.title }} diff --git a/.gitignore b/.gitignore index 5def5f48b3..55bd5c7ebc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules *.js !web-test-runner.config.js !css-to-ts.js +!commitlint.config.js *.css *.css.ts *.map @@ -25,4 +26,4 @@ catalog/site/about/images catalog/*.tsbuildinfo catalog/stories/*/ !catalog/stories/components/ -!catalog/src/types/**/*.d.ts \ No newline at end of file +!catalog/src/types/**/*.d.ts diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000000..d8f7a5b9ce --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,45 @@ +/** + * @license + * Copyright 2023 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +export default { + extends: ['@commitlint/config-conventional'], + rules: { + 'scope-enum': [ + 2, + 'always', + [ + // Use "/" for multiple scopes: `fix(button/checkbox): subject"` + // Omit scope for broad "all" changes. + 'button', + 'catalog', + 'checkbox', + 'chips', + 'color', + 'dialog', + 'divider', + 'elevation', + 'fab', + 'field', + 'focus', + 'icon', + 'iconbutton', + 'labs', + 'list', + 'menu', + 'progress', + 'radio', + 'ripple', + 'select', + 'slider', + 'switch', + 'tabs', + 'textfield', + 'tokens', + 'typography', + ], + ], + }, +};