rescript-lang / rescript-lang/rescript
formatter aggressively reformats externs into a mess
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 7.5k
- Forks
- 485
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 55
Description
background: https://forum.rescript-lang.org/t/my-main-gripes-with-rescript-constructive-criticism/6981/5
right now, the formatter is ruthless in formatting. this is usually appreciated, but for externs, it becomes messy sometimes.
imagine a file such as
@module("moduleX") external f1: someType1 => someType2 = "someFunc"
@module("moduleX") external f2: anotherType1 => thirdType = "someOtherFunc"
@module("moduleX") external f3: interestingType1 => interestingType2 = "someFuncWithALongerName"
@module("moduleX") external f4: t1 => t2 = "anotherFunc"
the formatter reformats it to:
@module("moduleX") external f1: someType1 => someType2 = "someFunc"
@module("moduleX") external f2: anotherType1 => thirdType = "someOtherFunc"
@module("moduleX")
external f3: interestingType1 => interestingType2 = "someFuncWithALongerName"
@module("moduleX") external f4: t1 => t2 = "anotherFunc"
because of the different lengths. this makes the externs really difficult to parse easily by looking at them because there are often repetitions and variants in the functions, so keeping them all on the same format is easier despite some lines being a little longer than what the formatter prefers.
let's discuss potential solutions for this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the formatter behavior and extern examples in this issue, then read the linked forum discussion for the proposed solutions and trade-offs. Done is not yet defined: the issue needs an agreed formatting rule before a newcomer can identify the implementation entry point or validation criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100