Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 855 Bytes

no-api-keys.md

File metadata and controls

32 lines (22 loc) · 855 Bytes

no-api-keys

Avoid placing API keys in source code. Instead use build tools that insert the API key using environment variables similar to:

const apiKey = process.env.GOOGLE_MAPS_API_KEY;

This pattern enables use of development keys and prevents use of production keys that may have higher quotas.

📋 This rule is enabled in plugin:googlemaps/recommended.

Rule details

❌ Examples of incorrect code:

const apiKey = "AIza00000000000000000000000000000000000";

✔️ Examples of correct code:

const apiKey = process.env.GOOGLE_MAPS_API_KEY;
const apiKey = "YOUR_API_KEY";
const apiKey = "AIzaSomeStringThatDoesntMatch";

Resources