Last active
October 11, 2021 05:40
-
-
Save unicornware/3cc464ed659f17a017ae519552da4e75 to your computer and use it in GitHub Desktop.
Commitlint Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { UserConfig } from '@commitlint/types' | |
| import workspaces from './tools/helpers/workspaces' | |
| /** | |
| * @file Commitlint Configuration | |
| * @see https://commitlint.js.org/#/guides-local-setup | |
| * @see https://commitlint.js.org/#/reference-configuration | |
| */ | |
| const config: UserConfig = { | |
| /** | |
| * Enable default ignore rules. | |
| */ | |
| defaultIgnores: true, | |
| /** | |
| * IDs of commitlint configurations to extend. | |
| */ | |
| extends: ['@commitlint/config-conventional'], | |
| /** | |
| * Name of formatter package. | |
| */ | |
| formatter: '@commitlint/format', | |
| /** | |
| * Functions that return true if commitlint should ignore the given message. | |
| */ | |
| ignores: [], | |
| /** | |
| * Rules to test commits against. | |
| * | |
| * @see https://commitlint.js.org/#/reference-rules | |
| */ | |
| rules: { | |
| /** | |
| * Scope casing. | |
| */ | |
| 'scope-case': [2, 'always', 'kebab-case'], | |
| /** | |
| * Commit scopes. | |
| */ | |
| 'scope-enum': [ | |
| 2, | |
| 'always', | |
| [ | |
| 'cjs', | |
| 'deploy', | |
| 'deps', | |
| 'deps-dev', | |
| 'deps-opt', | |
| 'deps-peer', | |
| 'esm', | |
| 'github', | |
| 'hybrid', | |
| 'release', | |
| 'scripts', | |
| 'tests', | |
| 'tools', | |
| 'typescript', | |
| 'workflows', | |
| 'yarn', | |
| ...workspaces() | |
| ] | |
| ], | |
| /** | |
| * Commit message subject casing. | |
| */ | |
| 'subject-case': [1, 'always', 'lower-case'], | |
| /** | |
| * Rules for valid commit types. | |
| */ | |
| 'type-enum': [ | |
| 2, | |
| 'always', | |
| [ | |
| 'build', | |
| 'chore', | |
| 'ci', | |
| 'docs', | |
| 'feat', | |
| 'fix', | |
| 'perf', | |
| 'refactor', | |
| 'revert', | |
| 'style', | |
| 'test' | |
| ] | |
| ] | |
| } | |
| } | |
| export default config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { lstatSync, readdirSync } from 'fs' | |
| import path from 'path' | |
| import { workspaces as GLOBS } from '../../package.json' | |
| /** | |
| * @file Helpers - Workspaces | |
| * @module tools/helpers/workspaces | |
| */ | |
| /** | |
| * Returns an array containing Yarn workspace directory names. | |
| * | |
| * @return {string[]} Array containing workspace directory names | |
| */ | |
| const workspaces = (): string[] => { | |
| return GLOBS.map(g => g.split('/')[0]).flatMap((proj: string): string[] => { | |
| // Get path to Yarn project directory | |
| const proj_path = path.resolve(process.env.PROJECT_CWD as string, proj) | |
| // Add subdirectories under Yarn project directory | |
| return readdirSync(proj_path).filter(workspace => { | |
| if (!lstatSync(path.resolve(proj_path, workspace)).isDirectory()) return | |
| return workspace | |
| }) | |
| }) | |
| } | |
| export default workspaces |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment