# Use prefix GRIDSOME_ when using process.env in browser (gridsome/use-env-prefix)

# 📖 Rule Details

  • This rule reports the process.env expression which do not include prefix GRIDSOME_.

If you want to know more information, see: Environment variables (opens new window)

👎 Examples of incorrect code for this rule:

<template></template>

<script>
  export default {
    data() {
      return {
        url: process.env.API_URL, // Possible error
      };
    },
  };
</script>

👍 Examples of correct code for this rule:

<template></template>

<script>
  export default {
    data() {
      return {
        url: process.env.GRIDSOME_API_URL,
      };
    },
  };
</script>

# 🔧 Options

{
  "gridsome/use-env-prefix": [
    "warn",
    {
      {
        "pathsForBrowserfile": ["src/**/*"],
        "envPath": ".env",
      },
    }
  ]
}
  • pathsForBrowserfile (string[]) ... This option can specify paths for browser.
    • default ... ["src/**/*"]
  • envPath (string) ... This option can specify path for env file.
    • default ... ".env"