@mimik/eslint-plugin-document-env
v2.1.2
Published
validation of environment variable documentation
Downloads
378
Readme
@mimik/eslint-plugin-document-env
An ESLint plugin that validates that all process.env usages are properly documented in markdown-style block comments.
Installation
npm install --save-dev @mimik/eslint-plugin-document-envUsage
Add the plugin to your eslint.config.js:
import documentEnv from '@mimik/eslint-plugin-document-env';
export default [
{
plugins: {
'@mimik/document-env': documentEnv,
},
rules: {
'@mimik/document-env/validate-document-env': 'error',
},
},
];Rule: validate-document-env
Verifies that when an environment variable is used via process.env, there is a corresponding documentation entry in a block comment with the following table header:
* | Env variable name | Description | Default | Comments |
* | ----------------- | ----------- | ------- | -------- |What Gets Checked
- Every
process.env.VAR_NAMEorprocess.env['VAR_NAME']access must have a matching row in a documentation table - The description column must not be empty or blank
- The variable must not be documented more than once (across separate tables or within the same table)
Messages
| Message ID | Description |
|---|---|
| unDocumentedProcessEnv | No documentation table entry found for the variable |
| unDescribedProcessEnv | Table entry exists but the description column is empty |
| duplicatedProcessEnv | Variable is documented in multiple tables or multiple rows |
Example
/**
* | Env variable name | Description | Default | Comments |
* | ----------------- | ----------- | ------- | -------- |
* | PORT | The port the server listens on | 3000 | |
* | NODE_ENV | Runtime environment | development | |
*/
const port = process.env.PORT; // OK
const env = process.env.NODE_ENV; // OK
const secret = process.env.SECRET; // Error: Undocumented environment variable: SECRETAPI Reference
License
MIT
