@rsvelte/compiler 0.7.5 → 0.7.8

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/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # rsvelte_lint
2
+
3
+ A fast, native Svelte linter built directly on the [rsvelte](../../) compiler —
4
+ no second ESTree parse, no Node.js in the hot path. See
5
+ [`docs/svelte-lint-design.md`](../../docs/svelte-lint-design.md) for the full
6
+ architecture & decision record.
7
+
8
+ It combines two diagnostic sources:
9
+
10
+ 1. **Validator wrap** — the rsvelte compiler already emits ~70 warning codes,
11
+ ~145 error codes, and 42 `a11y_*` rules during analysis. We surface those as
12
+ lint diagnostics with near-zero rule code (the "single biggest lever").
13
+ 2. **Native rule engine** — a single shared DFS over the template AST that
14
+ dispatches to `Rule` hooks, porting the proven `vize_patina` structure.
15
+
16
+ ## Try it
17
+
18
+ ```bash
19
+ cargo run -p rsvelte_lint -- crates/rsvelte_lint/demo/Demo.svelte
20
+ ```
21
+
22
+ See [`demo/README.md`](demo/README.md) for the expected output and the opt-in /
23
+ autofix / SARIF variants.
24
+
25
+ ## Usage
26
+
27
+ ```bash
28
+ cargo run -p rsvelte_lint -- src/ # lint a directory
29
+ cargo run -p rsvelte_lint -- --fix src/ # autofix in place
30
+ cargo run -p rsvelte_lint -- --format sarif src/ # SARIF for CI code-scanning
31
+ cargo run -p rsvelte_lint -- --list-rules # list the native rules
32
+ cargo run -p rsvelte_lint -- --print-eslint-config > eslint.rsvelte.json
33
+ ```
34
+
35
+ Key flags: `--config <file>` (auto-discovers `rsvelte-lint.json` upward when
36
+ omitted), `--config-from-eslint <eslint.config.js>` (import `svelte/*`
37
+ severities), `--off`/`--error <rule>`, `--max-warnings <n>`. Output formats:
38
+ `human`, `human-verbose`, `machine`, `machine-verbose`, `github-actions`,
39
+ `sarif`. Exit codes follow ESLint conventions (non-zero on any error or when
40
+ `--max-warnings` is exceeded).
41
+
42
+ ## Config (`rsvelte-lint.json`)
43
+
44
+ ```json
45
+ {
46
+ "extends": ["recommended"],
47
+ "rules": {
48
+ "svelte/no-at-html-tags": "error",
49
+ "svelte/button-has-type": ["warn", { "submit": true, "reset": false }],
50
+ "svelte/no-restricted-html-elements": ["error", { "elements": ["marquee"] }]
51
+ },
52
+ "files": ["src/**/*.svelte"],
53
+ "ignores": ["**/generated/**"]
54
+ }
55
+ ```
56
+
57
+ A rule value is a severity scalar (`"off"`/`"warn"`/`"error"` or `0`/`1`/`2`) or
58
+ a `[severity, ...options]` pair. `extends: ["none"]` starts from an empty
59
+ baseline.
60
+
61
+ ## Coexisting with ESLint
62
+
63
+ rsvelte-lint ships as a **complement** to ESLint, not (yet) a replacement. Run
64
+ `--print-eslint-config` to generate a flat-config snippet that turns the
65
+ native-owned `svelte/*` rules off in ESLint so each finding fires exactly once.
66
+
67
+ ## Native rules
68
+
69
+ Default-on (recommended): `no-at-html-tags`, `no-at-debug-tags` (autofix),
70
+ `require-each-key`, `no-dupe-else-if-blocks`, `no-dupe-style-properties`,
71
+ `no-object-in-text-mustaches`. Opt-in (off by default, matching
72
+ eslint-plugin-svelte's `recommended: false`): `button-has-type`,
73
+ `no-restricted-html-elements`. Each is a 1:1 port of the corresponding
74
+ eslint-plugin-svelte rule and validated against that plugin's own fixtures by the
75
+ compat oracle (`tests/eslint_plugin_oracle.rs`). Run `--list-rules` to see
76
+ defaults.
77
+
78
+ ## Testing
79
+
80
+ ```bash
81
+ cargo test -p rsvelte_lint
82
+ cargo clippy -p rsvelte_lint --all-targets --all-features -- -D warnings
83
+ ```
84
+
85
+ The compat oracle reads fixtures from the `eslint-plugin-svelte` reference
86
+ submodule and skips automatically when it isn't checked out.
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "@rsvelte/compiler",
3
3
  "type": "module",
4
- "description": "A high-performance Rust implementation of the Svelte compiler",
5
- "version": "0.7.5",
4
+ "description": "Fast native Svelte linter built on the rsvelte compiler (validator wrap + native rule engine)",
5
+ "version": "0.7.8",
6
6
  "license": "MIT",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/baseballyama/rsvelte.git"
10
- },
11
7
  "files": [
12
- "rsvelte_core_bg.wasm",
13
- "rsvelte_core.js",
14
- "rsvelte_core.d.ts"
8
+ "rsvelte_lint_bg.wasm",
9
+ "rsvelte_lint.js",
10
+ "rsvelte_lint.d.ts"
15
11
  ],
16
- "main": "rsvelte_core.js",
17
- "homepage": "https://github.com/baseballyama/rsvelte#readme",
18
- "types": "rsvelte_core.d.ts",
12
+ "main": "rsvelte_lint.js",
13
+ "types": "rsvelte_lint.d.ts",
19
14
  "sideEffects": [
20
15
  "./snippets/*"
21
16
  ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/baseballyama/rsvelte.git"
20
+ },
21
+ "homepage": "https://github.com/baseballyama/rsvelte#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/baseballyama/rsvelte/issues"
24
+ },
22
25
  "keywords": [
23
26
  "svelte",
24
27
  "compiler",
25
28
  "rust",
26
29
  "wasm"
27
- ],
28
- "bugs": {
29
- "url": "https://github.com/baseballyama/rsvelte/issues"
30
- }
30
+ ]
31
31
  }
@@ -41,6 +41,18 @@ export function compile_server(source: string, name: string): CompileResultWasm;
41
41
  */
42
42
  export function init(): void;
43
43
 
44
+ /**
45
+ * Lint `source`, returning a JSON array of diagnostics:
46
+ * `[{ "severity", "line", "column", "endLine", "endColumn", "code", "message" }]`.
47
+ * Lines are 1-indexed, columns 0-indexed (UTF-16), matching `rsvelte check`.
48
+ */
49
+ export function lint(source: string, filename: string): string;
50
+
51
+ /**
52
+ * The rsvelte-lint crate version (for the playground UI).
53
+ */
54
+ export function lint_version(): string;
55
+
44
56
  /**
45
57
  * Parse a Svelte component and return the AST as JSON.
46
58
  */
@@ -63,6 +75,8 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
63
75
 
64
76
  export interface InitOutput {
65
77
  readonly memory: WebAssembly.Memory;
78
+ readonly lint: (a: number, b: number, c: number, d: number) => [number, number];
79
+ readonly lint_version: () => [number, number];
66
80
  readonly __wbg_compileresultwasm_free: (a: number, b: number) => void;
67
81
  readonly __wbg_parseresultwasm_free: (a: number, b: number) => void;
68
82
  readonly compile_client: (a: number, b: number, c: number, d: number) => number;
@@ -1,4 +1,4 @@
1
- /* @ts-self-types="./rsvelte_core.d.ts" */
1
+ /* @ts-self-types="./rsvelte_lint.d.ts" */
2
2
 
3
3
  /**
4
4
  * Result of compiling a Svelte component.
@@ -166,6 +166,48 @@ export function init() {
166
166
  wasm.init();
167
167
  }
168
168
 
169
+ /**
170
+ * Lint `source`, returning a JSON array of diagnostics:
171
+ * `[{ "severity", "line", "column", "endLine", "endColumn", "code", "message" }]`.
172
+ * Lines are 1-indexed, columns 0-indexed (UTF-16), matching `rsvelte check`.
173
+ * @param {string} source
174
+ * @param {string} filename
175
+ * @returns {string}
176
+ */
177
+ export function lint(source, filename) {
178
+ let deferred3_0;
179
+ let deferred3_1;
180
+ try {
181
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
182
+ const len0 = WASM_VECTOR_LEN;
183
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
184
+ const len1 = WASM_VECTOR_LEN;
185
+ const ret = wasm.lint(ptr0, len0, ptr1, len1);
186
+ deferred3_0 = ret[0];
187
+ deferred3_1 = ret[1];
188
+ return getStringFromWasm0(ret[0], ret[1]);
189
+ } finally {
190
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
191
+ }
192
+ }
193
+
194
+ /**
195
+ * The rsvelte-lint crate version (for the playground UI).
196
+ * @returns {string}
197
+ */
198
+ export function lint_version() {
199
+ let deferred1_0;
200
+ let deferred1_1;
201
+ try {
202
+ const ret = wasm.lint_version();
203
+ deferred1_0 = ret[0];
204
+ deferred1_1 = ret[1];
205
+ return getStringFromWasm0(ret[0], ret[1]);
206
+ } finally {
207
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
208
+ }
209
+ }
210
+
169
211
  /**
170
212
  * Parse a Svelte component and return the AST as JSON.
171
213
  * @param {string} source
@@ -260,7 +302,7 @@ function __wbg_get_imports() {
260
302
  };
261
303
  return {
262
304
  __proto__: null,
263
- "./rsvelte_core_bg.js": import0,
305
+ "./rsvelte_lint_bg.js": import0,
264
306
  };
265
307
  }
266
308
 
@@ -436,7 +478,7 @@ async function __wbg_init(module_or_path) {
436
478
  }
437
479
 
438
480
  if (module_or_path === undefined) {
439
- module_or_path = new URL('rsvelte_core_bg.wasm', import.meta.url);
481
+ module_or_path = new URL('rsvelte_lint_bg.wasm', import.meta.url);
440
482
  }
441
483
  const imports = __wbg_get_imports();
442
484
 
Binary file
Binary file