@effected/changesets 0.2.0 → 0.4.0

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.
@@ -1,72 +0,0 @@
1
- // src/internal/lint/docs.ts
2
- const DOCS_BASE = "https://github.com/savvy-web/systems/blob/main/packages/silk-effects/docs/rules";
3
- const RULE_DOCS = {
4
- CSH001: `${DOCS_BASE}/CSH001.md`,
5
- CSH002: `${DOCS_BASE}/CSH002.md`,
6
- CSH003: `${DOCS_BASE}/CSH003.md`,
7
- CSH004: `${DOCS_BASE}/CSH004.md`,
8
- CSH005: `${DOCS_BASE}/CSH005.md`
9
- };
10
- /** The thirteen changeset category headings, in display order. */
11
- const CATEGORY_HEADINGS = [
12
- "Breaking Changes",
13
- "Features",
14
- "Bug Fixes",
15
- "Performance",
16
- "Documentation",
17
- "Refactoring",
18
- "Tests",
19
- "Build System",
20
- "CI",
21
- "Dependencies",
22
- "Maintenance",
23
- "Reverts",
24
- "Other"
25
- ];
26
- const headingSet = new Set(CATEGORY_HEADINGS.map((heading) => heading.toLowerCase()));
27
- /** Whether `heading` names a category, ignoring case. */
28
- const isValidHeading = (heading) => headingSet.has(heading.toLowerCase());
29
- /** A semver version, a protocol specifier, or the em-dash sentinel. */
30
- const VERSION_RE = /^(—|[~^]?\d+\.\d+\.\d+(?:[-+.][\w.+-]+)?|(?:catalog|workspace|npm|jsr|file|link|portal):[^\s|]+)$/u;
31
- const BACKSLASH_ESCAPE_RE = /\\([!-/:-@[-`{-~])/g;
32
- /**
33
- * A node's text as written, from its first child to its last, with
34
- * CommonMark backslash escapes resolved: what systems' markdownlint rules
35
- * read from a micromark heading or cell token. Inline formatting is kept, so
36
- * a heading of `Features` in a code span reads with its backticks.
37
- */
38
- const writtenText = (source, node) => {
39
- const first = node.children[0];
40
- const last = node.children.at(-1);
41
- if (first === void 0 || last === void 0) return "";
42
- return source.slice(first.position.start.offset, last.position.end.offset).replace(BACKSLASH_ESCAPE_RE, "$1");
43
- };
44
- /** Line breaks as spaces, as markdownlint writes every `errorDetail`. */
45
- const oneLine = (text) => text.replace(/\r\n?|\n/g, " ");
46
- /**
47
- * Where a top-level heading is reported. micromark reads link reference
48
- * definitions directly above a setext heading, with no blank line between, as
49
- * the start of the heading's own token, so markdownlint reports that heading
50
- * on the first definition's line; anywhere else the heading is its own anchor.
51
- */
52
- const headingAnchor = (source, siblings, index) => {
53
- const heading = siblings[index];
54
- const end = heading.position.end.offset;
55
- let start = heading.position.start.offset;
56
- if (heading.headingStyle !== "setext") return {
57
- offset: start,
58
- length: end - start
59
- };
60
- for (let previous = index - 1; previous >= 0; previous--) {
61
- const sibling = siblings[previous];
62
- if (sibling.type !== "definition") break;
63
- if (!/^[ \t]*(?:\r\n?|\n)[ \t]*$/.test(source.slice(sibling.position.end.offset, start))) break;
64
- start = sibling.position.start.offset;
65
- }
66
- return {
67
- offset: start,
68
- length: end - start
69
- };
70
- };
71
-
72
- export { CATEGORY_HEADINGS, RULE_DOCS, VERSION_RE, headingAnchor, isValidHeading, oneLine, writtenText };
@@ -1,32 +0,0 @@
1
- import { RULE_DOCS, headingAnchor } from "./docs.js";
2
- import { LintRule } from "@effected/markdown-lint";
3
-
4
- // src/internal/lint/heading-hierarchy.ts
5
- const HeadingHierarchy = LintRule.make({
6
- names: ["changeset-heading-hierarchy", "CSH001"],
7
- description: "Heading hierarchy must start at h2 with no h1 or depth skips",
8
- tags: ["changeset"],
9
- information: RULE_DOCS.CSH001,
10
- check: (context, report) => {
11
- let previous = 0;
12
- const children = context.root.children;
13
- children.forEach((heading, index) => {
14
- if (heading.type !== "heading") return;
15
- const at = headingAnchor(context.source, children, index);
16
- if (heading.depth === 1) {
17
- report(context.diagnostic({
18
- at,
19
- detail: `h1 headings are not allowed in changeset files. Use h2 (##) for top-level sections like "## Features" or "## Bug Fixes". h1 is reserved for the version title generated by the changelog formatter. See: ${RULE_DOCS.CSH001}`
20
- }));
21
- return;
22
- }
23
- if (previous > 0 && heading.depth > previous + 1) report(context.diagnostic({
24
- at,
25
- detail: `Heading level skipped: expected h${previous + 1} or lower, found h${heading.depth}. Headings must increase sequentially (h2 → h3 → h4). Add the missing intermediate level or reduce this heading's depth. See: ${RULE_DOCS.CSH001}`
26
- }));
27
- previous = heading.depth;
28
- });
29
- }
30
- });
31
-
32
- export { HeadingHierarchy };
@@ -1,23 +0,0 @@
1
- import { CATEGORY_HEADINGS, RULE_DOCS, headingAnchor, isValidHeading, oneLine, writtenText } from "./docs.js";
2
- import { LintRule } from "@effected/markdown-lint";
3
-
4
- // src/internal/lint/required-sections.ts
5
- const RequiredSections = LintRule.make({
6
- names: ["changeset-required-sections", "CSH002"],
7
- description: "Section headings must match known changeset categories",
8
- tags: ["changeset"],
9
- information: RULE_DOCS.CSH002,
10
- check: (context, report) => {
11
- const children = context.root.children;
12
- children.forEach((heading, index) => {
13
- if (heading.type !== "heading" || heading.depth !== 2) return;
14
- const text = oneLine(writtenText(context.source, heading));
15
- if (!isValidHeading(text)) report(context.diagnostic({
16
- at: headingAnchor(context.source, children, index),
17
- detail: `Unknown section "${text}". Valid h2 headings are: ${CATEGORY_HEADINGS.join(", ")}. Heading comparison is case-insensitive. See: ${RULE_DOCS.CSH002}`
18
- }));
19
- });
20
- }
21
- });
22
-
23
- export { RequiredSections };
@@ -1,22 +0,0 @@
1
- import { RULE_DOCS } from "./docs.js";
2
- import { LintRule } from "@effected/markdown-lint";
3
-
4
- // src/internal/lint/uncategorized-content.ts
5
- const UncategorizedContent = LintRule.make({
6
- names: ["changeset-uncategorized-content", "CSH004"],
7
- description: "All content must be placed under a category heading (## heading)",
8
- tags: ["changeset"],
9
- information: RULE_DOCS.CSH004,
10
- check: (context, report) => {
11
- for (const node of context.root.children) {
12
- if (node.type === "heading" && node.depth === 2) break;
13
- if (node.type === "heading" || node.type === "html" || node.type === "frontmatter") continue;
14
- report(context.diagnostic({
15
- at: node,
16
- detail: `Content must be placed under a category heading (## heading). Move this content under an appropriate section like "## Features" or "## Bug Fixes". If it doesn't fit an existing category, use "## Other". See: ${RULE_DOCS.CSH004}`
17
- }));
18
- }
19
- }
20
- });
21
-
22
- export { UncategorizedContent };