Ignoring Lines and Sections

dotenv-diff can skip certain lines or code sections from being flagged during scanning. This is helpful when you know a specific warning is safe in your source code.

Ignore a Single Line

example.ts
const apiKey = 'safe_secret_123123123'; // dotenv-diff-ignore

This will suppress potential secret warnings for the hardcoded URL but still allow dotenv-diff to report other issues (like missing variables) elsewhere.

HTML

index.html
<a href="https://safe.example.com">Link</a> <!-- dotenv-diff-ignore -->

Or tsx/jsx Files

index.html
<p>Database: {process.env.DATABASE_URL}</p> {/* <!-- dotenv-diff-ignore --> */}

Ignore Entire Sections

template.html
// dotenv-diff-ignore-start
const skKey = 'sk_test_1234567890abcdef';
const testKey = process.env.TEST_API_KEY;
// dotenv-diff-ignore-end
Or
template.html
<!-- dotenv-diff-ignore-start -->
<p>Hardcoded data, images or links that are safe to ignore</p>
<img src="https://cdn.safe-service.com/image.png" />
<!-- dotenv-diff-ignore-end -->

All lines between <!-- dotenv-diff-ignore-start --> and <!-- dotenv-diff-ignore-end --> are ignored.

Alternative Configuration

If you need to ignore entire files, folders, or key patterns globally, consider using configuration options instead:

  • --exclude-files - File patterns to exclude from scanning.
  • --ignore - List of keys to ignore during comparison or scanning.
  • --ignore-regex - Regex patterns to skip matching keys.

For full list of supported options and examples, see the configuration and flags documentation on GitHub.