@jpeakai/prose-gates 0.2.0 → 0.3.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.
@@ -15,6 +15,7 @@ export const RULE = {
15
15
  INLINE_ENUM: "list-inline-enumeration-markers",
16
16
  LABELLED_RUN: "list-comma-labelled-run",
17
17
  STACKED_RUNS: "list-stacked-interpunct-runs",
18
+ PARAGRAPH_LENGTH: "paragraph-sentence-budget-exceeded",
18
19
  } as const;
19
20
 
20
21
  // A core id has no slash. A plugin id is always namespace/name, so the slash
@@ -66,9 +67,12 @@ export interface TextHelpers {
66
67
  }
67
68
 
68
69
  // A check also names the file it reports against, and the sentence budget.
70
+ // `earlier` is what the rules of the categories in its `after` reported, and
71
+ // is empty for a rule that runs after none.
69
72
  export interface CheckContext extends RuleContext {
70
73
  file: string;
71
74
  maxWords: number;
75
+ earlier: readonly Finding[];
72
76
  options: RuleOptions;
73
77
  helpers: TextHelpers;
74
78
  }
@@ -105,8 +109,9 @@ export interface Edit {
105
109
  // sentence: how a sentence is laid out and how long it runs.
106
110
  // list: a list hidden in running prose, promoted to a real markdown list.
107
111
  // punctuation: a glyph that reads as generated text.
112
+ // paragraph: how many sentences a paragraph holds before a break.
108
113
  // A plugin may add a category of its own by declaring it.
109
- export const CATEGORIES = ["sentence", "list", "punctuation"] as const;
114
+ export const CATEGORIES = ["sentence", "paragraph", "list", "punctuation"] as const;
110
115
 
111
116
  export type Category = (typeof CATEGORIES)[number];
112
117
 
@@ -116,6 +121,9 @@ export interface Rule {
116
121
  summary: string;
117
122
  // The options the rule accepts. Absent when it takes none.
118
123
  options?: OptionSpec;
124
+ // Categories whose findings this rule reads, so its check runs after theirs.
125
+ // Absent for a rule that reads no other rule's findings.
126
+ after?: readonly string[];
119
127
  check: (ctx: CheckContext) => Awaitable<Finding[]>;
120
128
  // Absent for rules whose fix needs discretion (sentence-word-budget-exceeded).
121
129
  fix?: (ctx: FixContext) => Awaitable<Edit[]>;