turbo/no-undeclared-env-vars not recognizing changes

Viewed 86

I'm updating my project to use turborepo and I'm encountering a strange behavior with turbo/no-undeclared-env-vars.

In the starter project I added a hello constant from the environment variables:

export default function Web() {
  const hello = process.env.HELLO;
  return (
    <div>
      <h1>{hello}</h1>
      <Button />
    </div>
  );
}

And when running npm run lint I get the expected error:

web:lint: ./pages/index.tsx
web:lint: 4:17  Error: $HELLO is not listed as a dependency in turbo.json  turbo/no-undeclared-env-vars

But when I add it to turbo.json and re-run npm run lint it still shows the error.

{
  "$schema": "https://turborepo.org/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["^build", "$HELLO"],
      "outputs": ["dist/**", ".next/**"]
    },
    "lint": {
      "outputs": []
    },
    "dev": {
      "cache": false
    }
  }
}

It seems to be using the cache because if I remove the cache from apps/web/.next/.cache/.eslint and run it again it shows no error anymore.

It also works the other way. If I now remove the $HELLO from turbo.json and run npm run lint again it says there are not errors, while it should say that it is unlisted. Here as well, removing the cache manually shows it again but it seems to me that it should detect it automatically, no?

I also tried updating turbo.json not to use the cache during lint but that is also not helping:

{
  "$schema": "https://turborepo.org/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["^build", "$HELLO"],
      "outputs": ["dist/**", ".next/**"]
    },
    "lint": {
      "outputs": [],
      "cache": false
    },
    "dev": {
      "cache": false
    }
  }
}

Any suggestions?

0 Answers
Related