Comparing version 4.5.1 to 5.0.0-dev.0
Change Log | ||
=== | ||
v5.0.0-dev.0 | ||
--- | ||
- Include the current (incomplete) set of changes for v5.0.0 | ||
v5.0.0 | ||
--- | ||
- **BREAKING CHANGES** | ||
- The severity level of rules is now configurable and defaults to severity "error" | ||
- The following formatters have changed their outputs: | ||
- msbuildFormatter - default was "warning"; it is now "error" | ||
- pmdFormatter - default was priority 1; it is now "error" (priority 3). If set to "warning", it will output priority 4 | ||
- [enhancement] Enable WARN with new config file format (#629, #345) | ||
- Valid values for `severity`: "error|warn|warning|none|off" | ||
- Old style: | ||
```json | ||
{ | ||
"extends": "tslint:latest", | ||
"rules": { | ||
"callable-types": true | ||
} | ||
} | ||
``` | ||
- New style, with `interface-name` generating warnings, and passing options to `max-line-length`: | ||
```json | ||
{ | ||
"extends": "tslint:latest", | ||
"rules": { | ||
"callable-types": true, | ||
"interface-name": { | ||
"severity": "warn" | ||
}, | ||
"max-line-length": { | ||
"options": 140, | ||
"severity": "warning" | ||
} | ||
} | ||
} | ||
``` | ||
v4.5.1-dev.0 | ||
--- | ||
- Include latest v4.5.1 changes | ||
v4.5.1 | ||
@@ -120,2 +169,7 @@ --- | ||
v4.3.0-dev.0 | ||
--- | ||
* Include latest v4.3.1 changes | ||
v4.3.1 | ||
@@ -122,0 +176,0 @@ --- |
@@ -20,3 +20,5 @@ /** | ||
"no-angle-bracket-type-assertion": boolean; | ||
"only-arrow-functions": (string | boolean)[]; | ||
"only-arrow-functions": { | ||
options: string[]; | ||
}; | ||
"prefer-const": boolean; | ||
@@ -28,9 +30,11 @@ "callable-types": boolean; | ||
"import-spacing": boolean; | ||
"space-before-function-paren": (boolean | { | ||
"anonymous": string; | ||
"asyncArrow": string; | ||
"constructor": string; | ||
"method": string; | ||
"named": string; | ||
})[]; | ||
"space-before-function-paren": { | ||
options: { | ||
"anonymous": string; | ||
"asyncArrow": string; | ||
"constructor": string; | ||
"method": string; | ||
"named": string; | ||
}; | ||
}; | ||
"typeof-compare": boolean; | ||
@@ -41,3 +45,5 @@ "unified-signatures": boolean; | ||
"no-misused-new": boolean; | ||
"ban-types": (boolean | string[])[]; | ||
"ban-types": { | ||
options: string[][]; | ||
}; | ||
"no-duplicate-super": boolean; | ||
@@ -44,0 +50,0 @@ }; |
@@ -26,7 +26,9 @@ /** | ||
// added in v4.1 | ||
"only-arrow-functions": [true, | ||
"allow-declarations", | ||
// the following option was added in 4.1 | ||
"allow-named-functions", | ||
], | ||
"only-arrow-functions": { | ||
options: [ | ||
"allow-declarations", | ||
// the following option was added in 4.1 | ||
"allow-named-functions", | ||
], | ||
}, | ||
"prefer-const": true, | ||
@@ -40,3 +42,4 @@ // added in v4.2 | ||
"import-spacing": true, | ||
"space-before-function-paren": [true, { | ||
"space-before-function-paren": { | ||
options: { | ||
"anonymous": "never", | ||
@@ -47,3 +50,4 @@ "asyncArrow": "always", | ||
"named": "never", | ||
}], | ||
}, | ||
}, | ||
"typeof-compare": true, | ||
@@ -56,11 +60,12 @@ "unified-signatures": true, | ||
// added in v4.5 | ||
"ban-types": [ | ||
true, | ||
["Object", "Avoid using the `Object` type. Did you mean `object`?"], | ||
["Function", "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."], | ||
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"], | ||
["Number", "Avoid using the `Number` type. Did you mean `number`?"], | ||
["String", "Avoid using the `String` type. Did you mean `string`?"], | ||
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"], | ||
], | ||
"ban-types": { | ||
options: [ | ||
["Object", "Avoid using the `Object` type. Did you mean `object`?"], | ||
["Function", "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."], | ||
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"], | ||
["Number", "Avoid using the `Number` type. Did you mean `number`?"], | ||
["String", "Avoid using the `String` type. Did you mean `string`?"], | ||
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"], | ||
], | ||
}, | ||
"no-duplicate-super": true, | ||
@@ -67,0 +72,0 @@ }; |
@@ -19,7 +19,13 @@ /** | ||
"adjacent-overload-signatures": boolean; | ||
"align": (string | boolean)[]; | ||
"array-type": (string | boolean)[]; | ||
"align": { | ||
options: string[]; | ||
}; | ||
"array-type": { | ||
options: string[]; | ||
}; | ||
"arrow-parens": boolean; | ||
"class-name": boolean; | ||
"comment-format": (string | boolean)[]; | ||
"comment-format": { | ||
options: string[]; | ||
}; | ||
"curly": boolean; | ||
@@ -29,12 +35,22 @@ "cyclomatic-complexity": boolean; | ||
"forin": boolean; | ||
"indent": (string | boolean)[]; | ||
"interface-name": (string | boolean)[]; | ||
"indent": { | ||
options: string[]; | ||
}; | ||
"interface-name": { | ||
options: string[]; | ||
}; | ||
"jsdoc-format": boolean; | ||
"label-position": boolean; | ||
"max-classes-per-file": (number | boolean)[]; | ||
"max-line-length": (number | boolean)[]; | ||
"max-classes-per-file": { | ||
options: number[]; | ||
}; | ||
"max-line-length": { | ||
options: number[]; | ||
}; | ||
"member-access": boolean; | ||
"member-ordering": (boolean | { | ||
"order": string; | ||
})[]; | ||
"member-ordering": { | ||
options: { | ||
order: string; | ||
}; | ||
}; | ||
"new-parens": boolean; | ||
@@ -46,3 +62,5 @@ "no-any": boolean; | ||
"no-consecutive-blank-lines": boolean; | ||
"no-console": (string | boolean)[]; | ||
"no-console": { | ||
options: string[]; | ||
}; | ||
"no-construct": boolean; | ||
@@ -66,36 +84,62 @@ "no-debugger": boolean; | ||
"no-var-requires": boolean; | ||
"object-literal-key-quotes": (string | boolean)[]; | ||
"object-literal-key-quotes": { | ||
options: string[]; | ||
}; | ||
"object-literal-shorthand": boolean; | ||
"object-literal-sort-keys": boolean; | ||
"one-line": (string | boolean)[]; | ||
"one-variable-per-declaration": (string | boolean)[]; | ||
"only-arrow-functions": (string | boolean)[]; | ||
"ordered-imports": (boolean | { | ||
"import-sources-order": string; | ||
"named-imports-order": string; | ||
})[]; | ||
"one-line": { | ||
options: string[]; | ||
}; | ||
"one-variable-per-declaration": { | ||
options: string[]; | ||
}; | ||
"only-arrow-functions": { | ||
options: string[]; | ||
}; | ||
"ordered-imports": { | ||
options: { | ||
"import-sources-order": string; | ||
"named-imports-order": string; | ||
}; | ||
}; | ||
"prefer-for-of": boolean; | ||
"quotemark": (string | boolean)[]; | ||
"quotemark": { | ||
options: string[]; | ||
}; | ||
"radix": boolean; | ||
"semicolon": (string | boolean)[]; | ||
"semicolon": { | ||
options: string[]; | ||
}; | ||
"switch-default": boolean; | ||
"trailing-comma": (boolean | { | ||
"multiline": string; | ||
"singleline": string; | ||
})[]; | ||
"triple-equals": (string | boolean)[]; | ||
"trailing-comma": { | ||
options: { | ||
multiline: string; | ||
singleline: string; | ||
}; | ||
}; | ||
"triple-equals": { | ||
options: string[]; | ||
}; | ||
"typedef": boolean; | ||
"typedef-whitespace": (boolean | { | ||
"call-signature": string; | ||
"index-signature": string; | ||
"parameter": string; | ||
"property-declaration": string; | ||
"variable-declaration": string; | ||
})[]; | ||
"typedef-whitespace": { | ||
options: { | ||
"call-signature": string; | ||
"index-signature": string; | ||
"parameter": string; | ||
"property-declaration": string; | ||
"variable-declaration": string; | ||
}[]; | ||
}; | ||
"use-isnan": boolean; | ||
"variable-name": (string | boolean)[]; | ||
"whitespace": (string | boolean)[]; | ||
"variable-name": { | ||
options: string[]; | ||
}; | ||
"whitespace": { | ||
options: string[]; | ||
}; | ||
}; | ||
export declare const jsRules: { | ||
"align": (string | boolean)[]; | ||
"align": { | ||
options: string[]; | ||
}; | ||
"class-name": boolean; | ||
@@ -105,6 +149,10 @@ "curly": boolean; | ||
"forin": boolean; | ||
"indent": (string | boolean)[]; | ||
"indent": { | ||
options: string[]; | ||
}; | ||
"jsdoc-format": boolean; | ||
"label-position": boolean; | ||
"max-line-length": (number | boolean)[]; | ||
"max-line-length": { | ||
options: number[]; | ||
}; | ||
"new-parens": boolean; | ||
@@ -115,3 +163,5 @@ "no-arg": boolean; | ||
"no-consecutive-blank-lines": boolean; | ||
"no-console": (string | boolean)[]; | ||
"no-console": { | ||
options: string[]; | ||
}; | ||
"no-construct": boolean; | ||
@@ -131,16 +181,32 @@ "no-debugger": boolean; | ||
"object-literal-sort-keys": boolean; | ||
"one-line": (string | boolean)[]; | ||
"one-variable-per-declaration": (string | boolean)[]; | ||
"quotemark": (string | boolean)[]; | ||
"one-line": { | ||
options: string[]; | ||
}; | ||
"one-variable-per-declaration": { | ||
options: string[]; | ||
}; | ||
"quotemark": { | ||
options: string[]; | ||
}; | ||
"radix": boolean; | ||
"semicolon": (string | boolean)[]; | ||
"semicolon": { | ||
options: string[]; | ||
}; | ||
"switch-default": boolean; | ||
"trailing-comma": (boolean | { | ||
"multiline": string; | ||
"singleline": string; | ||
})[]; | ||
"triple-equals": (string | boolean)[]; | ||
"trailing-comma": { | ||
options: { | ||
multiline: string; | ||
singleline: string; | ||
}; | ||
}; | ||
"triple-equals": { | ||
options: string[]; | ||
}; | ||
"use-isnan": boolean; | ||
"variable-name": (string | boolean)[]; | ||
"whitespace": (string | boolean)[]; | ||
"variable-name": { | ||
options: string[]; | ||
}; | ||
"whitespace": { | ||
options: string[]; | ||
}; | ||
}; |
@@ -19,15 +19,18 @@ /** | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* tslint:disable:object-literal-key-quotes */ | ||
exports.rules = { | ||
"adjacent-overload-signatures": true, | ||
"align": [true, | ||
"parameters", | ||
"statements", | ||
], | ||
"array-type": [true, "array-simple"], | ||
"align": { | ||
options: [ | ||
"parameters", | ||
"statements", | ||
], | ||
}, | ||
"array-type": { | ||
options: ["array-simple"], | ||
}, | ||
"arrow-parens": true, | ||
"class-name": true, | ||
"comment-format": [true, | ||
"check-space", | ||
], | ||
"comment-format": { | ||
options: ["check-space"], | ||
}, | ||
"curly": true, | ||
@@ -37,12 +40,22 @@ "cyclomatic-complexity": false, | ||
"forin": true, | ||
"indent": [true, "spaces"], | ||
"interface-name": [true, "always-prefix"], | ||
"indent": { | ||
options: ["spaces"], | ||
}, | ||
"interface-name": { | ||
options: ["always-prefix"], | ||
}, | ||
"jsdoc-format": true, | ||
"label-position": true, | ||
"max-classes-per-file": [true, 1], | ||
"max-line-length": [true, 120], | ||
"max-classes-per-file": { | ||
options: [1], | ||
}, | ||
"max-line-length": { | ||
options: [120], | ||
}, | ||
"member-access": true, | ||
"member-ordering": [true, { | ||
"order": "statics-first", | ||
}], | ||
"member-ordering": { | ||
options: { | ||
order: "statics-first", | ||
}, | ||
}, | ||
"new-parens": true, | ||
@@ -54,10 +67,12 @@ "no-any": false, | ||
"no-consecutive-blank-lines": true, | ||
"no-console": [true, | ||
"debug", | ||
"info", | ||
"log", | ||
"time", | ||
"timeEnd", | ||
"trace", | ||
], | ||
"no-console": { | ||
options: [ | ||
"debug", | ||
"info", | ||
"log", | ||
"time", | ||
"timeEnd", | ||
"trace", | ||
], | ||
}, | ||
"no-construct": true, | ||
@@ -82,64 +97,91 @@ "no-debugger": true, | ||
"no-var-requires": true, | ||
"object-literal-key-quotes": [true, "consistent-as-needed"], | ||
"object-literal-key-quotes": { | ||
options: ["consistent-as-needed"], | ||
}, | ||
"object-literal-shorthand": true, | ||
"object-literal-sort-keys": true, | ||
"one-line": [true, | ||
"check-catch", | ||
"check-else", | ||
"check-finally", | ||
"check-open-brace", | ||
"check-whitespace", | ||
], | ||
"one-variable-per-declaration": [true, | ||
"ignore-for-loop", | ||
], | ||
"only-arrow-functions": [true, "allow-declarations"], | ||
"ordered-imports": [true, { | ||
"one-line": { | ||
options: [ | ||
"check-catch", | ||
"check-else", | ||
"check-finally", | ||
"check-open-brace", | ||
"check-whitespace", | ||
], | ||
}, | ||
"one-variable-per-declaration": { | ||
options: ["ignore-for-loop"], | ||
}, | ||
"only-arrow-functions": { | ||
options: ["allow-declarations"], | ||
}, | ||
"ordered-imports": { | ||
options: { | ||
"import-sources-order": "case-insensitive", | ||
"named-imports-order": "case-insensitive", | ||
}], | ||
}, | ||
}, | ||
"prefer-for-of": true, | ||
"quotemark": [true, "double", "avoid-escape"], | ||
"quotemark": { | ||
options: [ | ||
"double", | ||
"avoid-escape", | ||
], | ||
}, | ||
"radix": true, | ||
"semicolon": [true, "always"], | ||
"semicolon": { | ||
options: ["always"], | ||
}, | ||
"switch-default": true, | ||
"trailing-comma": [true, { | ||
"multiline": "always", | ||
"singleline": "never", | ||
}], | ||
"triple-equals": [true, "allow-null-check"], | ||
"trailing-comma": { | ||
options: { | ||
multiline: "always", | ||
singleline: "never", | ||
}, | ||
}, | ||
"triple-equals": { | ||
options: ["allow-null-check"], | ||
}, | ||
"typedef": false, | ||
"typedef-whitespace": [true, { | ||
"call-signature": "nospace", | ||
"index-signature": "nospace", | ||
"parameter": "nospace", | ||
"property-declaration": "nospace", | ||
"variable-declaration": "nospace", | ||
}, { | ||
"call-signature": "onespace", | ||
"index-signature": "onespace", | ||
"parameter": "onespace", | ||
"property-declaration": "onespace", | ||
"variable-declaration": "onespace", | ||
}], | ||
"typedef-whitespace": { | ||
options: [{ | ||
"call-signature": "nospace", | ||
"index-signature": "nospace", | ||
"parameter": "nospace", | ||
"property-declaration": "nospace", | ||
"variable-declaration": "nospace", | ||
}, { | ||
"call-signature": "onespace", | ||
"index-signature": "onespace", | ||
"parameter": "onespace", | ||
"property-declaration": "onespace", | ||
"variable-declaration": "onespace", | ||
}], | ||
}, | ||
"use-isnan": true, | ||
"variable-name": [true, | ||
"ban-keywords", | ||
"check-format", | ||
"allow-pascal-case", | ||
], | ||
"whitespace": [true, | ||
"check-branch", | ||
"check-decl", | ||
"check-operator", | ||
"check-separator", | ||
"check-type", | ||
"check-typecast", | ||
], | ||
"variable-name": { | ||
options: [ | ||
"ban-keywords", | ||
"check-format", | ||
"allow-pascal-case", | ||
], | ||
}, | ||
"whitespace": { | ||
options: [ | ||
"check-branch", | ||
"check-decl", | ||
"check-operator", | ||
"check-separator", | ||
"check-type", | ||
"check-typecast", | ||
], | ||
}, | ||
}; | ||
exports.jsRules = { | ||
"align": [true, | ||
"parameters", | ||
"statements", | ||
], | ||
"align": { | ||
options: [ | ||
"parameters", | ||
"statements", | ||
], | ||
}, | ||
"class-name": true, | ||
@@ -149,6 +191,10 @@ "curly": true, | ||
"forin": true, | ||
"indent": [true, "spaces"], | ||
"indent": { | ||
options: ["spaces"], | ||
}, | ||
"jsdoc-format": true, | ||
"label-position": true, | ||
"max-line-length": [true, 120], | ||
"max-line-length": { | ||
options: [120], | ||
}, | ||
"new-parens": true, | ||
@@ -159,10 +205,12 @@ "no-arg": true, | ||
"no-consecutive-blank-lines": true, | ||
"no-console": [true, | ||
"debug", | ||
"info", | ||
"log", | ||
"time", | ||
"timeEnd", | ||
"trace", | ||
], | ||
"no-console": { | ||
options: [ | ||
"debug", | ||
"info", | ||
"log", | ||
"time", | ||
"timeEnd", | ||
"trace", | ||
], | ||
}, | ||
"no-construct": true, | ||
@@ -183,36 +231,52 @@ "no-debugger": true, | ||
"object-literal-sort-keys": true, | ||
"one-line": [true, | ||
"check-catch", | ||
"check-else", | ||
"check-finally", | ||
"check-open-brace", | ||
"check-whitespace", | ||
], | ||
"one-variable-per-declaration": [true, | ||
"ignore-for-loop", | ||
], | ||
"quotemark": [true, "double", "avoid-escape"], | ||
"one-line": { | ||
options: [ | ||
"check-catch", | ||
"check-else", | ||
"check-finally", | ||
"check-open-brace", | ||
"check-whitespace", | ||
], | ||
}, | ||
"one-variable-per-declaration": { | ||
options: ["ignore-for-loop"], | ||
}, | ||
"quotemark": { | ||
options: [ | ||
"double", | ||
"avoid-escape", | ||
], | ||
}, | ||
"radix": true, | ||
"semicolon": [true, "always"], | ||
"semicolon": { | ||
options: ["always"], | ||
}, | ||
"switch-default": true, | ||
"trailing-comma": [true, { | ||
"multiline": "always", | ||
"singleline": "never", | ||
}], | ||
"triple-equals": [true, "allow-null-check"], | ||
"trailing-comma": { | ||
options: { | ||
multiline: "always", | ||
singleline: "never", | ||
}, | ||
}, | ||
"triple-equals": { | ||
options: ["allow-null-check"], | ||
}, | ||
"use-isnan": true, | ||
"variable-name": [true, | ||
"ban-keywords", | ||
"check-format", | ||
"allow-pascal-case", | ||
], | ||
"whitespace": [true, | ||
"check-branch", | ||
"check-decl", | ||
"check-operator", | ||
"check-separator", | ||
"check-type", | ||
"check-typecast", | ||
], | ||
"variable-name": { | ||
options: [ | ||
"ban-keywords", | ||
"check-format", | ||
"allow-pascal-case", | ||
], | ||
}, | ||
"whitespace": { | ||
options: [ | ||
"check-branch", | ||
"check-decl", | ||
"check-operator", | ||
"check-separator", | ||
"check-type", | ||
"check-typecast", | ||
], | ||
}, | ||
}; | ||
/* tslint:enable:object-literal-key-quotes */ |
@@ -0,9 +1,10 @@ | ||
import { IOptions } from "./language/rule/rule"; | ||
export interface IConfigurationFile { | ||
extends?: string | string[]; | ||
jsRules?: any; | ||
extends: string[]; | ||
jsRules: Map<string, Partial<IOptions>>; | ||
linterOptions?: { | ||
typeCheck?: boolean; | ||
}; | ||
rulesDirectory?: string | string[]; | ||
rules?: any; | ||
rulesDirectory: string[]; | ||
rules: Map<string, Partial<IOptions>>; | ||
} | ||
@@ -15,5 +16,4 @@ export interface IConfigurationLoadResult { | ||
export declare const CONFIG_FILENAME = "tslint.json"; | ||
export declare const DEFAULT_CONFIG: { | ||
"extends": string; | ||
}; | ||
export declare const DEFAULT_CONFIG: IConfigurationFile; | ||
export declare const EMPTY_CONFIG: IConfigurationFile; | ||
/** | ||
@@ -57,1 +57,12 @@ * Searches for a TSLint configuration and returns the data from the config. | ||
export declare function getRulesDirectories(directories?: string | string[], relativeTo?: string): string[]; | ||
/** | ||
* Parses a config file and normalizes legacy config settings | ||
* | ||
* @param configFile The raw object read from the JSON of a config file | ||
* @param configFileDir The directory of the config file | ||
*/ | ||
export declare function parseConfigFile(configFile: any, configFileDir?: string): IConfigurationFile; | ||
/** | ||
* Fills in default values for `IOption` properties and outputs an array of `IOption` | ||
*/ | ||
export declare function convertRuleOptions(ruleConfiguration: Map<string, Partial<IOptions>>): IOptions[]; |
@@ -26,7 +26,14 @@ /** | ||
exports.CONFIG_FILENAME = "tslint.json"; | ||
/* tslint:disable:object-literal-key-quotes */ | ||
exports.DEFAULT_CONFIG = { | ||
"extends": "tslint:recommended", | ||
extends: ["tslint:recommended"], | ||
jsRules: new Map(), | ||
rules: new Map(), | ||
rulesDirectory: [], | ||
}; | ||
/* tslint:enable:object-literal-key-quotes */ | ||
exports.EMPTY_CONFIG = { | ||
extends: [], | ||
jsRules: new Map(), | ||
rules: new Map(), | ||
rulesDirectory: [], | ||
}; | ||
var BUILT_IN_CONFIG = /^tslint:(.*)$/; | ||
@@ -104,3 +111,3 @@ /** | ||
var resolvedConfigFilePath = resolveConfigurationPath(configFilePath); | ||
var configFile = void 0; | ||
var rawConfigFile = void 0; | ||
if (path.extname(resolvedConfigFilePath) === ".json") { | ||
@@ -110,17 +117,17 @@ var fileContent = utils_1.stripComments(fs.readFileSync(resolvedConfigFilePath) | ||
.replace(/^\uFEFF/, "")); | ||
configFile = JSON.parse(fileContent); | ||
rawConfigFile = JSON.parse(fileContent); | ||
} | ||
else { | ||
configFile = require(resolvedConfigFilePath); | ||
rawConfigFile = require(resolvedConfigFilePath); | ||
delete require.cache[resolvedConfigFilePath]; | ||
} | ||
var configFileDir_1 = path.dirname(resolvedConfigFilePath); | ||
configFile.rulesDirectory = getRulesDirectories(configFile.rulesDirectory, configFileDir_1); | ||
var configFile = parseConfigFile(rawConfigFile, configFileDir_1); | ||
// load configurations, in order, using their identifiers or relative paths | ||
// apply the current configuration last by placing it last in this array | ||
var configs = utils_1.arrayify(configFile.extends).map(function (name) { | ||
var configs = configFile.extends.map(function (name) { | ||
var nextConfigFilePath = resolveConfigurationPath(name, configFileDir_1); | ||
return loadConfigurationFromPath(nextConfigFilePath); | ||
}).concat([configFile]); | ||
return configs.reduce(extendConfigurationFile, {}); | ||
return configs.reduce(extendConfigurationFile, exports.EMPTY_CONFIG); | ||
} | ||
@@ -161,6 +168,2 @@ } | ||
function extendConfigurationFile(targetConfig, nextConfigSource) { | ||
var combinedConfig = {}; | ||
var configRulesDirectory = utils_1.arrayify(targetConfig.rulesDirectory); | ||
var nextConfigRulesDirectory = utils_1.arrayify(nextConfigSource.rulesDirectory); | ||
combinedConfig.rulesDirectory = configRulesDirectory.concat(nextConfigRulesDirectory); | ||
var combineProperties = function (targetProperty, nextProperty) { | ||
@@ -179,6 +182,27 @@ var combinedProperty = {}; | ||
}; | ||
combinedConfig.rules = combineProperties(targetConfig.rules, nextConfigSource.rules); | ||
combinedConfig.jsRules = combineProperties(targetConfig.jsRules, nextConfigSource.jsRules); | ||
combinedConfig.linterOptions = combineProperties(targetConfig.linterOptions, nextConfigSource.linterOptions); | ||
return combinedConfig; | ||
var combineMaps = function (target, next) { | ||
var combined = new Map(); | ||
target.forEach(function (options, ruleName) { | ||
combined.set(ruleName, options); | ||
}); | ||
next.forEach(function (options, ruleName) { | ||
var combinedRule = combined.get(ruleName); | ||
if (combinedRule != null) { | ||
combined.set(ruleName, combineProperties(combinedRule, options)); | ||
} | ||
else { | ||
combined.set(ruleName, options); | ||
} | ||
}); | ||
return combined; | ||
}; | ||
var combinedRulesDirs = targetConfig.rulesDirectory.concat(nextConfigSource.rulesDirectory); | ||
var dedupedRulesDirs = Array.from(new Set(combinedRulesDirs)); | ||
return { | ||
extends: [], | ||
jsRules: combineMaps(targetConfig.jsRules, nextConfigSource.jsRules), | ||
linterOptions: combineProperties(targetConfig.linterOptions, nextConfigSource.linterOptions), | ||
rules: combineMaps(targetConfig.rules, nextConfigSource.rules), | ||
rulesDirectory: dedupedRulesDirs, | ||
}; | ||
} | ||
@@ -230,1 +254,99 @@ exports.extendConfigurationFile = extendConfigurationFile; | ||
exports.getRulesDirectories = getRulesDirectories; | ||
/** | ||
* Parses the options of a single rule and upgrades legacy settings such as `true`, `[true, "option"]` | ||
* | ||
* @param ruleConfigValue The raw option setting of a rule | ||
*/ | ||
function parseRuleOptions(ruleConfigValue) { | ||
var ruleArguments; | ||
var ruleSeverity; | ||
if (ruleConfigValue == null) { | ||
ruleArguments = []; | ||
ruleSeverity = "off"; | ||
} | ||
else if (Array.isArray(ruleConfigValue) && ruleConfigValue.length > 0) { | ||
// old style: array | ||
ruleArguments = ruleConfigValue.slice(1); | ||
ruleSeverity = ruleConfigValue[0] === true ? "error" : "off"; | ||
} | ||
else if (typeof ruleConfigValue === "boolean") { | ||
// old style: boolean | ||
ruleArguments = []; | ||
ruleSeverity = ruleConfigValue === true ? "error" : "off"; | ||
} | ||
else if (ruleConfigValue.severity) { | ||
switch (ruleConfigValue.severity.toLowerCase()) { | ||
case "warn": | ||
case "warning": | ||
ruleSeverity = "warning"; | ||
break; | ||
case "error": | ||
ruleSeverity = "error"; | ||
break; | ||
default: | ||
ruleSeverity = "off"; | ||
} | ||
} | ||
else if (typeof ruleConfigValue === "object") { | ||
ruleSeverity = undefined; | ||
} | ||
else { | ||
ruleSeverity = "off"; | ||
} | ||
if (ruleConfigValue && ruleConfigValue.options) { | ||
ruleArguments = utils_1.arrayify(ruleConfigValue.options); | ||
} | ||
return { | ||
ruleArguments: ruleArguments, | ||
ruleSeverity: ruleSeverity, | ||
}; | ||
} | ||
/** | ||
* Parses a config file and normalizes legacy config settings | ||
* | ||
* @param configFile The raw object read from the JSON of a config file | ||
* @param configFileDir The directory of the config file | ||
*/ | ||
function parseConfigFile(configFile, configFileDir) { | ||
var rules = new Map(); | ||
var jsRules = new Map(); | ||
if (configFile.rules) { | ||
for (var ruleName in configFile.rules) { | ||
if (configFile.rules.hasOwnProperty(ruleName)) { | ||
rules.set(ruleName, parseRuleOptions(configFile.rules[ruleName])); | ||
} | ||
} | ||
} | ||
if (configFile.jsRules) { | ||
for (var ruleName in configFile.jsRules) { | ||
if (configFile.jsRules.hasOwnProperty(ruleName)) { | ||
jsRules.set(ruleName, parseRuleOptions(configFile.jsRules[ruleName])); | ||
} | ||
} | ||
} | ||
return { | ||
extends: utils_1.arrayify(configFile.extends), | ||
jsRules: jsRules, | ||
linterOptions: configFile.linterOptions || {}, | ||
rulesDirectory: getRulesDirectories(configFile.rulesDirectory, configFileDir), | ||
rules: rules, | ||
}; | ||
} | ||
exports.parseConfigFile = parseConfigFile; | ||
/** | ||
* Fills in default values for `IOption` properties and outputs an array of `IOption` | ||
*/ | ||
function convertRuleOptions(ruleConfiguration) { | ||
var output = []; | ||
ruleConfiguration.forEach(function (partialOptions, ruleName) { | ||
var options = { | ||
disabledIntervals: [], | ||
ruleArguments: partialOptions.ruleArguments || [], | ||
ruleName: ruleName, | ||
ruleSeverity: partialOptions.ruleSeverity || "error", | ||
}; | ||
output.push(options); | ||
}); | ||
return output; | ||
} | ||
exports.convertRuleOptions = convertRuleOptions; |
import * as ts from "typescript"; | ||
import { IOptions } from "./language/rule/rule"; | ||
import { IEnableDisablePosition } from "./ruleLoader"; | ||
@@ -7,8 +8,4 @@ export declare class EnableDisableRulesWalker { | ||
private enabledRules; | ||
constructor(sourceFile: ts.SourceFile, rules: { | ||
[name: string]: any; | ||
}); | ||
getEnableDisableRuleMap(): { | ||
[rulename: string]: IEnableDisablePosition[]; | ||
}; | ||
constructor(sourceFile: ts.SourceFile, ruleOptionsList: IOptions[]); | ||
getEnableDisableRuleMap(): Map<string, IEnableDisablePosition[]>; | ||
private getStartOfLinePosition(position, lineOffset?); | ||
@@ -15,0 +12,0 @@ private switchRuleState(ruleName, isEnabled, start, end?); |
@@ -21,18 +21,15 @@ /** | ||
var ts = require("typescript"); | ||
var abstractRule_1 = require("./language/rule/abstractRule"); | ||
var EnableDisableRulesWalker = (function () { | ||
function EnableDisableRulesWalker(sourceFile, rules) { | ||
function EnableDisableRulesWalker(sourceFile, ruleOptionsList) { | ||
this.sourceFile = sourceFile; | ||
this.enableDisableRuleMap = {}; | ||
this.enableDisableRuleMap = new Map(); | ||
this.enabledRules = []; | ||
if (rules) { | ||
for (var _i = 0, _a = Object.keys(rules); _i < _a.length; _i++) { | ||
var rule = _a[_i]; | ||
if (abstractRule_1.AbstractRule.isRuleEnabled(rules[rule])) { | ||
this.enabledRules.push(rule); | ||
this.enableDisableRuleMap[rule] = [{ | ||
isEnabled: true, | ||
position: 0, | ||
}]; | ||
} | ||
for (var _i = 0, ruleOptionsList_1 = ruleOptionsList; _i < ruleOptionsList_1.length; _i++) { | ||
var ruleOptions = ruleOptionsList_1[_i]; | ||
if (ruleOptions.ruleSeverity !== "off") { | ||
this.enabledRules.push(ruleOptions.ruleName); | ||
this.enableDisableRuleMap.set(ruleOptions.ruleName, [{ | ||
isEnabled: true, | ||
position: 0, | ||
}]); | ||
} | ||
@@ -63,3 +60,3 @@ } | ||
EnableDisableRulesWalker.prototype.switchRuleState = function (ruleName, isEnabled, start, end) { | ||
var ruleStateMap = this.enableDisableRuleMap[ruleName]; | ||
var ruleStateMap = this.enableDisableRuleMap.get(ruleName); | ||
if (ruleStateMap === undefined || | ||
@@ -66,0 +63,0 @@ isEnabled === ruleStateMap[ruleStateMap.length - 1].isEnabled // no need to add switch points if there is no change |
@@ -46,2 +46,3 @@ /** | ||
var failure = failuresSorted_1[_i]; | ||
var severity = failure.getRuleSeverity(); | ||
if (failure.getFileName() !== previousFilename) { | ||
@@ -56,3 +57,3 @@ if (previousFilename) { | ||
output += "column=\"" + (failure.getStartPosition().getLineAndCharacter().character + 1) + "\" "; | ||
output += "severity=\"warning\" "; | ||
output += "severity=\"" + severity + "\" "; | ||
output += "message=\"" + this.escapeXml(failure.getFailure()) + "\" "; | ||
@@ -59,0 +60,0 @@ // checkstyle parser wants "source" to have structure like <anything>dot<category>dot<type> |
@@ -44,3 +44,4 @@ /** | ||
var positionTuple = "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + ")"; | ||
return "" + fileName + positionTuple + ": warning " + camelizedRule + ": " + failureString; | ||
var severity = failure.getRuleSeverity(); | ||
return "" + fileName + positionTuple + ": " + severity + " " + camelizedRule + ": " + failureString; | ||
}); | ||
@@ -47,0 +48,0 @@ return outputLines.join("\n") + "\n"; |
@@ -48,6 +48,7 @@ /** | ||
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); | ||
var priority = failure.getRuleSeverity() === "warning" ? 4 : 3; | ||
output += "<file name=\"" + failure.getFileName(); | ||
output += "\"><violation begincolumn=\"" + (lineAndCharacter.character + 1); | ||
output += "\" beginline=\"" + (lineAndCharacter.line + 1); | ||
output += "\" priority=\"1\""; | ||
output += "\" priority=\"" + priority + "\""; | ||
output += " rule=\"" + failureString + "\"> </violation></file>"; | ||
@@ -65,3 +66,3 @@ } | ||
descriptionDetails: "Imitates the XML output from PMD. All errors have a priority of 1.", | ||
sample: (_a = ["\n <pmd version=\"tslint\">\n <file name=\"myFile.ts\">\n <violation begincolumn=\"14\" beginline=\"1\" priority=\"1\" rule=\"Missing semicolon\"></violation>\n </file>\n </pmd>"], _a.raw = ["\n <pmd version=\"tslint\">\n <file name=\"myFile.ts\">\n <violation begincolumn=\"14\" beginline=\"1\" priority=\"1\" rule=\"Missing semicolon\"></violation>\n </file>\n </pmd>"], Utils.dedent(_a)), | ||
sample: (_a = ["\n <pmd version=\"tslint\">\n <file name=\"myFile.ts\">\n <violation begincolumn=\"14\" beginline=\"1\" priority=\"3\" rule=\"Missing semicolon\"></violation>\n </file>\n </pmd>"], _a.raw = ["\n <pmd version=\"tslint\">\n <file name=\"myFile.ts\">\n <violation begincolumn=\"14\" beginline=\"1\" priority=\"3\" rule=\"Missing semicolon\"></violation>\n </file>\n </pmd>"], Utils.dedent(_a)), | ||
consumer: "machine", | ||
@@ -68,0 +69,0 @@ }; |
@@ -38,3 +38,3 @@ /** | ||
if (failures.length === 0 && (!fixes || fixes.length === 0)) { | ||
return ""; | ||
return "\n"; | ||
} | ||
@@ -58,3 +58,3 @@ var fixLines = []; | ||
var positionTuple = "[" + (lineAndCharacter.line + 1) + ", " + (lineAndCharacter.character + 1) + "]"; | ||
return "" + fileName + positionTuple + ": " + failureString; | ||
return failure.getRuleSeverity().toUpperCase() + ": " + fileName + positionTuple + ": " + failureString; | ||
}); | ||
@@ -69,5 +69,5 @@ return fixLines.concat(errorLines).join("\n") + "\n"; | ||
description: "The default formatter which outputs simple human-readable messages.", | ||
sample: "myFile.ts[1, 14]: Missing semicolon", | ||
sample: "ERROR: myFile.ts[1, 14]: Missing semicolon", | ||
consumer: "human", | ||
}; | ||
exports.Formatter = Formatter; |
@@ -23,2 +23,3 @@ /** | ||
format(failures: RuleFailure[]): string; | ||
private mapToMessages(failures); | ||
private pad(str, len); | ||
@@ -25,0 +26,0 @@ private getPositionMaxSize(failures); |
@@ -39,5 +39,13 @@ /** | ||
Formatter.prototype.format = function (failures) { | ||
if (typeof failures[0] === "undefined") { | ||
return "\n"; | ||
var outputLines = this.mapToMessages(failures); | ||
// Removes initial blank line | ||
if (outputLines[0] === "") { | ||
outputLines.shift(); | ||
} | ||
return outputLines.join("\n") + "\n"; | ||
}; | ||
Formatter.prototype.mapToMessages = function (failures) { | ||
if (!failures) { | ||
return []; | ||
} | ||
var outputLines = []; | ||
@@ -66,12 +74,13 @@ var positionMaxSize = this.getPositionMaxSize(failures); | ||
positionTuple = this.pad(positionTuple, positionMaxSize); | ||
positionTuple = colors.red(positionTuple); | ||
// Ouput | ||
if (failure.getRuleSeverity() === "warning") { | ||
positionTuple = colors.blue(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple); | ||
} | ||
else { | ||
positionTuple = colors.red(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple); | ||
} | ||
// Output | ||
var output = positionTuple + " " + ruleName + " " + failureString; | ||
outputLines.push(output); | ||
} | ||
// Removes initial blank line | ||
if (outputLines[0] === "") { | ||
outputLines.shift(); | ||
} | ||
return outputLines.join("\n") + "\n\n"; | ||
return outputLines; | ||
}; | ||
@@ -78,0 +87,0 @@ Formatter.prototype.pad = function (str, len) { |
@@ -23,2 +23,3 @@ /** | ||
format(failures: RuleFailure[]): string; | ||
private mapToMessages(failures); | ||
} |
@@ -37,3 +37,7 @@ /** | ||
Formatter.prototype.format = function (failures) { | ||
var outputLines = failures.map(function (failure) { | ||
return this.mapToMessages(failures) | ||
.join("\n") + "\n"; | ||
}; | ||
Formatter.prototype.mapToMessages = function (failures) { | ||
return failures.map(function (failure) { | ||
var fileName = failure.getFileName(); | ||
@@ -44,5 +48,4 @@ var failureString = failure.getFailure(); | ||
var positionTuple = "[" + (lineAndCharacter.line + 1) + ", " + (lineAndCharacter.character + 1) + "]"; | ||
return "(" + ruleName + ") " + fileName + positionTuple + ": " + failureString; | ||
return failure.getRuleSeverity().toUpperCase() + ": (" + ruleName + ") " + fileName + positionTuple + ": " + failureString; | ||
}); | ||
return outputLines.join("\n") + "\n"; | ||
}; | ||
@@ -56,5 +59,5 @@ return Formatter; | ||
descriptionDetails: "The output is the same as the prose formatter with the rule name included", | ||
sample: "(semicolon) myFile.ts[1, 14]: Missing semicolon", | ||
sample: "ERROR: (semicolon) myFile.ts[1, 14]: Missing semicolon", | ||
consumer: "human", | ||
}; | ||
exports.Formatter = Formatter; |
@@ -22,3 +22,3 @@ /** | ||
static metadata: IFormatterMetadata; | ||
format(failures: RuleFailure[]): string; | ||
format(failures: RuleFailure[], warnings?: RuleFailure[]): string; | ||
} |
@@ -37,4 +37,6 @@ /** | ||
/* tslint:enable:object-literal-sort-keys */ | ||
Formatter.prototype.format = function (failures) { | ||
var outputLines = failures.map(function (failure) { | ||
Formatter.prototype.format = function (failures, warnings) { | ||
if (warnings === void 0) { warnings = []; } | ||
var all = failures.concat(warnings); | ||
var outputLines = all.map(function (failure) { | ||
var fileName = failure.getFileName(); | ||
@@ -41,0 +43,0 @@ var failureString = failure.getFailure(); |
@@ -34,3 +34,4 @@ /** | ||
export interface LintResult { | ||
failureCount: number; | ||
errorCount: number; | ||
warningCount: number; | ||
failures: RuleFailure[]; | ||
@@ -37,0 +38,0 @@ fixes?: RuleFailure[]; |
@@ -44,6 +44,6 @@ /** | ||
* Formats linter results | ||
* @param {RuleFailure[]} failures Linter errors that were not fixed | ||
* @param {RuleFailure[]} fixes Fixed linter errors. Available when the `--fix` argument is used on the command line | ||
* @param {RuleFailure[]} failures Linter failures that were not fixed | ||
* @param {RuleFailure[]} fixes Fixed linter failures. Available when the `--fix` argument is used on the command line | ||
*/ | ||
format(failures: RuleFailure[], fixes?: RuleFailure[]): string; | ||
} |
@@ -19,11 +19,10 @@ /** | ||
import { IWalker, WalkContext } from "../walker"; | ||
import { IDisabledInterval, IOptions, IRule, IRuleMetadata, RuleFailure } from "./rule"; | ||
import { IOptions, IRule, IRuleMetadata, RuleFailure, RuleSeverity } from "./rule"; | ||
export declare abstract class AbstractRule implements IRule { | ||
readonly ruleName: string; | ||
private value; | ||
private disabledIntervals; | ||
private options; | ||
static metadata: IRuleMetadata; | ||
protected readonly ruleArguments: any[]; | ||
static isRuleEnabled(ruleConfigValue: any): boolean; | ||
constructor(ruleName: string, value: any, disabledIntervals: IDisabledInterval[]); | ||
protected readonly ruleSeverity: RuleSeverity; | ||
ruleName: string; | ||
constructor(options: IOptions); | ||
getOptions(): IOptions; | ||
@@ -30,0 +29,0 @@ abstract apply(sourceFile: ts.SourceFile, languageService: ts.LanguageService): RuleFailure[]; |
@@ -22,28 +22,10 @@ /** | ||
var AbstractRule = (function () { | ||
function AbstractRule(ruleName, value, disabledIntervals) { | ||
this.ruleName = ruleName; | ||
this.value = value; | ||
this.disabledIntervals = disabledIntervals; | ||
if (Array.isArray(value) && value.length > 1) { | ||
this.ruleArguments = value.slice(1); | ||
} | ||
else { | ||
this.ruleArguments = []; | ||
} | ||
function AbstractRule(options) { | ||
this.options = options; | ||
this.ruleName = options.ruleName; | ||
this.ruleArguments = options.ruleArguments; | ||
this.ruleSeverity = options.ruleSeverity; | ||
} | ||
AbstractRule.isRuleEnabled = function (ruleConfigValue) { | ||
if (typeof ruleConfigValue === "boolean") { | ||
return ruleConfigValue; | ||
} | ||
if (Array.isArray(ruleConfigValue) && ruleConfigValue.length > 0) { | ||
return ruleConfigValue[0]; | ||
} | ||
return false; | ||
}; | ||
AbstractRule.prototype.getOptions = function () { | ||
return { | ||
disabledIntervals: this.disabledIntervals, | ||
ruleArguments: this.ruleArguments, | ||
ruleName: this.ruleName, | ||
}; | ||
return this.options; | ||
}; | ||
@@ -55,3 +37,3 @@ AbstractRule.prototype.applyWithWalker = function (walker) { | ||
AbstractRule.prototype.isEnabled = function () { | ||
return AbstractRule.isRuleEnabled(this.value); | ||
return this.ruleSeverity !== "off"; | ||
}; | ||
@@ -67,3 +49,3 @@ AbstractRule.prototype.applyWithFunction = function (sourceFile, walkFn, options) { | ||
// don't add failures for a rule if the failure intersects an interval where that rule is disabled | ||
if (!utils_1.doesIntersect(failure, this_1.disabledIntervals) && !result.some(function (f) { return f.equals(failure); })) { | ||
if (!utils_1.doesIntersect(failure, this_1.options.disabledIntervals) && !result.some(function (f) { return f.equals(failure); })) { | ||
result.push(failure); | ||
@@ -70,0 +52,0 @@ } |
@@ -73,4 +73,6 @@ /** | ||
export declare type RuleType = "functionality" | "maintainability" | "style" | "typescript"; | ||
export declare type RuleSeverity = "warning" | "error" | "off"; | ||
export interface IOptions { | ||
ruleArguments: any[]; | ||
ruleSeverity: RuleSeverity; | ||
ruleName: string; | ||
@@ -94,2 +96,3 @@ disabledIntervals: IDisabledInterval[]; | ||
name: string; | ||
ruleSeverity: string; | ||
ruleName: string; | ||
@@ -146,2 +149,3 @@ startPosition: IRuleFailurePositionJson; | ||
private rawLines; | ||
private ruleSeverity; | ||
constructor(sourceFile: ts.SourceFile, start: number, end: number, failure: string, ruleName: string, fix?: Fix); | ||
@@ -156,2 +160,4 @@ getFileName(): string; | ||
getRawLines(): string; | ||
getRuleSeverity(): RuleSeverity; | ||
setRuleSeverity(value: RuleSeverity): void; | ||
toJson(): IRuleFailureJson; | ||
@@ -158,0 +164,0 @@ equals(ruleFailure: RuleFailure): boolean; |
@@ -148,2 +148,3 @@ /** | ||
this.rawLines = sourceFile.text; | ||
this.ruleSeverity = "error"; | ||
} | ||
@@ -174,2 +175,8 @@ RuleFailure.prototype.getFileName = function () { | ||
}; | ||
RuleFailure.prototype.getRuleSeverity = function () { | ||
return this.ruleSeverity; | ||
}; | ||
RuleFailure.prototype.setRuleSeverity = function (value) { | ||
this.ruleSeverity = value; | ||
}; | ||
RuleFailure.prototype.toJson = function () { | ||
@@ -182,2 +189,3 @@ return { | ||
ruleName: this.ruleName, | ||
ruleSeverity: this.ruleSeverity.toUpperCase(), | ||
startPosition: this.startPosition.toJson(), | ||
@@ -184,0 +192,0 @@ }; |
@@ -113,6 +113,20 @@ /** | ||
this.failures = this.failures.concat(fileFailures); | ||
// add rule severity to failures | ||
var ruleSeverityMap = new Map(enabledRules.map(function (rule) { | ||
return [rule.getOptions().ruleName, rule.getOptions().ruleSeverity]; | ||
})); | ||
for (var _b = 0, _c = this.failures; _b < _c.length; _b++) { | ||
var failure = _c[_b]; | ||
var severity = ruleSeverityMap.get(failure.getRuleName()); | ||
if (severity === undefined) { | ||
throw new Error("Severity for rule '" + failure.getRuleName() + " not found"); | ||
} | ||
failure.setRuleSeverity(severity); | ||
} | ||
}; | ||
Linter.prototype.getResult = function () { | ||
var formatter; | ||
var formattersDirectory = configuration_1.getRelativePath(this.options.formattersDirectory); | ||
var formattersDirectory = this.options.formattersDirectory !== undefined | ||
? configuration_1.getRelativePath(this.options.formattersDirectory) | ||
: undefined; | ||
var formatterName = this.options.formatter || "prose"; | ||
@@ -127,4 +141,5 @@ var Formatter = formatterLoader_1.findFormatter(formatterName, formattersDirectory); | ||
var output = formatter.format(this.failures, this.fixes); | ||
var errorCount = this.failures.filter(function (failure) { return failure.getRuleSeverity() === "error"; }).length; | ||
return { | ||
failureCount: this.failures.length, | ||
errorCount: errorCount, | ||
failures: this.failures, | ||
@@ -134,2 +149,3 @@ fixes: this.fixes, | ||
output: output, | ||
warningCount: this.failures.length - errorCount, | ||
}; | ||
@@ -166,8 +182,8 @@ }; | ||
if (configuration === void 0) { configuration = configuration_1.DEFAULT_CONFIG; } | ||
var configurationRules = isJs ? configuration.jsRules : configuration.rules; | ||
var ruleOptionsList = configuration_1.convertRuleOptions(isJs ? configuration.jsRules : configuration.rules); | ||
// walk the code first to find all the intervals where rules are disabled | ||
var enableDisableRuleMap = new enableDisableRules_1.EnableDisableRulesWalker(sourceFile, configurationRules).getEnableDisableRuleMap(); | ||
var enableDisableRuleMap = new enableDisableRules_1.EnableDisableRulesWalker(sourceFile, ruleOptionsList).getEnableDisableRuleMap(); | ||
var rulesDirectories = utils_1.arrayify(this.options.rulesDirectory) | ||
.concat(utils_1.arrayify(configuration.rulesDirectory)); | ||
var configuredRules = ruleLoader_1.loadRules(configurationRules, enableDisableRuleMap, rulesDirectories, isJs); | ||
var configuredRules = ruleLoader_1.loadRules(ruleOptionsList, enableDisableRuleMap, rulesDirectories, isJs); | ||
return configuredRules.filter(function (r) { return r.isEnabled(); }); | ||
@@ -200,3 +216,3 @@ }; | ||
}()); | ||
Linter.VERSION = "4.5.1"; | ||
Linter.VERSION = "5.0.0-dev.0"; | ||
Linter.findConfiguration = configuration_1.findConfiguration; | ||
@@ -203,0 +219,0 @@ Linter.findConfigurationPath = configuration_1.findConfigurationPath; |
import { AbstractRule } from "./language/rule/abstractRule"; | ||
import { IRule } from "./language/rule/rule"; | ||
import { IOptions, IRule } from "./language/rule/rule"; | ||
export interface IEnableDisablePosition { | ||
@@ -7,7 +7,3 @@ isEnabled: boolean; | ||
} | ||
export declare function loadRules(ruleConfiguration: { | ||
[name: string]: any; | ||
}, enableDisableRuleMap: { | ||
[rulename: string]: IEnableDisablePosition[]; | ||
}, rulesDirectories?: string | string[], isJs?: boolean): IRule[]; | ||
export declare function loadRules(ruleOptionsList: IOptions[], enableDisableRuleMap: Map<string, IEnableDisablePosition[]>, rulesDirectories?: string | string[], isJs?: boolean): IRule[]; | ||
export declare function findRule(name: string, rulesDirectories?: string | string[]): typeof AbstractRule | null; |
@@ -23,3 +23,2 @@ /** | ||
var error_1 = require("./error"); | ||
var abstractRule_1 = require("./language/rule/abstractRule"); | ||
var utils_1 = require("./utils"); | ||
@@ -29,26 +28,26 @@ var moduleDirectory = path.dirname(module.filename); | ||
var cachedRules = new Map(); // null indicates that the rule was not found | ||
function loadRules(ruleConfiguration, enableDisableRuleMap, rulesDirectories, isJs) { | ||
function loadRules(ruleOptionsList, enableDisableRuleMap, rulesDirectories, isJs) { | ||
var rules = []; | ||
var notFoundRules = []; | ||
var notAllowedInJsRules = []; | ||
for (var ruleName in ruleConfiguration) { | ||
if (ruleConfiguration.hasOwnProperty(ruleName)) { | ||
var ruleValue = ruleConfiguration[ruleName]; | ||
if (abstractRule_1.AbstractRule.isRuleEnabled(ruleValue) || enableDisableRuleMap.hasOwnProperty(ruleName)) { | ||
var Rule = findRule(ruleName, rulesDirectories); | ||
if (Rule == null) { | ||
notFoundRules.push(ruleName); | ||
for (var _i = 0, ruleOptionsList_1 = ruleOptionsList; _i < ruleOptionsList_1.length; _i++) { | ||
var ruleOptions = ruleOptionsList_1[_i]; | ||
var ruleName = ruleOptions.ruleName; | ||
var enableDisableRules = enableDisableRuleMap.get(ruleName); | ||
if (ruleOptions.ruleSeverity !== "off" || enableDisableRuleMap) { | ||
var Rule = findRule(ruleName, rulesDirectories); | ||
if (Rule == null) { | ||
notFoundRules.push(ruleName); | ||
} | ||
else { | ||
if (isJs && Rule.metadata && Rule.metadata.typescriptOnly) { | ||
notAllowedInJsRules.push(ruleName); | ||
} | ||
else { | ||
if (isJs && Rule.metadata && Rule.metadata.typescriptOnly != null && Rule.metadata.typescriptOnly) { | ||
notAllowedInJsRules.push(ruleName); | ||
var ruleSpecificList = enableDisableRules || []; | ||
ruleOptions.disabledIntervals = buildDisabledIntervalsFromSwitches(ruleSpecificList); | ||
rules.push(new Rule(ruleOptions)); | ||
if (Rule.metadata && Rule.metadata.deprecationMessage) { | ||
error_1.showWarningOnce(Rule.metadata.ruleName + " is deprecated. " + Rule.metadata.deprecationMessage); | ||
} | ||
else { | ||
var ruleSpecificList = (ruleName in enableDisableRuleMap ? enableDisableRuleMap[ruleName] : []); | ||
var disabledIntervals = buildDisabledIntervalsFromSwitches(ruleSpecificList); | ||
rules.push(new Rule(ruleName, ruleValue, disabledIntervals)); | ||
if (Rule.metadata && Rule.metadata.deprecationMessage) { | ||
error_1.showWarningOnce(Rule.metadata.ruleName + " is deprecated. " + Rule.metadata.deprecationMessage); | ||
} | ||
} | ||
} | ||
@@ -55,0 +54,0 @@ } |
@@ -117,3 +117,3 @@ /** | ||
description: "Enforces documentation for important items be filled out.", | ||
optionsDescription: (_c = ["\n `true` to enable for [\"", "\", \"", "\", \"", "\", \"", "\"],\n or an array with each item in one of two formats:\n\n * `string` to enable for that type\n * `object` keying types to when their documentation is required:\n * `\"", "\"` and `\"", " may specify:\n * `\"", "\":\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", ":\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * All other types may specify `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n\n Types that may be enabled are:\n\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`"], _c.raw = ["\n \\`true\\` to enable for [\"", "\", \"", "\", \"", "\", \"", "\"],\n or an array with each item in one of two formats:\n\n * \\`string\\` to enable for that type\n * \\`object\\` keying types to when their documentation is required:\n * \\`\"", "\"\\` and \\`\"", " may specify:\n * \\`\"", "\":\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", ":\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * All other types may specify \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n\n Types that may be enabled are:\n\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`"], Lint.Utils.dedent(_c, exports.ARGUMENT_CLASSES, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_METHODS, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_METHODS, exports.ARGUMENT_PROPERTIES, exports.DESCRIPTOR_PRIVACIES, exports.ALL, exports.PRIVACY_PRIVATE, exports.PRIVACY_PROTECTED, exports.PRIVACY_PUBLIC, exports.DESCRIPTOR_LOCATIONS, exports.ALL, exports.LOCATION_INSTANCE, exports.LOCATION_STATIC, exports.DESCRIPTOR_VISIBILITIES, exports.ALL, exports.VISIBILITY_EXPORTED, exports.VISIBILITY_INTERNAL, exports.ARGUMENT_CLASSES, exports.ARGUMENT_ENUMS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_INTERFACES, exports.ARGUMENT_METHODS, exports.ARGUMENT_NAMESPACES, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_TYPES, exports.ARGUMENT_VARIABLES)), | ||
optionsDescription: (_c = ["\n `true` to enable for [\"", "\", \"", "\", \"", "\", \"", "\"],\n or an array with each item in one of two formats:\n\n * `string` to enable for that type\n * `object` keying types to when their documentation is required:\n * `\"", "\"` and `\"", " may specify:\n * `\"", "\":\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", ":\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * All other types may specify `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n\n Types that may be enabled are:\n\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`"], _c.raw = ["\n \\`true\\` to enable for [\"", "\", \"", "\", \"", "\", \"", "\"],\n or an array with each item in one of two formats:\n\n * \\`string\\` to enable for that type\n * \\`object\\` keying types to when their documentation is required:\n * \\`\"", "\"\\` and \\`\"", " may specify:\n * \\`\"", "\":\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", ":\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * All other types may specify \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n\n Types that may be enabled are:\n\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`"], Lint.Utils.dedent(_c, exports.ARGUMENT_CLASSES, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_METHODS, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_METHODS, exports.ARGUMENT_PROPERTIES, exports.DESCRIPTOR_PRIVACIES, exports.ALL, exports.PRIVACY_PRIVATE, exports.PRIVACY_PROTECTED, exports.PRIVACY_PUBLIC, exports.DESCRIPTOR_LOCATIONS, exports.ALL, exports.LOCATION_INSTANCE, exports.LOCATION_STATIC, exports.DESCRIPTOR_VISIBILITIES, exports.ALL, exports.VISIBILITY_EXPORTED, exports.VISIBILITY_INTERNAL, exports.ARGUMENT_CLASSES, exports.ARGUMENT_ENUMS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_INTERFACES, exports.ARGUMENT_METHODS, exports.ARGUMENT_NAMESPACES, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_TYPES, exports.ARGUMENT_VARIABLES)), | ||
options: { | ||
@@ -120,0 +120,0 @@ type: "array", |
@@ -63,3 +63,3 @@ /** | ||
description: "Requires files to remain under a certain number of lines", | ||
rationale: (_a = ["\n Limiting the number of lines allowed in a file allows files to remain small, \n single purpose, and maintainable."], _a.raw = ["\n Limiting the number of lines allowed in a file allows files to remain small, \n single purpose, and maintainable."], Lint.Utils.dedent(_a)), | ||
rationale: (_a = ["\n Limiting the number of lines allowed in a file allows files to remain small,\n single purpose, and maintainable."], _a.raw = ["\n Limiting the number of lines allowed in a file allows files to remain small,\n single purpose, and maintainable."], Lint.Utils.dedent(_a)), | ||
optionsDescription: "An integer indicating the maximum number of lines.", | ||
@@ -66,0 +66,0 @@ options: { |
@@ -18,3 +18,3 @@ /** | ||
import * as ts from "typescript"; | ||
import * as Lint from "tslint"; | ||
import * as Lint from "../index"; | ||
export declare class Rule extends Lint.Rules.AbstractRule { | ||
@@ -21,0 +21,0 @@ static metadata: Lint.IRuleMetadata; |
@@ -30,3 +30,3 @@ /** | ||
var ts = require("typescript"); | ||
var Lint = require("tslint"); | ||
var Lint = require("../index"); | ||
var OPTION_IGNORE_MODULE = "ignore-module"; | ||
@@ -33,0 +33,0 @@ var Rule = (function (_super) { |
@@ -263,3 +263,3 @@ /** | ||
: is(ts.TypeFlags.Null) ? 6 /* Null */ | ||
: is(ts.TypeFlags.Undefined | ts.TypeFlags.Void) ? 7 /* Undefined */ // tslint:disable-line:no-bitwise | ||
: is(ts.TypeFlags.Undefined | ts.TypeFlags.Void) ? 7 /* Undefined */ | ||
: is(ts.TypeFlags.EnumLike) ? 8 /* Enum */ | ||
@@ -266,0 +266,0 @@ : is(ts.TypeFlags.NumberLiteral) ? |
@@ -27,3 +27,2 @@ /** | ||
var test_1 = require("./test"); | ||
var updateNotifier_1 = require("./updateNotifier"); | ||
var Runner = (function () { | ||
@@ -166,13 +165,9 @@ function Runner(options, outputStream) { | ||
this.outputStream.write(lintResult.output, function () { | ||
if (lintResult.failureCount > 0) { | ||
onComplete(_this.options.force ? 0 : 2); | ||
if (_this.options.force || lintResult.errorCount === 0) { | ||
onComplete(0); | ||
} | ||
else { | ||
onComplete(0); | ||
onComplete(2); | ||
} | ||
}); | ||
if (lintResult.format === "prose") { | ||
// Check to see if there are any updates available | ||
updateNotifier_1.updateNotifierCheck(); | ||
} | ||
}; | ||
@@ -179,0 +174,0 @@ return Runner; |
{ | ||
"name": "tslint", | ||
"version": "4.5.1", | ||
"version": "5.0.0-dev.0", | ||
"description": "An extensible static analysis linter for the TypeScript language", | ||
@@ -46,7 +46,6 @@ "bin": { | ||
"resolve": "^1.1.7", | ||
"tsutils": "^1.1.0", | ||
"update-notifier": "^2.0.0" | ||
"tsutils": "^1.1.0" | ||
}, | ||
"peerDependencies": { | ||
"typescript": ">=2.0.0" | ||
"typescript": ">=2.0.0 || >=2.0.0-dev || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev" | ||
}, | ||
@@ -66,3 +65,2 @@ "devDependencies": { | ||
"@types/resolve": "0.0.4", | ||
"@types/update-notifier": "^1.0.0", | ||
"chai": "^3.5.0", | ||
@@ -74,5 +72,5 @@ "github": "^8.1.1", | ||
"rimraf": "^2.5.4", | ||
"tslint": "latest", | ||
"tslint": "next", | ||
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative", | ||
"typescript": "^2.2.1" | ||
"typescript": ">=2.3.0-dev" | ||
}, | ||
@@ -79,0 +77,0 @@ "license": "Apache-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1133823
9
21
23712
319
2
- Removedupdate-notifier@^2.0.0
- Removedansi-align@2.0.0(transitive)
- Removedansi-regex@3.0.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedboxen@1.3.0(transitive)
- Removedcamelcase@4.1.0(transitive)
- Removedcapture-stack-trace@1.0.2(transitive)
- Removedchalk@2.4.2(transitive)
- Removedci-info@1.6.0(transitive)
- Removedcli-boxes@1.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedconfigstore@3.1.5(transitive)
- Removedcreate-error-class@3.0.2(transitive)
- Removedcross-spawn@5.1.0(transitive)
- Removedcrypto-random-string@1.0.0(transitive)
- Removeddeep-extend@0.6.0(transitive)
- Removeddot-prop@4.2.1(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removedexeca@0.7.0(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedglobal-dirs@0.1.1(transitive)
- Removedgot@6.7.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedimport-lazy@2.1.0(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removedini@1.3.8(transitive)
- Removedis-ci@1.2.1(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedis-installed-globally@0.1.0(transitive)
- Removedis-npm@1.0.0(transitive)
- Removedis-obj@1.0.1(transitive)
- Removedis-path-inside@1.0.1(transitive)
- Removedis-redirect@1.0.0(transitive)
- Removedis-retry-allowed@1.2.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedlatest-version@3.1.0(transitive)
- Removedlowercase-keys@1.0.1(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmake-dir@1.3.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpackage-json@4.0.1(transitive)
- Removedpath-is-inside@1.0.2(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedpify@3.0.0(transitive)
- Removedprepend-http@1.0.4(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedrc@1.2.8(transitive)
- Removedregistry-auth-token@3.4.0(transitive)
- Removedregistry-url@3.1.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsemver-diff@2.1.0(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstring-width@2.1.1(transitive)
- Removedstrip-ansi@4.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedstrip-json-comments@2.0.1(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedterm-size@1.2.0(transitive)
- Removedtimed-out@4.0.1(transitive)
- Removedunique-string@1.0.0(transitive)
- Removedunzip-response@2.0.1(transitive)
- Removedupdate-notifier@2.5.0(transitive)
- Removedurl-parse-lax@1.0.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwidest-line@2.0.1(transitive)
- Removedwrite-file-atomic@2.4.3(transitive)
- Removedxdg-basedir@3.0.0(transitive)
- Removedyallist@2.1.2(transitive)