eslint-plugin-kerfjs 4.2.0-beta.3 → 4.2.0-beta.5
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.
|
@@ -35,9 +35,18 @@ Sanitization pipelines (`DOMPurify`, `sanitize-html`, server-rendered trusted co
|
|
|
35
35
|
- Bare `raw(expr)` calls
|
|
36
36
|
- Member-expression calls `kerf.raw(expr)` and `kerfjs.raw(expr)`
|
|
37
37
|
|
|
38
|
-
## The
|
|
38
|
+
## The sanctioned escape hatch: an explicit `eslint-disable`
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
There is one sanctioned way to inject a genuinely-trusted dynamic value — a CSRF token, a trusted `<script src>`, a server-issued id, a sanitized Markdown render: call `raw()` and acknowledge it with an inline `// eslint-disable-next-line kerfjs/no-raw-with-dynamic-arg` on that call. The disable comment is the audit marker — it says "a human reviewed this and it's trusted," and it's greppable across the codebase. There is deliberately no separate lint-exempt function; a second name that silently bypasses this rule would remove exactly the audit trail the rule exists to create.
|
|
41
|
+
|
|
42
|
+
## A lot of `raw()` is a smell
|
|
43
|
+
|
|
44
|
+
If a codebase reaches for `raw()` often, that's usually a sign the wrong tool is being used. kerf escapes automatically everywhere else, and the common cases have a safer, first-class answer:
|
|
45
|
+
|
|
46
|
+
- **Interpolating dynamic text or attributes?** Plain JSX escapes it (`<p>{value}</p>`, `class={sig}`) — no `raw()` needed.
|
|
47
|
+
- **Composing markup?** Build a `SafeHtml` the normal way — a JSX expression, the `html` tagged template (`kerfjs/html`), `each()`, or a component function returning JSX. All produce trusted `SafeHtml` without hand-writing an HTML string.
|
|
48
|
+
|
|
49
|
+
Prefer steering those call sites toward `SafeHtml`/JSX rather than suppressing the warning. Reserve `raw()` (with its `eslint-disable`) for the genuinely-trusted dynamic value that has no first-class form.
|
|
41
50
|
|
|
42
51
|
## What this rule does NOT catch
|
|
43
52
|
|