@boring-stack-pkg/eslint-plugin-env-access
v0.1.3
Published
ESLint rules that force all env-var reads through a single validated singleton — no raw process.env, every key must exist in the schema.
Downloads
2,618
Maintainers
Readme
eslint-plugin-env-access
ESLint rules that force every environment-variable read through a single validated singleton:
no-direct-process-env— no rawprocess.env.Xaccess outside the singleton's own files. Forces every consumer through the typed, boot-validated entrypoint.env-var-must-have-schema-entry— everyenv.Xaccess must correspond to a key declared in the schema file. Catches typos that inference alone can miss when types cross package boundaries.
Install
pnpm add -D @boring-stack-pkg/eslint-plugin-env-accessPeer deps: eslint >= 8.57, @typescript-eslint/parser >= 8,
typescript >= 5.
Use (flat config)
import tsParser from "@typescript-eslint/parser";
import envAccess from "@boring-stack-pkg/eslint-plugin-env-access";
export default [
{
files: ["**/*.{ts,tsx}"],
languageOptions: { parser: tsParser },
plugins: { "env-access": envAccess },
rules: {
"env-access/no-direct-process-env": "error",
"env-access/env-var-must-have-schema-entry": "error",
},
},
];Or use the bundled config:
import envAccess from "@boring-stack-pkg/eslint-plugin-env-access";
export default [envAccess.configs.recommended];Rules
| Rule | Description | Fixable |
| -------------------------------------------------------------------------------- | -------------------------------------------------- | ------- |
| no-direct-process-env | Disallow raw process.env.X outside allowed files | – |
| env-var-must-have-schema-entry | Every env.X must exist in the schema file | – |
License
MIT.
