Skip to content

Commit

Permalink
chore: fix lint errors and housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
icidasset committed Dec 20, 2023
1 parent 518e2b8 commit 0886d5a
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 30 deletions.
8 changes: 6 additions & 2 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
"vite-plugin-wasm": "^3.3.0"
},
"eslintConfig": {
"extends": ["@fission-codes"],
"ignorePatterns": ["dist"]
"extends": [
"@fission-codes"
],
"ignorePatterns": [
"dist"
]
}
}
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "@wnfs-wg/nest-root",
"version": "0.0.0",
"private": true,
"workspaces": ["packages/*", "examples/*"],
"workspaces": [
"packages/*",
"examples/*"
],
"packageManager": "[email protected]",
"engines": {
"node": ">=18"
Expand Down Expand Up @@ -38,7 +41,11 @@
},
"prettier": "@fission-codes/eslint-config/prettier.config.js",
"eslintConfig": {
"extends": ["@fission-codes"],
"ignorePatterns": ["docs"]
"extends": [
"@fission-codes"
],
"ignorePatterns": [
"docs"
]
}
}
4 changes: 2 additions & 2 deletions packages/nest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"types": "dist/src/index.d.ts",
"browser": {
"crypto": false,
"./dist/src/crypto.js": "./dist/src/crypto-browser.js"
"./src/crypto.js": "./src/crypto-browser.js"
},
"typesVersions": {
"*": {
Expand All @@ -75,7 +75,7 @@
},
"files": ["src", "dist/src/*.d.ts", "dist/src/*.d.ts.map"],
"scripts": {
"lint": "tsc --build && eslint . && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore",
"lint": "tsc --build && eslint . --quiet --ignore-pattern='readme.md' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore",
"build": "tsc --build",
"test": "pnpm run test:node && pnpm run test:browser",
"test:node": "mocha 'test/**/!(*.browser).test.ts' --bail --timeout 30000",
Expand Down
18 changes: 9 additions & 9 deletions packages/nest/src/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Blockstore } from 'interface-blockstore'
import type { PublicDirectory, PublicFile } from 'wnfs'
import type { PrivateForest, PublicDirectory, PublicFile } from 'wnfs'

import { CID } from 'multiformats/cid'
import { AccessKey, PrivateDirectory, PrivateFile, PrivateNode } from 'wnfs'
Expand Down Expand Up @@ -305,7 +305,7 @@ export class FileSystem {
const [accessKey, privateForest] = storeResult

this.#rootTree = await this.#rootTree.replacePrivateForest(
privateForest,
privateForest as PrivateForest,
[
{
path: Path.withPartition('private', n.path),
Expand Down Expand Up @@ -383,7 +383,7 @@ export class FileSystem {
}

/** @group Querying */
ls = this.listDirectory
ls = this.listDirectory // eslint-disable-line @typescript-eslint/unbound-method

/** @group Querying */
async read<D extends DataType, V = unknown>(
Expand Down Expand Up @@ -441,7 +441,7 @@ export class FileSystem {
}

/** @group Mutating */
cp = this.copy
cp = this.copy // eslint-disable-line @typescript-eslint/unbound-method

/** @group Mutating */
async createDirectory<P extends Partition>(
Expand Down Expand Up @@ -532,7 +532,7 @@ export class FileSystem {
}

/** @group Mutating */
mkdir = this.ensureDirectory
mkdir = this.ensureDirectory // eslint-disable-line @typescript-eslint/unbound-method

/** @group Mutating */
async move<From extends Partition, To extends Partition>(
Expand All @@ -557,7 +557,7 @@ export class FileSystem {
}

/** @group Mutating */
mv = this.move
mv = this.move // eslint-disable-line @typescript-eslint/unbound-method

/** @group Mutating */
async remove(
Expand All @@ -578,7 +578,7 @@ export class FileSystem {
}

/** @group Mutating */
rm = this.remove
rm = this.remove // eslint-disable-line @typescript-eslint/unbound-method

/** @group Mutating */
async rename<P extends Partition>(
Expand Down Expand Up @@ -730,10 +730,10 @@ export class FileSystem {

const capsuleCID = await fileOrDir
.store(Store.wnfs(this.#blockstore))
.then((a) => CID.decode(a))
.then((a) => CID.decode(a as Uint8Array))
const contentCID =
node.isFile() === true
? CID.decode(node.asFile().contentCid())
? CID.decode(node.asFile().contentCid() as Uint8Array)
: capsuleCID

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/nest/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function dataToBytes(dataType: DataType, data: any): Uint8Array {
}

case 'utf8': {
return new TextEncoder().encode(data)
return new TextEncoder().encode(data as string)
}
}
}
5 changes: 4 additions & 1 deletion packages/nest/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ export const publicRead = (options?: { offset: number; length: number }) => {
.publicRoot()
.read(params.pathSegments, Store.wnfs(params.blockstore))

return await publicReadFromCID(CID.decode(result), options)(params)
return await publicReadFromCID(
CID.decode(result as Uint8Array),
options
)(params)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/nest/src/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function capsuleCID(
? undefined
: CID.decode(
maybeNode.isFile()
? await maybeNode.asFile().store(wnfsBlockstore)
: await maybeNode.asDir().store(wnfsBlockstore)
? ((await maybeNode.asFile().store(wnfsBlockstore)) as Uint8Array)
: ((await maybeNode.asDir().store(wnfsBlockstore)) as Uint8Array)
)
}
6 changes: 3 additions & 3 deletions packages/nest/src/root-tree/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ export class BasicRootTree implements RootTree {
const links = [
{
Name: RootBranch.Exchange,
Hash: CID.decode(exchangeRoot),
Hash: CID.decode(exchangeRoot as Uint8Array),
},
{
Name: RootBranch.Private,
Hash: CID.decode(privateForest),
Hash: CID.decode(privateForest as Uint8Array),
},
{
Name: RootBranch.Public,
Hash: CID.decode(publicRoot),
Hash: CID.decode(publicRoot as Uint8Array),
},
{
Name: RootBranch.Unix,
Expand Down
10 changes: 5 additions & 5 deletions packages/nest/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export class TransactionContext {
}

/** @group Querying */
ls = this.listDirectory
ls = this.listDirectory // eslint-disable-line @typescript-eslint/unbound-method

/** @group Querying */
async read<D extends DataType, V = unknown>(
Expand Down Expand Up @@ -331,7 +331,7 @@ export class TransactionContext {
}

/** @group Mutating */
cp = this.copy
cp = this.copy // eslint-disable-line @typescript-eslint/unbound-method

/** @group Mutating */
async createDirectory(
Expand Down Expand Up @@ -389,7 +389,7 @@ export class TransactionContext {
}

/** @group Mutating */
mkdir = this.ensureDirectory
mkdir = this.ensureDirectory // eslint-disable-line @typescript-eslint/unbound-method

/** @group Mutating */
async move(
Expand All @@ -410,7 +410,7 @@ export class TransactionContext {
}

/** @group Mutating */
mv = this.move
mv = this.move // eslint-disable-line @typescript-eslint/unbound-method

/** @group Mutating */
async remove(
Expand Down Expand Up @@ -440,7 +440,7 @@ export class TransactionContext {
}

/** @group Mutating */
rm = this.remove
rm = this.remove // eslint-disable-line @typescript-eslint/unbound-method

/** @group Mutating */
async rename(
Expand Down
4 changes: 3 additions & 1 deletion packages/nest/test/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export async function assertUnixFsFile(
`${unixRoot.toString()}${pathString}`,
opts.blockstore
)
const unixBytes = Uint8Arrays.concat(await all(entry.content()))

const byteArrays: Uint8Array[] = await all(entry.content())
const unixBytes = Uint8Arrays.concat(byteArrays)

assert.equal(Uint8Arrays.equals(unixBytes, bytes), true)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "dist",
"noUnusedLocals": false
},
"include": ["src", "test"],
Expand Down

0 comments on commit 0886d5a

Please sign in to comment.