turbo
b1eda9d8 - Make ESLint envVar aware. (#2850)

Commit
3 years ago
Make ESLint envVar aware. (#2850) This optimizes for the typical use case. This means `process.cwd()` to find the closest `turbo.json` to the place where `eslint` was executed. Currently: - Fail, and have no keys contributing to the ESLint incremental cache. (Current behavior.) After this PR, depending on your invocation patterns this will: - Do _exactly_ what you want it to do. (Any time you invoke ESLint because we're finding up to the root of the project we will find the singular correct `turbo.json`.) - Fail, and have no content contributing to the ESLint incremental cache. (You're running from outside the root. Don't do that.) Once we're in composable `turbo.json` land this will either: - Do _exactly_ what you want it to do. (Your execution directory will find up to the closest `turbo.json` which is the correct composition entry point. Will be the majority of use-cases and matches the Turborepo recommendations.) - Fail, and have no content contributing to the ESLint incremental cache. (You're running from outside the root. Don't do that.) - Fail, and have the wrong values contributing to the key for the incremental cache. (You ran your command from a place where you "miss" the correct `turbo.json` when trying to find up. This failure is undetectable.) *** This last state needs the most explanation. When this occurs we will be adding a random set of environment variables to the cache key—and not necessarily the ones that matter. This will occur if `process.cwd()` does not represent the correct place in the file system to start walking to find `turbo.json` files. When this happens the ESLint incremental cache will be keyed on the wrong thing and won't necessarily invalidate for the correct changes, and will possibly invalidate for unrelated changes. The workaround here would be to modify the `.eslintrc.js` file in question to _not_ use `"extends": ["turbo"]` and look like the following: ```js { "plugins": ["turbo"], "rules": { "turbo/no-undeclared-env-vars": [ "error", { "turboConfig": require("path/to/turbo.json") } ] } } ``` We can't notify users of this failure which makes it especially rough.
Author
Parents
Loading