Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: have ESLint manage our JSDocs #1746

Merged
merged 9 commits into from
Sep 14, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(cosmic-swingset): eslint jsdoc
  • Loading branch information
michaelfig committed Sep 14, 2020
commit 9d009500072c9f4ccf2b2c3263501906729c1a3c
27 changes: 0 additions & 27 deletions packages/cosmic-swingset/.eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/cosmic-swingset/lib/ag-solo/chain-cosmos-sdk.js
Original file line number Diff line number Diff line change
@@ -317,6 +317,7 @@ ${chainID} chain does not yet know of address ${myAddr}${adviseProvision(

/**
* Get a notifier that announces every time a block lands.
*
* @returns {Notifier<any>}
*/
const getBlockNotifier = () => {
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

import { allComparable } from '@agoric/same-structure';
import {
makeLoopbackProtocolHandler,
5 changes: 3 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/bridge.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* global harden */
// @ts-check

import makeStore from '@agoric/store';

/**
* @template T
* @typedef {Object} Device
* @typedef {'Device' & { __deviceType__: T }} Device
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the double underbars?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly necessary, just to remind people not to try actually using d.__deviceType__. Do you have a better suggestion?

*/

/**
@@ -25,6 +24,7 @@ import makeStore from '@agoric/store';
* @property {(srcID: string, handler: BridgeHandler) => void} unregister
*/

/* eslint-disable jsdoc/valid-types */
/**
* Create a handler that demuxes/muxes the bridge device by its first argument.
*
@@ -33,6 +33,7 @@ import makeStore from '@agoric/store';
* @param {Device<BridgeDevice>} bridgeDevice The bridge to manage
* @returns {BridgeManager} admin facet for this handler
*/
/* eslint-enable jsdoc/valid-types */
export function makeBridgeManager(E, D, bridgeDevice) {
/**
* @type {import('@agoric/store').Store<string, BridgeHandler>}
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/captp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

// Avoid importing the full captp bundle, which would carry
// in its own makeHardener, etc.
import { makeCapTP } from '@agoric/captp/lib/captp';
3 changes: 2 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/ibc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global harden */
// @ts-check

import {
@@ -55,6 +54,7 @@ const FIXME_ALLOW_NAIVE_RELAYS = true;
const goodLetters = 'abcdefghijklmnopqrstuvwxyz';
/**
* Get a sequence of letters chosen from `goodLetters`.
*
* @param {number} n
*/
function getGoodLetters(n) {
@@ -145,6 +145,7 @@ export function makeIBCProtocolHandler(E, callIBCDevice) {

/**
* Send a packet out via the IBC device.
*
* @param {IBCPacket} packet
* @param {Store<number, PromiseRecord<Bytes, any>>} seqToAck
*/
7 changes: 4 additions & 3 deletions packages/cosmic-swingset/lib/ag-solo/vats/lib-board.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-check
/* global harden */

import { generateSparseInts } from '@agoric/sparse-ints';
import { assert, details, q } from '@agoric/assert';
@@ -11,8 +10,9 @@ const ID_REGEXP = new RegExp(`^[0-9]{${CRC_NUM_DIGITS + 1},}$`);

/**
* We calculate a CRC, ensuring it's of CRC_NUM_DIGITS length.
*
* @param {number} num
* @return {string}
* @returns {string}
*/
const calcCrc = num => {
// The explicit use of crcmodels is to avoid a typing error.
@@ -31,11 +31,12 @@ const calcCrc = num => {
* @property {(id: string) => any} getValue
* @property {(value: any) => string} getId
* @property {(value: any) => boolean} has
* @property {() => string[]} ids```
* @property {() => string[]} ids
*/

/**
* Create a board to post things on.
*
* @param {number} [seed=0]
* @returns {Board}
*/
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/repl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global harden Compartment */
/* global Compartment */

import { isPromise } from '@agoric/promise-kit';
import { E } from '@agoric/eventual-send';
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/scratch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

export default function makeScratchPad() {
const map = new Map();
async function get(idP) {
9 changes: 8 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/ui-agent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global harden */
// @ts-check

/**
@@ -11,16 +10,21 @@
* @property {typeof console} console
*/

/* eslint-disable jsdoc/valid-types */
/**
* Create a set of UI agent makers.
*
* @param {UIAgentEndowments} param0
* @returns {{[maker: string]: (petname: string, ext = {}) => UIAgent}}
*/
/* eslint-enable jsdoc/valid-types */
export default function makeAgentMakers({ console: agentConsole }) {
return harden({
/**
* Create an agent that prints to the console with a petname.
*
* @param {string} petname
* @param {Record<string, any>} [ext={}]
*/
text(petname, ext = {}) {
if (petname === undefined) {
@@ -37,6 +41,9 @@ export default function makeAgentMakers({ console: agentConsole }) {
},
/**
* Create a silent agent.
*
* @param {string} _petname
* @param {Record<string, any>} [ext={}]
*/
silent(_petname, ext = {}) {
return harden({
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-board.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

import { makeBoard } from './lib-board';

export function buildRootObject(_vatPowers) {
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-host.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright (C) 2018 Agoric, under Apache License 2.0

/* global harden */

import { makeContractHost } from '@agoric/spawner';

export function buildRootObject(vatPowers) {
1 change: 0 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global harden */
import { makeNotifierKit } from '@agoric/notifier';
import { E } from '@agoric/eventual-send';
import { getReplHandler } from './repl';
1 change: 0 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/vat-ibc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global harden */
import { E } from '@agoric/eventual-send';
import { makeIBCProtocolHandler } from './ibc';

2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-mints.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

import { makeIssuerKit } from '@agoric/ertp';

import makeStore from '@agoric/store';
1 change: 0 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/vat-network.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global harden */
// @ts-check
import { E } from '@agoric/eventual-send';
import { makeRouterProtocol } from '@agoric/swingset-vat/src/vats/network/router';
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global harden */
import { E } from '@agoric/eventual-send';

// This vat contains the controller-side provisioning service. To enable local
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-registrar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

import { makeRegistrar } from '@agoric/registrar';

// This vat contains the registrar for the demo.
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-sharing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

import { makeSharingService } from '@agoric/sharing-service';

// This vat contains the sharing service for the demo.
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-uploads.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

import makeScratchPad from './scratch';

// This vat contains the private upload scratch pad.
2 changes: 0 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-zoe.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global harden */

import { makeZoe } from '@agoric/zoe';

export function buildRootObject(_vatPowers, vatParameters) {
51 changes: 49 additions & 2 deletions packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
@@ -14,8 +14,9 @@
"pretty-check": "prettier --check '**/*.js'",
"lint-fix": "yarn lint --fix",
"lint-check": "yarn lint",
"lint": "yarn lint:types && eslint '**/*.js'",
"lint:types": "tsc -p jsconfig.json"
"lint": "yarn lint:types&&yarn lint:eslint",
"lint:types": "tsc -p jsconfig.json",
"lint:eslint": "eslint '**/*.js'"
},
"keywords": [],
"author": "Agoric",
@@ -72,6 +73,52 @@
"node-addon-api": "^1.7.1",
"nyc": "^15.1.0"
},
"eslintConfig": {
"extends": [
"airbnb-base",
"plugin:prettier/recommended",
"plugin:jsdoc/recommended"
],
"parser": "@typescript-eslint/parser",
"env": {
"es6": true
},
"globals": {
"harden": "readonly"
},
"rules": {
"implicit-arrow-linebreak": "off",
"function-paren-newline": "off",
"arrow-parens": "off",
"strict": "off",
"prefer-destructuring": "off",
"no-else-return": "off",
"no-console": "off",
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"no-return-assign": "off",
"no-param-reassign": "off",
"no-restricted-syntax": [
"off",
"ForOfStatement"
],
"no-unused-expressions": "off",
"no-loop-func": "off",
"no-inner-declarations": "off",
"import/prefer-default-export": "off",
"jsdoc/no-undefined-types": "off",
"jsdoc/require-jsdoc": "off",
"jsdoc/require-property-description": "off",
"jsdoc/require-param-description": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-returns-description": "off"
}
},
"publishConfig": {
"access": "public"
},
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global harden */
// eslint-disable-next-line import/no-extraneous-dependencies

import '@agoric/install-ses';