Fixed lint issues in server
This commit is contained in:
parent
e5cc6b86e7
commit
015614b1d6
@ -68,14 +68,6 @@ function write(value: any) {
|
|||||||
fn.apply(null, args);
|
fn.apply(null, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function withSpaces(value: string): string {
|
|
||||||
const lines = value.split("\n");
|
|
||||||
for (let i = 1; i < lines.length; i++) {
|
|
||||||
lines[i] = " " + lines[i];
|
|
||||||
}
|
|
||||||
return lines.join("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function filter(value: any) {
|
function filter(value: any) {
|
||||||
const keys = Object.keys(value);
|
const keys = Object.keys(value);
|
||||||
const result: any = {};
|
const result: any = {};
|
||||||
@ -93,19 +85,6 @@ function asISODate(time: string) {
|
|||||||
return new Date(time).toISOString();
|
return new Date(time).toISOString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTime(value: any, after?: string) {
|
|
||||||
after = after || "";
|
|
||||||
try {
|
|
||||||
if (!value || !value.time) {
|
|
||||||
return "";
|
|
||||||
} else {
|
|
||||||
return "[" + asISODate(value.time) + "]" + after;
|
|
||||||
}
|
|
||||||
} catch (_) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatSource(value: any): { str: string, args: any[] } {
|
function formatSource(value: any): { str: string, args: any[] } {
|
||||||
if (value.source) {
|
if (value.source) {
|
||||||
return { str: "%c(" + value.source + ") ", args: ["color: #FF00FF"] };
|
return { str: "%c(" + value.source + ") ", args: ["color: #FF00FF"] };
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { IObservableArray, observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { Duration } from "./Duration";
|
import { Duration } from "./Duration";
|
||||||
import { SprinklersDevice } from "./SprinklersDevice";
|
import { SprinklersDevice } from "./SprinklersDevice";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { IObservableArray, observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { Duration } from "./Duration";
|
import { Duration } from "./Duration";
|
||||||
import { Program } from "./Program";
|
import { Program } from "./Program";
|
||||||
import { Section } from "./Section";
|
import { Section } from "./Section";
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { IObservableArray, observable } from "mobx";
|
|
||||||
export * from "./Duration";
|
export * from "./Duration";
|
||||||
export * from "./ISprinklersApi";
|
export * from "./ISprinklersApi";
|
||||||
export * from "./Program";
|
export * from "./Program";
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/* tslint:disable:ordered-imports */
|
/* tslint:disable:ordered-imports */
|
||||||
import { assign, pick } from "lodash";
|
|
||||||
import {
|
import {
|
||||||
createSimpleSchema, createModelSchema, primitive, object, date, custom,
|
createSimpleSchema, primitive, object, ModelSchema, PropSchema,
|
||||||
ModelSchema, PropSchema,
|
|
||||||
} from "serializr";
|
} from "serializr";
|
||||||
import list from "./list";
|
import list from "./list";
|
||||||
import * as s from "..";
|
import * as s from "..";
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { cloneDeep } from "lodash";
|
|
||||||
import * as mqtt from "mqtt";
|
import * as mqtt from "mqtt";
|
||||||
import { deserialize, update } from "serializr";
|
import { update } from "serializr";
|
||||||
|
|
||||||
import logger from "@common/logger";
|
import logger from "@common/logger";
|
||||||
import * as s from "@common/sprinklers";
|
import * as s from "@common/sprinklers";
|
||||||
@ -260,11 +259,6 @@ interface IResponseData {
|
|||||||
|
|
||||||
type ResponseCallback = (data: IResponseData) => void;
|
type ResponseCallback = (data: IResponseData) => void;
|
||||||
|
|
||||||
interface ISectionJSON {
|
|
||||||
name: string;
|
|
||||||
pin: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IRunSectionJSON {
|
interface IRunSectionJSON {
|
||||||
duration: number;
|
duration: number;
|
||||||
}
|
}
|
||||||
|
6
env.js
6
env.js
@ -8,7 +8,7 @@ delete require.cache[require.resolve("./paths")];
|
|||||||
const NODE_ENV = process.env.NODE_ENV;
|
const NODE_ENV = process.env.NODE_ENV;
|
||||||
if (!NODE_ENV) {
|
if (!NODE_ENV) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"The NODE_ENV environment variable is required but was not specified."
|
"The NODE_ENV environment variable is required but was not specified.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) {
|
|||||||
// This should only be used as an escape hatch. Normally you would put
|
// This should only be used as an escape hatch. Normally you would put
|
||||||
// images into the `src` and `import` them in code to get their paths.
|
// images into the `src` and `import` them in code to get their paths.
|
||||||
PUBLIC_URL: publicUrl,
|
PUBLIC_URL: publicUrl,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
// Stringify all values so we can feed into Webpack DefinePlugin
|
// Stringify all values so we can feed into Webpack DefinePlugin
|
||||||
const stringified = {
|
const stringified = {
|
||||||
@ -83,4 +83,4 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return { raw, stringified };
|
return { raw, stringified };
|
||||||
}
|
};
|
||||||
|
12
paths.js
12
paths.js
@ -5,18 +5,17 @@ const url = require("url");
|
|||||||
exports.rootDir = fs.realpathSync(process.cwd());
|
exports.rootDir = fs.realpathSync(process.cwd());
|
||||||
const resolveRoot = (p) => path.resolve(exports.rootDir, p);
|
const resolveRoot = (p) => path.resolve(exports.rootDir, p);
|
||||||
|
|
||||||
function ensureSlash(path, needsSlash) {
|
function ensureSlash(p, needsSlash) {
|
||||||
const hasSlash = path.endsWith("/");
|
const hasSlash = p.endsWith("/");
|
||||||
if (hasSlash && !needsSlash) {
|
if (hasSlash && !needsSlash) {
|
||||||
return path.substr(path, path.length - 1);
|
return p.substr(p, p.length - 1);
|
||||||
} else if (!hasSlash && needsSlash) {
|
} else if (!hasSlash && needsSlash) {
|
||||||
return `${path}/`;
|
return `${p}/`;
|
||||||
} else {
|
} else {
|
||||||
return path;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exports.dotenv = resolveRoot(".env");
|
exports.dotenv = resolveRoot(".env");
|
||||||
exports.nodeModulesDir = resolveRoot("node_modules");
|
exports.nodeModulesDir = resolveRoot("node_modules");
|
||||||
exports.packageJson = resolveRoot("package.json");
|
exports.packageJson = resolveRoot("package.json");
|
||||||
@ -35,4 +34,3 @@ exports.publicDir = exports.appBuildDir;
|
|||||||
|
|
||||||
exports.serverDir = resolveRoot("server");
|
exports.serverDir = resolveRoot("server");
|
||||||
exports.serverBuildDir = resolveRoot("dist");
|
exports.serverBuildDir = resolveRoot("dist");
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Express } from "express";
|
import { Express } from "express";
|
||||||
import * as serveStatic from "serve-static";
|
import * as serveStatic from "serve-static";
|
||||||
|
|
||||||
import logger from "@common/logger";
|
|
||||||
import * as paths from "paths";
|
import * as paths from "paths";
|
||||||
|
|
||||||
export default function serveApp(app: Express) {
|
export default function serveApp(app: Express) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user