diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 43f463c6..00000000 --- a/.eslintrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": [ - "standard", - "plugin:@typescript-eslint/recommended" - ], - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/ban-ts-comment": "off" - } -} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f4689933..0bc3b42d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,16 +1,11 @@ version: 2 updates: - - package-ecosystem: 'github-actions' - directory: '/' - schedule: - interval: 'daily' - commit-message: - prefix: 'chore' - include: 'scope' - - package-ecosystem: 'npm' - directory: '/' - schedule: - interval: 'daily' - commit-message: - prefix: 'chore' - include: 'scope' +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 + commit-message: + prefix: "deps" + prefix-development: "deps(dev)" diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..d57c2a02 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,8 @@ +name: Automerge +on: [ pull_request ] + +jobs: + automerge: + uses: protocol/.github/.github/workflows/automerge.yml@master + with: + job: 'automerge' diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml new file mode 100644 index 00000000..76f568f3 --- /dev/null +++ b/.github/workflows/js-test-and-release.yml @@ -0,0 +1,145 @@ +name: test & maybe release +on: + push: + branches: + - esm-migration # with #262 - ${{{ github.default_branch }}} + pull_request: + branches: + - esm-migration # with #262 - ${{{ github.default_branch }}} + +jobs: + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present lint + - run: npm run --if-present dep-check + + test-node: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [16] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:node + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: node + + test-chrome: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: chrome + + test-chrome-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome-webworker + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: chrome-webworker + + test-firefox: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: firefox + + test-firefox-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox-webworker + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: firefox-webworker + + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-main + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: electron-main + + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-renderer + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: electron-renderer + + release: + needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer] + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/${{{ github.default_branch }}}' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/docker-login@master + with: + docker-token: ${{ secrets.DOCKER_TOKEN }} + docker-username: ${{ secrets.DOCKER_USERNAME }} + - run: npm run --if-present release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml deleted file mode 100644 index db0b1067..00000000 --- a/.github/workflows/test-and-release.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Test & Maybe Release -on: [push, pull_request] -jobs: - test: - strategy: - fail-fast: false - matrix: - node: [14.x, 16.x] - os: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v3.4.1 - with: - node-version: ${{ matrix.node }} - - name: Install Dependencies - run: | - npm install --no-progress - - name: Run tests - run: | - npm config set script-shell bash - npm run test:ci - release: - name: Release - needs: test - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup Node.js - uses: actions/setup-node@v3.4.1 - with: - node-version: 14 - - name: Install dependencies - run: | - npm install --no-progress --no-package-lock --no-save - - name: Build - run: | - npm run build - - name: Install plugins - run: | - npm install \ - @semantic-release/commit-analyzer \ - conventional-changelog-conventionalcommits \ - @semantic-release/release-notes-generator \ - @semantic-release/npm \ - @semantic-release/github \ - @semantic-release/git \ - @semantic-release/changelog \ - --no-progress --no-package-lock --no-save - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release - diff --git a/.gitignore b/.gitignore index 4f8f0207..16496d32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ -.nyc_output -build -dist -coverage +.coverage package-lock.json node_modules .DS_Store @@ -9,3 +6,4 @@ yarn.lock types test/ts-use/tsconfig.tsbuildinfo test/tsconfig.tsbuildinfo +*.log diff --git a/CHANGELOG.md b/CHANGELOG.md index 7611b36a..52ec2ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## [9.8.0](https://github.com/multiformats/js-multiformats/compare/v9.7.1...v9.8.0) (2022-09-06) + + +### Features + +* use aegir for build/testing/release ([10d4604](https://github.com/multiformats/js-multiformats/commit/10d4604d5e2ed8d643836f79cb0936a3f52c3488)) + + +### Bug Fixes + +* address JS & TS linting complaints ([e494e3c](https://github.com/multiformats/js-multiformats/commit/e494e3c6347547f79ba638952b2ced2c844a3c91)) + ## [9.7.1](https://github.com/multiformats/js-multiformats/compare/v9.7.0...v9.7.1) (2022-07-26) diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..20ce483c --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/LICENSE-APACHE b/LICENSE-APACHE index fcd6df33..14478a3b 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -1,13 +1,5 @@ -Copyright 2020 Protocol Labs +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT index 9bddb3e8..72dc60d8 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,7 +1,19 @@ -Copyright 2020 Protocol Labs +The MIT License (MIT) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 613af3dd..5515e280 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,40 @@ -# multiformats - -* [Interfaces](#interfaces) - * [Creating Blocks](#creating-blocks) - * [Multibase Encoders / Decoders / Codecs](#multibase-encoders--decoders--codecs) - * [Multicodec Encoders / Decoders / Codecs](#multicodec-encoders--decoders--codecs) - * [Multihash Hashers](#multihash-hashers) - * [Traversal](#traversal) -* [Legacy interface](#legacy-interface) -* [Implementations](#implementations) - * [Multibase codecs](#multibase-codecs) - * [Multihash hashers](#multihash-hashers-1) - * [IPLD codecs (multicodec)](#ipld-codecs-multicodec) -* [License](#license) - * [Contribution](#contribution) +# multiformats + +[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io) +[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-multiformats.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiformats) +[![CI](https://img.shields.io/github/workflow/status/multiformats/js-multiformats/test%20&%20maybe%20release/esm-migration?style=flat-square)](https://github.com/multiformats/js-multiformats/actions/workflows/js-test-and-release.yml) + +> Interface for multihash, multicodec, multibase and CID + +## Table of contents + +- [Install](#install) +- [Interfaces](#interfaces) + - [Creating Blocks](#creating-blocks) + - [Multibase Encoders / Decoders / Codecs](#multibase-encoders--decoders--codecs) + - [Multicodec Encoders / Decoders / Codecs](#multicodec-encoders--decoders--codecs) + - [Multihash Hashers](#multihash-hashers) + - [Traversal](#traversal) +- [Legacy interface](#legacy-interface) +- [Implementations](#implementations) + - [Multibase codecs](#multibase-codecs) + - [Multihash hashers](#multihash-hashers-1) + - [IPLD codecs (multicodec)](#ipld-codecs-multicodec) +- [License](#license) +- [Contribution](#contribution) + +## Install + +```console +$ npm i multiformats +``` + +## Interfaces This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume. This library provides implementations for most basics and many others can be found in linked repositories. -## Interfaces - ```js import { CID } from 'multiformats/cid' import * as json from 'multiformats/codecs/json' @@ -77,7 +92,6 @@ them as `encoder` and `decoder` properties. For added convenience codecs also implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be used as either or both: - ```js cid.toString(base64) CID.parse(cid.toString(base64), base64) @@ -189,43 +203,43 @@ import the ones you need yourself. ### Multibase codecs -| bases | import | repo | - --- | --- | --- | -`base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | -`base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | -`base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | -`base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | +| bases | import | repo | +| ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- | +| `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | +| `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | +| `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | +| `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`. ### Multihash hashers -| hashes | import | repo | -| --- | --- | --- | -| `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) | -| `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) | -| `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) | -| `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) | -| `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) | +| hashes | import | repo | +| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ | +| `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) | +| `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) | +| `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) | +| `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) | +| `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) | ### IPLD codecs (multicodec) -| codec | import | repo | -| --- | --- | --- | -| `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | -| `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | -| `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) | -| `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) | -| `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) | -| `dag-jose` | `dag-jose`| [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) | +| codec | import | repo | +| ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ | +| `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | +| `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | +| `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) | +| `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) | +| `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) | +| `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) | ## License Licensed under either of - * Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0) - * MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -### Contribution +## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/package.json b/package.json index 6c9b263a..0a043d21 100644 --- a/package.json +++ b/package.json @@ -1,159 +1,146 @@ { "name": "multiformats", - "version": "0.0.0-dev", + "version": "9.8.0", "description": "Interface for multihash, multicodec, multibase and CID", - "main": "./src/index.js", - "types": "./types/src/index.d.ts", - "type": "module", - "scripts": { - "build": "npm run build:js && npm run build:types", - "build:js": "ipjs build --tests --main && npm run build:copy", - "build:copy": "cp -a tsconfig.json src vendor test dist/ && rm -rf dist/test/ts-use", - "build:types": "npm run build:copy && cd dist && tsc --build", - "build:vendor": "npm run build:vendor:varint && npm run build:vendor:base-x", - "build:vendor:varint": "npm_config_yes=true npx brrp -x varint > vendor/varint.js", - "build:vendor:base-x": "npm_config_yes=true npx brrp -x @multiformats/base-x > vendor/base-x.js", - "lint": "standard", - "test:cjs": "npm run build:js && mocha dist/cjs/node-test/test-*.js && npm run test:cjs:browser", - "test:esm": "npm run build:js && mocha dist/esm/node-test/test-*.js && npm run test:esm:browser", - "test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/test-*.js", - "test:cjs:browser": "polendina --page --worker --serviceworker --cleanup dist/cjs/browser-test/test-*.js", - "test:esm:browser": "polendina --page --worker --serviceworker --cleanup dist/esm/browser-test/test-*.js", - "test:ts": "npm run build:types && npm run test --prefix test/ts-use", - "test": "npm run lint && npm run test:node && npm run test:esm && npm run test:ts", - "test:ci": "npm run lint && npm run test:node && npm run test:esm && npm run test:cjs && npm run test:ts", - "coverage": "c8 --reporter=html mocha test/test-*.js && npm_config_yes=true npx st -d coverage -p 8080" + "author": "Mikeal Rogers (https://www.mikealrogers.com/)", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/multiformats/js-multiformats#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/multiformats/js-multiformats.git" }, - "c8": { - "exclude": [ - "test/**", - "vendor/**" - ] + "bugs": { + "url": "https://github.com/multiformats/js-multiformats/issues" }, "keywords": [ "ipfs", "ipld", "multiformats" ], - "author": "Mikeal Rogers (https://www.mikealrogers.com/)", - "license": "(Apache-2.0 AND MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, + "files": [ + "src", + "dist", + "!dist/test", + "!**/*.tsbuildinfo" + ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, - "./cid": { - "import": "./src/cid.js" - }, - "./basics": { - "import": "./src/basics.js" - }, - "./block": { - "import": "./src/block.js" - }, - "./traversal": { - "import": "./src/traversal.js" - }, - "./bases/identity": { - "import": "./src/bases/identity.js" - }, - "./bases/base2": { - "import": "./src/bases/base2.js" - }, - "./bases/base8": { - "import": "./src/bases/base8.js" - }, "./bases/base10": { + "types": "./src/bases/base10.d.ts", "import": "./src/bases/base10.js" }, "./bases/base16": { + "types": "./src/bases/base16.d.ts", "import": "./src/bases/base16.js" }, + "./bases/base2": { + "types": "./src/bases/base2.d.ts", + "import": "./src/bases/base2.js" + }, + "./bases/base256emoji": { + "types": "./src/bases/base256emoji.d.ts", + "import": "./src/bases/base256emoji.js" + }, "./bases/base32": { + "types": "./src/bases/base32.d.ts", "import": "./src/bases/base32.js" }, "./bases/base36": { + "types": "./src/bases/base36.d.ts", "import": "./src/bases/base36.js" }, "./bases/base58": { + "types": "./src/bases/base58.d.ts", "import": "./src/bases/base58.js" }, "./bases/base64": { + "types": "./src/bases/base64.d.ts", "import": "./src/bases/base64.js" }, - "./bases/base256emoji": { - "import": "./src/bases/base256emoji.js" + "./bases/base8": { + "types": "./src/bases/base8.d.ts", + "import": "./src/bases/base8.js" }, - "./hashes/hasher": { - "import": "./src/hashes/hasher.js" + "./bases/identity": { + "types": "./src/bases/identity.d.ts", + "import": "./src/bases/identity.js" }, - "./hashes/digest": { - "import": "./src/hashes/digest.js" + "./basics": { + "types": "./src/basics.d.ts", + "import": "./src/basics.js" }, - "./hashes/sha2": { - "browser": "./src/hashes/sha2-browser.js", - "import": "./src/hashes/sha2.js" + "./block": { + "types": "./src/block.d.ts", + "import": "./src/block.js" }, - "./hashes/identity": { - "import": "./src/hashes/identity.js" + "./cid": { + "types": "./src/cid.d.ts", + "import": "./src/cid.js" }, "./codecs/json": { + "types": "./src/codecs/json.d.ts", "import": "./src/codecs/json.js" }, "./codecs/raw": { + "types": "./src/codecs/raw.d.ts", "import": "./src/codecs/raw.js" + }, + "./hashes/digest": { + "types": "./src/hashes/digest.d.ts", + "import": "./src/hashes/digest.js" + }, + "./hashes/hasher": { + "types": "./src/hashes/hasher.d.ts", + "import": "./src/hashes/hasher.js" + }, + "./hashes/identity": { + "types": "./src/hashes/identity.d.ts", + "import": "./src/hashes/identity.js" + }, + "./hashes/sha2": { + "types": "./src/hashes/sha2.d.ts", + "browser": "./src/hashes/sha2-browser.js", + "import": "./src/hashes/sha2.js" + }, + "./traversal": { + "types": "./src/traversal.d.ts", + "import": "./src/traversal.js" } }, - "devDependencies": { - "@ipld/dag-pb": "^2.1.14", - "@stablelib/sha256": "^1.0.1", - "@stablelib/sha512": "^1.0.1", - "@types/chai": "^4.3.0", - "@types/chai-as-promised": "^7.1.4", - "@types/mocha": "^9.0.0", - "@types/node": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.6.0", - "@typescript-eslint/parser": "^5.6.0", - "buffer": "^6.0.3", - "c8": "^7.10.0", - "chai": "^4.3.4", - "chai-as-promised": "^7.1.1", - "cids": "^1.1.9", - "ipjs": "^5.2.0", - "mocha": "^10.0.0", - "polendina": "^3.0.0", - "standard": "^17.0.0", - "typescript": "^4.5.4" - }, - "standard": { - "ignore": [ - "dist", - "vendor" - ] - }, - "directories": { - "test": "test" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/multiformats/js-multiformats.git" - }, - "bugs": { - "url": "https://github.com/multiformats/js-multiformats/issues" - }, - "homepage": "https://github.com/multiformats/js-multiformats#readme", - "typesVersions": { - "*": { - "*": [ - "types/src/*" - ], - "types/*": [ - "types/*" - ] + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" } }, "release": { "branches": [ - "master" + "esm-migration" ], "plugins": [ [ @@ -178,15 +165,15 @@ "release": "patch" }, { - "type": "chore", + "type": "docs", "release": "patch" }, { - "type": "docs", + "type": "test", "release": "patch" }, { - "type": "test", + "type": "deps", "release": "patch" }, { @@ -216,7 +203,11 @@ }, { "type": "docs", - "section": "Trivial Changes" + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" }, { "type": "test", @@ -227,14 +218,47 @@ } ], "@semantic-release/changelog", - [ - "@semantic-release/npm", - { - "pkgRoot": "dist" - } - ], + "@semantic-release/npm", "@semantic-release/github", "@semantic-release/git" ] - } + }, + "scripts": { + "lint": "aegir lint", + "release": "aegir release", + "build": "aegir build", + "test": "aegir test", + "test:node": "aegir test --target node", + "test:browser": "aegir test --target browser" + }, + "devDependencies": { + "@ipld/dag-pb": "^2.1.14", + "@stablelib/sha256": "^1.0.1", + "@stablelib/sha512": "^1.0.1", + "@types/chai": "^4.3.0", + "@types/chai-as-promised": "^7.1.4", + "@types/mocha": "^9.0.0", + "@types/node": "^18.0.0", + "aegir": "^37.5.1", + "buffer": "^6.0.3", + "chai": "^4.3.4", + "chai-as-promised": "^7.1.1", + "cids": "^1.1.9" + }, + "aegir": { + "build": { + "bundle": false + }, + "test": { + "cov": true, + "target": [ + "node", + "browser" + ] + } + }, + "directories": { + "test": "test" + }, + "main": "./src/index.js" } diff --git a/src/bases/base.js b/src/bases/base.js index 00bc80b9..f92a31df 100644 --- a/src/bases/base.js +++ b/src/bases/base.js @@ -20,6 +20,7 @@ import { coerce } from '../bytes.js' * Class represents both BaseEncoder and MultibaseEncoder meaning it * can be used to encode to multibase or base encode without multibase * prefix. + * * @class * @template {string} Base * @template {string} Prefix @@ -68,6 +69,7 @@ class Encoder { * Class represents both BaseDecoder and MultibaseDecoder so it could be used * to decode multibases (with matching prefix) or just base decode strings * with corresponding base encoding. + * * @class * @template {string} Base * @template {string} Prefix @@ -226,7 +228,7 @@ export class Codec { /** * @template {string} Base * @template {string} Prefix - * @param {Object} options + * @param {object} options * @param {Base} options.name * @param {Prefix} options.prefix * @param {(bytes:Uint8Array) => string} options.encode @@ -239,7 +241,7 @@ export const from = ({ name, prefix, encode, decode }) => /** * @template {string} Base * @template {string} Prefix - * @param {Object} options + * @param {object} options * @param {Base} options.name * @param {Prefix} options.prefix * @param {string} options.alphabet @@ -357,7 +359,7 @@ const encode = (data, alphabet, bitsPerChar) => { * * @template {string} Base * @template {string} Prefix - * @param {Object} options + * @param {object} options * @param {Base} options.name * @param {Prefix} options.prefix * @param {string} options.alphabet diff --git a/src/bases/interface.ts b/src/bases/interface.ts index dd4374e2..fd8617ca 100644 --- a/src/bases/interface.ts +++ b/src/bases/interface.ts @@ -8,9 +8,10 @@ export interface BaseEncoder { /** * Base encodes to a **plain** (and not a multibase) string. Unlike * `encode` no multibase prefix is added. + * * @param bytes */ - baseEncode(bytes: Uint8Array): string + baseEncode: (bytes: Uint8Array) => string } /** @@ -20,9 +21,10 @@ export interface BaseDecoder { /** * Decodes **plain** (and not a multibase) string. Unlike * decode + * * @param text */ - baseDecode(text: string): Uint8Array + baseDecode: (text: string) => Uint8Array } /** @@ -58,7 +60,7 @@ export interface MultibaseEncoder { * Encodes binary data into **multibase** string (which will have a * prefix added). */ - encode(bytes: Uint8Array): Multibase + encode: (bytes: Uint8Array) => Multibase } /** @@ -71,9 +73,10 @@ export interface MultibaseDecoder { /** * Decodes **multibase** string (which must have a multibase prefix added). * If prefix does not match + * * @param multibase */ - decode(multibase: Multibase): Uint8Array + decode: (multibase: Multibase) => Uint8Array } /** @@ -86,7 +89,6 @@ export interface MultibaseCodec { decoder: MultibaseDecoder } - export interface UnibaseDecoder extends MultibaseDecoder { // Reserve this property so it can be used to derive type. readonly decoders?: null diff --git a/src/block.js b/src/block.js index 75bed063..4a6503e6 100644 --- a/src/block.js +++ b/src/block.js @@ -1,10 +1,36 @@ import { bytes as binary, CID } from './index.js' -const readonly = ({ enumerable = true, configurable = false } = {}) => ({ - enumerable, - configurable, - writable: false -}) +function readonly ({ enumerable = true, configurable = false } = {}) { + return { enumerable, configurable, writable: false } +} + +/** + * @param {[string|number, string]} path + * @param {any} value + * @returns {Iterable<[string, CID]>} + */ +function * linksWithin (path, value) { + if (value != null && typeof value === 'object') { + if (Array.isArray(value)) { + for (const [index, element] of value.entries()) { + const elementPath = [...path, index] + const cid = CID.asCID(element) + if (cid) { + yield [elementPath.join('/'), cid] + } else if (typeof element === 'object') { + yield * links(element, elementPath) + } + } + } else { + const cid = CID.asCID(value) + if (cid) { + yield [path.join('/'), cid] + } else { + yield * links(value, path) + } + } + } +} /** * @template T @@ -12,31 +38,32 @@ const readonly = ({ enumerable = true, configurable = false } = {}) => ({ * @param {Array} base * @returns {Iterable<[string, CID]>} */ -const links = function * (source, base) { - if (source == null) return - if (source instanceof Uint8Array) return +function * links (source, base) { + if (source == null || source instanceof Uint8Array) { + return + } for (const [key, value] of Object.entries(source)) { - const path = [...base, key] - if (value != null && typeof value === 'object') { - if (Array.isArray(value)) { - for (const [index, element] of value.entries()) { - const elementPath = [...path, index] - const cid = CID.asCID(element) - if (cid) { - yield [elementPath.join('/'), cid] - } else if (typeof element === 'object') { - yield * links(element, elementPath) - } - } - } else { - const cid = CID.asCID(value) - if (cid) { - yield [path.join('/'), cid] - } else { - yield * links(value, path) - } + const path = /** @type {[string|number, string]} */ ([...base, key]) + yield * linksWithin(path, value) + } +} + +/** + * @param {[string|number, string]} path + * @param {any} value + * @returns {Iterable} + */ +function * treeWithin (path, value) { + if (Array.isArray(value)) { + for (const [index, element] of value.entries()) { + const elementPath = [...path, index] + yield elementPath.join('/') + if (typeof element === 'object' && !CID.asCID(element)) { + yield * tree(element, elementPath) } } + } else { + yield * tree(value, path) } } @@ -46,23 +73,15 @@ const links = function * (source, base) { * @param {Array} base * @returns {Iterable} */ -const tree = function * (source, base) { - if (source == null) return +function * tree (source, base) { + if (source == null || typeof source !== 'object') { + return + } for (const [key, value] of Object.entries(source)) { - const path = [...base, key] + const path = /** @type {[string|number, string]} */ ([...base, key]) yield path.join('/') if (value != null && !(value instanceof Uint8Array) && typeof value === 'object' && !CID.asCID(value)) { - if (Array.isArray(value)) { - for (const [index, element] of value.entries()) { - const elementPath = [...path, index] - yield elementPath.join('/') - if (typeof element === 'object' && !CID.asCID(element)) { - yield * tree(element, elementPath) - } - } - } else { - yield * tree(value, path) - } + yield * treeWithin(path, value) } } } @@ -72,9 +91,8 @@ const tree = function * (source, base) { * @param {T} source * @param {string[]} path */ -const get = (source, path) => { - /** @type {Record} */ - let node = source +function get (source, path) { + let node = /** @type {Record} */ (source) for (const [index, key] of path.entries()) { node = node[key] if (node == null) { @@ -93,7 +111,7 @@ const get = (source, path) => { */ class Block { /** - * @param {Object} options + * @param {object} options * @param {CID} options.cid * @param {ByteView} options.bytes * @param {T} options.value @@ -124,8 +142,8 @@ class Block { } /** - * @param {string} [path] - */ + * @param {string} [path] + */ get (path = '/') { return get(this.value, path.split('/').filter(Boolean)) } @@ -135,13 +153,13 @@ class Block { * @template T * @template {number} Code * @template {number} Algorithm - * @param {Object} options + * @param {object} options * @param {T} options.value * @param {BlockEncoder} options.codec * @param {Hasher} options.hasher * @returns {Promise>} */ -const encode = async ({ value, codec, hasher }) => { +async function encode ({ value, codec, hasher }) { if (typeof value === 'undefined') throw new Error('Missing required argument "value"') if (!codec || !hasher) throw new Error('Missing required argument: codec or hasher') @@ -156,13 +174,13 @@ const encode = async ({ value, codec, hasher }) => { * @template T * @template {number} Code * @template {number} Algorithm - * @param {Object} options + * @param {object} options * @param {ByteView} options.bytes * @param {BlockDecoder} options.codec * @param {Hasher} options.hasher * @returns {Promise>} */ -const decode = async ({ bytes, codec, hasher }) => { +async function decode ({ bytes, codec, hasher }) { if (!bytes) throw new Error('Missing required argument "bytes"') if (!codec || !hasher) throw new Error('Missing required argument: codec or hasher') @@ -174,7 +192,7 @@ const decode = async ({ bytes, codec, hasher }) => { } /** - * @typedef {Object} RequiredCreateOptions + * @typedef {object} RequiredCreateOptions * @property {CID} options.cid */ @@ -184,7 +202,7 @@ const decode = async ({ bytes, codec, hasher }) => { * @param {{ cid: CID, value:T, codec?: BlockDecoder, bytes: ByteView }|{cid:CID, bytes:ByteView, value?:void, codec:BlockDecoder}} options * @returns {Block} */ -const createUnsafe = ({ bytes, cid, value: maybeValue, codec }) => { +function createUnsafe ({ bytes, cid, value: maybeValue, codec }) { const value = maybeValue !== undefined ? maybeValue : (codec && codec.decode(bytes)) @@ -198,14 +216,14 @@ const createUnsafe = ({ bytes, cid, value: maybeValue, codec }) => { * @template T * @template {number} Code * @template {number} Algorithm - * @param {Object} options + * @param {object} options * @param {CID} options.cid * @param {ByteView} options.bytes * @param {BlockDecoder} options.codec * @param {Hasher} options.hasher * @returns {Promise>} */ -const create = async ({ bytes, cid, hasher, codec }) => { +async function create ({ bytes, cid, hasher, codec }) { if (!bytes) throw new Error('Missing required argument "bytes"') if (!hasher) throw new Error('Missing required argument "hasher"') const value = codec.decode(bytes) diff --git a/src/cid.js b/src/cid.js index 403c3104..3b688ae7 100644 --- a/src/cid.js +++ b/src/cid.js @@ -156,7 +156,7 @@ export class CID { */ static isCID (value) { deprecate(/^0\.0/, IS_CID_DEPRECATION) - return !!(value && (value[cidSymbol] || value.asCID === value)) + return Boolean(value && (value[cidSymbol] || value.asCID === value)) } get toBaseEncodedString () { @@ -188,6 +188,7 @@ export class CID { * * This allows two different incompatible versions of CID library to * co-exist and interop as long as binary interface is compatible. + * * @param {any} value * @returns {CID|null} */ @@ -218,12 +219,12 @@ export class CID { } /** - * - * @param {CIDVersion} version - Version of the CID - * @param {number} code - Code of the codec content is encoded in. - * @param {MultihashDigest} digest - (Multi)hash of the of the content. - * @returns {CID} - */ + * + * @param {CIDVersion} version - Version of the CID + * @param {number} code - Code of the codec content is encoded in. + * @param {MultihashDigest} digest - (Multi)hash of the of the content. + * @returns {CID} + */ static create (version, code, digest) { if (typeof code !== 'number') { throw new Error('String codecs are no longer supported') @@ -249,6 +250,7 @@ export class CID { /** * Simplified version of `create` for CIDv0. + * * @param {MultihashDigest} digest - Multihash. */ static createV0 (digest) { @@ -256,12 +258,13 @@ export class CID { } /** - * Simplified version of `create` for CIDv1. - * @template {number} Code - * @param {Code} code - Content encoding format code. - * @param {MultihashDigest} digest - Miltihash of the content. - * @returns {CID} - */ + * Simplified version of `create` for CIDv1. + * + * @template {number} Code + * @param {Code} code - Content encoding format code. + * @param {MultihashDigest} digest - Miltihash of the content. + * @returns {CID} + */ static createV1 (code, digest) { return CID.create(1, code, digest) } @@ -476,6 +479,7 @@ const version = '0.0.0-dev' * @param {string} message */ const deprecate = (range, message) => { + /* eslint-disable no-console */ if (range.test(version)) { console.warn(message) /* c8 ignore next 3 */ diff --git a/src/codecs/interface.ts b/src/codecs/interface.ts index dc8527c1..c672cb67 100644 --- a/src/codecs/interface.ts +++ b/src/codecs/interface.ts @@ -4,7 +4,7 @@ export interface BlockEncoder { name: string code: Code - encode(data: T): ByteView + encode: (data: T) => ByteView } /** @@ -12,7 +12,7 @@ export interface BlockEncoder { */ export interface BlockDecoder { code: Code - decode(bytes: ByteView): T + decode: (bytes: ByteView) => T } /** diff --git a/src/hashes/digest.js b/src/hashes/digest.js index 206e891b..822069d8 100644 --- a/src/hashes/digest.js +++ b/src/hashes/digest.js @@ -3,6 +3,7 @@ import * as varint from '../varint.js' /** * Creates a multihash digest. + * * @template {number} Code * @param {Code} code * @param {Uint8Array} digest @@ -22,6 +23,7 @@ export const create = (code, digest) => { /** * Turns bytes representation of multihash digest into an instance. + * * @param {Uint8Array} multihash * @returns {MultihashDigest} */ @@ -58,6 +60,7 @@ export const equals = (a, b) => { /** * Represents a multihash digest which carries information about the * hashing alogrithm and an actual hash digest. + * * @template {number} Code * @template {number} Size * @class @@ -66,6 +69,7 @@ export const equals = (a, b) => { export class Digest { /** * Creates a multihash digest. + * * @param {Code} code * @param {Size} size * @param {Uint8Array} digest diff --git a/src/hashes/hasher.js b/src/hashes/hasher.js index 703e416b..5c149803 100644 --- a/src/hashes/hasher.js +++ b/src/hashes/hasher.js @@ -3,7 +3,7 @@ import * as Digest from './digest.js' /** * @template {string} Name * @template {number} Code - * @param {Object} options + * @param {object} options * @param {Name} options.name * @param {Code} options.code * @param {(input: Uint8Array) => Await} options.encode diff --git a/src/hashes/interface.ts b/src/hashes/interface.ts index 09afdfe0..18c80751 100644 --- a/src/hashes/interface.ts +++ b/src/hashes/interface.ts @@ -44,7 +44,7 @@ export interface MultihashHasher { * * @param {Uint8Array} input */ - digest(input: Uint8Array): Promise | MultihashDigest + digest: (input: Uint8Array) => Promise | MultihashDigest /** * Name of the multihash @@ -68,5 +68,5 @@ export interface MultihashHasher { * impractical e.g. implementation of Hash Array Mapped Trie (HAMT). */ export interface SyncMultihashHasher extends MultihashHasher { - digest(input: Uint8Array): MultihashDigest + digest: (input: Uint8Array) => MultihashDigest } diff --git a/src/traversal.js b/src/traversal.js index a13d1d5c..66e1e003 100644 --- a/src/traversal.js +++ b/src/traversal.js @@ -11,7 +11,7 @@ import { base58btc } from './bases/base58.js' /** * @template T - * @param {Object} options + * @param {object} options * @param {CID} options.cid * @param {(cid: CID) => Promise|null>} options.load * @param {Set} [options.seen] diff --git a/test/test-block.js b/test/test-block.spec.js similarity index 100% rename from test/test-block.js rename to test/test-block.spec.js diff --git a/test/test-bytes.js b/test/test-bytes.spec.js similarity index 100% rename from test/test-bytes.js rename to test/test-bytes.spec.js diff --git a/test/test-cid.js b/test/test-cid.spec.js similarity index 97% rename from test/test-cid.js rename to test/test-cid.spec.js index 905d4644..1804f602 100644 --- a/test/test-cid.js +++ b/test/test-cid.spec.js @@ -165,23 +165,6 @@ describe('CID', () => { assert.deepStrictEqual({ ...cid1.multihash, ...clear }, { ...cid2.multihash, ...clear }) }) - /* TODO: after i have a keccak hash for the new interface - it('handles multibyte varint encoded codec codes', () => { - const ethBlockHash = textEncoder.encode('8a8e84c797605fbe75d5b5af107d4220a2db0ad35fd66d9be3d38d87c472b26d', 'hex') - const hash = keccak256.digest(ethBlockHash) - const cid1 = CID.create(1, 0x90, hash) - const cid2 = CID.parse(cid1.toString()) - - assert.deepStrictEqual(cid1.code, 0x90) - assert.deepStrictEqual(cid1.version, 1) - assert.deepStrictEqual(cid1.multihash, hash) - - assert.deepStrictEqual(cid2.code, 0x90) - assert.deepStrictEqual(cid2.version, 1) - assert.deepStrictEqual(cid2.multihash, hash) - }) - */ - it('.bytes', async () => { const hash = await sha256.digest(textEncoder.encode('abc')) const code = 0x71 diff --git a/test/test-multibase-spec.js b/test/test-multibase-spec.spec.js similarity index 99% rename from test/test-multibase-spec.js rename to test/test-multibase-spec.spec.js index d49040a6..9c802141 100644 --- a/test/test-multibase-spec.js +++ b/test/test-multibase-spec.spec.js @@ -1,5 +1,4 @@ /* eslint-env mocha */ -'use strict' import { bases } from 'multiformats/basics' import { fromString } from '../src/bytes.js' diff --git a/test/test-multibase.js b/test/test-multibase.spec.js similarity index 100% rename from test/test-multibase.js rename to test/test-multibase.spec.js diff --git a/test/test-multicodec.js b/test/test-multicodec.spec.js similarity index 100% rename from test/test-multicodec.js rename to test/test-multicodec.spec.js diff --git a/test/test-multihash.js b/test/test-multihash.spec.js similarity index 100% rename from test/test-multihash.js rename to test/test-multihash.spec.js diff --git a/test/test-traversal.js b/test/test-traversal.spec.js similarity index 100% rename from test/test-traversal.js rename to test/test-traversal.spec.js diff --git a/test/ts-use/package.json b/test/ts-use/package.json index c4ef82b8..805023fb 100644 --- a/test/ts-use/package.json +++ b/test/ts-use/package.json @@ -6,5 +6,14 @@ }, "scripts": { "test": "npm install && npm_config_yes=true npx -p typescript tsc --noEmit" + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module", + "project": [ + "./test/ts-use/tsconfig.json" + ] + } } -} +} \ No newline at end of file diff --git a/test/ts-use/src/main.ts b/test/ts-use/src/main.ts index d57c5688..ff7de729 100644 --- a/test/ts-use/src/main.ts +++ b/test/ts-use/src/main.ts @@ -9,6 +9,7 @@ const main = async () => { codec: json }) + /* eslint-disable no-console */ console.log(block) }