Skip to content

Commit ca9f420

Browse files
authored
feat(fmt): dprint for toml, json, md, dockerfile, ts, & yml (#10824)
* feat(fmt): dprint for toml, json, md, dockerfile, ts, & yml * chore: fmt
1 parent ed86c64 commit ca9f420

22 files changed

+198
-113
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ testdata/cheats/Vm.sol linguist-generated
44
# See <https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header>
55
*.rs diff=rust
66
crates/lint/testdata/* text eol=lf
7+
8+
dprint.json linguist-language=JSON-with-Comments
9+
.devcontainer/devcontainer.json linguist-language=JSON-with-Comments

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ the code change.
3131

3232
- [ ] Added Tests
3333
- [ ] Added Documentation
34-
- [ ] Breaking changes
34+
- [ ] Breaking changes

.github/workflows/dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
# Run weekly
88
- cron: "0 0 * * SUN"
99
workflow_dispatch:
10-
# Needed so we can run it manually
10+
# Needed so we can run it manually
1111

1212
permissions:
1313
contents: write

.github/workflows/docker-publish.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ jobs:
4040
if: github.event_name != 'pull_request'
4141
uses: docker/login-action@v2
4242
with:
43-
registry: ${{ env.REGISTRY }}
44-
username: ${{ github.actor }}
45-
password: ${{ secrets.GITHUB_TOKEN }}
43+
registry: ${{ env.REGISTRY }}
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
4646

4747
# Extract metadata (tags, labels) for Docker
4848
# https://github.com/docker/metadata-action
4949
- name: Extract Docker metadata
5050
id: meta
5151
uses: docker/metadata-action@v4
5252
with:
53-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5454

5555
# Creates an additional 'latest' or 'nightly' tag
5656
# If the job is triggered via cron schedule, tag nightly and nightly-{SHA}
@@ -59,22 +59,22 @@ jobs:
5959
- name: Finalize Docker Metadata
6060
id: docker_tagging
6161
run: |
62-
if [[ "${{ github.event_name }}" == 'schedule' ]]; then
63-
echo "cron trigger, assigning nightly tag"
64-
echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT
65-
elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then
66-
echo "manual trigger from master/main branch, assigning latest tag"
67-
echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT
68-
else
69-
echo "Neither scheduled nor manual release from main branch. Just tagging as branch name"
70-
echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
71-
fi
62+
if [[ "${{ github.event_name }}" == 'schedule' ]]; then
63+
echo "cron trigger, assigning nightly tag"
64+
echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT
65+
elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then
66+
echo "manual trigger from master/main branch, assigning latest tag"
67+
echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT
68+
else
69+
echo "Neither scheduled nor manual release from main branch. Just tagging as branch name"
70+
echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
71+
fi
7272
7373
# Log docker metadata to explicitly know what is being pushed
7474
- name: Inspect Docker Metadata
7575
run: |
76-
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}"
77-
echo "LABELS -> ${{ steps.meta.outputs.labels }}"
76+
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}"
77+
echo "LABELS -> ${{ steps.meta.outputs.labels }}"
7878
7979
- name: Build and push foundry image
8080
run: make DOCKER_IMAGE_NAME=${{ steps.docker_tagging.outputs.docker_tags }} CARGO_TAG_NAME=${{ inputs.tag_name }} PROFILE=maxperf docker-build-push

.github/workflows/nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
# Run weekly
66
- cron: "0 0 * * SUN"
77
workflow_dispatch:
8-
# Needed so we can run it manually
8+
# Needed so we can run it manually
99

1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
shell: bash
159159
run: |
160160
set -eo pipefail
161-
flags=(--target $TARGET --profile $PROFILE --bins
161+
flags=(--target $TARGET --profile $PROFILE --bins
162162
--no-default-features --features aws-kms,gcp-kms,cli,asm-keccak)
163163
164164
# `jemalloc` is not fully supported on MSVC or aarch64 Linux.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ out.json
77
.vscode
88
.claude
99
CLAUDE.md
10+
.env
11+
node_modules
12+
dist
13+
bin
14+
_

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Be aware that _how_ you communicate requests and reviews in your feedback can ha
186186

187187
##### Abandoned or stale pull requests
188188

189-
If a pull request appears to be abandoned or stalled, it is polite to first check with the contributor to see if they intend to continue the work before checking if they would mind if you took it over (especially if it just has nits left). When doing so, it is courteous to give the original contributor credit for the work they started, either by preserving their name and e-mail address in the commit log, or by using the `Author: ` or `Co-authored-by: ` metadata tag in the commits.
189+
If a pull request appears to be abandoned or stalled, it is polite to first check with the contributor to see if they intend to continue the work before checking if they would mind if you took it over (especially if it just has nits left). When doing so, it is courteous to give the original contributor credit for the work they started, either by preserving their name and e-mail address in the commit log, or by using the `Author:` or `Co-authored-by:` metadata tag in the commits.
190190

191191
_Adapted from the [ethers-rs contributing guide](https://github.com/gakonst/ethers-rs/blob/master/CONTRIBUTING.md)_.
192192

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1.4
22

3-
FROM alpine:3.21 as build-environment
3+
FROM alpine:3.21 AS build-environment
44

55
ARG TARGETARCH
66
WORKDIR /opt
@@ -30,7 +30,7 @@ RUN --mount=type=cache,target=/root/.cargo/registry --mount=type=cache,target=/r
3030
&& strip out/chisel \
3131
&& strip out/anvil;
3232

33-
FROM alpine:3.21 as foundry-client
33+
FROM alpine:3.21 AS foundry-client
3434

3535
RUN apk add --no-cache linux-headers git gcompat libstdc++
3636

@@ -43,7 +43,6 @@ RUN adduser -Du 1000 foundry
4343

4444
ENTRYPOINT ["/bin/sh", "-c"]
4545

46-
4746
LABEL org.label-schema.build-date=$BUILD_DATE \
4847
org.label-schema.name="Foundry" \
4948
org.label-schema.description="Foundry" \

FUNDING.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"opRetro": {
88
"projectId": "0x4562c0630907577f433cad78c7e2cc03349d918b6c14ef982f11a2678f5999ad"
99
}
10-
}
10+
}

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,21 @@ deny: ## Perform a `cargo` deny check.
133133
pr: ## Run all checks and tests.
134134
make deny && \
135135
make lint && \
136-
make test
136+
make test
137+
138+
# dprint formatting commands
139+
.PHONY: dprint-fmt
140+
dprint-fmt: ## Format code with dprint
141+
@if ! command -v dprint > /dev/null; then \
142+
echo "Installing dprint..."; \
143+
cargo install dprint; \
144+
fi
145+
dprint fmt
146+
147+
.PHONY: dprint-check
148+
dprint-check: ## Check formatting with dprint
149+
@if ! command -v dprint > /dev/null; then \
150+
echo "Installing dprint..."; \
151+
cargo install dprint; \
152+
fi
153+
dprint check

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ _In the above benchmarks, compilation was always skipped_
115115
<img src=".github/assets/build_benchmark_solady_light.png" width="600px">
116116
</picture>
117117

118-
<picture>
118+
<picture>
119119
<source media="(prefers-color-scheme: dark)" srcset=".github/assets/build_benchmark_openzeppelin_dark.png" width="600px">
120120
<img src=".github/assets/build_benchmark_openzeppelin_light.png" width="600px">
121121
</picture>

crates/cheatcodes/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The JSON interface is guaranteed to be stable, and can be used by third-party to
2626
the Foundry cheatcodes externally.
2727

2828
For example, here are some tools that make use of the JSON interface:
29+
2930
- Internally, this is used to generate [a simple Solidity interface](../../testdata/cheats/Vm.sol) for testing
3031
- Used by [`forge-std`](https://github.com/foundry-rs/forge-std) to generate [user-friendly Solidity interfaces](https://github.com/foundry-rs/forge-std/blob/master/src/Vm.sol)
3132
- (WIP) Used by [the Foundry book](https://github.com/foundry-rs/book) to generate [the cheatcodes reference](https://book.getfoundry.sh/cheatcodes)

crates/doc/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ In this phase, builder invokes 2 parsers: [solang parser](https://github.com/hyp
1414

1515
Then, builder takes the output of the internal `Parser` and creates documents with additional information: the path of the original item, display identity, the target path where this document will be written.
1616

17-
1817
2. Preprocess
1918

2019
The builder accepts an array of preprocessors which can be applied to documents produced in the `Parse` phase. The preprocessors can rearrange and/or change the array as well as modify the separate documents.
2120

2221
At the end of this phase, the builder maintains a possibly modified collection of documents.
2322

24-
2523
3. Write
2624

27-
At this point, builder has all necessary information to generate documentation for the source code. It takes every document, formats the source file contents and writes/copies additional files that are required for building documentation.
25+
At this point, builder has all necessary information to generate documentation for the source code. It takes every document, formats the source file contents and writes/copies additional files that are required for building documentation.

crates/fmt/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ event Greet(string indexed name);
115115
The formatter supports multiple configuration options defined in `FormatterConfig`.
116116

117117
| Option | Default | Description |
118-
|------------------------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
118+
| ---------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
119119
| line_length | 120 | Maximum line length where formatter will try to wrap the line |
120120
| tab_width | 4 | Number of spaces per indentation level |
121121
| bracket_spacing | false | Print spaces between brackets |
@@ -177,7 +177,7 @@ following process:
177177

178178
1. Preparse comments with config values
179179
2. Parse and compare the AST for source & expected files.
180-
- The `AstEq` trait defines the comparison rules for the AST nodes
180+
- The `AstEq` trait defines the comparison rules for the AST nodes
181181
3. Format the source file and assert the equality of the output with the expected file.
182182
4. Format the expected files and assert the idempotency of the formatting operation.
183183

@@ -190,17 +190,17 @@ Guidelines for contributing to `forge fmt`:
190190
### Opening an issue
191191

192192
1. Create a short concise title describing an issue.
193-
- Bad Title Examples
194-
```text
195-
Forge fmt does not work
196-
Forge fmt breaks
197-
Forge fmt unexpected behavior
198-
```
199-
- Good Title Examples
200-
```text
201-
Forge fmt postfix comment misplaced
202-
Forge fmt does not inline short yul blocks
203-
```
193+
- Bad Title Examples
194+
```text
195+
Forge fmt does not work
196+
Forge fmt breaks
197+
Forge fmt unexpected behavior
198+
```
199+
- Good Title Examples
200+
```text
201+
Forge fmt postfix comment misplaced
202+
Forge fmt does not inline short yul blocks
203+
```
204204
2. Fill in the issue template fields that include foundry version, platform & component info.
205205
3. Provide the code snippets showing the current & expected behaviors.
206206
4. If it's a feature request, specify why this feature is needed.
@@ -217,6 +217,6 @@ Guidelines for contributing to `forge fmt`:
217217
1. Specify an issue that is being addressed in the PR description.
218218
2. Add a note on the solution in the PR description.
219219
3. Provide the test coverage for the new feature. These should include:
220-
- Adding malformatted & expected solidity code under `fmt/testdata/$dir/`
221-
- Testing the behavior of pre and postfix comments
222-
- If it's a new config value, tests covering **all** available options
220+
- Adding malformatted & expected solidity code under `fmt/testdata/$dir/`
221+
- Testing the behavior of pre and postfix comments
222+
- If it's a new config value, tests covering **all** available options

crates/forge/assets/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
Foundry consists of:
66

7-
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8-
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9-
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10-
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
7+
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8+
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9+
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10+
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
1111

1212
## Documentation
1313

crates/lint/README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ It helps enforce best practices and improve code quality within Foundry projects
77

88
`forge-lint` includes rules across several categories:
99

10-
* **High Severity:**
11-
* `incorrect-shift`: Warns against shift operations where operands might be in the wrong order.
12-
* **Medium Severity:**
13-
* `divide-before-multiply`: Warns against performing division before multiplication in the same expression, which can cause precision loss.
14-
* **Informational / Style Guide:**
15-
* `pascal-case-struct`: Flags for struct names not adhering to `PascalCase`.
16-
* `mixed-case-function`: Flags for function names not adhering to `mixedCase`.
17-
* `mixed-case-variable`: Flags for mutable variable names not adhering to `mixedCase`.
18-
* `screaming-snake-case-const`: Flags for `constant` variable names not adhering to `SCREAMING_SNAKE_CASE`.
19-
* `screaming-snake-case-immutable`: Flags for `immutable` variable names not adhering to `SCREAMING_SNAKE_CASE`.
20-
* **Gas Optimizations:**
21-
* `asm-keccak256`: Recommends using inline assembly for `keccak256` for potential gas savings.
10+
- **High Severity:**
11+
- `incorrect-shift`: Warns against shift operations where operands might be in the wrong order.
12+
- **Medium Severity:**
13+
- `divide-before-multiply`: Warns against performing division before multiplication in the same expression, which can cause precision loss.
14+
- **Informational / Style Guide:**
15+
- `pascal-case-struct`: Flags for struct names not adhering to `PascalCase`.
16+
- `mixed-case-function`: Flags for function names not adhering to `mixedCase`.
17+
- `mixed-case-variable`: Flags for mutable variable names not adhering to `mixedCase`.
18+
- `screaming-snake-case-const`: Flags for `constant` variable names not adhering to `SCREAMING_SNAKE_CASE`.
19+
- `screaming-snake-case-immutable`: Flags for `immutable` variable names not adhering to `SCREAMING_SNAKE_CASE`.
20+
- **Gas Optimizations:**
21+
- `asm-keccak256`: Recommends using inline assembly for `keccak256` for potential gas savings.
2222

2323
## Configuration
2424

2525
The behavior of the `SolidityLinter` can be customized with the following options:
2626

2727
| Option | Default | Description |
28-
|---------------------|---------|------------------------------------------------------------------------------------------------------------|
28+
| ------------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
2929
| `with_severity` | `None` | Filters active lints by their severity (`High`, `Med`, `Low`, `Info`, `Gas`). `None` means all severities. |
3030
| `with_lints` | `None` | Specifies a list of `SolLint` instances to include. Overrides severity filter if a lint matches. |
3131
| `without_lints` | `None` | Specifies a list of `SolLint` instances to exclude, even if they match other criteria. |
@@ -41,16 +41,16 @@ Guidelines for contributing to `forge lint`:
4141
### Opening an issue
4242

4343
1. Create a short concise title describing an issue.
44-
- Bad Title Examples
45-
```text
46-
Forge lint does not work
47-
Forge lint breaks
48-
Forge lint unexpected behavior
49-
```
50-
- Good Title Examples
51-
```text
52-
Forge lint does not flag incorrect shift operations
53-
```
44+
- Bad Title Examples
45+
```text
46+
Forge lint does not work
47+
Forge lint breaks
48+
Forge lint unexpected behavior
49+
```
50+
- Good Title Examples
51+
```text
52+
Forge lint does not flag incorrect shift operations
53+
```
5454
2. Fill in the issue template fields that include foundry version, platform & component info.
5555
3. Provide the code snippets showing the current & expected behaviors.
5656
4. If it's a feature request, specify why this feature is needed.

deny.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ exceptions = [
7171
{ allow = ["CC0-1.0"], name = "dunce" },
7272
{ allow = ["CC0-1.0"], name = "aurora-engine-modexp" },
7373
]
74-
#copyleft = "deny"
74+
# copyleft = "deny"
7575

7676
# See note in unicode-ident's readme!
7777
[[licenses.clarify]]

0 commit comments

Comments
 (0)