harper.js 0.65.0 → 0.68.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
@@ -97,6 +97,8 @@ export declare interface Linter {
97
97
  setup(): Promise<void>;
98
98
  /** Lint the provided text. */
99
99
  lint(text: string, options?: LintOptions): Promise<Lint[]>;
100
+ /** Lint the provided text, maintaining the relationship with the source rule. */
101
+ organizedLints(text: string, options?: LintOptions): Promise<Record<string, Lint[]>>;
100
102
  /** Apply a suggestion from a lint to text, returning the changed text. */
101
103
  applySuggestion(text: string, lint: Lint, suggestion: Suggestion): Promise<string>;
102
104
  /** Determine if the provided text is likely to be intended to be English.
@@ -142,6 +144,8 @@ export declare interface Linter {
142
144
  contextHash(source: string, lint: Lint): Promise<bigint>;
143
145
  /** Clear records of all previously ignored lints. */
144
146
  clearIgnoredLints(): Promise<void>;
147
+ /** Clear the words which have been added to the dictionary. This will not clear words from the curated dictionary. */
148
+ clearWords(): Promise<void>;
145
149
  /** Import words into the dictionary. This is a significant operation, so try to batch words. */
146
150
  importWords(words: string[]): Promise<void>;
147
151
  /** Export all added words from the dictionary. Note that this will NOT export anything from the curated dictionary,
@@ -209,6 +213,7 @@ declare class Linter_2 {
209
213
  * Compute the context hash of a given lint.
210
214
  */
211
215
  context_hash(source_text: string, lint: Lint): bigint;
216
+ organized_lints(text: string, language: Language): OrganizedGroup[];
212
217
  /**
213
218
  * Perform the configured linting on the provided text.
214
219
  */
@@ -222,6 +227,10 @@ declare class Linter_2 {
222
227
  */
223
228
  import_ignored_lints(json: string): void;
224
229
  clear_ignored_lints(): void;
230
+ /**
231
+ * Clear the user dictionary.
232
+ */
233
+ clear_words(): void;
225
234
  /**
226
235
  * Import words into the dictionary.
227
236
  */
@@ -265,6 +274,7 @@ export declare class LocalLinter implements Linter {
265
274
  private createInner;
266
275
  setup(): Promise<void>;
267
276
  lint(text: string, options?: LintOptions): Promise<Lint[]>;
277
+ organizedLints(text: string, options?: LintOptions): Promise<Record<string, Lint[]>>;
268
278
  applySuggestion(text: string, lint: Lint, suggestion: Suggestion): Promise<string>;
269
279
  isLikelyEnglish(text: string): Promise<boolean>;
270
280
  isolateEnglish(text: string): Promise<string>;
@@ -285,6 +295,7 @@ export declare class LocalLinter implements Linter {
285
295
  importIgnoredLints(json: string): Promise<void>;
286
296
  contextHash(source: string, lint: Lint): Promise<bigint>;
287
297
  clearIgnoredLints(): Promise<void>;
298
+ clearWords(): Promise<void>;
288
299
  importWords(words: string[]): Promise<void>;
289
300
  exportWords(): Promise<string[]>;
290
301
  getDialect(): Promise<Dialect>;
@@ -294,6 +305,16 @@ export declare class LocalLinter implements Linter {
294
305
  importStatsFile(statsFile: string): Promise<void>;
295
306
  }
296
307
 
308
+ /**
309
+ * Used exclusively for [`Linter::organized_lints`]
310
+ */
311
+ declare class OrganizedGroup {
312
+ private constructor();
313
+ free(): void;
314
+ group: string;
315
+ lints: Lint[];
316
+ }
317
+
297
318
  /** Serializable argument to a procedure to be run on the web worker. */
298
319
  export declare interface RequestArg {
299
320
  json: string;
@@ -394,6 +415,7 @@ export declare class WorkerLinter implements Linter {
394
415
  private setupMainEventListeners;
395
416
  setup(): Promise<void>;
396
417
  lint(text: string, options?: LintOptions): Promise<Lint[]>;
418
+ organizedLints(text: string, options?: LintOptions): Promise<Record<string, Lint[]>>;
397
419
  applySuggestion(text: string, lint: Lint, suggestion: Suggestion): Promise<string>;
398
420
  isLikelyEnglish(text: string): Promise<boolean>;
399
421
  isolateEnglish(text: string): Promise<string>;
@@ -414,6 +436,7 @@ export declare class WorkerLinter implements Linter {
414
436
  importIgnoredLints(json: string): Promise<void>;
415
437
  contextHash(source: string, lint: Lint): Promise<bigint>;
416
438
  clearIgnoredLints(): Promise<void>;
439
+ clearWords(): Promise<void>;
417
440
  importWords(words: string[]): Promise<void>;
418
441
  exportWords(): Promise<string[]>;
419
442
  getDialect(): Promise<Dialect>;