remove "import for side effects"

deepsource-autofix-76c6eb20
Dan Gowans 2023-01-25 14:29:56 -05:00
parent a28d55cab8
commit 165d15b956
12 changed files with 37 additions and 16 deletions

1
app.d.ts vendored
View File

@ -1,3 +1,2 @@
import './helpers/polyfills.js';
export declare const app: import("express-serve-static-core").Express; export declare const app: import("express-serve-static-core").Express;
export default app; export default app;

3
app.js
View File

@ -1,4 +1,4 @@
import './helpers/polyfills.js'; import { applyPolyfills } from './helpers/polyfills.js';
import createError from 'http-errors'; import createError from 'http-errors';
import express from 'express'; import express from 'express';
import compression from 'compression'; import compression from 'compression';
@ -31,6 +31,7 @@ import { getSafeRedirectURL } from './helpers/functions.authentication.js';
import debug from 'debug'; import debug from 'debug';
import { useTestDatabases } from './data/databasePaths.js'; import { useTestDatabases } from './data/databasePaths.js';
const debugApp = debug('lot-occupancy-system:app'); const debugApp = debug('lot-occupancy-system:app');
applyPolyfills();
databaseInitializer.initializeDatabase(); databaseInitializer.initializeDatabase();
const _dirname = '.'; const _dirname = '.';
export const app = express(); export const app = express();

8
app.ts
View File

@ -1,4 +1,4 @@
import './helpers/polyfills.js' import { applyPolyfills } from './helpers/polyfills.js'
import createError from 'http-errors' import createError from 'http-errors'
import express, { type RequestHandler } from 'express' import express, { type RequestHandler } from 'express'
@ -41,6 +41,12 @@ import debug from 'debug'
import { useTestDatabases } from './data/databasePaths.js' import { useTestDatabases } from './data/databasePaths.js'
const debugApp = debug('lot-occupancy-system:app') const debugApp = debug('lot-occupancy-system:app')
/*
* Apply Polyfills
*/
applyPolyfills()
/* /*
* INITIALIZE THE DATABASE * INITIALIZE THE DATABASE
*/ */

View File

@ -1,4 +1,3 @@
import './polyfills.js';
import type * as recordTypes from '../types/recordTypes'; import type * as recordTypes from '../types/recordTypes';
export declare function regenerateApiKey(userName: string): Promise<void>; export declare function regenerateApiKey(userName: string): Promise<void>;
export declare function getApiKey(userName: string): Promise<string>; export declare function getApiKey(userName: string): Promise<string>;

View File

@ -1,8 +1,9 @@
import './polyfills.js'; import { applyPolyfills } from './polyfills.js';
import fs from 'node:fs/promises'; import fs from 'node:fs/promises';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import Debug from 'debug'; import Debug from 'debug';
const debug = Debug('lot-occupancy-system:functions.api'); const debug = Debug('lot-occupancy-system:functions.api');
applyPolyfills();
const apiKeyPath = 'data/apiKeys.json'; const apiKeyPath = 'data/apiKeys.json';
let apiKeys; let apiKeys;
async function loadApiKeys() { async function loadApiKeys() {

View File

@ -1,4 +1,4 @@
import './polyfills.js' import { applyPolyfills } from './polyfills.js'
import fs from 'node:fs/promises' import fs from 'node:fs/promises'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
@ -9,6 +9,8 @@ import type * as recordTypes from '../types/recordTypes'
const debug = Debug('lot-occupancy-system:functions.api') const debug = Debug('lot-occupancy-system:functions.api')
applyPolyfills()
const apiKeyPath = 'data/apiKeys.json' const apiKeyPath = 'data/apiKeys.json'
let apiKeys: Record<string, string> let apiKeys: Record<string, string>

View File

@ -1,4 +1,3 @@
import './polyfills.js';
import type * as configTypes from '../types/configTypes'; import type * as configTypes from '../types/configTypes';
export declare function getProperty(propertyName: 'application.applicationName'): string; export declare function getProperty(propertyName: 'application.applicationName'): string;
export declare function getProperty(propertyName: 'application.logoURL'): string; export declare function getProperty(propertyName: 'application.logoURL'): string;

View File

@ -1,5 +1,6 @@
import './polyfills.js'; import { applyPolyfills } from './polyfills.js';
import { config } from '../data/config.js'; import { config } from '../data/config.js';
applyPolyfills();
const configFallbackValues = new Map(); const configFallbackValues = new Map();
configFallbackValues.set('application.applicationName', 'Lot Occupancy System'); configFallbackValues.set('application.applicationName', 'Lot Occupancy System');
configFallbackValues.set('application.backgroundURL', '/images/cemetery-background.jpg'); configFallbackValues.set('application.backgroundURL', '/images/cemetery-background.jpg');

View File

@ -1,11 +1,13 @@
/* eslint-disable @typescript-eslint/indent, node/no-unpublished-import */ /* eslint-disable @typescript-eslint/indent, node/no-unpublished-import */
import './polyfills.js' import { applyPolyfills } from './polyfills.js'
import { config } from '../data/config.js' import { config } from '../data/config.js'
import type * as configTypes from '../types/configTypes' import type * as configTypes from '../types/configTypes'
applyPolyfills()
/* /*
* SET UP FALLBACK VALUES * SET UP FALLBACK VALUES
*/ */

View File

@ -1 +1,2 @@
export {}; export declare function applyPolyfills(): void;
export default applyPolyfills;

View File

@ -1,6 +1,10 @@
import Debug from 'debug'; import Debug from 'debug';
const debug = Debug('lot-occupancy-system:polyfills'); const debug = Debug('lot-occupancy-system:polyfills');
if (Object.hasOwn === undefined) { export function applyPolyfills() {
if (Object.hasOwn === undefined) {
debug('Applying Object.hasOwn(o, v) polyfill'); debug('Applying Object.hasOwn(o, v) polyfill');
Object.hasOwn = Object.prototype.hasOwnProperty.call; Object.hasOwn = Object.prototype.hasOwnProperty.call;
}
} }
applyPolyfills();
export default applyPolyfills;

View File

@ -1,7 +1,13 @@
import Debug from 'debug' import Debug from 'debug'
const debug = Debug('lot-occupancy-system:polyfills') const debug = Debug('lot-occupancy-system:polyfills')
if (Object.hasOwn === undefined) { export function applyPolyfills(): void {
if (Object.hasOwn === undefined) {
debug('Applying Object.hasOwn(o, v) polyfill') debug('Applying Object.hasOwn(o, v) polyfill')
Object.hasOwn = Object.prototype.hasOwnProperty.call Object.hasOwn = Object.prototype.hasOwnProperty.call
}
} }
applyPolyfills()
export default applyPolyfills