chore: mandate .js extensions for imports (#2128)

* feat: add eslint rule

* chore: update codebase import extensions
This commit is contained in:
Danish Arora 2024-09-13 14:18:29 +05:30 committed by GitHub
parent a2c5dba32d
commit 9d9a696024
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 72 additions and 58 deletions

View File

@ -74,7 +74,17 @@
"@typescript-eslint/await-thenable": "error", "@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-misused-promises": "error", "@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-explicit-any": "warn", "@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": [ "overrides": [
{ {

66
package-lock.json generated
View File

@ -39077,14 +39077,14 @@
}, },
"packages/core": { "packages/core": {
"name": "@waku/core", "name": "@waku/core",
"version": "0.0.31", "version": "0.0.32",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@libp2p/ping": "^1.1.2", "@libp2p/ping": "^1.1.2",
"@waku/enr": "^0.0.25", "@waku/enr": "^0.0.26",
"@waku/interfaces": "0.0.26", "@waku/interfaces": "0.0.27",
"@waku/proto": "0.0.8", "@waku/proto": "0.0.8",
"@waku/utils": "0.0.19", "@waku/utils": "0.0.20",
"debug": "^4.3.4", "debug": "^4.3.4",
"it-all": "^3.0.4", "it-all": "^3.0.4",
"it-length-prefixed": "^9.0.4", "it-length-prefixed": "^9.0.4",
@ -39144,14 +39144,14 @@
}, },
"packages/discovery": { "packages/discovery": {
"name": "@waku/discovery", "name": "@waku/discovery",
"version": "0.0.4", "version": "0.0.5",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@waku/core": "0.0.31", "@waku/core": "0.0.32",
"@waku/enr": "0.0.25", "@waku/enr": "0.0.26",
"@waku/interfaces": "0.0.26", "@waku/interfaces": "0.0.27",
"@waku/proto": "^0.0.8", "@waku/proto": "^0.0.8",
"@waku/utils": "0.0.19", "@waku/utils": "0.0.20",
"debug": "^4.3.4", "debug": "^4.3.4",
"dns-query": "^0.11.2", "dns-query": "^0.11.2",
"hi-base32": "^0.5.1", "hi-base32": "^0.5.1",
@ -39190,7 +39190,7 @@
}, },
"packages/enr": { "packages/enr": {
"name": "@waku/enr", "name": "@waku/enr",
"version": "0.0.25", "version": "0.0.26",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@ethersproject/rlp": "^5.7.0", "@ethersproject/rlp": "^5.7.0",
@ -39198,7 +39198,7 @@
"@libp2p/peer-id": "^4.2.1", "@libp2p/peer-id": "^4.2.1",
"@multiformats/multiaddr": "^12.0.0", "@multiformats/multiaddr": "^12.0.0",
"@noble/secp256k1": "^1.7.1", "@noble/secp256k1": "^1.7.1",
"@waku/utils": "0.0.19", "@waku/utils": "0.0.20",
"debug": "^4.3.4", "debug": "^4.3.4",
"js-sha3": "^0.9.2" "js-sha3": "^0.9.2"
}, },
@ -39210,7 +39210,7 @@
"@types/chai": "^4.3.11", "@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6", "@types/mocha": "^10.0.6",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.26", "@waku/interfaces": "0.0.27",
"chai": "^4.3.10", "chai": "^4.3.10",
"cspell": "^8.6.1", "cspell": "^8.6.1",
"fast-check": "^3.19.0", "fast-check": "^3.19.0",
@ -39234,7 +39234,7 @@
}, },
"packages/interfaces": { "packages/interfaces": {
"name": "@waku/interfaces", "name": "@waku/interfaces",
"version": "0.0.26", "version": "0.0.27",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@waku/proto": "^0.0.8" "@waku/proto": "^0.0.8"
@ -39252,14 +39252,14 @@
}, },
"packages/message-encryption": { "packages/message-encryption": {
"name": "@waku/message-encryption", "name": "@waku/message-encryption",
"version": "0.0.29", "version": "0.0.30",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@noble/secp256k1": "^1.7.1", "@noble/secp256k1": "^1.7.1",
"@waku/core": "0.0.31", "@waku/core": "0.0.32",
"@waku/interfaces": "0.0.26", "@waku/interfaces": "0.0.27",
"@waku/proto": "0.0.8", "@waku/proto": "0.0.8",
"@waku/utils": "0.0.19", "@waku/utils": "0.0.20",
"debug": "^4.3.4", "debug": "^4.3.4",
"js-sha3": "^0.9.2", "js-sha3": "^0.9.2",
"uint8arrays": "^5.0.1" "uint8arrays": "^5.0.1"
@ -39285,11 +39285,11 @@
}, },
"packages/message-hash": { "packages/message-hash": {
"name": "@waku/message-hash", "name": "@waku/message-hash",
"version": "0.1.15", "version": "0.1.16",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@noble/hashes": "^1.3.2", "@noble/hashes": "^1.3.2",
"@waku/utils": "0.0.19" "@waku/utils": "0.0.20"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-commonjs": "^25.0.7",
@ -39299,7 +39299,7 @@
"@types/debug": "^4.1.12", "@types/debug": "^4.1.12",
"@types/mocha": "^10.0.6", "@types/mocha": "^10.0.6",
"@waku/build-utils": "*", "@waku/build-utils": "*",
"@waku/interfaces": "0.0.26", "@waku/interfaces": "0.0.27",
"chai": "^4.3.10", "chai": "^4.3.10",
"cspell": "^8.6.1", "cspell": "^8.6.1",
"fast-check": "^3.19.0", "fast-check": "^3.19.0",
@ -39358,16 +39358,16 @@
}, },
"packages/relay": { "packages/relay": {
"name": "@waku/relay", "name": "@waku/relay",
"version": "0.0.14", "version": "0.0.15",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@chainsafe/libp2p-gossipsub": "^13.1.0", "@chainsafe/libp2p-gossipsub": "^13.1.0",
"@noble/hashes": "^1.3.2", "@noble/hashes": "^1.3.2",
"@waku/core": "0.0.31", "@waku/core": "0.0.32",
"@waku/interfaces": "0.0.26", "@waku/interfaces": "0.0.27",
"@waku/proto": "0.0.8", "@waku/proto": "0.0.8",
"@waku/sdk": "0.0.27", "@waku/sdk": "0.0.28",
"@waku/utils": "0.0.19", "@waku/utils": "0.0.20",
"chai": "^4.3.10", "chai": "^4.3.10",
"debug": "^4.3.4", "debug": "^4.3.4",
"fast-check": "^3.19.0" "fast-check": "^3.19.0"
@ -39393,7 +39393,7 @@
}, },
"packages/sdk": { "packages/sdk": {
"name": "@waku/sdk", "name": "@waku/sdk",
"version": "0.0.27", "version": "0.0.28",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@chainsafe/libp2p-noise": "^15.1.0", "@chainsafe/libp2p-noise": "^15.1.0",
@ -39403,12 +39403,12 @@
"@libp2p/ping": "^1.1.2", "@libp2p/ping": "^1.1.2",
"@libp2p/websockets": "^8.1.4", "@libp2p/websockets": "^8.1.4",
"@noble/hashes": "^1.3.3", "@noble/hashes": "^1.3.3",
"@waku/core": "0.0.31", "@waku/core": "0.0.32",
"@waku/discovery": "0.0.4", "@waku/discovery": "0.0.5",
"@waku/interfaces": "0.0.26", "@waku/interfaces": "0.0.27",
"@waku/message-hash": "0.1.15", "@waku/message-hash": "0.1.16",
"@waku/proto": "^0.0.8", "@waku/proto": "^0.0.8",
"@waku/utils": "0.0.19", "@waku/utils": "0.0.20",
"libp2p": "^1.8.1" "libp2p": "^1.8.1"
}, },
"devDependencies": { "devDependencies": {
@ -39485,11 +39485,11 @@
}, },
"packages/utils": { "packages/utils": {
"name": "@waku/utils", "name": "@waku/utils",
"version": "0.0.19", "version": "0.0.20",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@noble/hashes": "^1.3.2", "@noble/hashes": "^1.3.2",
"@waku/interfaces": "0.0.26", "@waku/interfaces": "0.0.27",
"chai": "^4.3.10", "chai": "^4.3.10",
"debug": "^4.3.4", "debug": "^4.3.4",
"uint8arrays": "^5.0.1" "uint8arrays": "^5.0.1"

View File

@ -1,6 +1,6 @@
import type { Peer, PeerId, TypedEventEmitter } from "@libp2p/interface"; import type { Peer, PeerId, TypedEventEmitter } from "@libp2p/interface";
import { PubsubTopic } from "./misc"; import { PubsubTopic } from "./misc.js";
export enum Tags { export enum Tags {
BOOTSTRAP = "bootstrap", BOOTSTRAP = "bootstrap",

View File

@ -2,7 +2,7 @@ import type { PeerId } from "@libp2p/interface";
import type { PeerInfo } from "@libp2p/interface"; import type { PeerInfo } from "@libp2p/interface";
import type { Multiaddr } from "@multiformats/multiaddr"; import type { Multiaddr } from "@multiformats/multiaddr";
import { ShardInfo } from "./sharding"; import { ShardInfo } from "./sharding.js";
export type ENRKey = string; export type ENRKey = string;
export type ENRValue = Uint8Array; export type ENRValue = Uint8Array;

View File

@ -1,4 +1,4 @@
import { Protocols } from "./protocols"; import { Protocols } from "./protocols.js";
export enum HealthStatus { export enum HealthStatus {
Unhealthy = "Unhealthy", Unhealthy = "Unhealthy",

View File

@ -4,7 +4,7 @@ import type { Libp2p as BaseLibp2p } from "@libp2p/interface";
import type { PingService } from "@libp2p/ping"; import type { PingService } from "@libp2p/ping";
import type { Libp2pInit, Libp2pOptions } from "libp2p"; import type { Libp2pInit, Libp2pOptions } from "libp2p";
import { IMetadata } from "./metadata"; import { IMetadata } from "./metadata.js";
export type Libp2pServices = { export type Libp2pServices = {
ping: PingService; ping: PingService;

View File

@ -3,8 +3,8 @@ import { NetworkConfig } from "@waku/interfaces";
import { derivePubsubTopicsFromNetworkConfig, Logger } from "@waku/utils"; import { derivePubsubTopicsFromNetworkConfig, Logger } from "@waku/utils";
import { expect } from "chai"; import { expect } from "chai";
import { DefaultTestPubsubTopic } from "../constants"; import { DefaultTestPubsubTopic } from "../constants.js";
import { Args, MessageRpcQuery, MessageRpcResponse } from "../types"; import { Args, MessageRpcQuery, MessageRpcResponse } from "../types.js";
import { delay, makeLogFileName } from "../utils/index.js"; import { delay, makeLogFileName } from "../utils/index.js";
import { MessageCollector } from "./message_collector.js"; import { MessageCollector } from "./message_collector.js";

View File

@ -2,8 +2,8 @@ import { exec } from "child_process";
import { setTimeout } from "timers"; import { setTimeout } from "timers";
import { promisify } from "util"; import { promisify } from "util";
import { SEPOLIA_RPC_URL } from "../dist/constants.js"; import { SEPOLIA_RPC_URL } from "./constants.js";
import { ServiceNode } from "../dist/lib/service_node.js"; import { ServiceNode } from "./lib/index.js";
const execAsync = promisify(exec); const execAsync = promisify(exec);

View File

@ -1,7 +1,7 @@
import { Logger } from "@waku/utils"; import { Logger } from "@waku/utils";
import { Suite } from "mocha"; 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"); const log = new Logger("test:mocha-hook");
function withGracefulTimeout( function withGracefulTimeout(

View File

@ -12,11 +12,11 @@ import { derivePubsubTopicsFromNetworkConfig, isDefined } from "@waku/utils";
import { Context } from "mocha"; import { Context } from "mocha";
import pRetry from "p-retry"; import pRetry from "p-retry";
import { NOISE_KEY_1 } from "../constants"; import { NOISE_KEY_1 } from "../constants.js";
import { ServiceNodesFleet } from "../lib"; import { ServiceNodesFleet } from "../lib/index.js";
import { Args } from "../types"; import { Args } from "../types.js";
import { waitForConnections } from "./waitForConnections"; import { waitForConnections } from "./waitForConnections.js";
export async function runMultipleNodes( export async function runMultipleNodes(
context: Context, context: Context,

View File

@ -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 // Utility to add test conditions based on nwaku/go-waku versions
export function isNwakuAtLeast(requiredVersion: string): boolean { export function isNwakuAtLeast(requiredVersion: string): boolean {

View File

@ -16,7 +16,7 @@ import {
TestEncoder, TestEncoder,
TestShardInfo, TestShardInfo,
validatePingError validatePingError
} from "./utils"; } from "./utils.js";
const runTests = (strictCheckNodes: boolean): void => { const runTests = (strictCheckNodes: boolean): void => {
describe(`Waku Filter V2: Ping: Multiple Nodes: Strict Checking: ${strictCheckNodes}`, function () { describe(`Waku Filter V2: Ping: Multiple Nodes: Strict Checking: ${strictCheckNodes}`, function () {

View File

@ -13,7 +13,7 @@ import {
TEST_STRING, TEST_STRING,
TEST_TIMESTAMPS TEST_TIMESTAMPS
} from "../../../src/index.js"; } from "../../../src/index.js";
import { runNodes } from "../../light-push/utils"; import { runNodes } from "../../light-push/utils.js";
import { import {
messageText, messageText,
TestContentTopic, TestContentTopic,

View File

@ -11,7 +11,7 @@ import {
ServiceNode, ServiceNode,
tearDownNodes tearDownNodes
} from "../../../src/index.js"; } from "../../../src/index.js";
import { runNodes } from "../../light-push/utils"; import { runNodes } from "../../light-push/utils.js";
import { import {
messagePayload, messagePayload,
messageText, messageText,

View File

@ -18,7 +18,11 @@ import { utf8ToBytes } from "@waku/utils/bytes";
import { Context } from "mocha"; import { Context } from "mocha";
import pRetry from "p-retry"; 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. // Constants for test configuration.
export const log = new Logger("test:filter"); export const log = new Logger("test:filter");

View File

@ -8,14 +8,14 @@ import {
runMultipleNodes, runMultipleNodes,
ServiceNode, ServiceNode,
ServiceNodesFleet ServiceNodesFleet
} from "../../src"; } from "../../src/index.js";
import { import {
messagePayload, messagePayload,
TestDecoder, TestDecoder,
TestEncoder, TestEncoder,
TestShardInfo TestShardInfo
} from "./utils"; } from "./utils.js";
describe("Node Health Status Matrix Tests", function () { describe("Node Health Status Matrix Tests", function () {
let waku: LightNode; let waku: LightNode;

View File

@ -11,7 +11,7 @@ import {
ServiceNodesFleet, ServiceNodesFleet,
teardownNodesWithRedundancy, teardownNodesWithRedundancy,
TEST_STRING TEST_STRING
} from "../../src"; } from "../../src/index.js";
import { import {
messagePayload, messagePayload,

View File

@ -12,7 +12,7 @@ import {
} from "@waku/utils"; } from "@waku/utils";
import { expect } from "chai"; import { expect } from "chai";
import { afterEachCustom, tearDownNodes } from "../../src"; import { afterEachCustom, tearDownNodes } from "../../src/index.js";
describe("Peer Exchange", () => { describe("Peer Exchange", () => {
describe("Auto Discovery", function () { describe("Auto Discovery", function () {

View File

@ -16,7 +16,7 @@ import { Logger, singleShardInfoToPubsubTopic } from "@waku/utils";
import { expect } from "chai"; import { expect } from "chai";
import { Context } from "mocha"; 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"); export const log = new Logger("test:store");

View File

@ -13,7 +13,7 @@ import {
shardInfoToPubsubTopics, shardInfoToPubsubTopics,
singleShardInfosToShardInfo, singleShardInfosToShardInfo,
singleShardInfoToPubsubTopic singleShardInfoToPubsubTopic
} from "."; } from "./index.js";
const testInvalidCases = ( const testInvalidCases = (
contentTopics: string[], contentTopics: string[],