From a3c4aadbeb3bdfcbdceb1c6e74a7e3142a3b2351 Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Wed, 7 Mar 2018 10:25:21 -0500 Subject: [PATCH 1/2] Add typings for winston-syslog --- types/winston-syslog/index.d.ts | 25 ++++++++++++++ types/winston-syslog/tsconfig.json | 24 +++++++++++++ types/winston-syslog/tslint.json | 6 ++++ types/winston-syslog/winston-syslog-tests.ts | 36 ++++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 types/winston-syslog/index.d.ts create mode 100644 types/winston-syslog/tsconfig.json create mode 100644 types/winston-syslog/tslint.json create mode 100644 types/winston-syslog/winston-syslog-tests.ts diff --git a/types/winston-syslog/index.d.ts b/types/winston-syslog/index.d.ts new file mode 100644 index 0000000000..816274ded8 --- /dev/null +++ b/types/winston-syslog/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for winston-syslog 1.0 +// Project: https://github.com/indexzero/winston-syslog#readme +// Definitions by: Chris Barth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as winston from "winston"; +export interface SyslogTransportOptions extends winston.GenericTextTransportOptions { + host?: string; + port?: number; + path?: string; + protocol?: string; + pid?: number; + facility?: string; + localhost?: string; + type?: string; + app_name?: string; + eol?: string; +} +export class Syslog extends winston.Transport implements winston.TransportInstance { +} +declare module "winston" { + interface Transports { + Syslog: Syslog; + } +} diff --git a/types/winston-syslog/tsconfig.json b/types/winston-syslog/tsconfig.json new file mode 100644 index 0000000000..e11a89c680 --- /dev/null +++ b/types/winston-syslog/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "winston-syslog-tests.ts" + ] +} \ No newline at end of file diff --git a/types/winston-syslog/tslint.json b/types/winston-syslog/tslint.json new file mode 100644 index 0000000000..1e30988418 --- /dev/null +++ b/types/winston-syslog/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-var-requires": false + } +} diff --git a/types/winston-syslog/winston-syslog-tests.ts b/types/winston-syslog/winston-syslog-tests.ts new file mode 100644 index 0000000000..ce83bbb918 --- /dev/null +++ b/types/winston-syslog/winston-syslog-tests.ts @@ -0,0 +1,36 @@ +import winston = require('winston'); +import { SyslogTransportOptions } from 'winston-syslog'; +require('winston-syslog').Syslog; + +const str = ""; +const bool = true; +const num = 1; +const obj: any = {}; + +const syslogOptions: SyslogTransportOptions = { + host: str, + port: num, + path: str, + protocol: str, + pid: num, + facility: str, + localhost: str, + type: str, + app_name: str, + eol: str, + json: bool, + colorize: bool, + colors: str, + prettyPrint: bool, + showLevel: bool, + label: str, + depth: num, +}; + +winston.add(winston.transports.Syslog, syslogOptions); + +const logger: winston.LoggerInstance = new (winston.Logger)({ + transports: [ + new (winston.transports.Syslog)(syslogOptions), + ] +}); From 155bf9571e6e33ca43c7880119d8a1084f854e25 Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Thu, 8 Mar 2018 10:06:59 -0500 Subject: [PATCH 2/2] Enable more linting --- types/winston-syslog/tslint.json | 5 +---- types/winston-syslog/winston-syslog-tests.ts | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/types/winston-syslog/tslint.json b/types/winston-syslog/tslint.json index 1e30988418..f93cf8562a 100644 --- a/types/winston-syslog/tslint.json +++ b/types/winston-syslog/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "no-var-requires": false - } + "extends": "dtslint/dt.json" } diff --git a/types/winston-syslog/winston-syslog-tests.ts b/types/winston-syslog/winston-syslog-tests.ts index ce83bbb918..a08b80b045 100644 --- a/types/winston-syslog/winston-syslog-tests.ts +++ b/types/winston-syslog/winston-syslog-tests.ts @@ -1,6 +1,5 @@ import winston = require('winston'); import { SyslogTransportOptions } from 'winston-syslog'; -require('winston-syslog').Syslog; const str = ""; const bool = true;