aspect-build / aspect-build/rules_lint
[Bug]: Prettier Config Overrides with Files and Slashes Doesn't Match
- Dominant language
- Starlark
- Stars
- 154
- Forks
- 125
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 20
Description
### What happened?
Prettier overrides with a slash such as `overrides: { files: ["**/*.json"], parser: "json" }` if the following the current example to use a [hermetic prettier config file](https://github.com/aspect-build/rules_lint/issues/176).
The motivating example was to use the folder name to change prettier-plugin-sql dialect options.
The reason this breaks is that prettier [calculates a relative path](https://github.com/prettier/prettier/blob/main/src/config/resolve-config.js#L89) from the config file to source file which is then used to evaluate the glob patterns. Their matching engine does not match `../` with `**`. Any pattern without a `/` is handled separately and works.
### Version
Development (host) and target OS/architectures: Ubuntu 22.04
Output of `bazel --version`: 7.4.0
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: HEAD
Language(s) and/or frameworks involved: prettier
### How to reproduce
```shell
A breaking example will be pushed
bazel run //tools/format:format_test_SQL_with_prettier src/hello.sql
```
### Any other information?
_No response_
Contributor guide
Research direction
Start with the //tools/format:format_test_SQL_with_prettier target and run the reproduction command against src/hello.sql. Compare the hermetic config behavior with Prettier's resolve-config.js path calculation and verify that slash-containing override patterns match as intended.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100