Skip to content

Commit

Permalink
lint a3p-integration (#10262)
Browse files Browse the repository at this point in the history
closes: #10238

## Description

Lint a3p-integration for consistency and stopping red squiggles in IDEs

Should unblock #10171 once it rebases on this

### Security Considerations
n/a

### Scaling Considerations
n/a


### Documentation Considerations
The config should explain

### Testing Considerations
per se

### Upgrade Considerations
none
  • Loading branch information
mergify[bot] authored Oct 15, 2024
2 parents c4690ab + 09055eb commit 4fccb10
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 19 deletions.
12 changes: 11 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ module.exports = {
'./packages/*/tsconfig.json',
'./packages/*/tsconfig.json',
'./packages/wallet/*/tsconfig.json',
'./a3p-integration/proposals/*/tsconfig.json',
'./tsconfig.json',
],
tsconfigRootDir: __dirname,
Expand Down Expand Up @@ -240,6 +239,17 @@ module.exports = {
project: false,
},
},
{
files: ['a3p-integration/**'],
extends: ['plugin:@typescript-eslint/disable-type-checked'],
parserOptions: {
EXPERIMENTAL_useProjectService: false,
project: false,
},
rules: {
'@jessie.js/safe-await-separator': 'off',
},
},
{
// Types files have no promises to lint and that linter chokes on the .d.ts twin.
// Maybe due to https://github.com/typescript-eslint/typescript-eslint/issues/7435
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,17 @@ jobs:
with:
node-version: '18.x'

- name: yarn lint rest
# Check some of a3p-integration in this job that runs on PRs instead of
# waiting for the slow integration test that by default only runs in the
# master merge check
- name: yarn lint rest of packages/*
run: ./scripts/lint-with-types.sh rest
- name: Lint a3p-integration
run: yarn install && yarn lint && yarn doctor
working-directory: a3p-integration
- name: build A3P submissions
run: yarn run build:submissions
working-directory: a3p-integration

##################
# Fast-running tests run as a group:
Expand Down
1 change: 1 addition & 0 deletions a3p-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build:priceFeeds-for-mainnet": "scripts/build-submission.sh proposals/f:replace-price-feeds inter-protocol/updatePriceFeeds.js submission/main main; scripts/build-submission.sh proposals/f:replace-price-feeds vats/add-auction.js submission/main; scripts/build-submission.sh proposals/f:replace-price-feeds vats/upgradeVaults.js submission/main",
"build:priceFeeds-for-devnet": "scripts/build-submission.sh proposals/f:replace-price-feeds inter-protocol/updatePriceFeeds.js submission/devnet devnet; scripts/build-submission.sh proposals/f:replace-price-feeds vats/add-auction.js submission/devnet; scripts/build-submission.sh proposals/f:replace-price-feeds vats/upgradeVaults.js submission/devnet",
"build:synthetic-chain": "yarn synthetic-chain build",
"lint": "../node_modules/.bin/eslint proposals",
"test": "yarn synthetic-chain test",
"doctor": "yarn synthetic-chain doctor"
},
Expand Down
3 changes: 1 addition & 2 deletions a3p-integration/proposals/n:upgrade-next/agd-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
GOV1ADDR,
GOV2ADDR,
GOV3ADDR,
newOfferId,
VALIDATORADDR,
} from '@agoric/synthetic-chain';

Expand Down Expand Up @@ -97,7 +96,7 @@ export const addPreexistingOracles = async (brandIn, oraclesByBrand) => {
const path = `published.wallet.${oracleAddress}.current`;
const wallet = await getQuoteBody(path);
const idToInvitation = wallet.offerToUsedInvitation.find(([k]) => {
return !isNaN(k[0]);
return !Number.isNaN(k[0]);
});
if (idToInvitation) {
oraclesWithID.push({
Expand Down
4 changes: 3 additions & 1 deletion a3p-integration/proposals/n:upgrade-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "^0.3.0",
"ava": "^5.3.1"
"ava": "^5.3.1",
"better-sqlite3": "^9.6.0",
"execa": "^9.3.1"
},
"ava": {
"concurrency": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file work-around: importing @agoric/synthetic-chain hangs XXX
*/
// @ts-check
/* eslint-env node */
import { $ } from 'execa';

const waitForBootstrap = async () => {
Expand Down Expand Up @@ -103,6 +104,7 @@ export const makeAgd = ({ execFileSync }) => {
const nameHub = freeze({
/**
* NOTE: synchronous I/O
* @param {...any} path
*/
lookup: (...path) => {
if (!Array.isArray(path)) {
Expand Down
3 changes: 3 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/vatDetails.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-env node */

import dbOpenAmbient from 'better-sqlite3';

const HOME = process.env.HOME;
Expand Down Expand Up @@ -43,6 +45,7 @@ const makeSwingstore = db => {
const sql = dbTool(db);

/** @param {string} key */
// @ts-expect-error cast
const kvGet = key => sql.get`select * from kvStore where key = ${key}`.value;
/** @param {string} key */
const kvGetJSON = key => JSON.parse(kvGet(key));
Expand Down
2 changes: 2 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,8 @@ __metadata:
dependencies:
"@agoric/synthetic-chain": "npm:^0.3.0"
ava: "npm:^5.3.1"
better-sqlite3: "npm:^9.6.0"
execa: "npm:^9.3.1"
languageName: unknown
linkType: soft

Expand Down
1 change: 0 additions & 1 deletion a3p-integration/proposals/s:stake-bld/stakeBld.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @jessie.js/safe-await-separator -- buggy version */
import test from 'ava';

import { QueryClient, setupStakingExtension } from '@cosmjs/stargate'; // fails to import after Endo/init
Expand Down
1 change: 0 additions & 1 deletion a3p-integration/proposals/s:stake-bld/test-lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const networkConfig = {
*/
const delay = ms => new Promise(resolve => setTimeout(() => resolve(), ms));

// eslint-disable-next-line @jessie.js/safe-await-separator -- buggy version
export const walletUtils = await makeWalletUtils(
{ delay, execFileSync, fetch },
networkConfig,
Expand Down
1 change: 0 additions & 1 deletion a3p-integration/proposals/z:acceptance/core-eval.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @jessie.js/safe-await-separator */
import test from 'ava';
import { readFile, writeFile } from 'node:fs/promises';

Expand Down
1 change: 1 addition & 0 deletions a3p-integration/proposals/z:acceptance/exitOffer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Note: limit imports to node modules for portability
/* eslint-env node */
import { parseArgs, promisify } from 'node:util';
import { execFile } from 'node:child_process';
import { writeFile, mkdtemp, rm } from 'node:fs/promises';
Expand Down
4 changes: 1 addition & 3 deletions a3p-integration/proposals/z:acceptance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
"@endo/far": "^1.1.5",
"@endo/init": "^1.1.4",
"ava": "^6.1.2",
"execa": "^9.3.1",
"tsx": "^4.17.0"
},
"resolutions": {
"execa": "^9.3.1"
},
"ava": {
"concurrency": 1,
"serial": true,
Expand Down
6 changes: 4 additions & 2 deletions a3p-integration/proposals/z:acceptance/test-lib/sync-tools.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-env node */

/**
* @file These tools mostly duplicate code that will be added in other PRs
* and eventually migrated to synthetic-chain. Sorry for the duplication.
Expand All @@ -7,12 +9,12 @@
* @typedef {object} RetryOptions
* @property {number} [maxRetries]
* @property {number} [retryIntervalMs]
* @property {(...arg0: string[]) => void} [log]
* @property {(...arg0: string[]) => void} log
* @property {(object) => void} [setTimeout]
* @property {string} [errorMessage=Error]
*/

const ambientSetTimeout = globalThis.setTimeout;
const ambientSetTimeout = global.setTimeout;

/**
* From https://github.com/Agoric/agoric-sdk/blob/442f07c8f0af03281b52b90e90c27131eef6f331/multichain-testing/tools/sleep.ts#L10
Expand Down
3 changes: 1 addition & 2 deletions a3p-integration/proposals/z:acceptance/test-lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ export const getBalances = async (addresses, targetDenom = undefined) => {
return addresses.length === 1 ? balancesList[0] : balancesList;
};

export const agopsVaults = async addr =>
await agops.vaults('list', '--from', addr);
export const agopsVaults = addr => agops.vaults('list', '--from', addr);
3 changes: 2 additions & 1 deletion a3p-integration/proposals/z:acceptance/vaults.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
import test from 'ava';
import {
agoric,
Expand Down Expand Up @@ -47,7 +48,7 @@ test.before(async t => {
'price not pushed yet',
{
log: t.log,
setTimeout: globalThis.setTimeout,
setTimeout: global.setTimeout,
// @ts-expect-error t.context is fine
...t.context.pushPriceRetryOpts,
},
Expand Down
8 changes: 5 additions & 3 deletions a3p-integration/proposals/z:acceptance/wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
CHAINID,
waitForBlock,
} from '@agoric/synthetic-chain';
import { $ } from 'execa';
import {
agd,
getBalances,
replaceTemplateValuesInFile,
} from './test-lib/utils.js';
import { $ } from 'execa';

test.serial(`send invitation via namesByAddress`, async t => {
const SUBMISSION_DIR = 'invitation-test-submission';
Expand Down Expand Up @@ -54,8 +54,10 @@ test.serial('exitOffer tool reclaims stuck payment', async t => {
const after = await getBalances([GOV1ADDR], 'uist');
t.log('uist balance after:', after);

t.true(after > before),
'The IST balance should increase after reclaiming the stuck payment';
t.true(
after > before,
'The IST balance should increase after reclaiming the stuck payment',
);
});

test.serial(`ante handler sends fee only to vbank/reserve`, async t => {
Expand Down
1 change: 1 addition & 0 deletions a3p-integration/proposals/z:acceptance/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2517,6 +2517,7 @@ __metadata:
"@endo/far": "npm:^1.1.5"
"@endo/init": "npm:^1.1.4"
ava: "npm:^6.1.2"
execa: "npm:^9.3.1"
tsx: "npm:^4.17.0"
typescript: "npm:^5.5.4"
languageName: unknown
Expand Down

0 comments on commit 4fccb10

Please sign in to comment.