Enforce single quotes

This commit is contained in:
Sebastian Seedorf
2020-11-19 20:40:21 +01:00
parent 7f44df42e7
commit 40b148b7c7
18 changed files with 81 additions and 80 deletions

View File

@@ -32,7 +32,7 @@ function getRouter(opts: ReloaderConfig): Router {
if (!DefaultConfig.isProduction) {
let uuid = v4();
let updateTimeout: Timeout|undefined = undefined;
import("node-watch").then((watch) => {
import('node-watch').then((watch) => {
for (const frontendDir of config.frontendDirs) {
watch.default(frontendDir, {recursive: true}, () => {
if (updateTimeout !== undefined) clearTimeout(updateTimeout);
@@ -46,7 +46,7 @@ function getRouter(opts: ReloaderConfig): Router {
// /auto-reload/client.js
router.get(urlJoin(config.subPath, config.jsName), (req, res) => {
Logger.debug(req.url, req.originalUrl, req.baseUrl);
res.setHeader('Content-Type', "application/javascript");
res.setHeader('Content-Type', 'application/javascript');
// language=JavaScript
res.send(`
const loc = window.location;
@@ -76,7 +76,7 @@ function getRouter(opts: ReloaderConfig): Router {
}
}
}, 3000);
`.replace(/\t/g, ""));
`.replace(/\t/g, ''));
});
// /auto-reload

View File

@@ -1,7 +1,7 @@
import * as env from 'env-var';
import {urlJoin} from '.';
const NODE_ENV = env.get('NODE_ENV').default("development").asString();
const NODE_ENV = env.get('NODE_ENV').default('development').asString();
const isProduction = NODE_ENV === 'production';
const envs = {
@@ -21,9 +21,9 @@ const envs = {
SESSION_SECRET: env.get('SESSION_SECRET').asString() || undefined,
// header where user info token is stored to request auth proxy
USERINFO_HEADER: env.get('USERINFO_HEADER').default("X-Userinfo-Token").asString(),
USERINFO_HEADER: env.get('USERINFO_HEADER').default('X-Userinfo-Token').asString(),
// header when user info token expires (seconds after 01/01/1970)
EXPIRE_HEADER: env.get('EXPIRE_HEADER').default("X-Userinfo-Expire").asString(),
EXPIRE_HEADER: env.get('EXPIRE_HEADER').default('X-Userinfo-Expire').asString(),
// base url to init a logout or request user info
AUTH_PROXY_URL: env.get('AUTH_PROXY_URL').asString() || undefined,
// override AUTH_PROXY_URL to request user info
@@ -40,11 +40,11 @@ export const DefaultConfig = {
...envs,
EXTERNAL_BASE_URL:
envs.EXTERNAL_BASE_URL ||
urlJoin(`http://${envs.HOSTNAME}${envs.PORT !== 80 ? `:${envs.PORT}` : ""}`, envs.BASE_PATH),
urlJoin(`http://${envs.HOSTNAME}${envs.PORT !== 80 ? `:${envs.PORT}` : ''}`, envs.BASE_PATH),
isProduction,
requireEnv,
AUTH_PROXY_USERINFO_URL: envs.AUTH_PROXY_USERINFO_URL ||
envs.AUTH_PROXY_URL && urlJoin(envs.AUTH_PROXY_URL, "userinfo"),
envs.AUTH_PROXY_URL && urlJoin(envs.AUTH_PROXY_URL, 'userinfo'),
AUTH_PROXY_INIT_LOGOUT_URL: envs.AUTH_PROXY_INIT_LOGOUT_URL ||
envs.AUTH_PROXY_URL && urlJoin(envs.AUTH_PROXY_URL, "init-logout"),
envs.AUTH_PROXY_URL && urlJoin(envs.AUTH_PROXY_URL, 'init-logout'),
};

View File

@@ -7,7 +7,7 @@ import prune = require('json-prune');
const logger = winston.createLogger({
level: DefaultConfig.isProduction ? "info" : "silly",
level: DefaultConfig.isProduction ? 'info' : 'silly',
format: winston.format.json(),
transports: [
new winston.transports.Console({
@@ -16,11 +16,11 @@ const logger = winston.createLogger({
],
});
export const levels = ["error", "warn", "info", "http", "verbose", "debug", "silly"] as const;
export type LogLevels = typeof levels[number]|"log";
export const levels = ['error', 'warn', 'info', 'http', 'verbose', 'debug', 'silly'] as const;
export type LogLevels = typeof levels[number]|'log';
const wrapper = (original: LeveledLogMethod) => {
return (...args: unknown[]) => {
return original(args.map((obj) => typeof obj === "string" ? obj : prune(obj)).join(" "));
return original(args.map((obj) => typeof obj === 'string' ? obj : prune(obj)).join(' '));
};
};
@@ -30,7 +30,7 @@ export const Logger = {
for (const level of levels) {
Logger[level] = wrapper(logger[level]);
}
Logger.log = wrapper(logger["silly"]);
Logger.log = wrapper(logger['silly']);
export const HttpLogger: RequestHandler = (req, res, next) => {
const start = Date.now();
@@ -45,8 +45,8 @@ export const HttpLogger: RequestHandler = (req, res, next) => {
: statusCode >= 200 ? colors.green
: colors.gray;
const status = colorFunction(res.statusCode.toString(10));
const method = req.method.toUpperCase().padEnd(6, " ");
const responseTime = (Date.now()-start).toString(10).padStart(3, " ");
const method = req.method.toUpperCase().padEnd(6, ' ');
const responseTime = (Date.now()-start).toString(10).padStart(3, ' ');
if (!req.noHttpLogging)
Logger.http(`${status} ${method} ${responseTime}ms ${path}`);
end.apply(res, args);

View File

@@ -87,7 +87,7 @@ export class PermQuery extends Query {
}
public sync(): PermQuery {
throw new AccessControlError("Sync method is not allowed on PermissionManager!");
throw new AccessControlError('Sync method is not allowed on PermissionManager!');
}
}

View File

@@ -1,15 +1,15 @@
// workers/add.js
import {expose} from "threads/worker";
import * as fs from "fs";
import {expose} from 'threads/worker';
import * as fs from 'fs';
import {analyze} from '@10xjs/polyfill-analyzer';
import allPolyfills from '@10xjs/polyfill-analyzer/dist/polyfills';
import {PolyfillFeatureList} from 'polyfill-library';
expose((fileToWatch) => {
const exclude = [
"console.markTimeline",
"console.timeline",
"console.timelineEnd",
'console.markTimeline',
'console.timeline',
'console.timelineEnd',
];
const featureList = analyze({
source: fs.readFileSync(fileToWatch, 'utf-8'),

View File

@@ -22,27 +22,27 @@ export type PolyfillOptions = {
function getRouter(fileToWatch: string, opts?: Partial<PolyfillOptions>): RequestHandler {
const features = new WaitForSync<PolyfillFeatureList>();
(async () => {
const worker = await spawn<WorkerFunction>(new Worker("./polyfill-worker"));
const worker = await spawn<WorkerFunction>(new Worker('./polyfill-worker'));
const feats = await worker(fileToWatch) as PolyfillFeatureList;
await Thread.terminate(worker);
return feats;
})()
.then(feats => {
feats["fetch"] = {};
Logger.debug("Polyfill analysed:", Object.keys(feats));
feats['fetch'] = {};
Logger.debug('Polyfill analysed:', Object.keys(feats));
features.setData(feats);
})
.catch(err => features.setError(err));
const options: Partial<PolyfillOptions> = {
minify: DefaultConfig.isProduction,
unknown: "polyfill",
unknown: 'polyfill',
...opts,
};
return async (req, res) => {
const polyfillBundle = await polyfillLibrary.getPolyfillString({
...options,
uaString: req.header("user-agent"),
uaString: req.header('user-agent'),
features: await features.resolve(),
stream: false,
});

View File

@@ -12,8 +12,8 @@ interface RedisType {
class RealRedis implements RedisType {
private _client: redis.RedisClient|undefined;
private _promGet: ((key: string) => Promise<string|null>)|undefined;
private _promSet: RedisType["set"]|undefined;
private _promDel: RedisType["del"]|undefined;
private _promSet: RedisType['set']|undefined;
private _promDel: RedisType['del']|undefined;
get client(): redis.RedisClient {
if (this._client !== undefined) return this._client;

View File

@@ -1,9 +1,9 @@
import * as session from 'express-session';
import {Store} from 'express-session';
import {DefaultConfig, Redis} from '.';
import * as redisStore from "connect-redis";
import * as redisStore from 'connect-redis';
import {RequestHandler, Router} from 'express';
import {promisify} from "util";
import {promisify} from 'util';
let sessionStore: Store|undefined = undefined;

View File

@@ -1,4 +1,4 @@
declare module "json-prune" {
declare module 'json-prune' {
function prune(object: unknown): string;
export = prune;

View File

@@ -1,4 +1,4 @@
declare module "polyfill-library" {
declare module 'polyfill-library' {
import {Readable} from 'stream';
function listAllPolyfills(): string[];