@recallnet/remark-lint-docs-freshness 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +2 -2
- package/src/index.js +8 -17
package/README.md
CHANGED
|
@@ -62,4 +62,5 @@ Document is stale: reviewed=2026-03-01 age_days=18 max_age_days=7.
|
|
|
62
62
|
|
|
63
63
|
- Docs with non-periodic policies such as `historical` are ignored.
|
|
64
64
|
- If frontmatter is missing or unreadable for an in-scope file, the rule reports that freshness could not be checked.
|
|
65
|
+
- Frontmatter parsing uses `vfile-matter`, which is the unified-recommended way to expose YAML metadata on `file.data.matter`.
|
|
65
66
|
- This package is intended for docs-governance setups that keep freshness policy in repo config rather than hardcoding date thresholds in lint config.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recallnet/remark-lint-docs-freshness",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Remark plugin that checks docs reviewed dates against repo policy.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"src"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"
|
|
28
|
+
"vfile-matter": "^5.0.1",
|
|
29
29
|
"@recallnet/docs-governance-policy": "0.2.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
package/src/index.js
CHANGED
|
@@ -9,24 +9,10 @@ import {
|
|
|
9
9
|
resolveDocsReviewPolicy,
|
|
10
10
|
resolveReviewPolicyConfig,
|
|
11
11
|
} from "@recallnet/docs-governance-policy";
|
|
12
|
-
import {
|
|
12
|
+
import { matter } from "vfile-matter";
|
|
13
13
|
|
|
14
14
|
const RULE_ID = "docs-freshness";
|
|
15
15
|
|
|
16
|
-
function findYamlNode(tree) {
|
|
17
|
-
return tree?.children?.find((node) => node.type === "yaml") ?? null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function parseFrontmatter(tree) {
|
|
21
|
-
const yamlNode = findYamlNode(tree);
|
|
22
|
-
if (!yamlNode?.value) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const data = parse(String(yamlNode.value));
|
|
27
|
-
return data && typeof data === "object" && !Array.isArray(data) ? data : null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
16
|
function dateDiffDays(older, newer) {
|
|
31
17
|
const olderMs = new Date(`${older}T00:00:00Z`).getTime();
|
|
32
18
|
const newerMs = new Date(`${newer}T00:00:00Z`).getTime();
|
|
@@ -58,8 +44,13 @@ export default function remarkLintDocsFreshness(options = {}) {
|
|
|
58
44
|
return;
|
|
59
45
|
}
|
|
60
46
|
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
matter(file);
|
|
48
|
+
const frontmatter =
|
|
49
|
+
file.data.matter && typeof file.data.matter === "object" && !Array.isArray(file.data.matter)
|
|
50
|
+
? file.data.matter
|
|
51
|
+
: null;
|
|
52
|
+
|
|
53
|
+
if (!frontmatter || Object.keys(frontmatter).length === 0) {
|
|
63
54
|
file.message("Document freshness could not be checked because frontmatter is unreadable.", {
|
|
64
55
|
ruleId: RULE_ID,
|
|
65
56
|
source: "@recallnet/remark-lint-docs-freshness",
|