1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const path = require("path");
|
4 | const minimatch = require("minimatch");
|
5 | const FsHelper_1 = require("./FsHelper");
|
6 | function loadLinterConfig(configFile) {
|
7 |
|
8 | const tslint = require('tslint');
|
9 | return tslint.Configuration.loadConfigurationFromPath(configFile);
|
10 | }
|
11 | exports.loadLinterConfig = loadLinterConfig;
|
12 | function 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 | }
|
34 | exports.makeGetLinterConfig = makeGetLinterConfig;
|
35 |
|
\ | No newline at end of file |