findForbiddenEnvReads
Finds import.meta.env.NAME reads of names the browser does not get.
Finds import.meta.env.NAME reads of names the browser does not get.
Import#
ts
import { findForbiddenEnvReads } from "@shadow-js/dusk/vite";
Signature#
ts
function findForbiddenEnvReads(
code: string,
file: string,
prefixes: readonly string[],
declared: readonly string[] = [],
): EnvViolation[]
Parameters#
| Name | Description |
|---|---|
code |
Module text (TypeScript and JSX allowed). |
file |
File name, for the language. |
prefixes |
Allowed prefixes, from publicPrefixes. |
declared |
Names declared in .env.public, which the browser gets whatever their prefix. |
Returns#
One entry per forbidden read, in source order.
Examples#
ts
findForbiddenEnvReads("export const k = import.meta.env.API_KEY;", "a.ts", ["DUSK_PUBLIC_"]);