Skip to content

Commit

Permalink
fix: fail missing scope (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef authored Feb 12, 2025
1 parent c3bd8ee commit e187277
Showing 13 changed files with 64 additions and 64 deletions.
10 changes: 0 additions & 10 deletions .github/dependabot.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/hooks/pre-commit

This file was deleted.

25 changes: 7 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -3,29 +3,18 @@ on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build-lint:
name: Build and lint
build_test_lint:
name: Build, test, and lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Setup build cache
uses: actions/cache@v3
uses: actions/setup-node@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
node-version-file: package.json
- name: Install dependencies
run: npm ci
- name: Compile TypeScript
run: npm run compile
- name: Run linter
run: npm run lint
- name: Test
run: npm run test
7 changes: 4 additions & 3 deletions .github/workflows/pr-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Pull Request Linter
name: Pull Request Title Linter
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
jobs:
lint-pr:
pr_lint:
name: Lint pull request title
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Lint pull request title
uses: ./
with:
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ on:
branches:
- main
jobs:
build-tag-release:
build_tag_release:
name: Build, tag, and release
runs-on: ubuntu-latest
steps:
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -14,15 +14,16 @@ Live examples:
## Usage

```yaml
name: Pull Request Linter
name: Pull Request Title Linter
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
jobs:
lint-pr:
pr_lint:
name: Lint pull request title
runs-on: ubuntu-latest
permissions:
@@ -32,6 +33,7 @@ jobs:
uses: jef/conventional-commits-pr-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

```

## Inputs
20 changes: 18 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -15741,6 +15741,14 @@ const { isUint8Array, isArrayBuffer } = __nccwpck_require__(8253)
const { File: UndiciFile } = __nccwpck_require__(3041)
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(4322)

let random
try {
const crypto = __nccwpck_require__(7598)
random = (max) => crypto.randomInt(0, max)
} catch {
random = (max) => Math.floor(Math.random(max))
}

let ReadableStream = globalThis.ReadableStream

/** @type {globalThis['File']} */
@@ -15826,7 +15834,7 @@ function extractBody (object, keepalive = false) {
// Set source to a copy of the bytes held by object.
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
} else if (util.isFormDataLike(object)) {
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
const prefix = `--${boundary}\r\nContent-Disposition: form-data`

/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
@@ -30034,7 +30042,7 @@ function getConventionalCommitTypes() {
}
async function lintPullRequest(title) {
const matches = types.map(type => {
return new RegExp(`^${type}(\\(.*\\))?!?:.*$`);
return new RegExp(`^${type}(\\(.+\\))?!?:.+$`);
});
return matches.some(regex => regex.test(title));
}
@@ -30163,6 +30171,14 @@ module.exports = require("net");

/***/ }),

/***/ 7598:
/***/ ((module) => {

"use strict";
module.exports = require("node:crypto");

/***/ }),

/***/ 8474:
/***/ ((module) => {

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/** @type {import('ts-jest').JestConfigWithTsJest} **/
/** @type {import("ts-jest").JestConfigWithTsJest} **/
module.exports = {
collectCoverage: true,
testEnvironment: 'node',
transform: {
'^.+.tsx?$': ['ts-jest', {}],
},
testPathIgnorePatterns: ['<rootDir>/dist/'],
};
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
"clean": "gts clean",
"fix": "gts fix",
"lint": "gts lint",
"start": "node --experimental-loader=node:ts ./src/main.js",
"start": "node --experimental-loader=node:ts ./src/main.ts",
"test": "jest",
"posttest": "npm run lint"
},
@@ -28,15 +28,15 @@
},
"devDependencies": {
"@types/jest": "^29.5.14",
"@types/node": "^22.10.2",
"@types/node": "^22.13.1",
"@vercel/ncc": "^0.38.3",
"gts": "^6.0.2",
"jest": "^29.7.0",
"prettier": "^3.4.2",
"prettier": "^3.5.0",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
},
"volta": {
"node": "20.18.1"
"node": "20.18.3"
}
}
4 changes: 4 additions & 0 deletions src/__tests__/lint.test.ts
Original file line number Diff line number Diff line change
@@ -34,6 +34,10 @@ describe('lintPullRequest tests', () => {
{args: 'feats: test', expected: false},
{args: '(feat): test', expected: false},
{args: 'test', expected: false},
{args: 'feat(): test', expected: false},
{args: 'feat:', expected: false},
{args: 'feat():', expected: false},
{args: 'feat(test):', expected: false},
];

tests.forEach(({args, expected}) => {
2 changes: 1 addition & 1 deletion src/lint.ts
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ export function getConventionalCommitTypes(): string {

export async function lintPullRequest(title: string) {
const matches = types.map(type => {
return new RegExp(`^${type}(\\(.*\\))?!?:.*$`);
return new RegExp(`^${type}(\\(.+\\))?!?:.+$`);
});

return matches.some(regex => regex.test(title));

0 comments on commit e187277

Please sign in to comment.