Clarify the working directory used for multiple config files
envgap__lint-staged__lint-staged-1768
01 / FAILURE SIGNATURE
As reported upstream
No identifying execution failure has been captured.
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
f03b9a9486c769ebe3635d1f8ac7c7539fcff435- Manifest
package.json- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
lint-staged/lint-staged #1768 · read the original issue
Given a basic monorepo (or other project with multiple config files)
```
.
├── ...
├── lint-staged.config.js <-- { "*.{js,css,html}": "eslint --fix" }
├── package.json
└── packages
└── frontend
├── ...
├── lint-staged.config.js <-- { ...baseConfig, "*.js": "tsc" }
└── package.json
```
It is currently not clear from the docs that any commands run on files under `packages/frontend` will run with a `cwd` of `packages/frontend` and _not_ the root where the `lint-staged` command was run.
For context, in the example above, we updated our eslint config to rely on another file at the project root. However when running `lint-staged` the `eslint` command was not finding the file because the `cwd` had changed unexpectedly.
The [`--cwd` flag docs](https://github.com/lint-staged/lint-staged#--cwd-path) state "By default tasks run in the current working directory. Use the `--cwd some/directory` to override this". To me this implies that commands will always be run at the root regardless of configs. An update here saying this may be overridden by nested configs would be good.
The [section on config files themselves](https://github.com/lint-staged/lint-staged#configuration) only states that "For a given staged file, the closest configuration file will always be used". This section makes not mention that the `cwd` could change based on this file. An update here saying that commands will always run from this as the new root would be helpful.
The [section on using in monorepos](https://github.com/lint-staged/lint-staged#how-to-use-lint-staged-in-a-multi-package-monorepo) expands on the idea of using the "closest configuration file". This makes sense to me but nowhere in this does it imply that the commands would actually run relative to said config file. There is a mention at the bottom of this section about using the `--cwd` flag to only run a specific directory but to me that doesn't imply that the `cwd` would change when _not_ using that flag.
I feel like I have the exact opposite expectation as outlined in https://github.com/lint-staged/lint-staged/issues/1716#issuecomment-365450443304 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]