harper.js 0.68.0 → 0.72.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.
package/dist/harper.d.ts CHANGED
@@ -49,16 +49,18 @@ declare enum Language {
49
49
  export declare class Lint {
50
50
  private constructor();
51
51
  free(): void;
52
- to_json(): string;
53
- static from_json(json: string): Lint;
54
52
  /**
55
- * Get the content of the source material pointed to by [`Self::span`]
53
+ * Get an array of any suggestions that may resolve the issue.
56
54
  */
57
- get_problem_text(): string;
55
+ suggestions(): Suggestion[];
58
56
  /**
59
- * Get a string representing the general category of the lint.
57
+ * Get a description of the error as HTML.
60
58
  */
61
- lint_kind(): string;
59
+ message_html(): string;
60
+ /**
61
+ * Get the content of the source material pointed to by [`Self::span`]
62
+ */
63
+ get_problem_text(): string;
62
64
  /**
63
65
  * Get a string representing the general category of the lint.
64
66
  */
@@ -67,10 +69,6 @@ export declare class Lint {
67
69
  * Equivalent to calling `.length` on the result of `suggestions()`.
68
70
  */
69
71
  suggestion_count(): number;
70
- /**
71
- * Get an array of any suggestions that may resolve the issue.
72
- */
73
- suggestions(): Suggestion[];
74
72
  /**
75
73
  * Get the location of the problematic text.
76
74
  */
@@ -79,10 +77,12 @@ export declare class Lint {
79
77
  * Get a description of the error.
80
78
  */
81
79
  message(): string;
80
+ to_json(): string;
81
+ static from_json(json: string): Lint;
82
82
  /**
83
- * Get a description of the error as HTML.
83
+ * Get a string representing the general category of the lint.
84
84
  */
85
- message_html(): string;
85
+ lint_kind(): string;
86
86
  }
87
87
 
88
88
  /** A linting rule configuration dependent on upstream Harper's available rules.
@@ -170,54 +170,49 @@ declare class Linter_2 {
170
170
  private constructor();
171
171
  free(): void;
172
172
  /**
173
- * Construct a new `Linter`.
174
- * Note that this can mean constructing the curated dictionary, which is the most expensive operation
175
- * in Harper.
173
+ * Clear the user dictionary.
176
174
  */
177
- static new(dialect: Dialect): Linter_2;
175
+ clear_words(): void;
178
176
  /**
179
- * Helper method to quickly check if a plain string is likely intended to be English
177
+ * Get the dialect this struct was constructed for.
180
178
  */
181
- is_likely_english(text: string): boolean;
179
+ get_dialect(): Dialect;
182
180
  /**
183
- * Helper method to remove non-English text from a plain English document.
181
+ * Add a specific context hash to the ignored lints list.
184
182
  */
185
- isolate_english(text: string): string;
183
+ ignore_hash(hash: bigint): void;
184
+ ignore_lint(source_text: string, lint: Lint): void;
186
185
  /**
187
- * Get a JSON map containing the descriptions of all the linting rules, formatted as HTML.
186
+ * Compute the context hash of a given lint.
188
187
  */
189
- get_lint_descriptions_html_as_json(): string;
188
+ context_hash(source_text: string, lint: Lint): bigint;
190
189
  /**
191
- * Get a Record containing the descriptions of all the linting rules, formatted as HTML.
190
+ * Export words from the dictionary.
191
+ * Note: this will only return words previously added by [`Self::import_words`].
192
192
  */
193
- get_lint_descriptions_html_as_object(): any;
193
+ export_words(): string[];
194
194
  /**
195
- * Get a JSON map containing the descriptions of all the linting rules, formatted as Markdown.
195
+ * Import words into the dictionary.
196
196
  */
197
- get_lint_descriptions_as_json(): string;
197
+ import_words(additional_words: string[]): void;
198
198
  /**
199
- * Get a Record containing the descriptions of all the linting rules, formatted as Markdown.
199
+ * Helper method to remove non-English text from a plain English document.
200
200
  */
201
- get_lint_descriptions_as_object(): any;
202
- get_lint_config_as_json(): string;
203
- set_lint_config_from_json(json: string): void;
201
+ isolate_english(text: string): string;
202
+ organized_lints(text: string, language: Language): OrganizedGroup[];
204
203
  summarize_stats(start_time?: bigint | null, end_time?: bigint | null): any;
205
- get_lint_config_as_object(): any;
206
- set_lint_config_from_object(object: any): void;
207
- ignore_lint(source_text: string, lint: Lint): void;
208
204
  /**
209
- * Add a specific context hash to the ignored lints list.
210
- */
211
- ignore_hash(hash: bigint): void;
212
- /**
213
- * Compute the context hash of a given lint.
205
+ * Apply a suggestion from a given lint.
206
+ * This action will be logged to the Linter's statistics.
214
207
  */
215
- context_hash(source_text: string, lint: Lint): bigint;
216
- organized_lints(text: string, language: Language): OrganizedGroup[];
208
+ apply_suggestion(source_text: string, lint: Lint, suggestion: Suggestion): string;
209
+ import_stats_file(file: string): void;
217
210
  /**
218
- * Perform the configured linting on the provided text.
211
+ * Helper method to quickly check if a plain string is likely intended to be English
219
212
  */
220
- lint(text: string, language: Language): Lint[];
213
+ is_likely_english(text: string): boolean;
214
+ clear_ignored_lints(): void;
215
+ generate_stats_file(): string;
221
216
  /**
222
217
  * Export the linter's ignored lints as a privacy-respecting JSON list of hashes.
223
218
  */
@@ -226,31 +221,36 @@ declare class Linter_2 {
226
221
  * Import into the linter's ignored lints from a privacy-respecting JSON list of hashes.
227
222
  */
228
223
  import_ignored_lints(json: string): void;
229
- clear_ignored_lints(): void;
224
+ get_lint_config_as_json(): string;
225
+ get_lint_config_as_object(): any;
226
+ set_lint_config_from_json(json: string): void;
227
+ set_lint_config_from_object(object: any): void;
230
228
  /**
231
- * Clear the user dictionary.
229
+ * Get a JSON map containing the descriptions of all the linting rules, formatted as Markdown.
232
230
  */
233
- clear_words(): void;
231
+ get_lint_descriptions_as_json(): string;
234
232
  /**
235
- * Import words into the dictionary.
233
+ * Get a Record containing the descriptions of all the linting rules, formatted as Markdown.
236
234
  */
237
- import_words(additional_words: string[]): void;
235
+ get_lint_descriptions_as_object(): any;
238
236
  /**
239
- * Export words from the dictionary.
240
- * Note: this will only return words previously added by [`Self::import_words`].
237
+ * Get a JSON map containing the descriptions of all the linting rules, formatted as HTML.
241
238
  */
242
- export_words(): string[];
239
+ get_lint_descriptions_html_as_json(): string;
243
240
  /**
244
- * Get the dialect this struct was constructed for.
241
+ * Get a Record containing the descriptions of all the linting rules, formatted as HTML.
245
242
  */
246
- get_dialect(): Dialect;
243
+ get_lint_descriptions_html_as_object(): any;
247
244
  /**
248
- * Apply a suggestion from a given lint.
249
- * This action will be logged to the Linter's statistics.
245
+ * Construct a new `Linter`.
246
+ * Note that this can mean constructing the curated dictionary, which is the most expensive operation
247
+ * in Harper.
250
248
  */
251
- apply_suggestion(source_text: string, lint: Lint, suggestion: Suggestion): string;
252
- generate_stats_file(): string;
253
- import_stats_file(file: string): void;
249
+ static new(dialect: Dialect): Linter_2;
250
+ /**
251
+ * Perform the configured linting on the provided text.
252
+ */
253
+ lint(text: string, language: Language): Lint[];
254
254
  }
255
255
 
256
256
  export declare interface LinterInit {
@@ -337,11 +337,11 @@ export declare interface SerializedRequest {
337
337
  export declare class Span {
338
338
  private constructor();
339
339
  free(): void;
340
- to_json(): string;
341
- static from_json(json: string): Span;
340
+ len(): number;
342
341
  static new(start: number, end: number): Span;
342
+ to_json(): string;
343
343
  is_empty(): boolean;
344
- len(): number;
344
+ static from_json(json: string): Span;
345
345
  start: number;
346
346
  end: number;
347
347
  }
@@ -352,8 +352,6 @@ export declare class Span {
352
352
  export declare class Suggestion {
353
353
  private constructor();
354
354
  free(): void;
355
- to_json(): string;
356
- static from_json(json: string): Suggestion;
357
355
  /**
358
356
  * Get the text that is going to replace the problematic section.
359
357
  * If [`Self::kind`] is `SuggestionKind::Remove`, this will return an empty
@@ -361,6 +359,8 @@ export declare class Suggestion {
361
359
  */
362
360
  get_replacement_text(): string;
363
361
  kind(): SuggestionKind;
362
+ to_json(): string;
363
+ static from_json(json: string): Suggestion;
364
364
  }
365
365
 
366
366
  /**