Skip to content

Commit b5368b3

Browse files
authored
Change prettier to a direct node use. (#4550)
The prettier pre-commit mirror is no longer supported (https://github.com/pre-commit/mirrors-prettier). This switches to a direct call, and updates to 3.3.3. And I'm now specifying types for it to apply to, rather than letting it ignore unknown files; overall just trying to separate out which linter sees what. To comment on formatting changes: - In most cases, seems to be getting confused by `[]` use in markdown when it's not part of a link. This looks like a regression, but not one we're broadly affected by. - p0107.md - caught an issue with a malformed broken bad link which I've tried to fix. - p3720.md - looks like a fix. Note, prettier has a 4.0.0 alpha release. As best as I could tell, that only affected the .prettierrc.yaml processing. I changed the glob there for forwards compatibility.
1 parent 4eb955b commit b5368b3

File tree

10 files changed

+37
-30
lines changed

10 files changed

+37
-30
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ repos:
4848
rev: 1b2427a2b785cc4aac97c19bb4b9a0de063f9547 # frozen: 24.10.0
4949
hooks:
5050
- id: black
51-
- repo: https://github.com/pre-commit/mirrors-prettier
52-
rev: ffb6a759a979008c0e6dff86e39f4745a2d9eac4 # frozen: v3.1.0
51+
- repo: local
5352
hooks:
5453
- id: prettier
54+
name: prettier
55+
language: node
56+
additional_dependencies: ['[email protected]']
57+
types_or: [html, javascript, markdown, yaml]
58+
entry: npx prettier --write --log-level=warn
5559
- repo: local
5660
hooks:
5761
- id: buildifier

.prettierrc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ tabWidth: 2
99
trailingComma: 'es5'
1010
useTabs: false
1111
overrides:
12-
- files: '*.md'
12+
- files: '**/*.md'
1313
options:
1414
tabWidth: 4

docs/design/pattern_matching.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ _pattern_ `=` _expression_ `;`.
335335
A tuple of patterns can be used as a pattern.
336336

337337
- _tuple-pattern_ ::= `(` [_expression_ `,`]\* _proper-pattern_ [`,`
338-
_pattern_]\* `,`? `)`
338+
_pattern_]\*
339+
`,`? `)`
339340
- _proper-pattern_ ::= _tuple-pattern_
340341

341342
A _tuple-pattern_ containing no commas is treated as grouping parens: the
@@ -355,7 +356,8 @@ compares fields left-to-right.
355356
A struct can be matched with a struct pattern.
356357

357358
- _proper-pattern_ ::= `{` [_field-init_ `,`]\* _proper-field-pattern_ [`,`
358-
_field-pattern_]\* `}`
359+
_field-pattern_]\*
360+
`}`
359361
- _proper-pattern_ ::= `{` [_field-pattern_ `,`]+ `_` `}`
360362
- _field-init_ ::= _designator_ `=` _expression_
361363
- _proper-field-pattern_ ::= _designator_ `=` _proper-pattern_

docs/design/values.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,8 @@ alternatives considered section of [P2006]:
674674
### Pointer syntax
675675

676676
The type of a pointer to a type `T` is written with a postfix `*` as in `T*`.
677-
Dereferencing a pointer is a [_reference expression_] and is written with a
678-
prefix `*` as in `*p`:
677+
Dereferencing a pointer is a [_reference expression_] and is written with a prefix
678+
`*` as in `*p`:
679679

680680
```carbon
681681
var i: i32 = 42;

proposals/p0107.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,10 @@ We could instead use `.` for library names and `/` for packages, such as
553553
Advantages:
554554
555555
- Clearer distinction between the package and library, increasing readability.
556-
- We have chosen not to [enforce file system
557-
paths](#strict-association-between-the-file
558-
system-path-and-librarynamespace) in order to ease refactoring, and
559-
encouraging a mental model where they may match could confuse users.
556+
- We have chosen not to
557+
[enforce file system paths](#should-there-be-a-tight-association-between-file-paths-and-packageslibraries)
558+
in order to ease refactoring, and encouraging a mental model where they may
559+
match could confuse users.
560560
561561
Disadvantages:
562562

proposals/p1083.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ Disadvantages:
286286
expectations, for example in some important bit-manipulation cases.
287287
- Give integer types a range of values rather than simply a bit-width. For
288288
example, we can say that negation on `i32` produces a type that can
289-
represent [-2<sup>31</sup>+1, 2<sup>31</sup>], which still fits in 32
290-
bits. However, this would add significant complexity to the type system,
291-
and with this approach, division would still increase the bit width: for
292-
example, `a / b`, where `a` and `b` are `iN`s, has 2<sup>`N`</sup>+1
293-
distinct possible values. This is especially surprising because integer
294-
division is usually expected to make a number smaller!
289+
represent [-2<sup>31</sup>+1, 2<sup>31</sup>], which still fits in 32 bits.
290+
However, this would add significant complexity to the type system, and with
291+
this approach, division would still increase the bit width: for example,
292+
`a / b`, where `a` and `b` are `iN`s, has 2<sup>`N`</sup>+1 distinct possible
293+
values. This is especially surprising because integer division is usually
294+
expected to make a number smaller!
295295
- Refactoring code becomes more challenging, as the appropriate intermediate
296296
type must be determined. Mitigating this, the type system would inform the
297297
programmer when they make a mistake.
@@ -379,9 +379,9 @@ cases are:
379379
difference of such unsigned quantities, and it's generally preferable for
380380
such subtractions to produce a negative result rather than a subtle bug.
381381
Moreover, while a restriction to non-negative values is common, supporting
382-
only the case of a range restriction to [0, 2<sup>N</sup>-1], but not any
383-
other range, does not do a good job of addressing the general desire to
384-
capture intent and to make invalid states unrepresentable.
382+
only the case of a range restriction to [0, 2<sup>N</sup>-1], but not any other
383+
range, does not do a good job of addressing the general desire to capture intent
384+
and to make invalid states unrepresentable.
385385
- Ability to reduce storage size. Spending a sign bit every time a number is
386386
stored, even when it's known to be non-negative is wasteful. This is an
387387
important concern, and one we should address, but it's thought to be better

proposals/p2188.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ _pattern_ `=` _expression_ `;`.
362362
A tuple of patterns can be used as a pattern.
363363

364364
- _tuple-pattern_ ::= `(` [_expression_ `,`]\* _proper-pattern_ [`,`
365-
_pattern_]\* `,`? `)`
365+
_pattern_]\*
366+
`,`? `)`
366367
- _proper-pattern_ ::= _tuple-pattern_
367368

368369
A _tuple-pattern_ containing no commas is treated as grouping parens: the
@@ -382,7 +383,8 @@ compares fields left-to-right.
382383
A struct can be matched with a struct pattern.
383384

384385
- _proper-pattern_ ::= `{` [_field-init_ `,`]\* _proper-field-pattern_ [`,`
385-
_field-pattern_]\* `}`
386+
_field-pattern_]\*
387+
`}`
386388
- _proper-pattern_ ::= `{` [_field-pattern_ `,`]+ `_` `}`
387389
- _field-init_ ::= _designator_ `=` _expression_
388390
- _proper-field-pattern_ ::= _designator_ `=` _proper-pattern_

proposals/p2550.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ provide a `main` function that is used as the entry point.
103103
In the `Main` package, the package declaration does not explicitly specify a
104104
package name. The package declaration syntax becomes:
105105

106-
- `package` _Foo_ [`library "`_Bar_`"`] \(`api` | `impl`) `;`, unchanged from
107-
#107, for a file that is part of a package other than the `Main` package.
106+
- `package` _Foo_ [`library "`_Bar_`"`] \(`api` | `impl`) `;`, unchanged from #107,
107+
for a file that is part of a package other than the `Main` package.
108108
- `library "`_Bar_`"` (`api` | `impl`) `;` for a library that is part of the
109109
`Main` package.
110110
- Omitted entirely for an `impl` file in the `Main` package that is not part

proposals/p3564.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ evaluation. We executed on this really well, but with mixed results.
5656
https://github.com/carbon-language/carbon-lang/blob/840cb1bed7cf9bd57e000cb4a61e986c383d3038/docs/project/roadmap.md
5757

5858
On getting ready for evaluation, we made fantastic progress on getting the
59-
language (design) ready. We have [milestone definitions], and closed the most
60-
critical gaps in the design from the start of the year. The remaining gaps are
61-
either lower risk, almost finished, or really need interop to effectively
62-
explore.
59+
language (design) ready. We have [milestone definitions], and closed the most critical
60+
gaps in the design from the start of the year. The remaining gaps are either lower
61+
risk, almost finished, or really need interop to effectively explore.
6362

6463
[milestone definitions]: /docs/project/milestones.md
6564

proposals/p3720.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ Assert((r as __Binding_C_Static).(Call(()).Op)() == 2);
229229
How does this arise?
230230

231231
1. First the simple member access is resolved using the type of the receiver: \
232-
`v.F` -> `v.(C.F)`, `v.Static` -> `v.(C.Static)`, `r.F` -> `r.(C.F)`, `r.Static`
233-
-> `r.(C.Static)`. \
232+
`v.F` -> `v.(C.F)`, `v.Static` -> `v.(C.Static)`, `r.F` -> `r.(C.F)`,
233+
`r.Static` -> `r.(C.Static)`. \
234234
Note that `C.F` is `__C_F` with type `__TypeOf_C_F`, and `C.Static` is
235235
`__C_Static` with type `__TypeOf_C_Static`.
236236
2. It then looks at the expression to the left of the `.`:

0 commit comments

Comments
 (0)