UNPKG

1.46 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const path = require("path");
4const minimatch = require("minimatch");
5const FsHelper_1 = require("./FsHelper");
6function loadLinterConfig(configFile) {
7 // tslint:disable-next-line:no-implicit-dependencies
8 const tslint = require('tslint');
9 return tslint.Configuration.loadConfigurationFromPath(configFile);
10}
11exports.loadLinterConfig = loadLinterConfig;
12function makeGetLinterConfig(linterConfigs, linterExclusions, context) {
13 const getLinterConfig = (file) => {
14 const dirname = path.dirname(file);
15 if (dirname in linterConfigs) {
16 return linterConfigs[dirname];
17 }
18 if (FsHelper_1.fileExistsSync(path.join(dirname, 'tslint.json'))) {
19 const config = loadLinterConfig(path.join(dirname, 'tslint.json'));
20 if (config.linterOptions && config.linterOptions.exclude) {
21 linterExclusions.concat(config.linterOptions.exclude.map(pattern => new minimatch.Minimatch(path.resolve(pattern))));
22 }
23 linterConfigs[dirname] = config;
24 }
25 else {
26 if (dirname !== context && dirname !== file) {
27 linterConfigs[dirname] = getLinterConfig(dirname);
28 }
29 }
30 return linterConfigs[dirname];
31 };
32 return getLinterConfig;
33}
34exports.makeGetLinterConfig = makeGetLinterConfig;
35//# sourceMappingURL=linterConfigHelpers.js.map
\No newline at end of file