-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tmigone/lint-config' into tmigone/subgraph-service
- Loading branch information
Showing
154 changed files
with
45,447 additions
and
1,604 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CI | ||
|
||
env: | ||
CI: true | ||
|
||
on: | ||
push: | ||
branches: "*" | ||
paths: | ||
- packages/token-distribution/** | ||
pull_request: | ||
branches: "*" | ||
paths: | ||
- packages/token-distribution/** | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up environment | ||
uses: ./.github/actions/setup | ||
- name: Run tests | ||
run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import eslint from '@eslint/js' | ||
import globals from 'globals' | ||
import noOnlyTests from 'eslint-plugin-no-only-tests' | ||
import noSecrets from 'eslint-plugin-no-secrets' | ||
import stylistic from '@stylistic/eslint-plugin' | ||
import tseslint from 'typescript-eslint' | ||
|
||
export default [ | ||
// Base eslint configuration | ||
eslint.configs.recommended, | ||
|
||
// Enable linting with type information | ||
// https://typescript-eslint.io/getting-started/typed-linting | ||
...tseslint.configs.recommendedTypeChecked, | ||
|
||
// Formatting and stylistic rules | ||
stylistic.configs['recommended-flat'], | ||
|
||
// Custom config | ||
{ | ||
languageOptions: { | ||
parserOptions: { | ||
project: ['../*/tsconfig.json', 'tsconfig.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
globals: { | ||
...globals.node, | ||
}, | ||
}, | ||
plugins: { | ||
'no-only-tests': noOnlyTests, | ||
'no-secrets': noSecrets, | ||
}, | ||
ignores: ['dist/*', 'node_modules/*', 'build/*'], | ||
rules: { | ||
'prefer-const': 'warn', | ||
'@typescript-eslint/no-inferrable-types': 'warn', | ||
'@typescript-eslint/no-empty-function': 'warn', | ||
'no-only-tests/no-only-tests': 'error', | ||
'no-secrets/no-secrets': 'error', | ||
'sort-imports': [ | ||
'warn', { | ||
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], | ||
ignoreCase: true, | ||
allowSeparatedGroups: true, | ||
}], | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/eslint-graph-config/typings/eslint-plugin-no-only-tests.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module 'eslint-plugin-no-only-tests' { | ||
import { FlatConfig } from 'typescript-eslint' | ||
const plugin: FlatConfig.Plugin | ||
export default plugin | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/eslint-graph-config/typings/eslint-plugin-no-secrets.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module 'eslint-plugin-no-secrets' { | ||
import { FlatConfig } from 'typescript-eslint' | ||
const plugin: FlatConfig.Plugin | ||
export default plugin | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# solhint-graph-config | ||
|
||
This repository contains shared linting and formatting rules for Solidity projects. | ||
|
||
## Code linting | ||
|
||
### Installation | ||
|
||
⚠️ Unfortunately there isn't a way to install peer dependencies using Yarn v4, so we need to install them manually. | ||
|
||
|
||
```bash | ||
# Install with peer packages | ||
yarn add --dev solhint solhint-graph-config | ||
|
||
# For projects on this monorepo | ||
yarn add --dev solhint solhint-graph-config@workspace:^x.y.z | ||
``` | ||
|
||
### Configuration | ||
|
||
Run `solhint` with `node_modules/solhint-graph-config/index.js` as the configuration file. We suggest creating an npm script to make it easier to run: | ||
|
||
```json | ||
|
||
{ | ||
"scripts": { | ||
"lint": "solhint --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js" | ||
} | ||
} | ||
|
||
``` | ||
|
||
## Code formatting | ||
|
||
### Installation | ||
|
||
⚠️ Unfortunately there isn't a way to install peer dependencies using Yarn v4, so we need to install them manually. | ||
|
||
|
||
```bash | ||
# Install with peer packages | ||
yarn add --dev solhint-graph-config prettier prettier-plugin-solidity | ||
|
||
# For projects on this monorepo | ||
yarn add --dev solhint-graph-config@workspace:^x.y.z prettier prettier-plugin-solidity | ||
``` | ||
|
||
|
||
### Configuration: formatting | ||
|
||
Create a configuration file for prettier at `prettier.config.js`: | ||
|
||
```javascript | ||
const prettierGraphConfig = require('solhint-graph-config/prettier') | ||
module.exports = prettierGraphConfig | ||
``` | ||
|
||
Running `prettier` will automatically pick up the configuration file. We suggest creating an npm script to make it easier to run: | ||
|
||
```json | ||
{ | ||
"scripts": { | ||
"format": "prettier --write 'contracts/**/*.sol'" | ||
} | ||
} | ||
``` | ||
|
||
## Tooling | ||
|
||
This package uses the following tools: | ||
- [solhint](https://protofire.github.io/solhint/) as the base linting tool | ||
- [prettier](https://prettier.io/) as the base formatting tool | ||
- [prettier-plugin-solidity](https://github.com/prettier-solidity/prettier-plugin-solidity) to format Solidity code | ||
|
||
|
||
## VSCode support | ||
|
||
If you are using VSCode you can install the [Solidity extension by Nomic Foundation](https://marketplace.visualstudio.com/items?itemName=NomicFoundation.hardhat-solidity). Unfortunately there is currently no way of getting real-time linting output from solhint, but this extension will provide formatting support using our prettier config and will also provide inline code validation using solc compiler output. | ||
|
||
For formatting, the following settings should be added to your `settings.json` file: | ||
```json | ||
"[solidity]": { | ||
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity" | ||
}, | ||
``` | ||
|
||
Additionally you can configure the `Format document` keyboard shortcut to run `prettier --write` on demand. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
extends: 'solhint:recommended', | ||
rules: { | ||
'func-visibility': ['warn', { ignoreConstructors: true }], | ||
'compiler-version': ['off'], | ||
'constructor-syntax': 'warn', | ||
'quotes': ['error', 'double'], | ||
'reason-string': ['off'], | ||
'not-rely-on-time': 'off', | ||
'no-empty-blocks': 'off', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "solhint-graph-config", | ||
"version": "0.0.1", | ||
"description": "Linting and formatting rules for The Graph's Solidity projects", | ||
"main": "index.js", | ||
"author": "The Graph Team", | ||
"license": "GPL-2.0-or-later", | ||
"peerDependencies": { | ||
"prettier": "^3.2.5", | ||
"prettier-plugin-solidity": "^1.3.1", | ||
"solhint": "^4.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
"printWidth": 120, | ||
"useTabs": false, | ||
"bracketSpacing": true, | ||
"plugins": ["prettier-plugin-solidity"], | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"tabWidth": 4, | ||
"singleQuote": false, | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MNEMONIC= | ||
ETHERSCAN_API_KEY= | ||
INFURA_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build/ | ||
cache/ | ||
dist/ | ||
node_modules/ | ||
reports/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2020, | ||
"sourceType": "module" | ||
}, | ||
"extends": ["plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], | ||
"rules": { | ||
"prefer-const": "warn", | ||
"no-extra-semi": "off", | ||
"@typescript-eslint/no-extra-semi": "warn", | ||
"@typescript-eslint/no-inferrable-types": "warn", | ||
"@typescript-eslint/no-empty-function": "warn" | ||
} | ||
} |
Oops, something went wrong.