Skip to content

eslint: add rule preventing reaching to dist #773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module.exports = {
extends: 'eslint-config-streamr-ts',
rules: {
'no-console': ['error', {allow: ['warn', 'error', 'info']}],
'no-restricted-imports': ['error', {
"patterns": ["*/dist"]
}],
'@typescript-eslint/no-inferrable-types': 'off'
}
}
2 changes: 1 addition & 1 deletion packages/broker/src/helpers/generateMnemonicFromAddress.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { entropyToMnemonic } from '@ethersproject/hdnode'
import { EthereumAddress } from 'streamr-client-protocol/dist/src/utils/types'
import { EthereumAddress } from 'streamr-client-protocol'

/**
* @param address - valid eth address with leading 0x
Expand Down
2 changes: 1 addition & 1 deletion packages/broker/src/plugins/info/InfoPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export class InfoPlugin extends Plugin<void> {

async stop(): Promise<void> {
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MessageRef from 'streamr-client-protocol/dist/src/protocol/message_layer/MessageRef'
import { MessageRef } from "streamr-client-protocol"

export default class GapFillFailedError extends Error {

Expand Down
4 changes: 3 additions & 1 deletion packages/client/src/utils/PatchTsyringe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
// See: https://github.com/microsoft/tsyringe/issues/177
// @ts-nocheck
import { container } from 'tsyringe'
// eslint-disable-next-line import/no-unresolved
// `dist` import below are intentional. Will not work properly if imported directly.
// eslint-disable-next-line import/no-unresolved,no-restricted-imports
import { isTokenDescriptor, isTransformDescriptor } from 'tsyringe/dist/cjs/providers/injection-token'
// eslint-disable-next-line no-restricted-imports
import { formatErrorCtor } from 'tsyringe/dist/cjs/error-helpers'

// Should be identical to original resolveParams, but replaces new Error with err.message = formatErrorCtor
Expand Down
26 changes: 15 additions & 11 deletions packages/client/test/unit/StreamMessageValidator.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import assert from 'assert'

import { SigningUtil, toStreamID, EthereumAddress } from 'streamr-client-protocol'
import StreamMessage from 'streamr-client-protocol/dist/src/protocol/message_layer/StreamMessage'
import MessageID from 'streamr-client-protocol/dist/src/protocol/message_layer/MessageID'
import GroupKeyMessage from 'streamr-client-protocol/dist/src/protocol/message_layer/GroupKeyMessage'
import GroupKeyRequest from 'streamr-client-protocol/dist/src/protocol/message_layer/GroupKeyRequest'
import GroupKeyResponse from 'streamr-client-protocol/dist/src/protocol/message_layer/GroupKeyResponse'
import GroupKeyAnnounce from 'streamr-client-protocol/dist/src/protocol/message_layer/GroupKeyAnnounce'
import MessageRef from 'streamr-client-protocol/dist/src/protocol/message_layer/MessageRef'
import GroupKeyErrorResponse from 'streamr-client-protocol/dist/src/protocol/message_layer/GroupKeyErrorResponse'
import EncryptedGroupKey from 'streamr-client-protocol/dist/src/protocol/message_layer/EncryptedGroupKey'
import ValidationError from 'streamr-client-protocol/dist/src/errors/ValidationError'
import {
SigningUtil,
toStreamID,
EthereumAddress,
StreamMessage,
MessageID,
GroupKeyMessage,
MessageRef,
EncryptedGroupKey,
GroupKeyRequest,
GroupKeyResponse,
GroupKeyAnnounce,
GroupKeyErrorResponse,
ValidationError
} from 'streamr-client-protocol'
import StreamMessageValidator, { StreamMetadata } from '../../src/StreamMessageValidator'

const groupKeyMessageToStreamMessage = (groupKeyMessage: GroupKeyMessage, messageId: MessageID, prevMsgRef: MessageRef | null): StreamMessage => {
Expand Down
2 changes: 1 addition & 1 deletion packages/network-tracker/src/browser/LocationManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Logger } from '@streamr/utils'
import { Location, NodeId } from 'streamr-network/dist/src/identifiers'
import { Location, NodeId } from 'streamr-network'

function isValidNodeLocation(location: Location | null) {
return location && (location.country || location.city || location.latitude || location.longitude)
Expand Down
2 changes: 1 addition & 1 deletion packages/network-tracker/src/protocol/TrackerServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
NodeId,
PeerId,
PeerInfo,
ServerWsEndpoint,
WsEndpointEvent
} from 'streamr-network'
import type { ServerWsEndpoint } from 'streamr-network'
import { Logger } from '@streamr/utils'

export enum Event {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Status, NodeId } from 'streamr-network/dist/src/identifiers'
import { runAndWaitForEvents } from 'streamr-test-utils'
import { wait } from '@streamr/utils'
import { Tracker } from '../../src/logic/Tracker'
import { startTracker } from '../../src/startTracker'

import { NodeToTracker, NodeToTrackerEvent, PeerInfo, NodeClientWsEndpoint } from 'streamr-network'
import { NodeToTracker, NodeToTrackerEvent, PeerInfo, NodeClientWsEndpoint, Status, NodeId } from 'streamr-network'
import { Event as TrackerServerEvent } from '../../src/protocol/TrackerServer'
import { getTopology } from '../../src/logic/trackerSummaryUtils'
import { toStreamID } from 'streamr-client-protocol'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Status } from 'streamr-network/dist/src/identifiers'
import { Status } from 'streamr-network'
import { InstructionCounter } from '../../src/logic/InstructionCounter'
import { StreamPartID, toStreamID } from 'streamr-client-protocol'

Expand Down
2 changes: 1 addition & 1 deletion packages/network/src/connection/ws/ServerWsEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@ export async function startHttpServer(
}
}
return httpServer
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Tracker, startTracker } from '@streamr/network-tracker'
import WebSocket from 'ws'
import { waitForEvent, waitForCondition, runAndWaitForEvents } from 'streamr-test-utils'

import { ServerWsEndpoint } from '../../dist/src/connection/ws/ServerWsEndpoint'
import { ServerWsEndpoint } from '../../src/connection/ws/ServerWsEndpoint'
import { PeerInfo } from '../../src/connection/PeerInfo'
import BrowserClientWsEndpoint from '../../src/connection/ws/BrowserClientWsEndpoint'
import { DisconnectionCode, Event } from '../../src/connection/ws/AbstractWsEndpoint'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('delivery of messages in protocol layer', () => {
nodeToNode1 = new NodeToNode(wrtcEndpoint1)
nodeToNode2 = new NodeToNode(wrtcEndpoint2)

trackerServer = new TrackerServer(wsEndpoint3)
trackerServer = new TrackerServer(wsEndpoint3 as any) // cast: get around weird circular dependency private property issue

// Connect nodeToTracker <-> trackerServer
await nodeToTracker.connectToTracker(trackerServer.getUrl(), trackerServerPeerInfo)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { waitForEvent } from 'streamr-test-utils'

import { ServerWsEndpoint } from '../../dist/src/connection/ws/ServerWsEndpoint'
import { ServerWsEndpoint } from '../../src/connection/ws/ServerWsEndpoint'
import { PeerInfo } from '../../src/connection/PeerInfo'
import NodeClientWsEndpoint from '../../src/connection/ws/NodeClientWsEndpoint'
import { Event } from '../../src/connection/ws/AbstractWsEndpoint'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ServerWsEndpoint } from '../../dist/src/connection/ws/ServerWsEndpoint'
import { ServerWsEndpoint } from '../../src/connection/ws/ServerWsEndpoint'
import NodeClientWsEndpoint from '../../src/connection/ws/NodeClientWsEndpoint'
import { PeerInfo } from '../../src/connection/PeerInfo'
import { Event } from '../../src/connection/ws/AbstractWsEndpoint'
Expand Down
2 changes: 1 addition & 1 deletion packages/network/test/integration/ws-endpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import WebSocket from 'ws'
import { waitForEvent } from 'streamr-test-utils'
import { wait } from '@streamr/utils'

import { ServerWsEndpoint } from '../../dist/src/connection/ws/ServerWsEndpoint'
import { ServerWsEndpoint } from '../../src/connection/ws/ServerWsEndpoint'
import { PeerInfo } from '../../src/connection/PeerInfo'
import NodeClientWsEndpoint from '../../src/connection/ws/NodeClientWsEndpoint'
import { DisconnectionCode, Event } from '../../src/connection/ws/AbstractWsEndpoint'
Expand Down
5 changes: 2 additions & 3 deletions packages/network/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { StreamPartID, toStreamID, toStreamPartID } from 'streamr-client-protocol'
import { Tracker } from '@streamr/network-tracker'
import { PeerInfo } from '../dist/src/connection/PeerInfo'
import { startHttpServer } from '../dist/src/connection/ws/ServerWsEndpoint'
import { PeerInfo } from '../src/connection/PeerInfo'
import { startHttpServer, ServerWsEndpoint } from '../src/connection/ws/ServerWsEndpoint'
import { Node } from '../src/logic/Node'
import { ServerWsEndpoint } from '../dist/src/connection/ws/ServerWsEndpoint'

export const startServerWsEndpoint = async (
host: string,
Expand Down