Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(lint): exempt filename/path date templates from placeholder-date (#6538)

time-attackf81aa98f8503
diff --git a/src/commands/lint.ts b/src/commands/lint.ts
index 90d28fe9f4..d6922b7109 100644
--- a/src/commands/lint.ts
+++ b/src/commands/lint.ts
@@ -221,9 +221,13 @@ export function lintContent(content: string, filePath: string, opts: LintContent
// DOCUMENTING date formats (```\ncreated: YYYY-MM-DD\n``` or `YYYY-MM-DD`)
// is not a page with an unfilled one. stripCodeBlocks masks fenced blocks
// and inline spans in place, so line numbers stay exact.
+ // #6538: in the body, a YYYY-MM-DD token followed by `-word`, `.ext` or `/` is a filename/path template
+ // (`YYYY-MM-DD-topic.md`), not an unfilled date; frontmatter stays strict.
const prose = stripCodeBlocks(content).split('\n');
+ const frontmatterLines = content.startsWith('---') ? lines.indexOf('---', 1) : -1;
for (let i = 0; i < lines.length; i++) {
- if (prose[i].match(/\bYYYY-MM-DD\b/) || prose[i].match(/\bXX-XX\b/) || prose[i].match(/\b\d{4}-XX-XX\b/)) {
+ const datePlaceholder = i <= frontmatterLines ? /\bYYYY-MM-DD\b/ : /\bYYYY-MM-DD\b(?![-./][A-Za-z0-9]|\/)/;
+ if (prose[i].match(datePlaceholder) || prose[i].match(/\bXX-XX\b/) || prose[i].match(/\b\d{4}-XX-XX\b/)) {
issues.push({
file: filePath, line: i + 1, rule: 'placeholder-date',
message: `Placeholder date found: ${lines[i].trim().slice(0, 60)}`,
diff --git a/test/lint-3958.test.ts b/test/lint-3958.test.ts
index fd58691f98..9bcbb08e24 100644
--- a/test/lint-3958.test.ts
+++ b/test/lint-3958.test.ts
@@ -44,6 +44,23 @@ describe('#6133 placeholder-date skips inline code spans', () => {
});
});
+// #6538: a filename/path template (`YYYY-MM-DD-topic.md`, `notes/YYYY-MM-DD/`) names a pattern, not an
+// unfilled date. A bare prose example keeps the "backtick it" rule, and frontmatter stays strict.
+describe('#6538 placeholder-date skips filename and path templates', () => {
+ test('template tokens give no hits; bare prose examples and frontmatter still fire', () => {
+ const content = [
+ '---', 'title: Formats', 'type: note', 'file: YYYY-MM-DD-topic.md', '---', '',
+ 'Dates use the ISO 8601 format: YYYY-MM-DD.',
+ 'Meeting notes are named YYYY-MM-DD-topic.md.',
+ 'Daily files live in journal/YYYY-MM-DD/ and exports in YYYY-MM-DD.json.',
+ 'Named YYYY-MM-DD-topic.md, due YYYY-MM-DD.',
+ 'Use YYYY-MM-DD here once confirmed.',
+ ].join('\n');
+ const hits = lintContent(content, 'test.md', { contentSanity: SANITY_OFF }).filter(i => i.rule === 'placeholder-date');
+ expect(hits.map(h => h.line)).toEqual([4, 7, 10, 11]);
+ });
+});
+
describe('#3958 placeholder-date skips fenced code blocks', () => {
test('YYYY-MM-DD inside a ``` fence is not a placeholder', () => {
const content =