aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/configuration.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tslint/lib/configuration.js')
-rw-r--r--node_modules/tslint/lib/configuration.js55
1 files changed, 23 insertions, 32 deletions
diff --git a/node_modules/tslint/lib/configuration.js b/node_modules/tslint/lib/configuration.js
index 797534a3b..a6064f015 100644
--- a/node_modules/tslint/lib/configuration.js
+++ b/node_modules/tslint/lib/configuration.js
@@ -37,13 +37,6 @@ exports.EMPTY_CONFIG = {
rulesDirectory: [],
};
var BUILT_IN_CONFIG = /^tslint:(.*)$/;
-/**
- * Searches for a TSLint configuration and returns the data from the config.
- * @param configFile A path to a config file, this can be null if the location of a config is not known
- * @param inputFilePath A path containing the current file being linted. This is the starting location
- * of the search for a configuration.
- * @returns Load status for a TSLint configuration object
- */
function findConfiguration(configFile, inputFilePath) {
var configPath = findConfigurationPath(configFile, inputFilePath);
var loadResult = { path: configPath };
@@ -56,18 +49,8 @@ function findConfiguration(configFile, inputFilePath) {
}
}
exports.findConfiguration = findConfiguration;
-/**
- * Searches for a TSLint configuration and returns the path to it.
- * Could return undefined if not configuration is found.
- * @param suppliedConfigFilePath A path to an known config file supplied by a user. Pass null here if
- * the location of the config file is not known and you want to search for one.
- * @param inputFilePath A path to the current file being linted. This is the starting location
- * of the search for a configuration.
- * @returns An absolute path to a tslint.json file
- * or undefined if neither can be found.
- */
function findConfigurationPath(suppliedConfigFilePath, inputFilePath) {
- if (suppliedConfigFilePath != null) {
+ if (suppliedConfigFilePath != undefined) {
if (!fs.existsSync(suppliedConfigFilePath)) {
throw new error_1.FatalError("Could not find config file at: " + path.resolve(suppliedConfigFilePath));
}
@@ -92,13 +75,13 @@ function findConfigurationPath(suppliedConfigFilePath, inputFilePath) {
inputFilePath = path.dirname(inputFilePath);
}
// search for tslint.json from input file location
- var configFilePath = findup(exports.CONFIG_FILENAME, inputFilePath);
+ var configFilePath = findup(exports.CONFIG_FILENAME, path.resolve(inputFilePath));
if (configFilePath !== undefined) {
- return path.resolve(configFilePath);
+ return configFilePath;
}
// search for tslint.json in home directory
var homeDir = getHomeDir();
- if (homeDir != null) {
+ if (homeDir != undefined) {
configFilePath = path.join(homeDir, exports.CONFIG_FILENAME);
if (fs.existsSync(configFilePath)) {
return path.resolve(configFilePath);
@@ -151,7 +134,7 @@ function findup(filename, directory) {
*/
function loadConfigurationFromPath(configFilePath, originalFilePath) {
if (originalFilePath === void 0) { originalFilePath = configFilePath; }
- if (configFilePath == null) {
+ if (configFilePath == undefined) {
return exports.DEFAULT_CONFIG;
}
else {
@@ -192,7 +175,7 @@ exports.loadConfigurationFromPath = loadConfigurationFromPath;
*/
function resolveConfigurationPath(filePath, relativeTo) {
var matches = filePath.match(BUILT_IN_CONFIG);
- var isBuiltInConfig = matches != null && matches.length > 0;
+ var isBuiltInConfig = matches !== null && matches.length > 0;
if (isBuiltInConfig) {
var configName = matches[1];
try {
@@ -241,7 +224,7 @@ function extendConfigurationFile(targetConfig, nextConfigSource) {
});
next.forEach(function (options, ruleName) {
var combinedRule = combined.get(ruleName);
- if (combinedRule != null) {
+ if (combinedRule !== undefined) {
combined.set(ruleName, combineProperties(combinedRule, options));
}
else {
@@ -271,7 +254,7 @@ function getHomeDir() {
];
for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) {
var homePath = paths_1[_i];
- if (homePath != null && fs.existsSync(homePath)) {
+ if (homePath !== undefined && fs.existsSync(homePath)) {
return homePath;
}
}
@@ -279,7 +262,7 @@ function getHomeDir() {
}
// returns the absolute path (contrary to what the name implies)
function getRelativePath(directory, relativeTo) {
- if (directory != null) {
+ if (directory != undefined) {
var basePath = relativeTo !== undefined ? relativeTo : process.cwd();
return path.resolve(basePath, directory);
}
@@ -311,7 +294,7 @@ function getRulesDirectories(directories, relativeTo) {
}
}
var absolutePath = getRelativePath(dir, relativeTo);
- if (absolutePath != null) {
+ if (absolutePath !== undefined) {
if (!fs.existsSync(absolutePath)) {
throw new error_1.FatalError("Could not find custom rule directory: " + dir);
}
@@ -344,7 +327,7 @@ function parseRuleOptions(ruleConfigValue, rawDefaultRuleSeverity) {
}
}
var ruleSeverity = defaultRuleSeverity;
- if (ruleConfigValue == null) {
+ if (ruleConfigValue == undefined) {
ruleArguments = [];
ruleSeverity = "off";
}
@@ -382,7 +365,7 @@ function parseRuleOptions(ruleConfigValue, rawDefaultRuleSeverity) {
ruleSeverity = defaultRuleSeverity;
}
}
- if (ruleConfigValue.options != null) {
+ if (ruleConfigValue.options != undefined) {
ruleArguments = utils_1.arrayify(ruleConfigValue.options);
}
}
@@ -401,7 +384,7 @@ function parseConfigFile(configFile, configFileDir) {
return {
extends: utils_1.arrayify(configFile.extends),
jsRules: parseRules(configFile.jsRules),
- linterOptions: configFile.linterOptions !== undefined ? configFile.linterOptions : {},
+ linterOptions: parseLinterOptions(configFile.linterOptions),
rules: parseRules(configFile.rules),
rulesDirectory: getRulesDirectories(configFile.rulesDirectory, configFileDir),
};
@@ -416,6 +399,14 @@ function parseConfigFile(configFile, configFileDir) {
}
return map;
}
+ function parseLinterOptions(raw) {
+ if (raw === undefined || raw.exclude === undefined) {
+ return {};
+ }
+ return {
+ exclude: utils_1.arrayify(raw.exclude).map(function (pattern) { return configFileDir === undefined ? path.resolve(pattern) : path.resolve(configFileDir, pattern); }),
+ };
+ }
}
exports.parseConfigFile = parseConfigFile;
/**
@@ -427,9 +418,9 @@ function convertRuleOptions(ruleConfiguration) {
var ruleArguments = _a.ruleArguments, ruleSeverity = _a.ruleSeverity;
var options = {
disabledIntervals: [],
- ruleArguments: ruleArguments != null ? ruleArguments : [],
+ ruleArguments: ruleArguments != undefined ? ruleArguments : [],
ruleName: ruleName,
- ruleSeverity: ruleSeverity != null ? ruleSeverity : "error",
+ ruleSeverity: ruleSeverity != undefined ? ruleSeverity : "error",
};
output.push(options);
});