harper.js 0.16.0 → 0.18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harper.js",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Elijah Potter",
6
6
  "description": "The grammar checker for developers.",
@@ -25,7 +25,7 @@
25
25
  "@vitest/browser": "^2.1.8",
26
26
  "playwright": "^1.49.1",
27
27
  "typescript": "~5.6.2",
28
- "vite": "^5.1.8",
28
+ "vite": "^5.4.12",
29
29
  "vite-plugin-dts": "^4.5.0",
30
30
  "vite-plugin-virtual": "^0.3.0",
31
31
  "vitest": "^2.1.8",
@@ -121,6 +121,16 @@ for (const [linterName, Linter] of Object.entries(linters)) {
121
121
  expect(value).not.toHaveLength(0);
122
122
  }
123
123
  });
124
+
125
+ test(`${linterName} default lint config has no null values`, async () => {
126
+ const linter = new Linter();
127
+
128
+ const lintConfig = await linter.getDefaultLintConfig();
129
+
130
+ for (const value of Object.values(lintConfig)) {
131
+ expect(value).not.toBeNull();
132
+ }
133
+ });
124
134
  }
125
135
 
126
136
  test('Linters have the same config format', async () => {
package/src/Linter.ts CHANGED
@@ -25,6 +25,14 @@ export default interface Linter {
25
25
  /** Get the linter's current configuration. */
26
26
  getLintConfig(): Promise<LintConfig>;
27
27
 
28
+ /** Get the default (unset) linter configuration as JSON.
29
+ * This method does not effect the caller's lint configuration, nor does it return the current one. */
30
+ getDefaultLintConfigAsJSON(): Promise<string>;
31
+
32
+ /** Get the default (unset) linter configuration.
33
+ * This method does not effect the caller's lint configuration, nor does it return the current one. */
34
+ getDefaultLintConfig(): Promise<LintConfig>;
35
+
28
36
  /** Set the linter's current configuration. */
29
37
  setLintConfig(config: LintConfig): Promise<void>;
30
38
 
@@ -53,6 +53,18 @@ export default class LocalLinter implements Linter {
53
53
  return this.inner!.get_lint_config_as_object();
54
54
  }
55
55
 
56
+ async getDefaultLintConfigAsJSON(): Promise<string> {
57
+ const wasm = await loadWasm();
58
+
59
+ return wasm.get_default_lint_config_as_json();
60
+ }
61
+
62
+ async getDefaultLintConfig(): Promise<LintConfig> {
63
+ const wasm = await loadWasm();
64
+
65
+ return wasm.get_default_lint_config();
66
+ }
67
+
56
68
  async setLintConfig(config: LintConfig): Promise<void> {
57
69
  await this.initialize();
58
70
 
@@ -105,6 +105,14 @@ export default class WorkerLinter implements Linter {
105
105
  return JSON.parse(await this.getLintDescriptionsAsJSON()) as Record<string, string>;
106
106
  }
107
107
 
108
+ getDefaultLintConfigAsJSON(): Promise<string> {
109
+ return this.rpc('getDefaultLintConfigAsJSON', []);
110
+ }
111
+
112
+ async getDefaultLintConfig(): Promise<LintConfig> {
113
+ return JSON.parse(await this.getDefaultLintConfigAsJSON()) as LintConfig;
114
+ }
115
+
108
116
  /** Run a procedure on the remote worker. */
109
117
  private async rpc(procName: string, args: any[]): Promise<any> {
110
118
  const promise = new Promise((resolve, reject) => {
package/src/loadWasm.ts CHANGED
@@ -14,7 +14,7 @@ export function setWasmUri(uri: string) {
14
14
  curWasmUri = uri;
15
15
  }
16
16
 
17
- /** Load the WebAssembly manually and dynamically, making sure to setup infrastructure.
17
+ /** Load the WebAssembly manually and dynamically, making sure to set up infrastructure.
18
18
  * You can use an optional data URL for the WebAssembly file if the module is being loaded from a Web Worker.
19
19
  * */
20
20
  export default async function loadWasm() {