aspect-build / aspect-build/rules_lint
[FR]: Split `javascript` attribute into separate `json` and `vue` attributes
- Dominant language
- Starlark
- Stars
- 154
- Forks
- 125
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 20
Description
### What is the current behavior?
The `javascript` attribute in `format_multirun` configures a single formatter binary that is automatically invoked for multiple file types: `.js`, `.jsx`, `.mjs`, `.cjs`, `.ts`, `.tsx`, `.mts`, `.cts`, `.json`, `.json5`, `.jsonc`, `.vue`, etc
This bundling is implemented in `format/private/format.sh`:
```bash
if [[ "$lang" == "JavaScript" ]]; then
for sublang in "JSON" "JSON5" "JSON with Comments" "TSX" "TypeScript" "Vue"; do
process_args_in_batches "$sublang" "$bin" "${flags:-""}" "$@"
done
fi
```
Users cannot format JS/TS code files with one tool while using a different tool for JSON or Vue files.
### Describe the feature
Split the javascript attribute into separate attributes for distinct file formats:
| File Type | Extensions |
|-----------|------------|
| JavaScript | `.js`, `.jsx`, `.mjs`, `.cjs` |
| TypeScript | `.ts`, `.tsx`, `.mts`, `.cts` |
| JSON | `.json`, `.json5`, `.jsonc` |
| Vue | `.vue` |
For backward compatibility, if json or vue are unset but javascript is set, the javascript formatter is used as a fallback.
## Motivation
https://oxc.rs/docs/guide/usage/formatter is a new Rust-based JavaScript/TypeScript formatter that is 30-45× faster than Prettier. Its single-binary, zero-dependency architecture makes it well-suited for Bazel's hermetic execution model—particularly in Remote Build Execution environments where Node.js cold-start overhead compounds across many format actions.
However, oxfmt only supports JS/TS code files. It does not support JSON or Vue. The current bundling of all these formats under the javascript attribute prevents users from adopting oxfmt for code files while continuing to use Prettier for JSON and Vue.
This change enables:
```
format_multirun(
name = "format",
javascript = ":oxfmt", # JS/TS code files
json = ":prettier", # JSON data files
vue = ":prettier", # Vue SFCs
)
```
Contributor guide
Research direction
Start in format/private/format.sh, where the JavaScript branch currently invokes one formatter for JSON, JSON5, TypeScript, TSX, and Vue. Trace the format_multirun attribute handling, then verify that JavaScript, TypeScript, JSON, and Vue use their separate formatters while unset json or vue attributes fall back to javascript.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, shell
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100