@pega/commitlint-plugin
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -23,6 +23,7 @@ import type { | ||
'@pega/reference-order': RuleConfig<V, void | { prefixes?: string[]; ascending?: boolean }>; | ||
'@pega/subject-present-tense': RuleConfig<V, void | { ignorePrefixes?: string[] }>; | ||
'@pega/agile-studio': RuleConfig<V, void | { prefixes?: string[] }>; | ||
'@pega/open-agile': RuleConfig<V, void | { prefixes?: string[] }>; | ||
'@pega/merge-commit': RuleConfig<V, void | { prefixes?: string[] }>; | ||
'@pega/revert-commit': RuleConfig<V, void | { prefixes?: string[] }>; | ||
'@pega/merge-commit': RuleConfig<V>; | ||
'@pega/revert-commit': RuleConfig<V>; | ||
'@pega/spellcheck': RuleConfig<V, void | { ignorePrefixes?: string[] }>; | ||
@@ -29,0 +30,0 @@ }; |
83
index.js
@@ -15,3 +15,3 @@ // @ts-check | ||
({ scope }, enable = 'always', { scopes = [], separator = /\\|\/|,/, trim = false } = {}) => { | ||
if (!scope || !scopes.length) return [true, '']; | ||
if (!scope || !scopes.length) return [true]; | ||
@@ -35,3 +35,3 @@ if (enable === 'always') { | ||
({ header, references }, enable = 'always') => { | ||
if (!header) return [true, '']; | ||
if (!header) return [true]; | ||
@@ -72,3 +72,3 @@ if (enable === 'always') { | ||
) => { | ||
if (!references.length) return [true, '']; | ||
if (!references.length) return [true]; | ||
@@ -100,3 +100,3 @@ if (!caseSensitive) actions = actions.map(action => action.toLowerCase()); | ||
({ references }, enable = 'always', { prefixes = ['#'], ascending = true } = {}) => { | ||
if (references.length < 2 || enable !== 'always') return [true, '']; | ||
if (references.length < 2 || enable !== 'always') return [true]; | ||
@@ -147,9 +147,26 @@ /** @type {{ [prefix: string]: string[][]; }} */ | ||
return [true, '']; | ||
return [true]; | ||
}, | ||
'@pega/subject-present-tense': | ||
/** @satisfies {import('@commitlint/types').SyncRule<{ ignorePrefixes?: string[] }>} */ | ||
({ subject }, enable = 'always', { ignorePrefixes = [] } = {}) => { | ||
if (enable !== 'always' || !subject) return [true]; | ||
if (/^[a-zA-Z]+s\b/.test(subject)) return [true]; | ||
for (const prefix of ignorePrefixes) { | ||
if (subject.startsWith(prefix)) return [true]; | ||
} | ||
return [ | ||
false, | ||
`Subject must start with a present tense verb${ignorePrefixes.length ? `or one of the following: [${ignorePrefixes.join(', ')}]` : ''}.` | ||
]; | ||
}, | ||
'@pega/agile-studio': | ||
/** @satisfies {import('@commitlint/types').SyncRule<{ prefixes?: string[] }>} */ | ||
({ footer }, enable = 'always', { prefixes = ['#'] } = {}) => { | ||
if (enable !== 'always' || !footer) return [true, '']; | ||
if (enable !== 'always' || !footer) return [true]; | ||
@@ -160,5 +177,23 @@ if (footer.indexOf('AgileStudio:') !== footer.lastIndexOf('AgileStudio:')) { | ||
if (/^AgileStudio:$/m.test(footer)) { | ||
return [false, 'Empty Agile Studio note found.']; | ||
} | ||
if (/^AgileStudio(?!:)/m.test(footer)) { | ||
return [false, 'Agile Studio note must have a colon.']; | ||
} | ||
const re = /^(AgileStudio):/gim; | ||
/** @type {RegExpExecArray | null} */ | ||
let match; | ||
// eslint-disable-next-line no-cond-assign | ||
while ((match = re.exec(footer)) !== null) { | ||
if (match[1] !== 'AgileStudio') { | ||
return [false, 'Improper Agile Studio note casing, should be "AgileStudio:".']; | ||
} | ||
} | ||
const [, agileStudioNote] = /^AgileStudio:(.+)$/m.exec(footer) ?? []; | ||
if (!agileStudioNote) return [true, '']; | ||
if (!agileStudioNote) return [true]; | ||
@@ -186,3 +221,3 @@ if (!agileStudioNote.startsWith(' ')) { | ||
return [true, '']; | ||
return [true]; | ||
}, | ||
@@ -193,3 +228,3 @@ | ||
({ footer }, enable = 'always', { prefixes = ['#'] } = {}) => { | ||
if (enable !== 'always' || !footer) return [true, '']; | ||
if (enable !== 'always' || !footer) return [true]; | ||
@@ -200,5 +235,23 @@ if (footer.indexOf('OpenAgile:') !== footer.lastIndexOf('OpenAgile:')) { | ||
if (/^OpenAgile:$/m.test(footer)) { | ||
return [false, 'Empty Open Agile note found.']; | ||
} | ||
if (/^OpenAgile(?!:)/m.test(footer)) { | ||
return [false, 'Open Agile note must have a colon.']; | ||
} | ||
const re = /^(OpenAgile):/gim; | ||
/** @type {RegExpExecArray | null} */ | ||
let match; | ||
// eslint-disable-next-line no-cond-assign | ||
while ((match = re.exec(footer)) !== null) { | ||
if (match[1] !== 'OpenAgile') { | ||
return [false, 'Improper Open Agile note casing, should be "OpenAgile:".']; | ||
} | ||
} | ||
const [, openAgileNote] = /^OpenAgile:(.+)$/m.exec(footer) ?? []; | ||
if (!openAgileNote) return [true, '']; | ||
if (!openAgileNote) return [true]; | ||
@@ -226,3 +279,3 @@ if (!openAgileNote.startsWith(' ')) { | ||
return [true, '']; | ||
return [true]; | ||
}, | ||
@@ -233,3 +286,3 @@ | ||
({ merge }, enable = 'never') => { | ||
if (enable !== 'never') return [true, '']; | ||
if (enable !== 'never') return [true]; | ||
@@ -242,3 +295,3 @@ return [!merge, 'Merge commits are not allowed.']; | ||
({ revert }, enable = 'never') => { | ||
if (enable !== 'never') return [true, '']; | ||
if (enable !== 'never') return [true]; | ||
@@ -251,3 +304,3 @@ return [!revert, 'Revert commits are not allowed.']; | ||
async ({ raw }, enable = 'always', { ignorePrefixes = [] } = {}) => { | ||
if (enable !== 'always' || !raw) return [true, '']; | ||
if (enable !== 'always' || !raw) return [true]; | ||
@@ -276,3 +329,3 @@ const cspell = fork(require.resolve('cspell/bin'), ['--no-summary', '--unique', 'stdin'], { | ||
cspell.on('exit', code => { | ||
if (code === 0) resolve([true, '']); | ||
if (code === 0) resolve([true]); | ||
@@ -279,0 +332,0 @@ const output = Buffer.concat(out, outLen).toString('utf-8'); |
{ | ||
"name": "@pega/commitlint-plugin", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Pega front-end commitlint plugin.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26099
298