Skip to content

Commit 0dc1dc9

Browse files
authored
Merge pull request #262 from crytic/add-ci-formatter-lint
Add CI formatter lint
2 parents f3b623e + 73d4c98 commit 0dc1dc9

File tree

6 files changed

+55
-18
lines changed

6 files changed

+55
-18
lines changed

.github/workflows/lint_format.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint Check Format
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 16
21+
22+
- name: Install npm and dependencies
23+
run: |
24+
npm ci
25+
26+
- name: Run lint
27+
run: |
28+
npm run lint:format

.github/workflows/check_links.yml renamed to .github/workflows/lint_links.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
name: Check Markdown links
1+
name: Lint Check Markdown Links
22

33
on:
44
push:
55
branches:
66
- master
7-
- dev
87
pull_request:
98
schedule:
109
# run CI at 09:00, on day 1 of the month even if no PRs/merges occur

CONTRIBUTING.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,23 @@ To install the formatters and linters, run:
4545
npm install
4646
```
4747

48-
The formatter is run with:
48+
To run the formatter, use:
4949

5050
```bash
5151
npm run format
5252
```
5353

54-
The linter is run with:
54+
To run the linters, use:
5555

5656
```bash
5757
npm run lint
5858
```
5959

60+
To run the individual linters, use:
61+
62+
- `npm run lint:format` to check the formatting
63+
- `npm run lint:links` to check for invalid links in markdown files
64+
6065
## Create the book
6166

6267
We use `mdbook` to generate [secure-contracts.com](https://secure-contracts.com/).

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"prettier-plugin-solidity": "^1.1.3"
1010
},
1111
"scripts": {
12-
"format": "prettier --write . && npm run format-embedded-solidity",
13-
"format-embedded-solidity": "prettier --write \"**/*.md\" --embedded-language-formatting=auto --plugin prettier-plugin-solidity --tab-width 4 --print-width 120 && prettier --write \"**/*.md\"",
14-
"lint": "npm run lint-check-format && npm run lint-check-links",
15-
"lint-check-format": "prettier --check .",
16-
"lint-check-links": "find . -name '*.md' -print0 | xargs -0 -n1 markdown-link-check"
12+
"format": "prettier --write . && npm run format:embedded",
13+
"format:embedded": "prettier --write \"**/*.md\" --embedded-language-formatting=auto --plugin prettier-plugin-solidity --tab-width 4 --print-width 120 && prettier --write \"**/*.md\"",
14+
"lint": "npm run lint:format && npm run lint:links",
15+
"lint:format": "prettier --check .",
16+
"lint:links": "find . -name '*.md' -print0 | xargs -0 -n1 markdown-link-check"
1717
}
1818
}

program-analysis/echidna/example/TestDepositWithPermit.sol

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ contract TestDepositWithPermit {
2323
}
2424

2525
//helper method to get signature, signs with private key 2
26-
function getSignature(address owner, address spender, uint256 assetAmount)
27-
internal
28-
returns (uint8 v, bytes32 r, bytes32 s)
29-
{
26+
function getSignature(
27+
address owner,
28+
address spender,
29+
uint256 assetAmount
30+
) internal returns (uint8 v, bytes32 r, bytes32 s) {
3031
bytes32 digest = keccak256(
3132
abi.encodePacked(
3233
"\x19\x01",
@@ -55,12 +56,10 @@ contract TestDepositWithPermit {
5556

5657
emit LogBalance(previousOwnerBalance, previousCallerBalance);
5758
(uint8 v, bytes32 r, bytes32 s) = getSignature(OWNER, address(this), amount);
58-
try asset.permit(OWNER, address(this), amount, block.timestamp, v, r, s) {}
59-
catch {
59+
try asset.permit(OWNER, address(this), amount, block.timestamp, v, r, s) {} catch {
6060
emit AssertionFailed("signature is invalid");
6161
}
62-
try asset.transferFrom(OWNER, address(this), amount) {}
63-
catch {
62+
try asset.transferFrom(OWNER, address(this), amount) {} catch {
6463
emit AssertionFailed("transferFrom reverted");
6564
}
6665
uint256 currentOwnerBalance = asset.balanceOf(OWNER);

static/script.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/22554992.js"></script>
1+
<script
2+
type="text/javascript"
3+
id="hs-script-loader"
4+
async
5+
defer
6+
src="//js.hs-scripts.com/22554992.js"
7+
></script>;

0 commit comments

Comments
 (0)