Skip to content

Commit 3f363df

Browse files
committed
add exception to frontmatter validator
1 parent 30f3797 commit 3f363df

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

plugins/frontmatter-validation/customParseFrontMatter.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,17 @@ async function customParseFrontMatter(params) {
175175
currentFieldName = fieldMatch[1];
176176

177177
// Check for single space between key and value
178-
if (!/^[a-zA-Z_]+: /.test(line) && !line.includes(': [')) {
178+
// Exception: 'integration' field is allowed to have no value (block style array follows)
179+
if (!/^[a-zA-Z_]+: /.test(line) && !line.includes(': [') && currentFieldName !== 'integration') {
179180
issues.push(`incorrect spacing in line: "${line.trim()}"`);
180181
}
181182

182183
// Check for block style arrays (should be flow style with brackets)
184+
// Exception: 'integration' field is allowed to use block style
183185
if (line.trim().match(/^[a-zA-Z_]+: ?$/)) {
184186
// This field has no value on the same line, check if next line starts with a dash
185187
const nextLine = (i + 1 < yamlLines.length) ? yamlLines[i + 1].trim() : '';
186-
if (nextLine.startsWith('-')) {
188+
if (nextLine.startsWith('-') && currentFieldName !== 'integration') {
187189
issues.push(`field '${currentFieldName}' should use flow style array with square brackets`);
188190
}
189191
}
@@ -303,6 +305,7 @@ async function customParseFrontMatter(params) {
303305
// This is not a new field nor a continuation of a multi-line value
304306

305307
// Check for block style array items that should be flow style
308+
// Exception: 'integration' field is allowed to use block style
306309
if (line.trim().startsWith('-')) {
307310
// Find the previous field to associate with this block array item
308311
let j = i - 1;
@@ -311,7 +314,8 @@ async function customParseFrontMatter(params) {
311314
if (prevLine.match(/^[a-zA-Z_]+: ?$/)) {
312315
const fieldName = prevLine.split(':')[0].trim();
313316
// Only report once per field to avoid multiple errors
314-
if (!issues.some(issue => issue.includes(`field '${fieldName}'`) && issue.includes('flow style array'))) {
317+
// Exception: 'integration' field is allowed to use block style
318+
if (fieldName !== 'integration' && !issues.some(issue => issue.includes(`field '${fieldName}'`) && issue.includes('flow style array'))) {
315319
issues.push(`field '${fieldName}' should use flow style array with square brackets`);
316320
}
317321
break;

0 commit comments

Comments
 (0)