Skip to content

Commit 71578d6

Browse files
authored
style: use the guild's shared config for eslint and prettier (#1031)
* add eslint and use the guild shared config * prettier * eslint * node protocol for imports not ready yet
1 parent 4c5e452 commit 71578d6

File tree

127 files changed

+6789
-5438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+6789
-5438
lines changed

.eslintignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
dist
3+
build
4+
generated
5+
packages/cli/tests/cli/init
6+
packages/cli/tests/cli/validation
7+
8+
# TODO: cleanup examples and lint
9+
examples

.eslintrc.cjs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
extends: ['@theguild'],
3+
rules: {
4+
// not necessary here, we dont build with bob
5+
'import/extensions': 'off',
6+
// pushing to array multiple times is not a big deal
7+
'unicorn/no-array-push-push': 'off',
8+
// TODO: warning for now, clean up
9+
'@typescript-eslint/no-this-alias': 'warn',
10+
// TODO: remove default exports, breaking change?
11+
'import/no-default-export': 'off',
12+
// TODO: remove once we get rid of all anys
13+
'@typescript-eslint/no-explicit-any': 'off',
14+
// TODO: not ready yet
15+
'unicorn/prefer-node-protocol': 'off',
16+
},
17+
};

.github/ISSUE_TEMPLATE/config.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ blank_issues_enabled: false
22
contact_links:
33
- name: Have a question?
44
url: https://discord.gg/vtvv7FP
5-
about: Not sure about something? need help from the community? have a question to our team? please ask and answer questions here.
5+
about:
6+
Not sure about something? need help from the community? have a question to our team? please
7+
ask and answer questions here.

.github/workflows/ci.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ jobs:
4343
uses: actions/cache@v3
4444
with:
4545
path: ${{ steps.pnpm-store.outputs.PATH }}
46-
key: ${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
46+
key:
47+
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{
48+
hashFiles('**/pnpm-lock.yaml') }}
4749
restore-keys: |
4850
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-
4951
@@ -88,7 +90,9 @@ jobs:
8890
uses: actions/cache@v3
8991
with:
9092
path: ${{ steps.pnpm-store.outputs.PATH }}
91-
key: ${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
93+
key:
94+
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{
95+
hashFiles('**/pnpm-lock.yaml') }}
9296
restore-keys: |
9397
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-
9498

.prettierrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@theguild/prettier-config');

.prettierrc.json

-7
This file was deleted.

CONTRIBUTING.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22

33
Welcome to the Graph Protocol! Thanks a ton for your interest in contributing.
44

5-
If you run into any problems feel free to create an issue. PRs are much appreciated for simple things. If it's something more complex we'd appreciate having a quick chat in GitHub Issues or Discord.
5+
If you run into any problems feel free to create an issue. PRs are much appreciated for simple
6+
things. If it's something more complex we'd appreciate having a quick chat in GitHub Issues or
7+
Discord.
68

79
Join the conversation on our [Discord](https://discord.gg/9a5VCua).
810

9-
Please follow the [Code of Conduct](https://github.com/graphprotocol/graph-node/blob/master/CODE_OF_CONDUCT.md) for all the communications and at events. Thank you!
11+
Please follow the
12+
[Code of Conduct](https://github.com/graphprotocol/graph-node/blob/master/CODE_OF_CONDUCT.md) for
13+
all the communications and at events. Thank you!
1014

1115
## Commit messages
1216

13-
We use the following format for commit messages:
14-
`{component-name}: {Brief description of changes}`, for example: `cli: Print stacktrace of codegen errors`.
17+
We use the following format for commit messages: `{component-name}: {Brief description of changes}`,
18+
for example: `cli: Print stacktrace of codegen errors`.
1519

16-
If multiple components are being changed list them all like this: `src/cli, src/runtime: Fix accessing EthereumEvent params`
20+
If multiple components are being changed list them all like this:
21+
`src/cli, src/runtime: Fix accessing EthereumEvent params`

NEWS.md

+18-25
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# NEWS
22

3-
Note: This file only includes short summaries of the changes introduced in
4-
each release. More detailed release notes can be found in the
5-
[graph-node](https://github.com/graphprotocol/graph-node/tree/master/NEWS.md)
6-
repo.
3+
Note: This file only includes short summaries of the changes introduced in each release. More
4+
detailed release notes can be found in the
5+
[graph-node](https://github.com/graphprotocol/graph-node/tree/master/NEWS.md) repo.
76

87
## Unreleased
98

@@ -17,8 +16,7 @@ repo.
1716
- Allow specifying a graft base in the manifest.
1817
- Fix `Value is not a XYZ` errors for null values.
1918
- Fix path lookups in compiler script (thanks @fubhy!).
20-
- Add support for yarn workspaces and otherwise hoisted node modules (thanks
21-
@fubhy!).
19+
- Add support for yarn workspaces and otherwise hoisted node modules (thanks @fubhy!).
2220
- Fix validating call handlers for functions with tuple parameters (#500).
2321
- Properly unfold tuple event/call parameters in signatures.
2422
- Pass `--debug` to AssemblyScript compiler.
@@ -28,13 +26,13 @@ repo.
2826

2927
### Feature: `graph test` (#414, #420, #421)
3028

31-
This release introduces a new `graph test` command that can be used to run
32-
test commands against a (customizable) test environment (by default: Graph
33-
Node, Postgres, IPFS and Ganache in Docker Compose).
29+
This release introduces a new `graph test` command that can be used to run test commands against a
30+
(customizable) test environment (by default: Graph Node, Postgres, IPFS and Ganache in Docker
31+
Compose).
3432

35-
This essentially provides a framework for writing integration tests, where a
36-
subgraph is indexed against a fresh Graph node, tests can wait for it to
37-
synced, run queries at specific blocks and so on.
33+
This essentially provides a framework for writing integration tests, where a subgraph is indexed
34+
against a fresh Graph node, tests can wait for it to synced, run queries at specific blocks and so
35+
on.
3836

3937
```
4038
graph test [options] <test-command>
@@ -52,29 +50,24 @@ Options:
5250
--node-logs Print the Graph Node logs (optional)
5351
```
5452

55-
The `<test-command>` can be anything: it can be a shell script that builds
56-
and deploys a subgraph, it can be a JS test suite run with Jest or it can be
57-
a Truffle test suite, run with `truffle test`.
53+
The `<test-command>` can be anything: it can be a shell script that builds and deploys a subgraph,
54+
it can be a JS test suite run with Jest or it can be a Truffle test suite, run with `truffle test`.
5855

59-
Overriding the `--node-image` allows to use a custom build of Graph Node,
60-
which is useful for running integration tests for specific versions of Graph
61-
Node.
56+
Overriding the `--node-image` allows to use a custom build of Graph Node, which is useful for
57+
running integration tests for specific versions of Graph Node.
6258

63-
Overriding the `--compose-file` allows to e.g. use a different Ethereum
64-
provider than the default Ganache, making it possible to test subgraphs
65-
against mainnet for instance.
59+
Overriding the `--compose-file` allows to e.g. use a different Ethereum provider than the default
60+
Ganache, making it possible to test subgraphs against mainnet for instance.
6661

6762
### Misc
6863

6964
- Fix codegen for tuple arrays (#455 via #456). Thanks @JamesLefrere!
7065
- Add `createWithContext()` code generation for data source templates (#446).
71-
- Fix building in situations where `subgraph.yaml` is not in the working
72-
directory (#443).
66+
- Fix building in situations where `subgraph.yaml` is not in the working directory (#443).
7367
- Add validation for new `@fulltext` directive (#433).
7468
- Fix `URL` not being defined in older Node.js versions (#422).
7569
- Add auto-migration from `apiVersion` 0.0.3 to 0.0.4 (#418).
7670
- Fix Entity field getters for nullable fields (#417).
7771
- Add support for overloaded Ethereum contract functions (#415).
7872
- Update code generation to dedicated `ethereum` module in graph-ts (#409).
79-
- Dependency updates: docker-compose, handlebars, jest, tern, keytar,
80-
request.
73+
- Dependency updates: docker-compose, handlebars, jest, tern, keytar, request.

README.md

+39-16
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ As of today, the command line interface supports the following commands:
1212
- `graph remove` — Unregisters a subgraph name with a Graph Node.
1313
- `graph codegen` — Generates AssemblyScript types for smart contract ABIs and the subgraph schema.
1414
- `graph build` — Compiles a subgraph to WebAssembly.
15-
- `graph deploy` — Deploys a subgraph to a [Graph Node](https://github.com/graphprotocol/graph-node).
16-
- `graph auth` — Stores a [Graph Node](https://github.com/graphprotocol/graph-node) access token in the system's keychain.
17-
- `graph local` — Runs tests against a [Graph Node](https://github.com/graphprotocol/graph-node) test environment (using Ganache by default).
18-
- `graph test` — Downloads and runs the [Matchstick](https://github.com/LimeChain/matchstick) rust binary in order to test a subgraph.
19-
- `graph add` - Adds a new datasource to the yaml file and writes the necessary changes to other files - schema.graphql, abi and mapping.
15+
- `graph deploy` — Deploys a subgraph to a
16+
[Graph Node](https://github.com/graphprotocol/graph-node).
17+
- `graph auth` — Stores a [Graph Node](https://github.com/graphprotocol/graph-node) access token in
18+
the system's keychain.
19+
- `graph local` — Runs tests against a [Graph Node](https://github.com/graphprotocol/graph-node)
20+
test environment (using Ganache by default).
21+
- `graph test` — Downloads and runs the [Matchstick](https://github.com/LimeChain/matchstick) rust
22+
binary in order to test a subgraph.
23+
- `graph add` - Adds a new datasource to the yaml file and writes the necessary changes to other
24+
files - schema.graphql, abi and mapping.
2025

2126
## How It Works
2227

@@ -26,7 +31,9 @@ The Graph CLI takes a subgraph manifest (defaults to `subgraph.yaml`) with refer
2631
- Smart contract ABIs, and
2732
- Mappings written in AssemblyScript.
2833

29-
It compiles the mappings to WebAssembly, builds a ready-to-use version of the subgraph saved to IPFS or a local directory for debugging, and deploys the subgraph to a [Graph Node](https://github.com/graphprotocol/graph-node).
34+
It compiles the mappings to WebAssembly, builds a ready-to-use version of the subgraph saved to IPFS
35+
or a local directory for debugging, and deploys the subgraph to a
36+
[Graph Node](https://github.com/graphprotocol/graph-node).
3037

3138
## Installation
3239

@@ -42,24 +49,34 @@ yarn global add @graphprotocol/graph-cli
4249

4350
### On Linux
4451

45-
`libsecret` is used for storing access tokens, so you may need to install it before getting started. Use one of the following commands depending on your distribution:
52+
`libsecret` is used for storing access tokens, so you may need to install it before getting started.
53+
Use one of the following commands depending on your distribution:
4654

4755
- Debian/Ubuntu: `sudo apt-get install libsecret-1-dev`
4856
- Red Hat: `sudo yum install libsecret-devel`
4957
- Arch Linux: `sudo pacman -S libsecret`
5058

5159
## Getting Started
5260

53-
The Graph CLI can be used with a local or self-hosted [Graph Node](https://github.com/graphprotocol/graph-node) or with the [Hosted Service](https://thegraph.com/explorer/). To help you get going, there are [quick start guides](https://thegraph.com/docs/en/developer/quick-start/) available for both.
61+
The Graph CLI can be used with a local or self-hosted
62+
[Graph Node](https://github.com/graphprotocol/graph-node) or with the
63+
[Hosted Service](https://thegraph.com/explorer/). To help you get going, there are
64+
[quick start guides](https://thegraph.com/docs/en/developer/quick-start/) available for both.
5465

55-
If you are ready to dive into the details of building a subgraph from scratch, there is a [detailed walkthrough](https://thegraph.com/docs/en/developer/create-subgraph-hosted/) for that as well, along with API documentation for the [AssemblyScript API](https://thegraph.com/docs/en/developer/assemblyscript-api/).
66+
If you are ready to dive into the details of building a subgraph from scratch, there is a
67+
[detailed walkthrough](https://thegraph.com/docs/en/developer/create-subgraph-hosted/) for that as
68+
well, along with API documentation for the
69+
[AssemblyScript API](https://thegraph.com/docs/en/developer/assemblyscript-api/).
5670

5771
## Release process
5872

59-
We use `changeset` to manage releases. Every PR should include a changeset file. The release process is as follows:
73+
We use `changeset` to manage releases. Every PR should include a changeset file. The release process
74+
is as follows:
6075

61-
1. Author creates the PR with changes and runs `pnpm changeset` to create a changeset file to summarize the changes.
62-
2. When the PR is merged to `main`, a Github Action will run and create a PR with the version bump and changelog.
76+
1. Author creates the PR with changes and runs `pnpm changeset` to create a changeset file to
77+
summarize the changes.
78+
2. When the PR is merged to `main`, a Github Action will run and create a PR with the version bump
79+
and changelog.
6380
3. We will merge the bot generated PR to `main`.
6481
4. A Github Action will run and publish the new version to npm.
6582

@@ -71,20 +88,26 @@ Helpful links:
7188

7289
### Stable release example
7390

74-
When PRs are merged and to `main` we can choose to merge the bot generated changeset PR to `main` and it will publish a new version to npm.
91+
When PRs are merged and to `main` we can choose to merge the bot generated changeset PR to `main`
92+
and it will publish a new version to npm.
7593

7694
Example of a `graph-client` release: https://github.com/graphprotocol/graph-client/pull/295
7795

7896
### Alpha release example
7997

8098
Every PR to `main` that includes a changeset file will create a new alpha version.
8199

82-
Example of `graph-client` snapshot release: https://github.com/graphprotocol/graph-client/pull/178#issuecomment-1214822036
100+
Example of `graph-client` snapshot release:
101+
https://github.com/graphprotocol/graph-client/pull/178#issuecomment-1214822036
83102

84103
## License
85104

86105
Copyright &copy; 2018-2019 Graph Protocol, Inc. and contributors.
87106

88-
The Graph CLI is dual-licensed under the [MIT license](LICENSE-MIT) and the [Apache License, Version 2.0](LICENSE-APACHE).
107+
The Graph CLI is dual-licensed under the [MIT license](LICENSE-MIT) and the
108+
[Apache License, Version 2.0](LICENSE-APACHE).
89109

90-
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License.
110+
Unless required by applicable law or agreed to in writing, software distributed under the License is
111+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or
112+
implied. See the License for the specific language governing permissions and limitations under the
113+
License.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Example Subgraph
22

3-
An example to help you get started with The Graph. For more information see the docs on https://thegraph.com/docs/.
3+
An example to help you get started with The Graph. For more information see the docs on
4+
https://thegraph.com/docs/.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var Migrations = artifacts.require('./Migrations.sol')
1+
var Migrations = artifacts.require('./Migrations.sol');
22

33
module.exports = function (deployer) {
4-
deployer.deploy(Migrations)
5-
}
4+
deployer.deploy(Migrations);
5+
};
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
1+
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol');
22

33
module.exports = async function (deployer) {
4-
await deployer.deploy(GravatarRegistry)
5-
}
4+
await deployer.deploy(GravatarRegistry);
5+
};
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
1+
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol');
22

33
module.exports = async function (deployer) {
4-
let accounts = await web3.eth.getAccounts()
4+
const accounts = await web3.eth.getAccounts();
55

6-
const registry = await GravatarRegistry.deployed()
7-
await registry.setMythicalGravatar({ from: accounts[0] })
6+
const registry = await GravatarRegistry.deployed();
7+
await registry.setMythicalGravatar({ from: accounts[0] });
88
await registry.createGravatar('Carl', 'https://thegraph.com/img/team/team_04.png', {
99
from: accounts[0],
10-
})
10+
});
1111
await registry.createGravatar('Lucas', 'https://thegraph.com/img/team/bw_Lucas.jpg', {
1212
from: accounts[1],
13-
})
14-
}
13+
});
14+
};
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
1+
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol');
22

33
module.exports = async function (deployer) {
4-
let accounts = await web3.eth.getAccounts()
4+
const accounts = await web3.eth.getAccounts();
55

6-
const registry = await GravatarRegistry.deployed()
7-
await registry.updateGravatarName('Nena', { from: accounts[0] })
8-
await registry.updateGravatarName('Jorge', { from: accounts[1] })
9-
}
6+
const registry = await GravatarRegistry.deployed();
7+
await registry.updateGravatarName('Nena', { from: accounts[0] });
8+
await registry.updateGravatarName('Jorge', { from: accounts[1] });
9+
};

examples/basic-event-handlers/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
22
"name": "basic-event-handlers",
3-
"private": true,
43
"version": "0.1.0",
4+
"private": true,
55
"scripts": {
6-
"codegen": "../../packages/cli/dist/bin.js codegen",
76
"build": "../../packages/cli/dist/bin.js build",
8-
"test": "docker compose up -d && sleep 30 && truffle test --network test && docker compose down",
7+
"codegen": "../../packages/cli/dist/bin.js codegen",
98
"create-test": "../../packages/cli/dist/bin.js create test/basic-event-handlers --node http://127.0.0.1:18020",
10-
"deploy-test": "../../packages/cli/dist/bin.js deploy test/basic-event-handlers --version-label v0.0.1 --ipfs http://localhost:15001 --node http://127.0.0.1:18020"
11-
},
12-
"devDependencies": {
13-
"@graphprotocol/graph-ts": "0.29.1",
14-
"apollo-fetch": "^0.7.0"
9+
"deploy-test": "../../packages/cli/dist/bin.js deploy test/basic-event-handlers --version-label v0.0.1 --ipfs http://localhost:15001 --node http://127.0.0.1:18020",
10+
"test": "docker compose up -d && sleep 30 && truffle test --network test && docker compose down"
1511
},
1612
"dependencies": {
1713
"babel-polyfill": "6.26.0",
1814
"babel-register": "6.26.0",
1915
"truffle": "5.0.12",
2016
"truffle-hdwallet-provider": "1.0.6"
2117
},
18+
"devDependencies": {
19+
"@graphprotocol/graph-ts": "0.29.1",
20+
"apollo-fetch": "^0.7.0"
21+
},
2222
"resolutions": {
2323
"assemblyscript": "0.19.10"
2424
}

0 commit comments

Comments
 (0)