Skip to content

Commit

Permalink
chore: mandate .js extensions for imports (#2128)
Browse files Browse the repository at this point in the history
* feat: add eslint rule

* chore: update codebase import extensions
  • Loading branch information
danisharora099 authored Sep 13, 2024
1 parent a2c5dba commit 9d9a696
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 58 deletions.
12 changes: 11 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/interfaces/src/connection_manager.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/interfaces/src/enr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/interfaces/src/health_manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Protocols } from "./protocols";
import { Protocols } from "./protocols.js";

export enum HealthStatus {
Unhealthy = "Unhealthy",
Expand Down
2 changes: 1 addition & 1 deletion packages/interfaces/src/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/tests/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions packages/tests/src/sync-rln-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion packages/tests/src/utils/custom_mocha_hooks.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
8 changes: 4 additions & 4 deletions packages/tests/src/utils/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/src/utils/waku_versions_utils.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/filter/ping.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/filter/single_node/push.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion packages/tests/tests/filter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions packages/tests/tests/health-manager/node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/light-push/index.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ServiceNodesFleet,
teardownNodesWithRedundancy,
TEST_STRING
} from "../../src";
} from "../../src/index.js";

import {
messagePayload,
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/peer-exchange/pe.optional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/store/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/common/sharding/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
shardInfoToPubsubTopics,
singleShardInfosToShardInfo,
singleShardInfoToPubsubTopic
} from ".";
} from "./index.js";

const testInvalidCases = (
contentTopics: string[],
Expand Down

0 comments on commit 9d9a696

Please sign in to comment.