Skip to content

Commit 433e619

Browse files
Add global prettier configuration
We added repo-wide prettier configuration to handle all possible file types. With lint:js we are supporting `*.js` files. With lint:sol we are supporting `*.sol` files. We were missing handling for bunch of other file types, like `*.json`, `*.sh`, `*.yaml` which prettier now allows us to handle.
1 parent 2972eff commit 433e619

9 files changed

+196
-21
lines changed

.git-blame-ignore-revs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file contains commit hashes of bulk changes that can be omitted by the
2+
# `git blame` function. These are expected to be commits containing code generated
3+
# by automatic tools.
4+
#
5+
# For more details see: https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt
6+
7+
# Auto-formatted code generated by `yarn format:fix` command.

.github/workflows/contracts.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v2
1919
if: github.event_name == 'pull_request'
20-
20+
2121
- uses: dorny/paths-filter@v2
2222
if: github.event_name == 'pull_request'
2323
id: filter
@@ -66,6 +66,14 @@ jobs:
6666
with:
6767
node-version: "14.x"
6868

69+
# Below step is a workaround. Eslint executed in `solidity` directory
70+
# finds `.prettierrc.js` config in the root directory and fails if
71+
# referenced `@keep-network/prettier-config-keep` module is missing.
72+
- name: Install dependencies in the root directory
73+
run: |
74+
cd ..
75+
yarn install --frozen-lockfile
76+
6977
- name: Install dependencies
7078
run: yarn install
7179

.github/workflows/format.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Code Format Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
code-format:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- uses: actions/setup-node@v2
17+
with:
18+
node-version: "14"
19+
cache: "yarn"
20+
21+
- name: Install dependencies
22+
run: yarn install
23+
24+
- name: Check formatting
25+
run: yarn format

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
artifacts/
33
cache/
44
typechain/
5+
.vscode/

.pre-commit-config.yaml

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
repos:
2-
- repo: https://github.com/keep-network/pre-commit-hooks.git
3-
rev: v1.3.0
4-
hooks:
5-
- id: check-added-large-files
6-
- id: pretty-format-json
7-
args: ['--autofix']
8-
- repo: local
9-
hooks:
10-
- id: lint-js
11-
name: 'lint js'
12-
entry: /usr/bin/env bash -c "cd solidity && npm run lint:js"
13-
files: '\.js$'
14-
language: script
15-
description: "Checks JS code according to the package's linter configuration"
16-
- id: lint-sol
17-
name: 'lint solidity'
18-
entry: /usr/bin/env bash -c "cd solidity && npm run lint:sol"
19-
files: '\.sol$'
20-
language: script
21-
description: "Checks Solidity code according to the package's linter configuration"
2+
- repo: https://github.com/keep-network/pre-commit-hooks.git
3+
rev: v1.3.0
4+
hooks:
5+
- id: check-added-large-files
6+
- repo: local
7+
hooks:
8+
- id: lint-js
9+
name: "lint js"
10+
entry: /usr/bin/env bash -c "npm run lint:js"
11+
files: '\.js$'
12+
language: script
13+
description: "Checks JS code according to the package's linter configuration"
14+
- id: lint-sol
15+
name: "lint solidity"
16+
entry: /usr/bin/env bash -c "npm run lint:sol"
17+
files: '\.sol$'
18+
language: script
19+
description: "Checks Solidity code according to the package's linter configuration"
20+
- id: prettier
21+
name: "prettier"
22+
entry: /usr/bin/env bash -c "npx prettier --check ."
23+
language: script
24+
description: "Checks code according to the package's formatting configuration"

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Following directories have their own formatting configuration:
2+
solidity/

.prettierrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
...require("@keep-network/prettier-config-keep"),
3+
plugins: ["prettier-plugin-sh"],
4+
}

package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"scripts": {
3+
"format": "prettier --check .",
4+
"format:fix": "prettier --write ."
5+
},
6+
"devDependencies": {
7+
"@keep-network/prettier-config-keep": "github:keep-network/prettier-config-keep",
8+
"prettier": "^2.3.2",
9+
"prettier-plugin-sh": "^0.7.1",
10+
"prettier-plugin-solidity": "^1.0.0-beta.14"
11+
}
12+
}

yarn.lock

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@keep-network/prettier-config-keep@github:keep-network/prettier-config-keep":
6+
version "0.0.1"
7+
resolved "https://codeload.github.com/keep-network/prettier-config-keep/tar.gz/d6ec02e80dd76edfba073ca58ef99aee39002c2c"
8+
9+
"@solidity-parser/parser@^0.13.2":
10+
version "0.13.2"
11+
resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.13.2.tgz#b6c71d8ca0b382d90a7bbed241f9bc110af65cbe"
12+
integrity sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw==
13+
dependencies:
14+
antlr4ts "^0.5.0-alpha.4"
15+
16+
ansi-regex@^5.0.0:
17+
version "5.0.0"
18+
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
19+
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
20+
21+
antlr4ts@^0.5.0-alpha.4:
22+
version "0.5.0-alpha.4"
23+
resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a"
24+
integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ==
25+
26+
emoji-regex@^8.0.0:
27+
version "8.0.0"
28+
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
29+
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
30+
31+
emoji-regex@^9.2.2:
32+
version "9.2.2"
33+
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72"
34+
integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==
35+
36+
escape-string-regexp@^4.0.0:
37+
version "4.0.0"
38+
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
39+
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
40+
41+
is-fullwidth-code-point@^3.0.0:
42+
version "3.0.0"
43+
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
44+
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
45+
46+
lru-cache@^6.0.0:
47+
version "6.0.0"
48+
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
49+
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
50+
dependencies:
51+
yallist "^4.0.0"
52+
53+
mvdan-sh@^0.5.0:
54+
version "0.5.0"
55+
resolved "https://registry.yarnpkg.com/mvdan-sh/-/mvdan-sh-0.5.0.tgz#fa76f611a103595ad0f04f5d18e582892c46e87c"
56+
integrity sha512-UWbdl4LHd2fUnaEcOUFVWRdWGLkNoV12cKVIPiirYd8qM5VkCoCTXErlDubevrkEG7kGohvjRxAlTQmOqG80tw==
57+
58+
prettier-plugin-sh@^0.7.1:
59+
version "0.7.1"
60+
resolved "https://registry.yarnpkg.com/prettier-plugin-sh/-/prettier-plugin-sh-0.7.1.tgz#a2d38de10e55919ea945a6e72c4815b16d6614ad"
61+
integrity sha512-2MWRdGOSz0yf/z2kTKF1AqxDuH9MZD8faoDAz5ySGphxssi9oyM3Ys+jp7AfqsCXvGUDbRA4EJOlKS0yZKAW6w==
62+
dependencies:
63+
mvdan-sh "^0.5.0"
64+
65+
prettier-plugin-solidity@^1.0.0-beta.14:
66+
version "1.0.0-beta.15"
67+
resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.15.tgz#ca7388e17e2620dc6251746e405150479abdc0a3"
68+
integrity sha512-5+pM/Z1BgQN6xMCe/AfXmiVhoteaVgruVoGT8aa0zJMRiNOiK+SeaW2kOyzTI6sgg3QsUW58+ahf1hxlc/Adbw==
69+
dependencies:
70+
"@solidity-parser/parser" "^0.13.2"
71+
emoji-regex "^9.2.2"
72+
escape-string-regexp "^4.0.0"
73+
semver "^7.3.5"
74+
solidity-comments-extractor "^0.0.7"
75+
string-width "^4.2.2"
76+
77+
prettier@^2.3.2:
78+
version "2.3.2"
79+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
80+
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==
81+
82+
semver@^7.3.5:
83+
version "7.3.5"
84+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
85+
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
86+
dependencies:
87+
lru-cache "^6.0.0"
88+
89+
solidity-comments-extractor@^0.0.7:
90+
version "0.0.7"
91+
resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19"
92+
integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==
93+
94+
string-width@^4.2.2:
95+
version "4.2.2"
96+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5"
97+
integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==
98+
dependencies:
99+
emoji-regex "^8.0.0"
100+
is-fullwidth-code-point "^3.0.0"
101+
strip-ansi "^6.0.0"
102+
103+
strip-ansi@^6.0.0:
104+
version "6.0.0"
105+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
106+
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
107+
dependencies:
108+
ansi-regex "^5.0.0"
109+
110+
yallist@^4.0.0:
111+
version "4.0.0"
112+
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
113+
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

0 commit comments

Comments
 (0)