Skip to content

Commit

Permalink
chore: add lint to ci (#1034)
Browse files Browse the repository at this point in the history
* chore: fix types warning

* chore: fix lint

* chore: update to typescript 5

* chore: raise error on lint error on CI

* chore: `lint` task should raise an error

* chore: bump compilation target to es6

* v0.11.39

---------

Co-authored-by: Chaitanya <[email protected]>
  • Loading branch information
wa0x6e and ChaituVR authored Jul 11, 2024
1 parent 63f74f1 commit 710c50c
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 45 deletions.
28 changes: 4 additions & 24 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
name: Lint
on:
workflow_dispatch:
schedule:
- cron: 0 10 * * 0

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Run lint script
run: |
npm ci
npm run lint
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Automated lint
title: Automated lint
body: |
- Changes from lint script
Auto-generated by Github Actions
branch: automated-lint
uses: snapshot-labs/actions/.github/workflows/lint.yml@main
secrets: inherit
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
yarn install --frozen-lockfile
yarn build
yarn test:once --coverage
yarn lint
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snapshot-labs/snapshot.js",
"version": "0.11.38",
"version": "0.11.39",
"repository": "snapshot-labs/snapshot.js",
"license": "MIT",
"main": "dist/snapshot.cjs.js",
Expand Down Expand Up @@ -45,7 +45,7 @@
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript2": "^0.27.0",
"ts-node": "^10.9.2",
"typescript": "^3.8.3",
"typescript": "^5.0.0",
"vitest": "^0.33.0"
},
"scripts": {
Expand All @@ -54,7 +54,9 @@
"test": "vitest",
"test:once": "vitest run",
"dev": "rollup -c -w",
"lint": "eslint . --ext .ts --fix",
"lint": "eslint . --ext .ts",
"lint:fix": "yarn lint --fix",
"typecheck": "tsc --noEmit",
"prepublishOnly": "yarn build"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/sign/eip1271.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function verifyDefault(
[abi],
[address, 'isValidSignature', [arrayify(hash), sig]]
);
} catch (e) {
} catch (e: any) {
// @ts-ignore
if (e.message.startsWith('missing revert data in call exception')) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/sign/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function verify(address, sig, data, network = '1', options = {}) {
const recoverAddress = verifyTypedData(domain, types, message, sig);
// console.log('Recover address', recoverAddress);
if (address === recoverAddress) return true;
} catch (e) {
} catch (e: any) {
// console.log('Could not recoverAddress:' + e.message);
}

Expand Down
16 changes: 8 additions & 8 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function parseScoreAPIResponse(res: any) {
let data: any = await res.text();
try {
data = JSON.parse(data);
} catch (e) {
} catch (e: any) {
return Promise.reject({
code: res.status || 500,
message: 'Failed to parse response from score API',
Expand Down Expand Up @@ -206,7 +206,7 @@ export async function call(provider, abi: any[], call: any[], options?) {
try {
const params = call[2] || [];
return await contract[call[1]](...params, options || {});
} catch (e) {
} catch (e: any) {
return Promise.reject(e);
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ export async function multicall(
return results.map((call, i) =>
itf.decodeFunctionResult(calls[i][1], call)
);
} catch (e) {
} catch (e: any) {
return Promise.reject(e);
}
}
Expand All @@ -265,7 +265,7 @@ export async function subgraphRequest(url: string, query, options: any = {}) {
let responseData: any = await res.text();
try {
responseData = JSON.parse(responseData);
} catch (e) {
} catch (e: any) {
throw new Error(
`Errors found in subgraphRequest: URL: ${url}, Status: ${
res.status
Expand Down Expand Up @@ -390,7 +390,7 @@ export async function getScores(
return options.returnValue === 'all'
? response.result
: response.result[options.returnValue || 'scores'];
} catch (e) {
} catch (e: any) {
if (e.errno) {
return Promise.reject({ code: e.errno, message: e.toString(), data: '' });
}
Expand Down Expand Up @@ -450,7 +450,7 @@ export async function getVp(
const res = await fetch(url, init);
const response = await parseScoreAPIResponse(res);
return response.result;
} catch (e) {
} catch (e: any) {
if (e.errno) {
return Promise.reject({ code: e.errno, message: e.toString(), data: '' });
}
Expand Down Expand Up @@ -504,7 +504,7 @@ export async function validate(
const res = await fetch(url, init);
const response = await parseScoreAPIResponse(res);
return response.result;
} catch (e) {
} catch (e: any) {
if (e.errno) {
return Promise.reject({ code: e.errno, message: e.toString(), data: '' });
}
Expand Down Expand Up @@ -574,7 +574,7 @@ export async function getSpaceUri(
): Promise<string | null> {
try {
return await getEnsTextRecord(id, 'snapshot', network, options);
} catch (e) {
} catch (e: any) {
console.log(e);
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getBlockNumber(provider) {
try {
const blockNumber: any = await provider.getBlockNumber();
return parseInt(blockNumber);
} catch (e) {
} catch (e: any) {
return Promise.reject();
}
}
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"module": "es6",
"noImplicitAny": false,
"outDir": "./dist",
"target": "es5",
"target": "es6",
"lib": ["es2018", "dom", "esnext"],
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"downlevelIteration": true
"downlevelIteration": true,
"skipLibCheck": true
},
"include": [
"src/**/*"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4934,10 +4934,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^3.8.3:
version "3.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
typescript@^5.0.0:
version "5.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa"
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==

ufo@^1.1.2:
version "1.1.2"
Expand Down

0 comments on commit 710c50c

Please sign in to comment.