Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate environment variables used in runtimeConfig #267

Open
danielroe opened this issue Jan 27, 2023 · 5 comments
Open

validate environment variables used in runtimeConfig #267

danielroe opened this issue Jan 27, 2023 · 5 comments
Labels
enhancement New feature or request eslint-plugin

Comments

@danielroe
Copy link
Member

they need to match the object pattern - would be nice if we could provide support for this

@pi0
Copy link
Member

pi0 commented Jan 27, 2023

Maybe move to plugin repo?

@danielroe
Copy link
Member Author

I was thinking to rename to nuxt/eslint and include plugin in this repo.

Copy link
Member

atinux commented Feb 20, 2023

Looks good to me!

@antfu
Copy link
Member

antfu commented Mar 21, 2024

@danielroe Could you elaborate more on what you expect on this? I could give it a try

@antfu antfu added enhancement New feature or request eslint-plugin labels Mar 21, 2024
@danielroe
Copy link
Member Author

danielroe commented Mar 21, 2024

I'm thinking:

export default defineNuxtConfig({
  runtimeConfig: {
    // should be process.env.NUXT_GITHUB_TOKEN
    githubToken: process.env.MY_GITHUB_TOKEN,
    public: {
      // should be process.env.NUXT_PUBLIC_SOME_VAR
      someVar: process.env.SOMEVAR
    }
  }
})

The reason being that often people are not aware that their nuxt config isn't 'reread' in production. And they may have these variables set in an env - which works in dev, but will fail when built.

It should also be valid to set these variables to some value without referencing process.env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request eslint-plugin
Projects
None yet
Development

No branches or pull requests

4 participants