Skip to content

Commit

Permalink
fix: update linter and github CI (#212)
Browse files Browse the repository at this point in the history
* fix linter and github CI

* remove const disabling

* fix ci

* merge decimals opt
  • Loading branch information
mzywang authored Apr 2, 2024
1 parent 0eeb07a commit 13078d9
Show file tree
Hide file tree
Showing 16 changed files with 3,780 additions and 1,661 deletions.
5 changes: 0 additions & 5 deletions .eslintrc

This file was deleted.

33 changes: 33 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require('@uniswap/eslint-config/load')

module.exports = {
extends: ['@uniswap/eslint-config/node'],
rules: {
'import/no-unused-modules': 'off',
'@typescript-eslint/no-restricted-imports': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }
],
'@typescript-eslint/no-this-alias': [
'error',
{
allowDestructuring: true, // Allow `const { props, state } = this`; false by default
allowedNames: [
'self' // Allow `const self= this`; `[]` by default
]
}
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
// Allow BigInt (uppercase)
BigInt: false
}
}
]
}
}
61 changes: 52 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,58 @@ on:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
strategy:
matrix:
node: ['12.x', '14.x']
os: [ubuntu-latest]
lint:
name: lint
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref || '' }}
token: ${{ secrets.github_token }}

- name: Set up node
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: https://registry.npmjs.org

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Install dependencies
run: yarn install

- name: Lint
run: yarn run lint

- name: Commit lint fixes
if: github.event_name == 'pull_request'
run: |
git config --global user.name "${{ github.event.pull_request.user.login }}"
git config --global user.email "${{ github.event.pull_request.user.login }}@users.noreply.github.com"
if [ -z "$(git diff)" ]; then exit; fi
git commit -a -m "fix(lint): auto-fix [ci]"
git push
runs-on: ${{ matrix.os }}
build:
needs: lint
name: build
runs-on: ubuntu-latest

steps:
- name: Checkout code
Expand All @@ -22,7 +65,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
node-version: '18.x'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand All @@ -32,9 +75,9 @@ jobs:
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ matrix.os }}-yarn-
yarn-
- name: Install dependencies
run: yarn install
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"repository": "https://github.com/graphprotocol/uniswap-v3-subgraph",
"license": "GPL-3.0-or-later",
"scripts": {
"lint": "eslint . --ext .ts --fix",
"codegen": "graph codegen --output-dir src/types/",
"build": "graph build",
"create-local": "graph create ianlapham/uniswap-v3 --node http://127.0.0.1:8020",
Expand All @@ -18,7 +19,8 @@
"@graphprotocol/graph-ts": "^0.32.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"eslint": "^6.2.2",
"@uniswap/eslint-config": "^1.2.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^6.1.0",
"prettier": "^1.18.2",
"typescript": "^3.5.2"
Expand Down
Loading

0 comments on commit 13078d9

Please sign in to comment.