Skip to content

Commit

Permalink
adopt eslint-env directive (#8702)
Browse files Browse the repository at this point in the history
## Description

Make our `lint-fix` script use report-unused-disable-directives and run that to remove them. (This requires `yarn format` after because for some reason it puts spaces in front of the Jessie directive.)

Replace many `global` directives with `eslint-env node`. I think those all are to be run in Node. If some are to be run under XS, maybe we should contribute an eslint-env for it: https://eslint.org/docs/latest/use/configure/language-options

### Security Considerations

Arguably reduces visibility of ambient authority. For that I created a script that interested parties can use any time to report on it.

### Scaling Considerations

none

### Documentation Considerations

none

### Testing Considerations

nothing special

### Upgrade Considerations

n/a
  • Loading branch information
mergify[bot] authored Sep 24, 2024
2 parents f46aec9 + 64d54f6 commit c0c733c
Show file tree
Hide file tree
Showing 68 changed files with 157 additions and 74 deletions.
2 changes: 1 addition & 1 deletion golang/cosmos/index.cjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* global module require */
/* eslint-env node */
module.exports = require('bindings')('agcosmosdaemon.node');
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/initializeSwingset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
import fs from 'fs';
import path from 'path';

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/worker-protocol.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Buffer */
/* eslint-env node */
// eslint-disable-next-line import/order
import { test } from '../tools/prepare-test-env-ava.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/scripts/get-sdk-package-names.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env node
/* global process, Buffer */
/* eslint-env node */
import { spawn } from 'child_process';
import { basename } from 'path';

Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/src/anylogger-agoric.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
import {
getEnvironmentOption,
getEnvironmentOptionsList,
Expand Down
3 changes: 1 addition & 2 deletions packages/agoric-cli/src/bin-agops.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env node
/* eslint-env node */
// @ts-check
// @jessie-check

/* global fetch, setTimeout */

import '@endo/init/pre.js';

import '@endo/init';
Expand Down
10 changes: 5 additions & 5 deletions packages/agoric-cli/src/commands/oracle.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// @ts-check
/* eslint-disable func-names */
/* global fetch, setTimeout, process */
/* eslint-env node */
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
import { Fail } from '@endo/errors';
import { Nat } from '@endo/nat';
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { Command } from 'commander';
import * as cp from 'child_process';
import { Command } from 'commander';
import { inspect } from 'util';
import { oracleBrandFeedName } from '@agoric/inter-protocol/src/proposals/utils.js';
import { normalizeAddressWithOptions } from '../lib/chain.js';
import { bigintReplacer } from '../lib/format.js';
import { getNetworkConfig, makeRpcUtils, storageHelper } from '../lib/rpc.js';
import {
getCurrent,
Expand All @@ -17,7 +18,6 @@ import {
sendAction,
sendHint,
} from '../lib/wallet.js';
import { bigintReplacer } from '../lib/format.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/perf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
/* eslint-disable func-names */
/* global process */
/* eslint-env node */
import {
iterateEach,
makeCastingSpec,
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/psm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
/* eslint-disable func-names */
/* global fetch, process */
/* eslint-env node */
import { Command } from 'commander';
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { asPercent } from '../lib/format.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/reserve.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
/* eslint-disable func-names */
/* global fetch, process */
/* eslint-env node */
import { Offers } from '@agoric/inter-protocol/src/clientSupport.js';
import { Command } from 'commander';
import { makeRpcUtils } from '../lib/rpc.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/test-upgrade.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process */
/* eslint-env node */
import { Fail } from '@endo/errors';
import { CommanderError } from 'commander';
import { normalizeAddressWithOptions } from '../lib/chain.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/vaults.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
/* eslint-disable func-names */
/* global fetch, process */
/* eslint-env node */
import { Command } from 'commander';
import {
lookupOfferIdForVault,
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/wallet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
/* eslint-disable func-names */
/* global fetch, process */
/* eslint-env node */
import {
iterateLatest,
makeCastingSpec,
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/deploy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process setTimeout setInterval clearInterval */
/* eslint-env node */

import { X } from '@endo/errors';
import { makePromiseKit } from '@endo/promise-kit';
Expand Down
3 changes: 1 addition & 2 deletions packages/agoric-cli/src/entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env node
/* eslint-env node */
// @jessie-check

/* global process */

import '@endo/init/pre.js';
import 'esm';
import '@endo/init/legacy.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
// @ts-check

/** @import { ChildProcess } from 'child_process' */
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/install.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process Buffer */
/* eslint-env node */
import path from 'path';
import chalk from 'chalk';
import { makePspawn } from './helpers.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/agoric-cli/src/lib/bundles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-check

/* global Buffer */
/* eslint-env node */

import assert from 'node:assert/strict';
import fs from 'node:fs';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/lib/chain.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process */
/* eslint-env node */
import { normalizeBech32 } from '@cosmjs/encoding';
import { execFileSync as execFileSyncAmbient } from 'child_process';

Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/lib/rpc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global Buffer, fetch, process */
/* eslint-env node */

import { NonNullish } from '@agoric/internal';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/lib/wallet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process */
/* eslint-env node */

import { Fail } from '@endo/errors';
import { iterateReverse } from '@agoric/casting';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/main-publish.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
// @ts-check

import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
import { Command } from 'commander';
import path from 'path';
import url from 'url';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/open.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process setInterval clearInterval */
/* eslint-env node */
import opener from 'opener';
import { assert, X } from '@endo/errors';
import { getAccessToken } from '@agoric/access-token';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/scripts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process */
/* eslint-env node */
import bundleSource from '@endo/bundle-source';
import { E } from '@endo/captp';
import { search as readContainingPackageDescriptor } from '@endo/compartment-mapper';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/start.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process setTimeout */
/* eslint-env node */
import chalk from 'chalk';
import { createHash } from 'crypto';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/test/inter-cli.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global Buffer */
/* eslint-env node */
import '@endo/init';
import test from 'ava';
import { createCommand, CommanderError } from 'commander';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */

import { makeHelpers } from '@agoric/deploy-script-support';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */

import { makeHelpers } from '@agoric/deploy-script-support';

Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/tools/getting-started.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process setTimeout setInterval clearInterval Buffer */
/* eslint-env node */

import fs from 'fs';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable jsdoc/require-param, @jessie.js/safe-await-separator */
/* global process */
/* eslint-env node */

import childProcessAmbient from 'child_process';
import { promises as fsAmbientPromises } from 'fs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
import { makeHelpers } from '@agoric/deploy-script-support';

import { getManifestForAddAssetToVault } from '@agoric/inter-protocol/src/proposals/addAssetToVault.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/scripts/inter-protocol/init-core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
/**
* @file can be run with `agoric deploy` after a chain is running (depends on
* chain state) Only works with "local" chain and not sim-chain b/c it needs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
import { makeHelpers } from '@agoric/deploy-script-support';

import { getManifestForInviteCommittee } from '@agoric/inter-protocol/src/proposals/committee-proposal.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
import { makeHelpers } from '@agoric/deploy-script-support';

export const DEFAULT_CONTRACT_TERMS = {
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/check-validator.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env node
/* eslint-env node */
// @jessie-check

/* global process require Buffer */
// check-validator - Find if there is a validator that matches the current ag-chain-cosmos
// Michael FIG <mfig@agoric.com>, 2021-06-25
const oper = process.argv[2];
Expand Down
3 changes: 1 addition & 2 deletions packages/cosmic-swingset/scripts/clean-core-eval.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env node
/* global globalThis */

/* eslint-env node */
import '@endo/init/debug.js';
import * as farExports from '@endo/far';
import { isEntrypoint } from '../src/helpers/is-entrypoint.js';
Expand Down Expand Up @@ -63,7 +63,6 @@ export const main = async (argv, { readFile, stdout }) => {
};

if (isEntrypoint(import.meta.url)) {
/* global process */
void farExports.E.when(import('fs/promises'), fsp =>
main([...process.argv], {
readFile: fsp.readFile,
Expand Down
1 change: 1 addition & 0 deletions packages/cosmic-swingset/src/anylogger-agoric.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env node */
import {
getEnvironmentOptionsList,
getEnvironmentOption,
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process */
/* eslint-env node */

// XXX the JSON configs specify that launching the chain requires @agoric/builders,
// so let the JS tooling know about it by importing it here.
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/src/sim-chain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process setTimeout clearTimeout */
/* eslint-env node */
import path from 'path';
import fs from 'fs';
import { Fail } from '@endo/errors';
Expand Down
3 changes: 1 addition & 2 deletions packages/deployment/scripts/crunch.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#! /usr/bin/env node
/* eslint-env node */
// crunch.mjs - crunch a kvstore trace file's writes into TSV

/* global process,Buffer */

import fs from 'fs';
import ReadlineTransform from 'readline-transform';

Expand Down
2 changes: 1 addition & 1 deletion packages/deployment/scripts/docker-deployment.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env node
/* global process */
/* eslint-env node */
// Get a deployment.json for a 2-node docker setup.

const DEFAULT_NUM_VALIDATORS = 2;
Expand Down
1 change: 0 additions & 1 deletion packages/deployment/src/entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#! /usr/bin/env node
/* eslint-env node */

import '@endo/init';

import fs from 'fs';
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/src/lib-nodejs/worker-protocol.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Buffer */
/* eslint-env node */
import { Transform } from 'stream';

// Transform objects which convert from hardened Arrays of JSON-serializable
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/src/netstring.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Buffer */
/* eslint-env node */
import { Fail } from '@endo/errors';

// adapted from 'netstring-stream', https://github.com/tlivings/netstring-stream/
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/src/node/buffer-line-transform.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Buffer */
/* eslint-env node */
/* eslint-disable no-underscore-dangle */

import { Transform } from 'node:stream';
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/src/node/createBundles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
// Use modules not prefixed with `node:` since some deploy scripts may
// still be running in esm emulation
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/test/netstring.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Buffer */
/* eslint-env node */
import test from 'ava';

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/src/init-basedir.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process */
/* eslint-env node */
import fs from 'fs';
import path from 'path';
import { execFileSync } from 'child_process';
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/src/outbound.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
import anylogger from 'anylogger';

import { Fail } from '@endo/errors';
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/src/pipe-entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */
// @ts-check
import '@endo/init/pre-bundle-source.js';
import '@endo/init/unsafe-fast.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/src/start.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
/* global process setTimeout */
/* eslint-env node */
import fs from 'fs';
import url from 'url';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/test/captp-fixture.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process setTimeout */
/* eslint-env node */
import { spawn } from 'child_process';
import WebSocket from 'ws';
import { makeCapTP, E } from '@endo/captp';
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/test/home.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process */
/* eslint-env node */

import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';

Expand Down
Loading

0 comments on commit c0c733c

Please sign in to comment.