From 9d9a696024d75efebc73e66e8749b77793903405 Mon Sep 17 00:00:00 2001 From: Danish Arora <35004822+danisharora099@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:18:29 +0530 Subject: [PATCH] chore: mandate `.js` extensions for imports (#2128) * feat: add eslint rule * chore: update codebase import extensions --- .eslintrc.json | 12 +++- package-lock.json | 66 +++++++++---------- packages/interfaces/src/connection_manager.ts | 2 +- packages/interfaces/src/enr.ts | 2 +- packages/interfaces/src/health_manager.ts | 2 +- packages/interfaces/src/libp2p.ts | 2 +- packages/tests/src/lib/index.ts | 4 +- packages/tests/src/sync-rln-tree.js | 4 +- .../tests/src/utils/custom_mocha_hooks.ts | 2 +- packages/tests/src/utils/nodes.ts | 8 +-- .../tests/src/utils/waku_versions_utils.ts | 2 +- packages/tests/tests/filter/ping.node.spec.ts | 2 +- .../filter/single_node/push.node.spec.ts | 2 +- .../single_node/unsubscribe.node.spec.ts | 2 +- packages/tests/tests/filter/utils.ts | 6 +- .../tests/tests/health-manager/node.spec.ts | 4 +- .../tests/tests/light-push/index.node.spec.ts | 2 +- .../tests/peer-exchange/pe.optional.spec.ts | 2 +- packages/tests/tests/store/utils.ts | 2 +- .../utils/src/common/sharding/index.spec.ts | 2 +- 20 files changed, 72 insertions(+), 58 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index e7b70bc0d5..2f31d3e6ef 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -74,7 +74,17 @@ "@typescript-eslint/await-thenable": "error", "@typescript-eslint/no-misused-promises": "error", "@typescript-eslint/no-explicit-any": "warn", - "id-match": ["error", "^(?!.*[pP]ubSub)"] + "id-match": ["error", "^(?!.*[pP]ubSub)"], + "import/extensions": [ + "error", + "ignorePackages", + { + "js": "never", + "jsx": "never", + "ts": "always", + "tsx": "never" + } + ] }, "overrides": [ { diff --git a/package-lock.json b/package-lock.json index ea60aebd84..cb8799416c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39077,14 +39077,14 @@ }, "packages/core": { "name": "@waku/core", - "version": "0.0.31", + "version": "0.0.32", "license": "MIT OR Apache-2.0", "dependencies": { "@libp2p/ping": "^1.1.2", - "@waku/enr": "^0.0.25", - "@waku/interfaces": "0.0.26", + "@waku/enr": "^0.0.26", + "@waku/interfaces": "0.0.27", "@waku/proto": "0.0.8", - "@waku/utils": "0.0.19", + "@waku/utils": "0.0.20", "debug": "^4.3.4", "it-all": "^3.0.4", "it-length-prefixed": "^9.0.4", @@ -39144,14 +39144,14 @@ }, "packages/discovery": { "name": "@waku/discovery", - "version": "0.0.4", + "version": "0.0.5", "license": "MIT OR Apache-2.0", "dependencies": { - "@waku/core": "0.0.31", - "@waku/enr": "0.0.25", - "@waku/interfaces": "0.0.26", + "@waku/core": "0.0.32", + "@waku/enr": "0.0.26", + "@waku/interfaces": "0.0.27", "@waku/proto": "^0.0.8", - "@waku/utils": "0.0.19", + "@waku/utils": "0.0.20", "debug": "^4.3.4", "dns-query": "^0.11.2", "hi-base32": "^0.5.1", @@ -39190,7 +39190,7 @@ }, "packages/enr": { "name": "@waku/enr", - "version": "0.0.25", + "version": "0.0.26", "license": "MIT OR Apache-2.0", "dependencies": { "@ethersproject/rlp": "^5.7.0", @@ -39198,7 +39198,7 @@ "@libp2p/peer-id": "^4.2.1", "@multiformats/multiaddr": "^12.0.0", "@noble/secp256k1": "^1.7.1", - "@waku/utils": "0.0.19", + "@waku/utils": "0.0.20", "debug": "^4.3.4", "js-sha3": "^0.9.2" }, @@ -39210,7 +39210,7 @@ "@types/chai": "^4.3.11", "@types/mocha": "^10.0.6", "@waku/build-utils": "*", - "@waku/interfaces": "0.0.26", + "@waku/interfaces": "0.0.27", "chai": "^4.3.10", "cspell": "^8.6.1", "fast-check": "^3.19.0", @@ -39234,7 +39234,7 @@ }, "packages/interfaces": { "name": "@waku/interfaces", - "version": "0.0.26", + "version": "0.0.27", "license": "MIT OR Apache-2.0", "dependencies": { "@waku/proto": "^0.0.8" @@ -39252,14 +39252,14 @@ }, "packages/message-encryption": { "name": "@waku/message-encryption", - "version": "0.0.29", + "version": "0.0.30", "license": "MIT OR Apache-2.0", "dependencies": { "@noble/secp256k1": "^1.7.1", - "@waku/core": "0.0.31", - "@waku/interfaces": "0.0.26", + "@waku/core": "0.0.32", + "@waku/interfaces": "0.0.27", "@waku/proto": "0.0.8", - "@waku/utils": "0.0.19", + "@waku/utils": "0.0.20", "debug": "^4.3.4", "js-sha3": "^0.9.2", "uint8arrays": "^5.0.1" @@ -39285,11 +39285,11 @@ }, "packages/message-hash": { "name": "@waku/message-hash", - "version": "0.1.15", + "version": "0.1.16", "license": "MIT OR Apache-2.0", "dependencies": { "@noble/hashes": "^1.3.2", - "@waku/utils": "0.0.19" + "@waku/utils": "0.0.20" }, "devDependencies": { "@rollup/plugin-commonjs": "^25.0.7", @@ -39299,7 +39299,7 @@ "@types/debug": "^4.1.12", "@types/mocha": "^10.0.6", "@waku/build-utils": "*", - "@waku/interfaces": "0.0.26", + "@waku/interfaces": "0.0.27", "chai": "^4.3.10", "cspell": "^8.6.1", "fast-check": "^3.19.0", @@ -39358,16 +39358,16 @@ }, "packages/relay": { "name": "@waku/relay", - "version": "0.0.14", + "version": "0.0.15", "license": "MIT OR Apache-2.0", "dependencies": { "@chainsafe/libp2p-gossipsub": "^13.1.0", "@noble/hashes": "^1.3.2", - "@waku/core": "0.0.31", - "@waku/interfaces": "0.0.26", + "@waku/core": "0.0.32", + "@waku/interfaces": "0.0.27", "@waku/proto": "0.0.8", - "@waku/sdk": "0.0.27", - "@waku/utils": "0.0.19", + "@waku/sdk": "0.0.28", + "@waku/utils": "0.0.20", "chai": "^4.3.10", "debug": "^4.3.4", "fast-check": "^3.19.0" @@ -39393,7 +39393,7 @@ }, "packages/sdk": { "name": "@waku/sdk", - "version": "0.0.27", + "version": "0.0.28", "license": "MIT OR Apache-2.0", "dependencies": { "@chainsafe/libp2p-noise": "^15.1.0", @@ -39403,12 +39403,12 @@ "@libp2p/ping": "^1.1.2", "@libp2p/websockets": "^8.1.4", "@noble/hashes": "^1.3.3", - "@waku/core": "0.0.31", - "@waku/discovery": "0.0.4", - "@waku/interfaces": "0.0.26", - "@waku/message-hash": "0.1.15", + "@waku/core": "0.0.32", + "@waku/discovery": "0.0.5", + "@waku/interfaces": "0.0.27", + "@waku/message-hash": "0.1.16", "@waku/proto": "^0.0.8", - "@waku/utils": "0.0.19", + "@waku/utils": "0.0.20", "libp2p": "^1.8.1" }, "devDependencies": { @@ -39485,11 +39485,11 @@ }, "packages/utils": { "name": "@waku/utils", - "version": "0.0.19", + "version": "0.0.20", "license": "MIT OR Apache-2.0", "dependencies": { "@noble/hashes": "^1.3.2", - "@waku/interfaces": "0.0.26", + "@waku/interfaces": "0.0.27", "chai": "^4.3.10", "debug": "^4.3.4", "uint8arrays": "^5.0.1" diff --git a/packages/interfaces/src/connection_manager.ts b/packages/interfaces/src/connection_manager.ts index d85991eb3c..a8a6591fdc 100644 --- a/packages/interfaces/src/connection_manager.ts +++ b/packages/interfaces/src/connection_manager.ts @@ -1,6 +1,6 @@ import type { Peer, PeerId, TypedEventEmitter } from "@libp2p/interface"; -import { PubsubTopic } from "./misc"; +import { PubsubTopic } from "./misc.js"; export enum Tags { BOOTSTRAP = "bootstrap", diff --git a/packages/interfaces/src/enr.ts b/packages/interfaces/src/enr.ts index 6bb663edc1..ec4b4ab54c 100644 --- a/packages/interfaces/src/enr.ts +++ b/packages/interfaces/src/enr.ts @@ -2,7 +2,7 @@ import type { PeerId } from "@libp2p/interface"; import type { PeerInfo } from "@libp2p/interface"; import type { Multiaddr } from "@multiformats/multiaddr"; -import { ShardInfo } from "./sharding"; +import { ShardInfo } from "./sharding.js"; export type ENRKey = string; export type ENRValue = Uint8Array; diff --git a/packages/interfaces/src/health_manager.ts b/packages/interfaces/src/health_manager.ts index d26354cae2..8d3a1a9863 100644 --- a/packages/interfaces/src/health_manager.ts +++ b/packages/interfaces/src/health_manager.ts @@ -1,4 +1,4 @@ -import { Protocols } from "./protocols"; +import { Protocols } from "./protocols.js"; export enum HealthStatus { Unhealthy = "Unhealthy", diff --git a/packages/interfaces/src/libp2p.ts b/packages/interfaces/src/libp2p.ts index 3b7197a0e5..53bb106308 100644 --- a/packages/interfaces/src/libp2p.ts +++ b/packages/interfaces/src/libp2p.ts @@ -4,7 +4,7 @@ import type { Libp2p as BaseLibp2p } from "@libp2p/interface"; import type { PingService } from "@libp2p/ping"; import type { Libp2pInit, Libp2pOptions } from "libp2p"; -import { IMetadata } from "./metadata"; +import { IMetadata } from "./metadata.js"; export type Libp2pServices = { ping: PingService; diff --git a/packages/tests/src/lib/index.ts b/packages/tests/src/lib/index.ts index c123a88c4d..8f804633a3 100644 --- a/packages/tests/src/lib/index.ts +++ b/packages/tests/src/lib/index.ts @@ -3,8 +3,8 @@ import { NetworkConfig } from "@waku/interfaces"; import { derivePubsubTopicsFromNetworkConfig, Logger } from "@waku/utils"; import { expect } from "chai"; -import { DefaultTestPubsubTopic } from "../constants"; -import { Args, MessageRpcQuery, MessageRpcResponse } from "../types"; +import { DefaultTestPubsubTopic } from "../constants.js"; +import { Args, MessageRpcQuery, MessageRpcResponse } from "../types.js"; import { delay, makeLogFileName } from "../utils/index.js"; import { MessageCollector } from "./message_collector.js"; diff --git a/packages/tests/src/sync-rln-tree.js b/packages/tests/src/sync-rln-tree.js index 0fadf54b28..d69c3d1899 100644 --- a/packages/tests/src/sync-rln-tree.js +++ b/packages/tests/src/sync-rln-tree.js @@ -2,8 +2,8 @@ import { exec } from "child_process"; import { setTimeout } from "timers"; import { promisify } from "util"; -import { SEPOLIA_RPC_URL } from "../dist/constants.js"; -import { ServiceNode } from "../dist/lib/service_node.js"; +import { SEPOLIA_RPC_URL } from "./constants.js"; +import { ServiceNode } from "./lib/index.js"; const execAsync = promisify(exec); diff --git a/packages/tests/src/utils/custom_mocha_hooks.ts b/packages/tests/src/utils/custom_mocha_hooks.ts index 1f55855a23..905c94aec4 100644 --- a/packages/tests/src/utils/custom_mocha_hooks.ts +++ b/packages/tests/src/utils/custom_mocha_hooks.ts @@ -1,7 +1,7 @@ import { Logger } from "@waku/utils"; import { Suite } from "mocha"; -import { MOCHA_HOOK_MAX_TIMEOUT } from "../constants"; +import { MOCHA_HOOK_MAX_TIMEOUT } from "../constants.js"; const log = new Logger("test:mocha-hook"); function withGracefulTimeout( diff --git a/packages/tests/src/utils/nodes.ts b/packages/tests/src/utils/nodes.ts index 76c2ba5762..2cdef056aa 100644 --- a/packages/tests/src/utils/nodes.ts +++ b/packages/tests/src/utils/nodes.ts @@ -12,11 +12,11 @@ import { derivePubsubTopicsFromNetworkConfig, isDefined } from "@waku/utils"; import { Context } from "mocha"; import pRetry from "p-retry"; -import { NOISE_KEY_1 } from "../constants"; -import { ServiceNodesFleet } from "../lib"; -import { Args } from "../types"; +import { NOISE_KEY_1 } from "../constants.js"; +import { ServiceNodesFleet } from "../lib/index.js"; +import { Args } from "../types.js"; -import { waitForConnections } from "./waitForConnections"; +import { waitForConnections } from "./waitForConnections.js"; export async function runMultipleNodes( context: Context, diff --git a/packages/tests/src/utils/waku_versions_utils.ts b/packages/tests/src/utils/waku_versions_utils.ts index 17bdbf2090..1dfbd81b76 100644 --- a/packages/tests/src/utils/waku_versions_utils.ts +++ b/packages/tests/src/utils/waku_versions_utils.ts @@ -1,4 +1,4 @@ -import { DOCKER_IMAGE_NAME } from "../lib/service_node"; +import { DOCKER_IMAGE_NAME } from "../lib/service_node.js"; // Utility to add test conditions based on nwaku/go-waku versions export function isNwakuAtLeast(requiredVersion: string): boolean { diff --git a/packages/tests/tests/filter/ping.node.spec.ts b/packages/tests/tests/filter/ping.node.spec.ts index a88d9874bf..f9552f048b 100644 --- a/packages/tests/tests/filter/ping.node.spec.ts +++ b/packages/tests/tests/filter/ping.node.spec.ts @@ -16,7 +16,7 @@ import { TestEncoder, TestShardInfo, validatePingError -} from "./utils"; +} from "./utils.js"; const runTests = (strictCheckNodes: boolean): void => { describe(`Waku Filter V2: Ping: Multiple Nodes: Strict Checking: ${strictCheckNodes}`, function () { diff --git a/packages/tests/tests/filter/single_node/push.node.spec.ts b/packages/tests/tests/filter/single_node/push.node.spec.ts index 6e47e586ae..79fd020ae3 100644 --- a/packages/tests/tests/filter/single_node/push.node.spec.ts +++ b/packages/tests/tests/filter/single_node/push.node.spec.ts @@ -13,7 +13,7 @@ import { TEST_STRING, TEST_TIMESTAMPS } from "../../../src/index.js"; -import { runNodes } from "../../light-push/utils"; +import { runNodes } from "../../light-push/utils.js"; import { messageText, TestContentTopic, diff --git a/packages/tests/tests/filter/single_node/unsubscribe.node.spec.ts b/packages/tests/tests/filter/single_node/unsubscribe.node.spec.ts index a2af7c4b4b..48241441c6 100644 --- a/packages/tests/tests/filter/single_node/unsubscribe.node.spec.ts +++ b/packages/tests/tests/filter/single_node/unsubscribe.node.spec.ts @@ -11,7 +11,7 @@ import { ServiceNode, tearDownNodes } from "../../../src/index.js"; -import { runNodes } from "../../light-push/utils"; +import { runNodes } from "../../light-push/utils.js"; import { messagePayload, messageText, diff --git a/packages/tests/tests/filter/utils.ts b/packages/tests/tests/filter/utils.ts index 34999295cb..2bcbd88125 100644 --- a/packages/tests/tests/filter/utils.ts +++ b/packages/tests/tests/filter/utils.ts @@ -18,7 +18,11 @@ import { utf8ToBytes } from "@waku/utils/bytes"; import { Context } from "mocha"; import pRetry from "p-retry"; -import { NOISE_KEY_1, ServiceNodesFleet, waitForConnections } from "../../src"; +import { + NOISE_KEY_1, + ServiceNodesFleet, + waitForConnections +} from "../../src/index.js"; // Constants for test configuration. export const log = new Logger("test:filter"); diff --git a/packages/tests/tests/health-manager/node.spec.ts b/packages/tests/tests/health-manager/node.spec.ts index decd505cc6..b0edc41cb5 100644 --- a/packages/tests/tests/health-manager/node.spec.ts +++ b/packages/tests/tests/health-manager/node.spec.ts @@ -8,14 +8,14 @@ import { runMultipleNodes, ServiceNode, ServiceNodesFleet -} from "../../src"; +} from "../../src/index.js"; import { messagePayload, TestDecoder, TestEncoder, TestShardInfo -} from "./utils"; +} from "./utils.js"; describe("Node Health Status Matrix Tests", function () { let waku: LightNode; diff --git a/packages/tests/tests/light-push/index.node.spec.ts b/packages/tests/tests/light-push/index.node.spec.ts index 4acdb6eb5d..44c6dbee7c 100644 --- a/packages/tests/tests/light-push/index.node.spec.ts +++ b/packages/tests/tests/light-push/index.node.spec.ts @@ -11,7 +11,7 @@ import { ServiceNodesFleet, teardownNodesWithRedundancy, TEST_STRING -} from "../../src"; +} from "../../src/index.js"; import { messagePayload, diff --git a/packages/tests/tests/peer-exchange/pe.optional.spec.ts b/packages/tests/tests/peer-exchange/pe.optional.spec.ts index 608d5f5409..80671816c3 100644 --- a/packages/tests/tests/peer-exchange/pe.optional.spec.ts +++ b/packages/tests/tests/peer-exchange/pe.optional.spec.ts @@ -12,7 +12,7 @@ import { } from "@waku/utils"; import { expect } from "chai"; -import { afterEachCustom, tearDownNodes } from "../../src"; +import { afterEachCustom, tearDownNodes } from "../../src/index.js"; describe("Peer Exchange", () => { describe("Auto Discovery", function () { diff --git a/packages/tests/tests/store/utils.ts b/packages/tests/tests/store/utils.ts index efaa92b030..c4d1a1811d 100644 --- a/packages/tests/tests/store/utils.ts +++ b/packages/tests/tests/store/utils.ts @@ -16,7 +16,7 @@ import { Logger, singleShardInfoToPubsubTopic } from "@waku/utils"; import { expect } from "chai"; import { Context } from "mocha"; -import { delay, NOISE_KEY_1, runNodes, ServiceNode } from "../../src"; +import { delay, NOISE_KEY_1, runNodes, ServiceNode } from "../../src/index.js"; export const log = new Logger("test:store"); diff --git a/packages/utils/src/common/sharding/index.spec.ts b/packages/utils/src/common/sharding/index.spec.ts index 2e5da8d754..59cec4b50a 100644 --- a/packages/utils/src/common/sharding/index.spec.ts +++ b/packages/utils/src/common/sharding/index.spec.ts @@ -13,7 +13,7 @@ import { shardInfoToPubsubTopics, singleShardInfosToShardInfo, singleShardInfoToPubsubTopic -} from "."; +} from "./index.js"; const testInvalidCases = ( contentTopics: string[],