UNPKG

typescript-strict-plugin

Version:

Typescript tools that help with migration to the strict mode

38 lines (37 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isFileStrict = void 0; const isFileStrictByPath_1 = require("./isFileStrictByPath"); const constants_1 = require("./constants"); const isFileExcludedByPath_1 = require("./isFileExcludedByPath"); const isFileExcludedByPattern_1 = require("./isFileExcludedByPattern"); // Common logic determining whether file is strict or not function isFileStrict({ filePath, config, projectPath, isCommentPresent, }) { var _a, _b, _c; if (isCommentPresent(constants_1.TS_STRICT_IGNORE_COMMENT, filePath)) { return false; } if (isCommentPresent(constants_1.TS_STRICT_COMMENT, filePath)) { return true; } const configExclude = (_a = config === null || config === void 0 ? void 0 : config.exclude) !== null && _a !== void 0 ? _a : []; const configExcludePattern = (_b = config === null || config === void 0 ? void 0 : config.excludePattern) !== null && _b !== void 0 ? _b : []; if ((0, isFileExcludedByPath_1.isFileExcludedByPath)({ filePath, configExclude, projectPath, }) || (0, isFileExcludedByPattern_1.isFileExcludedByPattern)({ filePath, configExcludePattern, })) { return false; } const configPaths = (_c = config === null || config === void 0 ? void 0 : config.paths) !== null && _c !== void 0 ? _c : []; const fileStrictByPath = (0, isFileStrictByPath_1.isFileStrictByPath)({ filePath, configPaths, projectPath }); if (configPaths.length > 0 && !fileStrictByPath) { return false; } return true; } exports.isFileStrict = isFileStrict;