Skip to content

Commit

Permalink
feat: lint pr head, base and add optional url
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed Mar 14, 2021
1 parent 9482131 commit fac951c
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 77 deletions.
83 changes: 60 additions & 23 deletions dist/index-node12-dev.cjs.js

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

2 changes: 1 addition & 1 deletion dist/index-node12-dev.cjs.js.map

Large diffs are not rendered by default.

83 changes: 60 additions & 23 deletions dist/index-node12.cjs.js

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

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/accountConfigs/christophehurpeau.ts
Expand Up @@ -14,7 +14,7 @@ const config: Config<'dev', never> = {
{
regExp:
// eslint-disable-next-line unicorn/no-unsafe-regex
/^(revert: )?(build|chore|ci|docs|feat|fix|perf|refactor|style|test)(\(([/a-z-]*)\))?(!)?:\s/,
/^(?<revert>revert: )?(?<type>build|chore|ci|docs|feat|fix|perf|refactor|style|test)(?<scope>\([/a-z-]+\)?((?=:\s)|(?=!:\s)))?(?<breaking>!)?(?<subject>:\s.*)$/,
error: {
title: 'Title does not match commitlint conventional',
summary:
Expand Down
29 changes: 25 additions & 4 deletions src/accountConfigs/ornikar.ts
Expand Up @@ -14,9 +14,8 @@ const config: Config<'dev' | 'design', 'ops' | 'frontends' | 'backends'> = {
parsePR: {
title: [
{
regExp:
// eslint-disable-next-line unicorn/no-unsafe-regex
/^(revert: )?(build|chore|ci|docs|feat|fix|perf|refactor|style|test)(\(([/A-Za-z-]*)\))?:\s/,
// eslint-disable-next-line unicorn/no-unsafe-regex
regExp: /^(?<revert>revert: )?(?<type>build|chore|ci|docs|feat|fix|perf|refactor|style|test)(?<scope>\([/A-Za-z-]+\)?((?=:\s)|(?=!:\s)))?(?<breaking>!)?(?<subject>:\s.*)$/,
error: {
title: 'Title does not match commitlint conventional',
summary:
Expand All @@ -27,7 +26,7 @@ const config: Config<'dev' | 'design', 'ops' | 'frontends' | 'backends'> = {
bot: false,
regExp: /\s([A-Z][\dA-Z]+-(\d+)|\[no issue])$/,
error: {
title: 'Title does not have JIRA issue',
title: 'Title does not have Jira issue',
summary: 'The PR title should end with ONK-0000, or [no issue]',
},
status: 'jira-issue',
Expand All @@ -48,6 +47,28 @@ const config: Config<'dev' | 'design', 'ops' | 'frontends' | 'backends'> = {
},
},
],
head: [
{
bot: false,
// eslint-disable-next-line unicorn/no-unsafe-regex
regExp: /^(?<revert>revert-\d+-)?(?<type>build|chore|ci|docs|feat|fix|perf|refactor|style|test)(?<scope>\/[a-z-]+)?\/(?<breaking>!)?(?<subject>.*)-(?<jiraIssue>[A-Z][\dA-Z]+-(\d+))$/,
warning: true,
error: {
title: 'Branch name does not match commitlint conventional',
summary: '',
},
},
],
base: [
{
regExp: /^(master|main)$/,
error: {
title: 'PR to branches other than main is not recommended',
summary:
'https://ornikar.atlassian.net/wiki/spaces/TECH/pages/2221900272/Should+I+make+a+feature-branch+or+not',
},
},
],
},

botUsers: ['michael-robot'],
Expand Down
4 changes: 4 additions & 0 deletions src/accountConfigs/types.ts
Expand Up @@ -10,6 +10,7 @@ export interface StatusInfo {
export interface StatusError {
title: string;
summary: string;
url?: string;
}

export interface Group {
Expand All @@ -26,13 +27,16 @@ export interface ParsePRRule {
bot?: false;
regExp: RegExp;
error: StatusError;
warning?: boolean;

status?: string;
statusInfoFromMatch?: (match: RegExpMatchArray) => StatusInfo;
}

export interface ParsePR {
title: ParsePRRule[];
head?: ParsePRRule[];
base?: ParsePRRule[];
}

export interface LabelDescriptor {
Expand Down
4 changes: 1 addition & 3 deletions src/context/utils.ts
@@ -1,8 +1,6 @@
import createEmojiRegex from 'emoji-regex';

export const getKeys = <T extends Record<keyof T, unknown>>(
o: T,
): (keyof T)[] => Object.keys(o) as (keyof T)[];
export const getKeys = <T>(o: T): (keyof T)[] => Object.keys(o) as (keyof T)[];

const emojiRegex = createEmojiRegex();

Expand Down

0 comments on commit fac951c

Please sign in to comment.