Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 2ff7ca5

Browse files
Gozalaachingbrain
andauthored
chore: use eslint-config-ipfs (#3287)
Uses shared eslint config `eslint-config-ipfs` by integrating ipfs/aegir#638. Shared config uses new jsdoc plugin enabling use to remove bunch of `eslint-disable-next-line valid-jsdoc` comments. On the flip side it adds bit more requirements for structuring jsdoc comments. Most changes are generated automatically by eslint with `--fix` flag. This change also intentionally adds `.eslintrc` files to every package with content `{ "extends": "ipfs" }`, so that all the tools that support eslint pick up desired configuration. `eslint-config-ipfs` package itself isn't added to dependencies, because it gets installed as `aegir` dependency. Co-authored-by: achingbrain <[email protected]>
1 parent 0c88348 commit 2ff7ca5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+247
-180
lines changed
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "ipfs"
3+
}

packages/interface-ipfs-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"uint8arrays": "^1.1.0"
6767
},
6868
"devDependencies": {
69-
"aegir": "^26.0.0",
69+
"aegir": "^27.0.0",
7070
"ipfsd-ctl": "^7.0.0"
7171
},
7272
"contributors": [

packages/ipfs-cli/.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "ipfs"
3+
}

packages/ipfs-cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"yargs": "^16.0.3"
7575
},
7676
"devDependencies": {
77-
"aegir": "^26.0.0",
77+
"aegir": "^27.0.0",
7878
"nanoid": "^3.1.12",
7979
"ncp": "^2.0.0",
8080
"rimraf": "^3.0.2",

packages/ipfs-cli/test/utils/ipfs-exec.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ module.exports = (repoPath, opts) => {
7373

7474
/**
7575
* Expect the command passed as @param arguments to fail.
76-
* @param {String} command String command to run, e.g. `'pin ls'`
77-
* @param {Object} options Options to pass to `execa`
78-
* @return {Promise} Resolves if the command passed as @param arguments fails,
79-
* rejects if it was successful.
76+
*
77+
* @param {string} command - String command to run, e.g. `'pin ls'`
78+
* @param {Object} options - Options to pass to `execa`
79+
* @returns {Promise} Resolves if the command passed as @param arguments fails,
80+
* rejects if it was successful.
8081
*/
8182
ipfs.fail = function ipfsFail (command, options) {
8283
return ipfs(command, { disableErrorLog: true, ...(options || {}) })

packages/ipfs-core-utils/.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "ipfs"
3+
}

packages/ipfs-core-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"uint8arrays": "^1.1.0"
4040
},
4141
"devDependencies": {
42-
"aegir": "^26.0.0",
42+
"aegir": "^27.0.0",
4343
"delay": "^4.4.0"
4444
}
4545
}

packages/ipfs-core-utils/src/cid.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
const CID = require('cids')
44

55
/**
6-
* Stringify a CID encoded in the requested base, upgrading to v1 if necessary.
7-
*
8-
* Setting upgrade to false will disable automatic CID upgrading from v0 to v1
9-
* which is necessary if the multibase is something other than base58btc. Note
10-
* that it will also not apply the encoding (since v0 CIDs can only be encoded
11-
* as base58btc).
12-
*
13-
* @param {CID|Buffer|String} cid The CID to encode
14-
* @param {Object} [options] Optional options
15-
* @param {String} [options.base] Name of multibase codec to encode the CID with
16-
* @param {Boolean} [options.upgrade] Automatically upgrade v0 CIDs to v1 when
17-
* necessary. Default: true.
18-
* @returns {String}
19-
*/
6+
* Stringify a CID encoded in the requested base, upgrading to v1 if necessary.
7+
*
8+
* Setting upgrade to false will disable automatic CID upgrading from v0 to v1
9+
* which is necessary if the multibase is something other than base58btc. Note
10+
* that it will also not apply the encoding (since v0 CIDs can only be encoded
11+
* as base58btc).
12+
*
13+
* @param {CID | Buffer | string} cid - The CID to encode
14+
* @param {Object} [options] - Optional options
15+
* @param {string} [options.base] - Name of multibase codec to encode the CID with
16+
* @param {boolean} [options.upgrade] - Automatically upgrade v0 CIDs to v1 when
17+
* necessary. Default: true.
18+
* @returns {string}
19+
*/
2020
exports.cidToString = (cid, options) => {
2121
options = options || {}
2222
options.upgrade = options.upgrade !== false

packages/ipfs-core/.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "ipfs"
3+
}

packages/ipfs-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"uint8arrays": "^1.1.0"
118118
},
119119
"devDependencies": {
120-
"aegir": "^26.0.0",
120+
"aegir": "^27.0.0",
121121
"delay": "^4.4.0",
122122
"ipfsd-ctl": "^7.0.0",
123123
"interface-ipfs-core": "^0.140.0",

packages/ipfs-core/src/api-manager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = class ApiManager {
88

99
/**
1010
* @template API
11-
* @typedef {{ cancel(): any; api: API; }} Updated
11+
* @typedef {{ cancel: () => any, api: API }} Updated
1212
*/
1313

1414
constructor () {

packages/ipfs-core/src/components/add-all/index.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ const { withTimeoutOption } = require('../../utils')
88
const mergeOptions = require('merge-options').bind({ ignoreUndefined: true })
99

1010
/**
11-
* @typedef {Uint8Array | Blob | String | Iterable<Uint8Array> | Iterable<number> | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>} FileContent
11+
* @typedef {Uint8Array | Blob | string | Iterable<Uint8Array> | Iterable<number> | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>} FileContent
1212
*
1313
* @typedef {object} FileObject
14-
* - If no path is specified, then the item will be added to the root level and will be given a name according to it's CID.
15-
* - If no content is passed, then the item is treated as an empty directory.
16-
* - One of path or content must be passed.
14+
* - If no path is specified, then the item will be added to the root level and will be given a name according to it's CID.
15+
* - If no content is passed, then the item is treated as an empty directory.
16+
* - One of path or content must be passed.
1717
* @property {string} [path] - The path you want to the file to be accessible at from the root CID _after_ it has been added
1818
* @property {FileContent} [content] - The contents of the file
1919
* @property {number | string} [mode] - File mode to store the entry with (see https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation)
@@ -45,6 +45,7 @@ const mergeOptions = require('merge-options').bind({ ignoreUndefined: true })
4545

4646
/**
4747
* Import multiple files and data into IPFS.
48+
*
4849
* @template {Record<string, any>} ExtraOptions
4950
* @callback AddAll
5051
* @param {FileStream} source
@@ -54,8 +55,6 @@ const mergeOptions = require('merge-options').bind({ ignoreUndefined: true })
5455

5556
module.exports = ({ block, gcLock, preload, pin, options: constructorOptions }) => {
5657
const isShardingEnabled = constructorOptions.EXPERIMENTAL && constructorOptions.EXPERIMENTAL.sharding
57-
58-
// eslint-disable-next-line valid-jsdoc
5958
/**
6059
* @type {AddAll<{}>}
6160
*/

packages/ipfs-core/src/components/add-all/utils.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
* Parses chunker string into options used by DAGBuilder in ipfs-unixfs-engine
55
*
66
*
7-
* @param {String} chunker Chunker algorithm supported formats:
8-
* "size-{size}"
9-
* "rabin"
10-
* "rabin-{avg}"
11-
* "rabin-{min}-{avg}-{max}"
7+
* @param {string} chunker - Chunker algorithm supported formats:
8+
* "size-{size}"
9+
* "rabin"
10+
* "rabin-{avg}"
11+
* "rabin-{min}-{avg}-{max}"
1212
*
13-
* @return {Object} Chunker options for DAGBuilder
13+
* @returns {Object} Chunker options for DAGBuilder
1414
*/
1515
const parseChunkerString = (chunker) => {
1616
if (!chunker) {
@@ -40,12 +40,12 @@ const parseChunkerString = (chunker) => {
4040
/**
4141
* Parses rabin chunker string
4242
*
43-
* @param {String} chunker Chunker algorithm supported formats:
44-
* "rabin"
45-
* "rabin-{avg}"
46-
* "rabin-{min}-{avg}-{max}"
43+
* @param {string} chunker - Chunker algorithm supported formats:
44+
* "rabin"
45+
* "rabin-{avg}"
46+
* "rabin-{min}-{avg}-{max}"
4747
*
48-
* @return {Object} rabin chunker options
48+
* @returns {Object} rabin chunker options
4949
*/
5050
const parseRabinString = (chunker) => {
5151
const options = {}

packages/ipfs-core/src/components/add.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ const last = require('it-last')
1414
* @property {string} [hashAlg] - multihash hashing algorithm to use (default: `'sha2-256'`)
1515
* @property {boolean} [onlyHash] - If true, will not add blocks to the blockstore (default: `false`)
1616
* @property {boolean} [pin] - pin this object when adding (default: `true`)
17-
* @property {function} [progress] - a function that will be called with the byte length of chunks as a file is added to ipfs (default: `undefined`)
17+
* @property {Function} [progress] - a function that will be called with the byte length of chunks as a file is added to ipfs (default: `undefined`)
1818
* @property {boolean} [rawLeaves] - if true, DAG leaves will contain raw file data and not be wrapped in a protobuf (default: `false`)
1919
* @property {boolean} [trickle] - if true will use the [trickle DAG](https://godoc.org/github.com./ipsn/go-ipfs/gxlibs/github.com./ipfs/go-unixfs/importer/trickle) format for DAG generation (default: `false`)
2020
* @property {boolean} [wrapWithDirectory] - Adds a wrapping node around the content (default: `false`)
2121
*/
2222

2323
/**
2424
* Import a file or data into IPFS.
25+
*
2526
* @template {Record<string, any>} ExtraOptions
2627
* @callback Add
2728
* @param {Source} source - Data to import
@@ -30,7 +31,6 @@ const last = require('it-last')
3031
*/
3132

3233
module.exports = ({ addAll }) => {
33-
// eslint-disable-next-line valid-jsdoc
3434
/**
3535
* @type {Add<{}>}
3636
*/

packages/ipfs-core/src/components/bitswap/stat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ const { withTimeoutOption } = require('../../utils')
1919

2020
/**
2121
* Show diagnostic information on the bitswap agent.
22+
*
2223
* @template {Record<string, any>} ExtraOptions
2324
* @callback Stat
2425
* @param {import('../../utils').AbortOptions & ExtraOptions} [options]
2526
* @returns {Promise<BitswapStats>}
2627
*/
2728

2829
module.exports = ({ bitswap }) => {
29-
// eslint-disable-next-line valid-jsdoc
3030
/**
3131
* @type {Stat<{}>}
3232
*/

packages/ipfs-core/src/components/bitswap/unwant.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const { withTimeoutOption } = require('../../utils')
1010

1111
/**
1212
* Removes one or more CIDs from the wantlist
13+
*
1314
* @template {Record<string, any>} ExtraOptions
1415
* @callback Unwant
1516
* @param {CID | CID[]} cids - The CIDs to remove from the wantlist
@@ -18,7 +19,6 @@ const { withTimeoutOption } = require('../../utils')
1819
*/
1920

2021
module.exports = ({ bitswap }) => {
21-
// eslint-disable-next-line valid-jsdoc
2222
/**
2323
* @type {Unwant<{}>}
2424
*/

packages/ipfs-core/src/components/bitswap/wantlist-for-peer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const { withTimeoutOption } = require('../../utils')
1010

1111
/**
1212
* Returns the wantlist for a connected peer
13+
*
1314
* @template {Record<string, any>} ExtraOptions
1415
* @callback WantlistForPeer
1516
* @param {PeerId | CID | string | Buffer} peerId - A peer ID to return the wantlist for\
@@ -18,7 +19,6 @@ const { withTimeoutOption } = require('../../utils')
1819
*/
1920

2021
module.exports = ({ bitswap }) => {
21-
// eslint-disable-next-line valid-jsdoc
2222
/**
2323
* @type {WantlistForPeer<{}>}
2424
*/

packages/ipfs-core/src/components/bitswap/wantlist.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ const { withTimeoutOption } = require('../../utils')
88

99
/**
1010
* Returns the wantlist for your node
11+
*
1112
* @template {Record<string, any>} ExtraOptions
1213
* @callback WantlistFn
1314
* @param {import('../../utils').AbortOptions & ExtraOptions} [options]
1415
* @returns {Promise<CID[]>} - An array of CIDs currently in the wantlist
1516
*/
1617

1718
module.exports = ({ bitswap }) => {
18-
// eslint-disable-next-line valid-jsdoc
1919
/**
2020
* @type {WantlistFn<{}>}
2121
*/

packages/ipfs-core/src/components/block/get.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const { withTimeoutOption } = require('../../utils')
1515

1616
/**
1717
* Get a raw IPFS block.
18+
*
1819
* @template {Record<string, any>} ExtraOptions
1920
* @callback BlockGet
2021
* @param {CID | string | Buffer} cid - A CID that corresponds to the desired block
@@ -23,7 +24,6 @@ const { withTimeoutOption } = require('../../utils')
2324
*/
2425

2526
module.exports = ({ blockService, preload }) => {
26-
// eslint-disable-next-line valid-jsdoc
2727
/**
2828
* @type {BlockGet<PreloadOptions>}
2929
*/

packages/ipfs-core/src/components/block/put.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const { withTimeoutOption } = require('../../utils')
2424

2525
/**
2626
* Stores input as an IPFS block.
27+
*
2728
* @template {Record<string, any>} ExtraOptions
2829
* @callback BlockPut
2930
* @param {Buffer | Block} block - The block or data to store
@@ -32,7 +33,6 @@ const { withTimeoutOption } = require('../../utils')
3233
*/
3334

3435
module.exports = ({ blockService, pin, gcLock, preload }) => {
35-
// eslint-disable-next-line valid-jsdoc
3636
/**
3737
* @type {BlockPut<import('./get').PreloadOptions>}
3838
*/

packages/ipfs-core/src/components/dht.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = ({ libp2p, repo }) => {
9696
* Query the DHT for all multiaddresses associated with a `PeerId`.
9797
*
9898
* @param {PeerId} peerId - The id of the peer to search for.
99-
* @returns {Promise<{ id: String, addrs: Multiaddr[] }>}
99+
* @returns {Promise<{id: string, addrs: Multiaddr[]}>}
100100
*/
101101
findPeer: withTimeoutOption(async peerId => { // eslint-disable-line require-await
102102
if (typeof peerId === 'string') {

0 commit comments

Comments
 (0)