From 4a988f79a231ec9dacb211ab090fa2146c5c599d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Sun, 8 Mar 2020 21:57:54 +0100 Subject: [PATCH] Resolve pull request comments: - constants import changed - re-export redefined - contants module reshape to comply with native module details. Using namespace import and named import for constant required TSLint config update to allow named imports: see: palantir/tslint#4524 /cc @43081j Thanks! --- types/karma/index.d.ts | 6 +-- types/karma/lib/constants.d.ts | 72 ++++++++++++++++------------------ types/karma/tslint.json | 12 +++++- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/types/karma/index.d.ts b/types/karma/index.d.ts index 9c341412a32f1d..7a5e4a716e130c 100644 --- a/types/karma/index.d.ts +++ b/types/karma/index.d.ts @@ -14,10 +14,10 @@ import Promise = require('bluebird'); import https = require('https'); import { Appender } from 'log4js'; import { EventEmitter } from 'events'; -import constants = require('./lib/constants'); +import * as karmaConstants from './lib/constants'; +import { VERSION } from './lib/constants'; -export { constants }; -export const VERSION: typeof constants.VERSION; +export { karmaConstants as constants, VERSION }; /** * `start` method is deprecated since 0.13. It will be removed in 0.14. * Please use diff --git a/types/karma/lib/constants.d.ts b/types/karma/lib/constants.d.ts index dfe1c42b8917ac..8cd14682fba6cd 100644 --- a/types/karma/lib/constants.d.ts +++ b/types/karma/lib/constants.d.ts @@ -1,42 +1,36 @@ -declare const constants: Constants; +/** The current version of karma */ +export const VERSION: string; +/** The default port used for the karma server */ +export const DEFAULT_PORT: string | number; +/** The default hostname used for the karma server */ +export const DEFAULT_HOSTNAME: string; +/** The default listen address used for the karma server */ +export const DEFAULT_LISTEN_ADDR: string; +/** The value for disabling logs */ +export const LOG_DISABLE: 'OFF'; +/** The value for the log `error` level */ +export const LOG_ERROR: 'ERROR'; +/** The value for the log `warn` level */ +export const LOG_WARN: 'WARN'; +/** The value for the log `info` level */ +export const LOG_INFO: 'INFO'; +/** The value for the log `debug` level */ +export const LOG_DEBUG: 'DEBUG'; +export const LOG_LOG: 'LOG'; +/** An array of log levels in descending order, i.e. LOG_DISABLE, LOG_ERROR, LOG_WARN, LOG_LOG, LOG_INFO, and LOG_DEBUG */ +export const LOG_PRIORITIES: ['OFF', 'ERROR', 'WARN', 'LOG', 'INFO', 'DEBUG']; -interface Constants { - /** The current version of karma */ - VERSION: string; - /** The default port used for the karma server */ - DEFAULT_PORT: string | number; - /** The default hostname used for the karma server */ - DEFAULT_HOSTNAME: string; - /** The default listen address used for the karma server */ - DEFAULT_LISTEN_ADDR: string; - /** The value for disabling logs */ - LOG_DISABLE: 'OFF'; - /** The value for the log `error` level */ - LOG_ERROR: 'ERROR'; - /** The value for the log `warn` level */ - LOG_WARN: 'WARN'; - /** The value for the log `info` level */ - LOG_INFO: 'INFO'; - /** The value for the log `debug` level */ - LOG_DEBUG: 'DEBUG'; - LOG_LOG: 'LOG'; - /** An array of log levels in descending order, i.e. LOG_DISABLE, LOG_ERROR, LOG_WARN, LOG_LOG, LOG_INFO, and LOG_DEBUG */ - LOG_PRIORITIES: ['OFF', 'ERROR', 'WARN', 'LOG', 'INFO', 'DEBUG']; - - /** The default color pattern for log output */ - COLOR_PATTERN: string; - /** The default pattern for log output without color */ - NO_COLOR_PATTERN: string; - /** The default console appender */ - CONSOLE_APPENDER: { +/** The default color pattern for log output */ +export const COLOR_PATTERN: string; +/** The default pattern for log output without color */ +export const NO_COLOR_PATTERN: string; +/** The default console appender */ +export const CONSOLE_APPENDER: { + type: string; + layout: { type: string; - layout: { - type: string; - pattern: string; - }; + pattern: string; }; - /** The exit code */ - EXIT_CODE: string; -} - -export = constants; +}; +/** The exit code */ +export const EXIT_CODE: string; diff --git a/types/karma/tslint.json b/types/karma/tslint.json index 3db14f85eaf7b9..e27ae39541c4f3 100644 --- a/types/karma/tslint.json +++ b/types/karma/tslint.json @@ -1 +1,11 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-duplicate-imports": [ + true, + { + "allow-namespace-imports": true + } + ] + } +}