Browse Source

Fixed lint issues in server

update-deps
Alex Mikhalev 7 years ago
parent
commit
015614b1d6
  1. 21
      common/logger.ts
  2. 2
      common/sprinklers/SectionRunner.ts
  3. 2
      common/sprinklers/SprinklersDevice.ts
  4. 1
      common/sprinklers/index.ts
  5. 4
      common/sprinklers/json/index.ts
  6. 8
      common/sprinklers/mqtt/index.ts
  7. 6
      env.js
  8. 12
      paths.js
  9. 1
      server/app/serveApp.ts

21
common/logger.ts

@ -68,14 +68,6 @@ function write(value: any) { @@ -68,14 +68,6 @@ function write(value: any) {
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) {
const keys = Object.keys(value);
const result: any = {};
@ -93,19 +85,6 @@ function asISODate(time: string) { @@ -93,19 +85,6 @@ function asISODate(time: string) {
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[] } {
if (value.source) {
return { str: "%c(" + value.source + ") ", args: ["color: #FF00FF"] };

2
common/sprinklers/SectionRunner.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import { IObservableArray, observable } from "mobx";
import { observable } from "mobx";
import { Duration } from "./Duration";
import { SprinklersDevice } from "./SprinklersDevice";

2
common/sprinklers/SprinklersDevice.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import { IObservableArray, observable } from "mobx";
import { observable } from "mobx";
import { Duration } from "./Duration";
import { Program } from "./Program";
import { Section } from "./Section";

1
common/sprinklers/index.ts

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
import { IObservableArray, observable } from "mobx";
export * from "./Duration";
export * from "./ISprinklersApi";
export * from "./Program";

4
common/sprinklers/json/index.ts

@ -1,8 +1,6 @@ @@ -1,8 +1,6 @@
/* tslint:disable:ordered-imports */
import { assign, pick } from "lodash";
import {
createSimpleSchema, createModelSchema, primitive, object, date, custom,
ModelSchema, PropSchema,
createSimpleSchema, primitive, object, ModelSchema, PropSchema,
} from "serializr";
import list from "./list";
import * as s from "..";

8
common/sprinklers/mqtt/index.ts

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
import { cloneDeep } from "lodash";
import * as mqtt from "mqtt";
import { deserialize, update } from "serializr";
import { update } from "serializr";
import logger from "@common/logger";
import * as s from "@common/sprinklers";
@ -260,11 +259,6 @@ interface IResponseData { @@ -260,11 +259,6 @@ interface IResponseData {
type ResponseCallback = (data: IResponseData) => void;
interface ISectionJSON {
name: string;
pin: number;
}
interface IRunSectionJSON {
duration: number;
}

6
env.js

@ -8,7 +8,7 @@ delete require.cache[require.resolve("./paths")]; @@ -8,7 +8,7 @@ delete require.cache[require.resolve("./paths")];
const NODE_ENV = process.env.NODE_ENV;
if (!NODE_ENV) {
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) { @@ -72,7 +72,7 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) {
// 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.
PUBLIC_URL: publicUrl,
}
},
);
// Stringify all values so we can feed into Webpack DefinePlugin
const stringified = {
@ -83,4 +83,4 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) { @@ -83,4 +83,4 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) {
};
return { raw, stringified };
}
};

12
paths.js

@ -5,18 +5,17 @@ const url = require("url"); @@ -5,18 +5,17 @@ const url = require("url");
exports.rootDir = fs.realpathSync(process.cwd());
const resolveRoot = (p) => path.resolve(exports.rootDir, p);
function ensureSlash(path, needsSlash) {
const hasSlash = path.endsWith("/");
function ensureSlash(p, needsSlash) {
const hasSlash = p.endsWith("/");
if (hasSlash && !needsSlash) {
return path.substr(path, path.length - 1);
return p.substr(p, p.length - 1);
} else if (!hasSlash && needsSlash) {
return `${path}/`;
return `${p}/`;
} else {
return path;
return p;
}
}
exports.dotenv = resolveRoot(".env");
exports.nodeModulesDir = resolveRoot("node_modules");
exports.packageJson = resolveRoot("package.json");
@ -35,4 +34,3 @@ exports.publicDir = exports.appBuildDir; @@ -35,4 +34,3 @@ exports.publicDir = exports.appBuildDir;
exports.serverDir = resolveRoot("server");
exports.serverBuildDir = resolveRoot("dist");

1
server/app/serveApp.ts

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
import { Express } from "express";
import * as serveStatic from "serve-static";
import logger from "@common/logger";
import * as paths from "paths";
export default function serveApp(app: Express) {

Loading…
Cancel
Save