harper.js 0.67.0 → 0.71.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 +62 -62
- package/dist/harper.js +329 -329
- package/dist/harper_wasm_bg.wasm +0 -0
- package/package.json +6 -5
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
|
|
53
|
+
* Get an array of any suggestions that may resolve the issue.
|
|
56
54
|
*/
|
|
57
|
-
|
|
55
|
+
suggestions(): Suggestion[];
|
|
58
56
|
/**
|
|
59
|
-
* Get a
|
|
57
|
+
* Get a description of the error as HTML.
|
|
60
58
|
*/
|
|
61
|
-
|
|
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
|
|
83
|
+
* Get a string representing the general category of the lint.
|
|
84
84
|
*/
|
|
85
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
175
|
+
clear_words(): void;
|
|
178
176
|
/**
|
|
179
|
-
*
|
|
177
|
+
* Get the dialect this struct was constructed for.
|
|
180
178
|
*/
|
|
181
|
-
|
|
179
|
+
get_dialect(): Dialect;
|
|
182
180
|
/**
|
|
183
|
-
*
|
|
181
|
+
* Add a specific context hash to the ignored lints list.
|
|
184
182
|
*/
|
|
185
|
-
|
|
183
|
+
ignore_hash(hash: bigint): void;
|
|
184
|
+
ignore_lint(source_text: string, lint: Lint): void;
|
|
186
185
|
/**
|
|
187
|
-
*
|
|
186
|
+
* Compute the context hash of a given lint.
|
|
188
187
|
*/
|
|
189
|
-
|
|
188
|
+
context_hash(source_text: string, lint: Lint): bigint;
|
|
190
189
|
/**
|
|
191
|
-
*
|
|
190
|
+
* Export words from the dictionary.
|
|
191
|
+
* Note: this will only return words previously added by [`Self::import_words`].
|
|
192
192
|
*/
|
|
193
|
-
|
|
193
|
+
export_words(): string[];
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
195
|
+
* Import words into the dictionary.
|
|
196
196
|
*/
|
|
197
|
-
|
|
197
|
+
import_words(additional_words: string[]): void;
|
|
198
198
|
/**
|
|
199
|
-
*
|
|
199
|
+
* Helper method to remove non-English text from a plain English document.
|
|
200
200
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
216
|
-
|
|
208
|
+
apply_suggestion(source_text: string, lint: Lint, suggestion: Suggestion): string;
|
|
209
|
+
import_stats_file(file: string): void;
|
|
217
210
|
/**
|
|
218
|
-
*
|
|
211
|
+
* Helper method to quickly check if a plain string is likely intended to be English
|
|
219
212
|
*/
|
|
220
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
229
|
+
* Get a JSON map containing the descriptions of all the linting rules, formatted as Markdown.
|
|
232
230
|
*/
|
|
233
|
-
|
|
231
|
+
get_lint_descriptions_as_json(): string;
|
|
234
232
|
/**
|
|
235
|
-
*
|
|
233
|
+
* Get a Record containing the descriptions of all the linting rules, formatted as Markdown.
|
|
236
234
|
*/
|
|
237
|
-
|
|
235
|
+
get_lint_descriptions_as_object(): any;
|
|
238
236
|
/**
|
|
239
|
-
*
|
|
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
|
-
|
|
239
|
+
get_lint_descriptions_html_as_json(): string;
|
|
243
240
|
/**
|
|
244
|
-
* Get the
|
|
241
|
+
* Get a Record containing the descriptions of all the linting rules, formatted as HTML.
|
|
245
242
|
*/
|
|
246
|
-
|
|
243
|
+
get_lint_descriptions_html_as_object(): any;
|
|
247
244
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
/**
|