Skip to content

Commit 3d74818

Browse files
committed
fix: linting
1 parent 638dbed commit 3d74818

20 files changed

+64
-62
lines changed

src/bases/identity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

3-
import { from } from './base.js'
43
import { fromString, toString } from '../bytes.js'
4+
import { from } from './base.js'
55

66
export const identity = from({
77
prefix: '\x00',

src/basics.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
// @ts-check
22

3-
import * as identityBase from './bases/identity.js'
4-
import * as base2 from './bases/base2.js'
5-
import * as base8 from './bases/base8.js'
63
import * as base10 from './bases/base10.js'
74
import * as base16 from './bases/base16.js'
5+
import * as base2 from './bases/base2.js'
6+
import * as base256emoji from './bases/base256emoji.js'
87
import * as base32 from './bases/base32.js'
98
import * as base36 from './bases/base36.js'
109
import * as base58 from './bases/base58.js'
1110
import * as base64 from './bases/base64.js'
12-
import * as base256emoji from './bases/base256emoji.js'
13-
import * as sha2 from './hashes/sha2.js'
14-
import * as identity from './hashes/identity.js'
15-
16-
import * as raw from './codecs/raw.js'
11+
import * as base8 from './bases/base8.js'
12+
import * as identityBase from './bases/identity.js'
1713
import * as json from './codecs/json.js'
18-
14+
import * as raw from './codecs/raw.js'
15+
import * as identity from './hashes/identity.js'
16+
import * as sha2 from './hashes/sha2.js'
1917
import { CID, hasher, digest, varint, bytes } from './index.js'
2018

2119
const bases = { ...identityBase, ...base2, ...base8, ...base10, ...base16, ...base32, ...base36, ...base58, ...base64, ...base256emoji }

src/block/interface.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
22
/* eslint-disable no-use-before-define */
3-
import { Link, Version } from '../link/interface.js'
4-
import { CID } from '../cid.js'
3+
4+
import type { CID } from '../cid.js'
5+
import type { Link, Version } from '../link/interface.js'
56

67
/**
78
* A byte-encoded representation of some type of `Data`.

src/cid.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import * as varint from './varint.js'
2-
import * as Digest from './hashes/digest.js'
3-
import { base58btc } from './bases/base58.js'
41
import { base32 } from './bases/base32.js'
2+
import { base58btc } from './bases/base58.js'
53
import { coerce } from './bytes.js'
4+
import * as Digest from './hashes/digest.js'
65
// Linter can see that API is used in types.
76
// eslint-disable-next-line
87
import * as API from "./link/interface.js"
8+
import * as varint from './varint.js'
99

1010
// This way TS will also expose all the types from module
1111
export * from './link/interface.js'
@@ -82,7 +82,6 @@ export class CID {
8282
* @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
8383
* @param {API.MultihashDigest<Alg>} multihash - (Multi)hash of the of the content.
8484
* @param {Uint8Array} bytes
85-
*
8685
*/
8786
constructor (version, code, multihash, bytes) {
8887
/** @readonly */
@@ -215,6 +214,9 @@ export class CID {
215214
return format(this, base)
216215
}
217216

217+
/**
218+
* @returns {API.LinkJSON<this>}
219+
*/
218220
toJSON () {
219221
return { '/': format(this) }
220222
}

src/hashes/sha2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @ts-check
22

33
import crypto from 'crypto'
4-
import { from } from './hasher.js'
54
import { coerce } from '../bytes.js'
5+
import { from } from './hasher.js'
66

77
export const sha256 = from({
88
name: 'sha2-256',

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { CID } from './cid.js'
2-
import * as varint from './varint.js'
31
import * as bytes from './bytes.js'
4-
import * as hasher from './hashes/hasher.js'
2+
import { CID } from './cid.js'
53
import * as digest from './hashes/digest.js'
4+
import * as hasher from './hashes/hasher.js'
5+
import * as varint from './varint.js'
6+
67
// This way TS will also expose all the types from module
78
export * from './interface.js'
89

src/link.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { CID, format, toJSON, fromJSON } from './cid.js'
12
// Linter can see that API is used in types.
23
// eslint-disable-next-line
34
import * as API from "./link/interface.js"
4-
import { CID, format, toJSON, fromJSON } from './cid.js'
55
// This way TS will also expose all the types from module
66
export * from './link/interface.js'
77

src/link/interface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
22
/* eslint-disable no-use-before-define */
3-
import type { MultihashDigest } from '../hashes/interface.js'
3+
44
import type { MultibaseEncoder, MultibaseDecoder, Multibase } from '../bases/interface.js'
55
import type { Phantom, ByteView } from '../block/interface.js'
6+
import type { MultihashDigest } from '../hashes/interface.js'
67

78
export type { MultihashDigest, MultibaseEncoder, MultibaseDecoder }
89
export type Version = 0 | 1

src/traversal.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { base58btc } from './bases/base58.js'
22

33
/**
4-
* @template [C=number] - multicodec code corresponding to codec used to encode the block
5-
* @template [A=number] - multicodec code corresponding to the hashing algorithm used in CID creation.
6-
* @template [V=0|1] - CID version
7-
* @typedef {import('./cid').CID<unknown, C, A, V>} CID
4+
* @typedef {import('./cid').CID} CID
85
*/
96

107
/**
11-
* @template [T=unknown] - Logical type of the data encoded in the block
12-
* @template [C=number] - multicodec code corresponding to codec used to encode the block
13-
* @template [A=number] - multicodec code corresponding to the hashing algorithm used in CID creation.
14-
* @template [V=0|1] - CID version
15-
* @typedef {import('./block/interface.js').BlockView<T, C, A, V>} BlockView
8+
* @typedef {import('./block/interface.js').BlockView} BlockView
169
*/
1710

1811
/**

test/test-block.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* globals describe, it */
2+
3+
import { assert } from 'aegir/chai'
4+
import * as main from '../src/block.js'
25
import * as codec from '../src/codecs/json.js'
36
import { sha256 as hasher } from '../src/hashes/sha2.js'
4-
import * as main from '../src/block.js'
57
import { CID, bytes } from '../src/index.js'
6-
import { assert } from 'aegir/chai'
78

89
const fixture = { hello: 'world' }
910
const link = CID.parse('bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae')

0 commit comments

Comments
 (0)