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
.
❌ 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";