Skip to content

Commit

Permalink
chore(repo): Update commitlint and use globby (#3411)
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed May 21, 2024
1 parent 29bf434 commit 80a93ee
Show file tree
Hide file tree
Showing 5 changed files with 694 additions and 557 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ packages/*/examples
.yalc
package-lock.json
**/integration/templates/**/*
commitlint.config.ts
10 changes: 8 additions & 2 deletions .github/workflows/pr-title-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup
id: config
uses: ./.github/actions/init
with:
fetch-depth: 0
show-progress: false
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
turbo-team: ${{ vars.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
playwright-enabled: true # Must be present to enable caching on branched workflows

- name: Lint Pull Request Title
run: echo "${{ github.event.pull_request.title }}" | npx commitlint
16 changes: 7 additions & 9 deletions commitlint.config.js → commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
/* eslint-env es2021 */
const glob = require('glob');
const fs = require('fs');
import { globbySync } from 'globby';
import { readFileSync } from 'node:fs';

const getPackageNames = () => {
const files = glob.sync('./packages/*/package.json');
const names = files.map(f => JSON.parse(fs.readFileSync(f, 'utf8')).name);
const files = globbySync('./packages/*/package.json');
const names = files.map(f => JSON.parse(readFileSync(f, 'utf8')).name as string);
return names.map(n => n.split('/').pop());
};

/**
* @type {import('@commitlint/types').UserConfig}
*/
module.exports = {
const Configuration = {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-case': [2, 'always', ['sentence-case']],
Expand All @@ -20,3 +16,5 @@ module.exports = {
'scope-enum': [2, 'always', [...getPackageNames(), 'repo', 'release', 'e2e', '*']],
},
};

export default Configuration;
Loading

0 comments on commit 80a93ee

Please sign in to comment.