Skip to content

Commit

Permalink
Fix some multiline destructured imports
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLittleMods committed Apr 21, 2023
1 parent 8afd31c commit 4bbc400
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 43 deletions.
2 changes: 1 addition & 1 deletion server/lib/status-error.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var http = require('http');
import http from 'http';

/* Create an error as per http://bluebirdjs.com/docs/api/catch.html */
function StatusError(status, inputMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import escapeStringRegexp from 'escape-string-regexp';
import config from '../lib/config';
const basePath = config.get('basePath');
assert(basePath);
const {
VALID_SIGIL_TO_ENTITY_DESCRIPTOR_MAP,
} = require('matrix-public-archive-shared/lib/reference-values');
import { VALID_SIGIL_TO_ENTITY_DESCRIPTOR_MAP } from 'matrix-public-archive-shared/lib/reference-values';

// Create a regex string that will match a normal string or the URI encoded string or
// any combination of some characters being URI encoded. Only worries about characters
Expand Down
12 changes: 6 additions & 6 deletions server/routes/room-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import identifyRoute from '../middleware/identify-route-middleware';

import { HTTPResponseError } from '../lib/fetch-endpoint';
import parseViaServersFromUserInput from '../lib/parse-via-servers-from-user-input';
const {
import {
fetchRoomData,
fetchPredecessorInfo,
fetchSuccessorInfo,
} = require('../lib/matrix-utils/fetch-room-data');
} from '../lib/matrix-utils/fetch-room-data';
import fetchEventsFromTimestampBackwards from '../lib/matrix-utils/fetch-events-from-timestamp-backwards';
import ensureRoomJoined from '../lib/matrix-utils/ensure-room-joined';
import timestampToEvent from '../lib/matrix-utils/timestamp-to-event';
Expand All @@ -25,14 +25,14 @@ import getMessagesResponseFromEventId from '../lib/matrix-utils/get-messages-res
import renderHydrogenVmRenderScriptToPageHtml from '../hydrogen-render/render-hydrogen-vm-render-script-to-page-html';
import setHeadersToPreloadAssets from '../lib/set-headers-to-preload-assets';
import MatrixPublicArchiveURLCreator from 'matrix-public-archive-shared/lib/url-creator';
const {
import {
MS_LOOKUP,
TIME_PRECISION_VALUES,
DIRECTION,
VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP,
} = require('matrix-public-archive-shared/lib/reference-values');
} from 'matrix-public-archive-shared/lib/reference-values';
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;
const {
import {
roundUpTimestampToUtcDay,
roundUpTimestampToUtcHour,
roundUpTimestampToUtcMinute,
Expand All @@ -45,7 +45,7 @@ const {
areTimestampsFromSameUtcHour,
areTimestampsFromSameUtcMinute,
areTimestampsFromSameUtcSecond,
} = require('matrix-public-archive-shared/lib/timestamp-utilities');
} from 'matrix-public-archive-shared/lib/timestamp-utilities';

import config from '../lib/config';
const basePath = config.get('basePath');
Expand Down
4 changes: 2 additions & 2 deletions server/tracing/serialize-span.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {
import {
hrTimeToMilliseconds,
//hrTimeToMicroseconds
} = require('@opentelemetry/core');
} from '@opentelemetry/core';

const SAFE_ATTRIBUTES = ['http.method', 'http.url', 'http.status_code', 'http.target'];

Expand Down
4 changes: 2 additions & 2 deletions server/tracing/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
const {
import {
BasicTracerProvider,
// ConsoleSpanExporter,
// SimpleSpanProcessor,
BatchSpanProcessor,
} = require('@opentelemetry/sdk-trace-base');
} from '@opentelemetry/sdk-trace-base';
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
import { OTTracePropagator } from '@opentelemetry/propagator-ot-trace';
import { Resource } from '@opentelemetry/resources';
Expand Down
12 changes: 4 additions & 8 deletions shared/viewmodels/ArchiveRoomViewModel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {
import {
ViewModel,
setupLightboxNavigation,
TilesCollection,
Expand All @@ -7,7 +7,7 @@ const {
EventEntry,
encodeKey,
encodeEventIdKey,
} = require('hydrogen-view-sdk');
} from 'hydrogen-view-sdk';

import assert from 'matrix-public-archive-shared/lib/assert';

Expand All @@ -18,14 +18,10 @@ import TimeSelectorViewModel from 'matrix-public-archive-shared/viewmodels/TimeS
import DeveloperOptionsContentViewModel from 'matrix-public-archive-shared/viewmodels/DeveloperOptionsContentViewModel';
import RightPanelContentView from 'matrix-public-archive-shared/views/RightPanelContentView';
import AvatarViewModel from 'matrix-public-archive-shared/viewmodels/AvatarViewModel';
const {
customTileClassForEntry,
} = require('matrix-public-archive-shared/lib/custom-tile-utilities');
import { customTileClassForEntry } from 'matrix-public-archive-shared/lib/custom-tile-utilities';
import stubPowerLevelsObservable from 'matrix-public-archive-shared/lib/stub-powerlevels-observable';
import { TIME_PRECISION_VALUES } from 'matrix-public-archive-shared/lib/reference-values';
const {
areTimestampsFromSameUtcDay,
} = require('matrix-public-archive-shared/lib/timestamp-utilities');
import { areTimestampsFromSameUtcDay } from 'matrix-public-archive-shared/lib/timestamp-utilities';

let txnCount = 0;
function getFakeEventId() {
Expand Down
8 changes: 3 additions & 5 deletions shared/views/ArchiveRoomView.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const {
import {
TemplateView,
AvatarView,
TimelineView,
RightPanelView,
LightboxView,
} = require('hydrogen-view-sdk');
} from 'hydrogen-view-sdk';

const {
customViewClassForTile,
} = require('matrix-public-archive-shared/lib/custom-tile-utilities');
import { customViewClassForTile } from 'matrix-public-archive-shared/lib/custom-tile-utilities';

import DeveloperOptionsContentView from 'matrix-public-archive-shared/views/DeveloperOptionsContentView';
import ModalView from 'matrix-public-archive-shared/views/ModalView';
Expand Down
4 changes: 1 addition & 3 deletions shared/views/CalendarView.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Be mindful to do all date operations in UTC (the archive is all in UTC date/times)

import { TemplateView } from 'hydrogen-view-sdk';
const {
areTimestampsFromSameUtcDay,
} = require('matrix-public-archive-shared/lib/timestamp-utilities');
import { areTimestampsFromSameUtcDay } from 'matrix-public-archive-shared/lib/timestamp-utilities';

// Get the number of days in the given month where the `inputDate` lies.
//
Expand Down
4 changes: 2 additions & 2 deletions shared/views/TimeSelectorView.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from 'matrix-public-archive-shared/lib/assert';
import { TemplateView } from 'hydrogen-view-sdk';
const {
import {
MS_LOOKUP,
TIME_PRECISION_VALUES,
} = require('matrix-public-archive-shared/lib/reference-values');
} from 'matrix-public-archive-shared/lib/reference-values';
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;
import { getUtcStartOfDayTs } from 'matrix-public-archive-shared/lib/timestamp-utilities';

Expand Down
12 changes: 6 additions & 6 deletions test/e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import RethrownError from '../server/lib/rethrown-error';
import MatrixPublicArchiveURLCreator from 'matrix-public-archive-shared/lib/url-creator';
import { fetchEndpointAsText, fetchEndpointAsJson } from '../server/lib/fetch-endpoint';
import config from '../server/lib/config';
const {
import {
MS_LOOKUP,
TIME_PRECISION_VALUES,
DIRECTION,
} = require('matrix-public-archive-shared/lib/reference-values');
} from 'matrix-public-archive-shared/lib/reference-values';
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;

const {
import {
getTestClientForAs,
getTestClientForHs,
createTestRoom,
Expand All @@ -34,7 +34,7 @@ const {
getMessagesInRoom,
updateProfile,
uploadContent,
} = require('./test-utils/client-utils');
} from './test-utils/client-utils';
import TestError from './test-utils/test-error';
import parseRoomDayMessageStructure from './test-utils/parse-room-day-message-structure';
import parseArchiveUrlForRoom from './test-utils/parse-archive-url-for-room';
Expand Down Expand Up @@ -79,9 +79,9 @@ function assertExpectedTimePrecisionAgainstUrl(expectedTimePrecision, url) {

describe('matrix-public-archive', () => {
let server;
before(() => {
before(async () => {
// Start the archive server
server = require('../server/server');
server = await import('../server/server');
});

after(() => {
Expand Down
4 changes: 2 additions & 2 deletions test/shared/lib/timestamp-utilties-tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'assert';

const {
import {
roundUpTimestampToUtcDay,
roundUpTimestampToUtcHour,
roundUpTimestampToUtcMinute,
Expand All @@ -13,7 +13,7 @@ const {
areTimestampsFromSameUtcHour,
areTimestampsFromSameUtcMinute,
areTimestampsFromSameUtcSecond,
} = require('matrix-public-archive-shared/lib/timestamp-utilities');
} from 'matrix-public-archive-shared/lib/timestamp-utilities';

describe('timestamp-utilities', () => {
describe('roundUpTimestampToUtcX', () => {
Expand Down
4 changes: 1 addition & 3 deletions test/test-utils/parse-archive-url-for-room.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const {
VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP,
} = require('matrix-public-archive-shared/lib/reference-values');
import { VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP } from 'matrix-public-archive-shared/lib/reference-values';

// http://archive.matrix.org/r/some-room:matrix.org/date/2022/11/16T23:59:59?at=$xxx
function parseArchiveUrlForRoom(archiveUrlForRoom) {
Expand Down

0 comments on commit 4bbc400

Please sign in to comment.