Sha256: fd9353a7f8ee1294779695a5e9471ef1a715c704a7af0a44b0d53a04421c7dc7
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
import { case as ensureCase } from '@commitlint/ensure'; import message from '@commitlint/message'; const negated = (when) => when === 'never'; export const scopeCase = (parsed, when = 'always', value = []) => { const { scope } = parsed; if (!scope) { return [true]; } const checks = (Array.isArray(value) ? value : [value]).map((check) => { if (typeof check === 'string') { return { when: 'always', case: check, }; } return check; }); // Scopes may contain slash or comma delimiters to separate them and mark them as individual segments. // This means that each of these segments should be tested separately with `ensure`. const delimiters = /\/|\\|, ?/g; const scopeSegments = scope.split(delimiters); const result = checks.some((check) => { const r = scopeSegments.every((segment) => delimiters.test(segment) || ensureCase(segment, check.case)); return negated(check.when) ? !r : r; }); const list = checks.map((c) => c.case).join(', '); return [ negated(when) ? !result : result, message([`scope must`, negated(when) ? `not` : null, `be ${list}`]), ]; }; //# sourceMappingURL=scope-case.js.map
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pcp-server-ruby-sdk-0.0.6 | node_modules/@commitlint/rules/lib/scope-case.js |
pcp-server-ruby-sdk-0.1.0 | node_modules/@commitlint/rules/lib/scope-case.js |