UNPKG

tsconfig-lint

Version:

A tsconfig tool for running tslint on files found in the tsconfig. Integrates with tsconfig-glob to allow for `filesGlob` in the tsconfig.json.

219 lines (218 loc) 7.08 kB
"use strict"; var __nativeIsArray = !!Array.isArray, __objToString = Object.prototype.toString, __toStringClass = '[object ', __errorClass = __toStringClass + 'Error]', __fileClass = __toStringClass + 'File]', __arrayClass = __toStringClass + 'Array]', __boolClass = __toStringClass + 'Boolean]', __dateClass = __toStringClass + 'Date]', __funcClass = __toStringClass + 'Function]', __numberClass = __toStringClass + 'Number]', __objectClass = __toStringClass + 'Object]', __regexpClass = __toStringClass + 'RegExp]', __stringClass = __toStringClass + 'String]', __promiseClass = __toStringClass + 'Promise]', __objectTypes = { 'boolean': false, 'function': true, 'object': true, 'number': false, 'string': false, 'undefined': false }; function _defineProperty(obj, key, value, enumerable, configurable, writable) { Object.defineProperty(obj, key, { value: value, enumerable: enumerable === true, configurable: configurable === true, writable: writable === true }); } function extend(deep, redefine, destination) { var sources = []; for (var _i = 3; _i < arguments.length; _i++) { sources[_i - 3] = arguments[_i]; } if (isNull(destination)) { return destination; } var keys, property, define; if (isFunction(redefine)) { define = redefine; } else if (redefine) { define = function (obj, key, value) { _defineProperty(obj, key, value, true, true, true); }; } else { define = function (obj, key, value) { obj[key] = value; }; } if (isEmpty(sources)) { sources.push(destination); } forEach(function (source, k) { if (!isObject(source)) { return; } keys = Object.keys(source); forEach(function (key) { property = source[key]; if (deep) { if (isArray(property)) { extend(deep, define, destination[key] || (destination[key] = []), property); return; } else if (isDate(property)) { define(destination, key, new Date(property.getTime())); return; } else if (isRegExp(property)) { define(destination, key, new RegExp(property)); return; } else if (isNode(property)) { define(destination, key, property.cloneNode(true)); return; } else if (isObject(property)) { extend(deep, define, destination[key] || (destination[key] = {}), property); return; } } define(destination, key, property); }, keys); }, sources); return destination; } exports.extend = extend; function clone(obj, deep) { if (!isObject(obj)) { return obj; } else if (isDate(obj)) { return new Date(obj.getTime()); } else if (isRegExp(obj)) { return new RegExp(obj); } else if (isNode(obj)) { return obj.cloneNode(deep); } else if (isError(obj)) { return new obj.constructor(obj.message); } var type = {}; if (isArray(obj)) { type = []; } if (isBoolean(deep) && deep) { return extend(true, false, type, obj); } return extend(false, false, type, obj); } exports.clone = clone; function isError(obj) { return __objToString.call(obj) === __errorClass; } exports.isError = isError; function isObject(obj) { return obj != null && typeof obj === 'object'; } exports.isObject = isObject; function isWindow(obj) { return !!(obj && obj.document && obj.setInterval); } exports.isWindow = isWindow; function isDocument(obj) { return !!(obj && obj.nodeType === Node.DOCUMENT_NODE); } exports.isDocument = isDocument; function isNode(obj) { return !!(obj && typeof obj.nodeType === 'number'); } exports.isNode = isNode; function isDocumentFragment(obj) { return !!(obj && obj.nodeType === Node.DOCUMENT_FRAGMENT_NODE); } exports.isDocumentFragment = isDocumentFragment; function isFile(obj) { return isObject(obj) && __objToString.call(obj) === __fileClass; } exports.isFile = isFile; function isString(obj) { return typeof obj === 'string' || isObject(obj) && __objToString.call(obj) === __stringClass; } exports.isString = isString; function isRegExp(obj) { return isObject(obj) && __objToString.call(obj) === __regexpClass; } exports.isRegExp = isRegExp; function isPromise(obj) { return isObject(obj) && (__objToString.call(obj) === __promiseClass || isFunction(obj.then)); } exports.isPromise = isPromise; function isEmpty(obj) { if (isNull(obj)) { return true; } if (isString(obj) || isArray(obj)) { return obj.length === 0; } if (!isObject(obj)) { return false; } return Object.keys(obj).length === 0; } exports.isEmpty = isEmpty; function isBoolean(obj) { return obj === true || obj === false || isObject(obj) && __objToString.call(obj) === __boolClass; } exports.isBoolean = isBoolean; function isNumber(obj) { return (typeof obj === 'number' || isObject(obj) && __objToString.call(obj) === __numberClass) && !isNaN(obj); } exports.isNumber = isNumber; function isFunction(obj) { return typeof obj === 'function'; } exports.isFunction = isFunction; function isNull(obj) { return obj === null || obj === undefined; } exports.isNull = isNull; function isUndefined(obj) { return obj === undefined; } exports.isUndefined = isUndefined; function isArray(obj) { if (__nativeIsArray) { return Array.isArray(obj); } return __objToString.call(obj) === __arrayClass; } exports.isArray = isArray; function isArrayLike(obj) { if (isNull(obj) || isWindow(obj) || isFunction(obj)) { return false; } return isString(obj) || obj.length >= 0; } exports.isArrayLike = isArrayLike; function isDate(obj) { return typeof obj === 'object' && __objToString.call(obj) === __dateClass; } exports.isDate = isDate; function forEach(iterator, obj, context) { if (isNull(obj) || !(isObject(obj) || isArrayLike(obj))) { return obj; } var i, key, length; if (isFunction(obj.forEach)) { return obj.forEach(iterator, context); } else if (isArrayLike(obj)) { for (i = 0, length = obj.length; i < length; ++i) { iterator.call(context, obj[i], i, obj); } } else { var keys = Object.keys(obj); length = keys.length; while (keys.length > 0) { key = keys.shift(); iterator.call(context, obj[key], key, obj); } } return obj; } exports.forEach = forEach;