aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
commit0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch)
treef9864d4a4148621378958794cbbfdc2393733283 /node_modules/tslint
parent6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff)
downloadwallet-core-0469abd4a9c9270a1fdc962969e36e63699af8b4.tar.xz
upgrade dependencies
Diffstat (limited to 'node_modules/tslint')
-rw-r--r--node_modules/tslint/CHANGELOG.md112
-rw-r--r--node_modules/tslint/README.md4
-rw-r--r--node_modules/tslint/lib/configs/all.d.ts9
-rw-r--r--node_modules/tslint/lib/configs/all.js11
-rw-r--r--node_modules/tslint/lib/configs/latest.d.ts7
-rw-r--r--node_modules/tslint/lib/configs/latest.js8
-rw-r--r--node_modules/tslint/lib/configs/recommended.d.ts1
-rw-r--r--node_modules/tslint/lib/configs/recommended.js1
-rw-r--r--node_modules/tslint/lib/configuration.d.ts10
-rw-r--r--node_modules/tslint/lib/configuration.js55
-rw-r--r--node_modules/tslint/lib/enableDisableRules.js2
-rw-r--r--node_modules/tslint/lib/error.js5
-rw-r--r--node_modules/tslint/lib/formatterLoader.js2
-rw-r--r--node_modules/tslint/lib/formatters/codeFrameFormatter.js9
-rw-r--r--node_modules/tslint/lib/formatters/index.d.ts1
-rw-r--r--node_modules/tslint/lib/formatters/index.js2
-rw-r--r--node_modules/tslint/lib/formatters/junitFormatter.d.ts24
-rw-r--r--node_modules/tslint/lib/formatters/junitFormatter.js77
-rw-r--r--node_modules/tslint/lib/formatters/msbuildFormatter.js3
-rw-r--r--node_modules/tslint/lib/formatters/proseFormatter.js1
-rw-r--r--node_modules/tslint/lib/formatters/stylishFormatter.js13
-rw-r--r--node_modules/tslint/lib/formatters/verboseFormatter.js1
-rw-r--r--node_modules/tslint/lib/formatters/vsoFormatter.d.ts2
-rw-r--r--node_modules/tslint/lib/formatters/vsoFormatter.js6
-rw-r--r--node_modules/tslint/lib/language/formatter/abstractFormatter.d.ts1
-rw-r--r--node_modules/tslint/lib/language/formatter/abstractFormatter.js4
-rw-r--r--node_modules/tslint/lib/language/formatter/formatter.d.ts4
-rw-r--r--node_modules/tslint/lib/language/rule/rule.d.ts1
-rw-r--r--node_modules/tslint/lib/language/rule/rule.js6
-rw-r--r--node_modules/tslint/lib/language/utils.d.ts3
-rw-r--r--node_modules/tslint/lib/language/utils.js6
-rw-r--r--node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js1
-rw-r--r--node_modules/tslint/lib/linter.js8
-rw-r--r--node_modules/tslint/lib/ruleLoader.js2
-rw-r--r--node_modules/tslint/lib/rules/arrowParensRule.js4
-rw-r--r--node_modules/tslint/lib/rules/awaitPromiseRule.d.ts1
-rw-r--r--node_modules/tslint/lib/rules/awaitPromiseRule.js36
-rw-r--r--node_modules/tslint/lib/rules/banCommaOperatorRule.d.ts7
-rw-r--r--node_modules/tslint/lib/rules/banCommaOperatorRule.js53
-rw-r--r--node_modules/tslint/lib/rules/callableTypesRule.js15
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts26
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/blockExclusion.js42
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts30
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/classExclusion.js59
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts25
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusion.js33
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts28
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js18
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts8
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js60
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts34
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/tagExclusion.js82
-rw-r--r--node_modules/tslint/lib/rules/completedDocsRule.d.ts38
-rw-r--r--node_modules/tslint/lib/rules/completedDocsRule.js301
-rw-r--r--node_modules/tslint/lib/rules/curlyRule.js27
-rw-r--r--node_modules/tslint/lib/rules/deprecationRule.js35
-rw-r--r--node_modules/tslint/lib/rules/importBlacklistRule.js45
-rw-r--r--node_modules/tslint/lib/rules/jsdocFormatRule.js27
-rw-r--r--node_modules/tslint/lib/rules/maxClassesPerFileRule.js18
-rw-r--r--node_modules/tslint/lib/rules/memberAccessRule.js34
-rw-r--r--node_modules/tslint/lib/rules/memberOrderingRule.js11
-rw-r--r--node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.js17
-rw-r--r--node_modules/tslint/lib/rules/noConditionalAssignmentRule.d.ts16
-rw-r--r--node_modules/tslint/lib/rules/noConditionalAssignmentRule.js119
-rw-r--r--node_modules/tslint/lib/rules/noDuplicateImportsRule.js44
-rw-r--r--node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.d.ts23
-rw-r--r--node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.js65
-rw-r--r--node_modules/tslint/lib/rules/noEmptyInterfaceRule.js15
-rw-r--r--node_modules/tslint/lib/rules/noImplicitDependenciesRule.d.ts7
-rw-r--r--node_modules/tslint/lib/rules/noImplicitDependenciesRule.js132
-rw-r--r--node_modules/tslint/lib/rules/noInvalidThisRule.d.ts18
-rw-r--r--node_modules/tslint/lib/rules/noInvalidThisRule.js6
-rw-r--r--node_modules/tslint/lib/rules/noNonNullAssertionRule.js2
-rw-r--r--node_modules/tslint/lib/rules/noRedundantJsdocRule.d.ts9
-rw-r--r--node_modules/tslint/lib/rules/noRedundantJsdocRule.js133
-rw-r--r--node_modules/tslint/lib/rules/noReferenceImportRule.js63
-rw-r--r--node_modules/tslint/lib/rules/noRequireImportsRule.js18
-rw-r--r--node_modules/tslint/lib/rules/noReturnAwaitRule.d.ts7
-rw-r--r--node_modules/tslint/lib/rules/noReturnAwaitRule.js110
-rw-r--r--node_modules/tslint/lib/rules/noShadowedVariableRule.js2
-rw-r--r--node_modules/tslint/lib/rules/noStringLiteralRule.js4
-rw-r--r--node_modules/tslint/lib/rules/noSubmoduleImportsRule.js72
-rw-r--r--node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js9
-rw-r--r--node_modules/tslint/lib/rules/noUnboundMethodRule.js1
-rw-r--r--node_modules/tslint/lib/rules/noUnnecessaryClassRule.d.ts25
-rw-r--r--node_modules/tslint/lib/rules/noUnnecessaryClassRule.js113
-rw-r--r--node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.js2
-rw-r--r--node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.js26
-rw-r--r--node_modules/tslint/lib/rules/noUnsafeAnyRule.js360
-rw-r--r--node_modules/tslint/lib/rules/noUnusedVariableRule.js24
-rw-r--r--node_modules/tslint/lib/rules/noVarRequiresRule.js3
-rw-r--r--node_modules/tslint/lib/rules/objectLiteralShorthandRule.d.ts3
-rw-r--r--node_modules/tslint/lib/rules/objectLiteralShorthandRule.js40
-rw-r--r--node_modules/tslint/lib/rules/objectLiteralSortKeysRule.js26
-rw-r--r--node_modules/tslint/lib/rules/oneLineRule.d.ts4
-rw-r--r--node_modules/tslint/lib/rules/oneLineRule.js280
-rw-r--r--node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js13
-rw-r--r--node_modules/tslint/lib/rules/orderedImportsRule.d.ts1
-rw-r--r--node_modules/tslint/lib/rules/orderedImportsRule.js156
-rw-r--r--node_modules/tslint/lib/rules/preferConstRule.js3
-rw-r--r--node_modules/tslint/lib/rules/restrictPlusOperandsRule.d.ts1
-rw-r--r--node_modules/tslint/lib/rules/restrictPlusOperandsRule.js8
-rw-r--r--node_modules/tslint/lib/rules/returnUndefinedRule.js33
-rw-r--r--node_modules/tslint/lib/rules/semicolonRule.js14
-rw-r--r--node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.js13
-rw-r--r--node_modules/tslint/lib/rules/strictBooleanExpressionsRule.js2
-rw-r--r--node_modules/tslint/lib/rules/trailingCommaRule.d.ts1
-rw-r--r--node_modules/tslint/lib/rules/trailingCommaRule.js77
-rw-r--r--node_modules/tslint/lib/rules/typeofCompareRule.js3
-rw-r--r--node_modules/tslint/lib/rules/variableNameRule.js2
-rw-r--r--node_modules/tslint/lib/rules/whitespaceRule.js1
-rw-r--r--node_modules/tslint/lib/runner.d.ts2
-rw-r--r--node_modules/tslint/lib/runner.js15
-rw-r--r--node_modules/tslint/lib/test.js37
-rw-r--r--node_modules/tslint/lib/tslint-cli.js19
-rw-r--r--node_modules/tslint/lib/utils.js4
-rw-r--r--node_modules/tslint/lib/verify/lines.js8
-rw-r--r--node_modules/tslint/lib/verify/lintError.d.ts1
-rw-r--r--node_modules/tslint/lib/verify/lintError.js3
-rw-r--r--node_modules/tslint/lib/verify/parse.d.ts2
-rw-r--r--node_modules/tslint/lib/verify/parse.js53
-rw-r--r--node_modules/tslint/node_modules/chalk/index.js228
-rw-r--r--node_modules/tslint/node_modules/chalk/license9
-rw-r--r--node_modules/tslint/node_modules/chalk/package.json66
-rw-r--r--node_modules/tslint/node_modules/chalk/readme.md309
-rw-r--r--node_modules/tslint/node_modules/chalk/templates.js128
-rw-r--r--node_modules/tslint/node_modules/chalk/types/index.d.ts97
-rw-r--r--node_modules/tslint/node_modules/commander/CHANGELOG.md326
-rw-r--r--node_modules/tslint/node_modules/commander/LICENSE22
-rw-r--r--node_modules/tslint/node_modules/commander/Readme.md370
-rw-r--r--node_modules/tslint/node_modules/commander/index.js1158
-rw-r--r--node_modules/tslint/node_modules/commander/package.json34
-rw-r--r--node_modules/tslint/node_modules/commander/typings/index.d.ts295
-rw-r--r--node_modules/tslint/node_modules/resolve/.editorconfig20
-rw-r--r--node_modules/tslint/node_modules/resolve/.eslintignore1
-rw-r--r--node_modules/tslint/node_modules/resolve/.eslintrc30
-rw-r--r--node_modules/tslint/node_modules/resolve/.travis.yml173
-rw-r--r--node_modules/tslint/node_modules/resolve/LICENSE18
-rw-r--r--node_modules/tslint/node_modules/resolve/appveyor.yml44
-rw-r--r--node_modules/tslint/node_modules/resolve/example/async.js5
-rw-r--r--node_modules/tslint/node_modules/resolve/example/sync.js3
-rw-r--r--node_modules/tslint/node_modules/resolve/index.js8
-rw-r--r--node_modules/tslint/node_modules/resolve/lib/async.js203
-rw-r--r--node_modules/tslint/node_modules/resolve/lib/caller.js8
-rw-r--r--node_modules/tslint/node_modules/resolve/lib/core.js34
-rw-r--r--node_modules/tslint/node_modules/resolve/lib/core.json43
-rw-r--r--node_modules/tslint/node_modules/resolve/lib/node-modules-paths.js45
-rw-r--r--node_modules/tslint/node_modules/resolve/lib/sync.js93
-rw-r--r--node_modules/tslint/node_modules/resolve/package.json40
-rw-r--r--node_modules/tslint/node_modules/resolve/readme.markdown160
-rw-r--r--node_modules/tslint/node_modules/resolve/test/core.js36
-rw-r--r--node_modules/tslint/node_modules/resolve/test/dotdot.js29
-rw-r--r--node_modules/tslint/node_modules/resolve/test/dotdot/abc/index.js2
-rw-r--r--node_modules/tslint/node_modules/resolve/test/dotdot/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/faulty_basedir.js13
-rw-r--r--node_modules/tslint/node_modules/resolve/test/filter.js19
-rw-r--r--node_modules/tslint/node_modules/resolve/test/filter_sync.js16
-rw-r--r--node_modules/tslint/node_modules/resolve/test/mock.js143
-rw-r--r--node_modules/tslint/node_modules/resolve/test/mock_sync.js67
-rw-r--r--node_modules/tslint/node_modules/resolve/test/module_dir.js56
-rw-r--r--node_modules/tslint/node_modules/resolve/test/module_dir/xmodules/aaa/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/module_dir/ymodules/aaa/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/module_dir/zmodules/bbb/main.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/module_dir/zmodules/bbb/package.json3
-rw-r--r--node_modules/tslint/node_modules/resolve/test/node-modules-paths.js93
-rw-r--r--node_modules/tslint/node_modules/resolve/test/node_path.js49
-rw-r--r--node_modules/tslint/node_modules/resolve/test/node_path/x/aaa/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/node_path/x/ccc/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/node_path/y/bbb/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/node_path/y/ccc/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/nonstring.js9
-rw-r--r--node_modules/tslint/node_modules/resolve/test/pathfilter.js42
-rw-r--r--node_modules/tslint/node_modules/resolve/test/pathfilter/deep_ref/main.js0
-rw-r--r--node_modules/tslint/node_modules/resolve/test/precedence.js23
-rw-r--r--node_modules/tslint/node_modules/resolve/test/precedence/aaa.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/precedence/aaa/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/precedence/aaa/main.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/precedence/bbb.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/precedence/bbb/main.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver.js349
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/baz/doom.js0
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/baz/package.json3
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/baz/quux.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/cup.coffee1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/dot_main/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/dot_main/package.json3
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/dot_slash_main/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/dot_slash_main/package.json3
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/foo.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/incorrect_main/index.js2
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/incorrect_main/package.json3
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/mug.coffee0
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/mug.js0
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/other_path/lib/other-lib.js0
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/other_path/root.js0
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/quux/foo/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/same_names/foo.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/same_names/foo/index.js1
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/symlinked/_/symlink_target/.gitkeep0
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver/without_basedir/main.js5
-rw-r--r--node_modules/tslint/node_modules/resolve/test/resolver_sync.js267
-rw-r--r--node_modules/tslint/node_modules/resolve/test/subdirs.js13
-rw-r--r--node_modules/tslint/node_modules/resolve/test/symlinks.js54
-rw-r--r--node_modules/tslint/package.json13
204 files changed, 8000 insertions, 1075 deletions
diff --git a/node_modules/tslint/CHANGELOG.md b/node_modules/tslint/CHANGELOG.md
index 9055970df..e1190823d 100644
--- a/node_modules/tslint/CHANGELOG.md
+++ b/node_modules/tslint/CHANGELOG.md
@@ -1,6 +1,118 @@
Change Log
===
+v5.8.0
+---
+
+## :warning: Deprecations
+
+- [deprecation] [`typeof-compare`](https://palantir.github.io/tslint/rules/typeof-compare/) is deprecated because typescript already does that check (#3286)
+- [deprecation] CLI argument `--type-check` is no longer necessary and will be removed in the next major version (#3322)
+
+## Updates to `tslint:latest` configuration
+
+```diff
++ "ban-comma-operator": true,
++ "jsdoc-format": {
++ options: "check-multiline-start",
++ },
++ "no-duplicate-switch-case": true,
++ "no-implicit-dependencies": true,
++ "no-return-await": true,
+```
+
+## :tada: Features
+
+- [feature] Added `linterOptions` configuration field to `tslint.json`, which supports a list of `exclude` globs to disable linting for a subset of files (#2409)
+- [new-rule] [`no-return-await`](https://palantir.github.io/tslint/rules/no-return-await/) (#3233)
+- [new-rule] [`no-redundant-jsdoc`](https://palantir.github.io/tslint/rules/no-redundant-jsdoc/) (#2754)
+- [new-rule] [`no-duplicate-switch-case`](https://palantir.github.io/tslint/rules/no-duplicate-switch-case/) (#2937)
+- [new-rule] [`no-implicit-dependencies`](https://palantir.github.io/tslint/rules/no-implicit-dependencies/) (#3343)
+- [new-rule] [`no-unnecessary-class`](https://palantir.github.io/tslint/rules/no-unnecessary-class/) (#3119)
+- [new-rule] [`ban-comma-operator`](https://palantir.github.io/tslint/rules/ban-comma-operator/) (#3250)
+- [new-fixer] [`one-line`](https://palantir.github.io/tslint/rules/one-line/) (#3200)
+- [new-fixer] [`curly`](https://palantir.github.io/tslint/rules/curly/) (#3262)
+- [new-rule-option] [`jsdoc-format`](https://palantir.github.io/tslint/rules/jsdoc-format/) adds option `"check-multiline-start"` to enforce the first line of a multiline JSDoc comment to be empty. (#3181)
+- [new-rule-option] [`trailing-comma`](https://palantir.github.io/tslint/rules/trailing-comma/) adds option `"esSpecCompliant"` to make it compatible with the ES spec regarding trailing commas after object/array rest and rest parameters. (#3176)
+- [new-rule-option] `"check-parameter-property"` option for [`member-access`](https://palantir.github.io/tslint/rules/member-access/) rule (#3325)
+- [new-rule-option] `"strict-bound-class-methods"` option for [`semicolon`](https://palantir.github.io/tslint/rules/semicolon/) rule (#3294)
+- [new-rule-option] `"grouped-imports"` option for [`ordered-imports`](https://palantir.github.io/tslint/rules/ordered-imports/) rule (#3138)
+- [new-rule-option] `"ignore-blank-lines"` option for [`no-trailing-whitespace`](https://palantir.github.io/tslint/rules/no-trailing-whitespace/) rule (#3346)
+- [new-rule-option] `"never"` option for [`object-literal-shorthand`](https://palantir.github.io/tslint/rules/object-literal-shorthand/) disallows shorthand notation (#3268)
+- [new-rule-option] `"exclude-class-expressions"` option for [`max-classes-per-file`](https://palantir.github.io/tslint/rules/max-classes-per-file/) rule (#3281)
+- [new-rule-option] [`no-unnecessary-type-assertion`](https://palantir.github.io/tslint/rules/no-unnecessary-type-assertion/) supports a whitelist of types to ignore (#3257)
+- [new-rule-option] `"module-source-path"` for [`ordered-imports`](https://palantir.github.io/tslint/rules/ordered-imports/) allows sorting imports by trailing end of path (#3178)
+- [new-formatter] JUnit (#3194)
+
+## :hammer_and_wrench: Bugfixes & enhancements
+
+- [bugfix] [`no-empty-interface`](https://palantir.github.io/tslint/rules/no-empty-interface/) allows providing type arguments for extended type (#3260)
+- [bugfix] Fixed line switches to not disable failures in the next line following the disabled line (#3177)
+- [bugfix] [`return-undefined`](https://palantir.github.io/tslint/rules/return-undefined/) handles union return types in async functions (#3298)
+- [bugfix] [`deprecation`](https://palantir.github.io/tslint/rules/deprecation/) checks correct constructor overload (#3203)
+- [bugfix] [`return-undefined`](https://palantir.github.io/tslint/rules/return-undefined/) declared return type takes precedence over contextual type (#3298)
+- [bugfix] Correctly mark `inputFilePath` as an optional parameter in `Configuration.findConfiguration()` (#3195)
+- [bugfix] [`return-undefined`](https://palantir.github.io/tslint/rules/return-undefined/) fixed regressions: once again allows anything if return type is `any` (#3298)
+- [bugfix] [`only-arrow-functions`](https://palantir.github.io/tslint/rules/only-arrow-functions/) allow function if `this` is used in parameter initializer (#3315)
+- [bugfix] [`no-conditional-assignment`](https://palantir.github.io/tslint/rules/no-conditional-assignment/): exclude intentional assignments, e.g. inside functions (#2629)
+- [bugfix] [`no-angle-bracket-type-assertion`](https://palantir.github.io/tslint/rules/no-angle-bracket-type-assertion/) fixer adds parentheses when necessary (#3301)
+- [bugfix] [`no-angle-bracket-type-assertion`](https://palantir.github.io/tslint/rules/no-angle-bracket-type-assertion/) fixed order when autofixing consecutive assertions (#3301)
+- [bugfix] `vso` formatter no longer duplicates output for fixed failures (#3348)
+- [bugfix] [`no-unbound-method`](https://palantir.github.io/tslint/rules/no-unbound-method/): Allow negation of method (#3349)
+- [bugfix] [`arrow-parens`](https://palantir.github.io/tslint/rules/arrow-parens/) with option `"ban-single-arg-parens"` no longer produces invalid code when fixed (#3247)
+- [bugfix] Fixed regression where the lookup of `tslint.json` stopped at the current directory. (#3309)
+- [bugfix] `--test` works correctly with any `compilerOptions.target` (#3296)
+- [bugfix] `whitepace` handles files with BOM and other irregular whitespace (#3305)
+- [bugfix] [`callable-types`](https://palantir.github.io/tslint/rules/callable-types/) auto fix produces invalid results (#3342)
+- [bugfix] [`no-string-literal`](https://palantir.github.io/tslint/rules/no-string-literal/) correctly fix property names with leading underscores (#3184)
+- [bugfix] [`variable-name`](https://palantir.github.io/tslint/rules/variable-name/) fixed crash on empty variable name (#3292)
+- [bugfix] [`trailing-comma`](https://palantir.github.io/tslint/rules/trailing-comma/) fixed crash on arrow function without parens (#3246)
+- [bugfix] Fix [`space-before-function-paren`](https://palantir.github.io/tslint/rules/space-before-function-paren/) for anonymous/arrow generic functions (#3085)
+- [bugfix] Removed warning printed to console when using the [`no-unused-variable`](https://palantir.github.io/tslint/rules/no-unused-variable/) along with the `noUnusedLocals` and `noUnusedParameters` compiler options (#3227)
+- [bugfix] [`no-invalid-this`](https://palantir.github.io/tslint/rules/no-invalid-this/) ignores functions with a `this` param (#3267)
+- [enhancement] Sort failures by line and character for formatters (#3345)
+- [enhancement] [`import-blacklist`](https://palantir.github.io/tslint/rules/import-blacklist/) also checks exports and dynamic imports (#3258)
+- [enhancement] [`no-conditional-assignment`](https://palantir.github.io/tslint/rules/no-conditional-assignment/) added check for conditional (ternary) expressions (#2629)
+- [enhancement] Allow [`completed-docs`](https://palantir.github.io/tslint/rules/completed-docs/) to list doc tags that mark a node as not requiring a documentation body. Tags can also provide a regexp matcher to validate that their contents are docs-valid. (#2415)
+- [enhancement] [`await-promise`](https://palantir.github.io/tslint/rules/await-promise/) enforces that `for-await-of` is only used with `AsyncIterable` (#3297)
+- [enhancement] [`one-line`](https://palantir.github.io/tslint/rules/one-line/) checks type alias declarations (#3200)
+- [enhancement] [`deprecation`](https://palantir.github.io/tslint/rules/deprecation/) checks object destructuring (#3318)
+- [enhancement] [`no-submodule-imports`](https://palantir.github.io/tslint/rules/no-submodule-imports/) also checks exports (#3258)
+- [enhancement] [`restrict-plus-operands`](https://palantir.github.io/tslint/rules/restrict-plus-operands/): More specific error message when arguments include strings (#3220)
+- [enhancement] [`no-unsafe-any`](https://palantir.github.io/tslint/rules/no-unsafe-any/) checks more expressions, for example destructuring, `yield`, property initializer (#3196)
+- [enhancement] [`object-literal-sort-keys`](https://palantir.github.io/tslint/rules/object-literal-sort-keys/): allow grouping of object properties via additional blank lines when using alphabetical ordering. (#3191)
+- [enhancement] Migrated CLI from using `colors` module to `chalk` module (#3171)
+- [enhancement] [`no-unused-variable`](https://palantir.github.io/tslint/rules/no-unused-variable/) applies the ignorePattern to imports (#3187)
+
+Thanks to our contributors!
+
+- Klaus Meinhardt
+- Charles Samborski
+- Donald Pipowitch
+- Josh Goldberg
+- mmkal
+- Erik
+- Csaba Miklos
+- Dominik Moritz
+- Khalid Saifullah
+- Lukas Spieß
+- Merott Movahedi
+- Bowen Ni
+- ksvitkovsky
+- Hutson Betts
+- Caleb Eggensperger
+- Brent Erickson
+- Trivikram
+- Brandon Furtwangler
+- Pavel Zet
+- aervin_
+- Holger Jeromin
+- Danny Guo
+- Jeremy Morton
+- Cyril Gandon
+- Andy Hanson
+- yadan
+
v5.7.0
---
diff --git a/node_modules/tslint/README.md b/node_modules/tslint/README.md
index 648054338..f9667ee14 100644
--- a/node_modules/tslint/README.md
+++ b/node_modules/tslint/README.md
@@ -15,7 +15,7 @@ TSLint supports:
- inline disabling and enabling of rules with comment flags
- configuration presets (`tslint:latest`, `tslint-react`, etc.) and plugin composition
- automatic fixing of formatting & style violations
-- integration with [MSBuild](https://github.com/joshuakgoldberg/tslint.msbuild), [Grunt](https://github.com/palantir/grunt-tslint), [Gulp](https://github.com/panuhorsmalahti/gulp-tslint), [Atom](https://github.com/AtomLinter/linter-tslint), [Eclipse](https://github.com/palantir/eclipse-tslint), [Emacs](http://flycheck.org), [Sublime](https://packagecontrol.io/packages/SublimeLinter-contrib-tslint), [Vim](https://github.com/scrooloose/syntastic), [Visual Studio 2015](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.WebAnalyzer), [Visual Studio 2017](https://marketplace.visualstudio.com/items?itemName=RichNewman.TypeScriptAnalyzer) [Visual Studio code](https://marketplace.visualstudio.com/items?itemName=eg2.tslint), [WebStorm](https://www.jetbrains.com/webstorm/help/tslint.html) and [more](https://palantir.github.io/tslint/usage/third-party-tools/)
+- integration with [MSBuild](https://github.com/joshuakgoldberg/tslint.msbuild), [Grunt](https://github.com/palantir/grunt-tslint), [Gulp](https://github.com/panuhorsmalahti/gulp-tslint), [Atom](https://github.com/AtomLinter/linter-tslint), [Eclipse](https://github.com/palantir/eclipse-tslint), [Emacs](http://flycheck.org), [Sublime](https://packagecontrol.io/packages/SublimeLinter-contrib-tslint), [Vim](https://github.com/scrooloose/syntastic), [Visual Studio 2015](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.WebAnalyzer), [Visual Studio 2017](https://marketplace.visualstudio.com/items?itemName=RichNewman.TypeScriptAnalyzer), [Visual Studio code](https://marketplace.visualstudio.com/items?itemName=eg2.tslint), [WebStorm](https://www.jetbrains.com/webstorm/help/tslint.html) and [more](https://palantir.github.io/tslint/usage/third-party-tools/)
Installation & Usage
------------
@@ -74,4 +74,4 @@ Creating a new release
6. Once your PR is merged, wait for the tests to pass on CircleCI for develop
7. Create a "Release" on GitHub with the proper tag version and notes from the changelog.
- The tag should be identical to the version in `package.json`
-8. Run `yarn run publish:local` \ No newline at end of file
+8. Run `yarn run publish:local`
diff --git a/node_modules/tslint/lib/configs/all.d.ts b/node_modules/tslint/lib/configs/all.d.ts
index cb04d518a..6c285be54 100644
--- a/node_modules/tslint/lib/configs/all.d.ts
+++ b/node_modules/tslint/lib/configs/all.d.ts
@@ -32,6 +32,7 @@ export declare const rules: {
})[];
"unified-signatures": boolean;
"await-promise": boolean;
+ "ban-comma-operator": boolean;
"curly": boolean;
"forin": boolean;
"label-position": boolean;
@@ -42,22 +43,26 @@ export declare const rules: {
"no-construct": boolean;
"no-debugger": boolean;
"no-duplicate-super": boolean;
+ "no-duplicate-switch-case": boolean;
"no-duplicate-variable": (string | boolean)[];
"no-empty": boolean;
"no-eval": boolean;
"no-floating-promises": boolean;
"no-for-in-array": boolean;
+ "no-implicit-dependencies": boolean;
"no-inferred-empty-object-type": boolean;
"no-invalid-template-strings": boolean;
"no-misused-new": boolean;
"no-null-keyword": boolean;
"no-object-literal-type-assertion": boolean;
+ "no-return-await": boolean;
"no-shadowed-variable": boolean;
"no-string-literal": boolean;
"no-string-throw": boolean;
"no-sparse-arrays": boolean;
"no-submodule-imports": boolean;
"no-unbound-method": boolean;
+ "no-unnecessary-class": (string | boolean)[];
"no-unsafe-any": boolean;
"no-unsafe-finally": boolean;
"no-unused-expression": boolean;
@@ -108,7 +113,7 @@ export declare const rules: {
"import-spacing": boolean;
"interface-name": boolean;
"interface-over-type-literal": boolean;
- "jsdoc-format": boolean;
+ "jsdoc-format": (string | boolean)[];
"match-default-export-name": boolean;
"new-parens": boolean;
"newline-before-return": boolean;
@@ -116,6 +121,7 @@ export declare const rules: {
"no-boolean-literal-compare": boolean;
"no-consecutive-blank-lines": boolean;
"no-parameter-properties": boolean;
+ "no-redundant-jsdoc": boolean;
"no-reference-import": boolean;
"no-unnecessary-callback-wrapper": boolean;
"no-unnecessary-initializer": boolean;
@@ -129,6 +135,7 @@ export declare const rules: {
"ordered-imports": (boolean | {
"import-sources-order": string;
"named-imports-order": string;
+ "module-source-path": string;
})[];
"prefer-function-over-method": boolean;
"prefer-method-signature": boolean;
diff --git a/node_modules/tslint/lib/configs/all.js b/node_modules/tslint/lib/configs/all.js
index 017ab5098..73c78a011 100644
--- a/node_modules/tslint/lib/configs/all.js
+++ b/node_modules/tslint/lib/configs/all.js
@@ -34,7 +34,7 @@ exports.rules = {
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"],
],
},
- "member-access": [true, "check-accessor", "check-constructor"],
+ "member-access": [true, "check-accessor", "check-constructor", "check-parameter-property"],
"member-ordering": [true, {
"order": "statics-first",
"alphabetize": true,
@@ -85,6 +85,7 @@ exports.rules = {
// Functionality
"await-promise": true,
// "ban": no sensible default
+ "ban-comma-operator": true,
"curly": true,
"forin": true,
// "import-blacklist": no sensible default
@@ -96,6 +97,7 @@ exports.rules = {
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
+ "no-duplicate-switch-case": true,
"no-duplicate-variable": [
true,
"check-parameters",
@@ -104,18 +106,21 @@ exports.rules = {
"no-eval": true,
"no-floating-promises": true,
"no-for-in-array": true,
+ "no-implicit-dependencies": true,
"no-inferred-empty-object-type": true,
"no-invalid-template-strings": true,
// "no-invalid-this": Won't this be deprecated?
"no-misused-new": true,
"no-null-keyword": true,
"no-object-literal-type-assertion": true,
+ "no-return-await": true,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-string-throw": true,
"no-sparse-arrays": true,
"no-submodule-imports": true,
"no-unbound-method": true,
+ "no-unnecessary-class": [true, "allow-empty-class"],
"no-unsafe-any": true,
"no-unsafe-finally": true,
"no-unused-expression": true,
@@ -180,7 +185,7 @@ exports.rules = {
"import-spacing": true,
"interface-name": true,
"interface-over-type-literal": true,
- "jsdoc-format": true,
+ "jsdoc-format": [true, "check-multiline-start"],
"match-default-export-name": true,
"new-parens": true,
"newline-before-return": true,
@@ -188,6 +193,7 @@ exports.rules = {
"no-boolean-literal-compare": true,
"no-consecutive-blank-lines": true,
"no-parameter-properties": true,
+ "no-redundant-jsdoc": true,
"no-reference-import": true,
"no-unnecessary-callback-wrapper": true,
"no-unnecessary-initializer": true,
@@ -208,6 +214,7 @@ exports.rules = {
"ordered-imports": [true, {
"import-sources-order": "case-insensitive",
"named-imports-order": "case-insensitive",
+ "module-source-path": "full",
}],
"prefer-function-over-method": true,
"prefer-method-signature": true,
diff --git a/node_modules/tslint/lib/configs/latest.d.ts b/node_modules/tslint/lib/configs/latest.d.ts
index 79dc26d46..af4a4e9bd 100644
--- a/node_modules/tslint/lib/configs/latest.d.ts
+++ b/node_modules/tslint/lib/configs/latest.d.ts
@@ -31,6 +31,13 @@ export declare const rules: {
"whitespace": {
options: string[];
};
+ "ban-comma-operator": boolean;
+ "jsdoc-format": {
+ options: string;
+ };
+ "no-duplicate-switch-case": boolean;
+ "no-implicit-dependencies": boolean;
+ "no-return-await": boolean;
};
declare const xtends = "tslint:recommended";
export { xtends as extends };
diff --git a/node_modules/tslint/lib/configs/latest.js b/node_modules/tslint/lib/configs/latest.js
index dcbb72b43..681ad1c98 100644
--- a/node_modules/tslint/lib/configs/latest.js
+++ b/node_modules/tslint/lib/configs/latest.js
@@ -58,6 +58,14 @@ exports.rules = {
"check-rest-spread",
],
},
+ // added in v5.8
+ "ban-comma-operator": true,
+ "jsdoc-format": {
+ options: "check-multiline-start",
+ },
+ "no-duplicate-switch-case": true,
+ "no-implicit-dependencies": true,
+ "no-return-await": true,
};
// tslint:enable object-literal-sort-keys
// work around "extends" being a keyword
diff --git a/node_modules/tslint/lib/configs/recommended.d.ts b/node_modules/tslint/lib/configs/recommended.d.ts
index 75e3bba56..ecbbf0a1b 100644
--- a/node_modules/tslint/lib/configs/recommended.d.ts
+++ b/node_modules/tslint/lib/configs/recommended.d.ts
@@ -107,6 +107,7 @@ export declare const rules: {
"ordered-imports": {
options: {
"import-sources-order": string;
+ "module-source-path": string;
"named-imports-order": string;
};
};
diff --git a/node_modules/tslint/lib/configs/recommended.js b/node_modules/tslint/lib/configs/recommended.js
index 16f44613e..e1f7aec93 100644
--- a/node_modules/tslint/lib/configs/recommended.js
+++ b/node_modules/tslint/lib/configs/recommended.js
@@ -129,6 +129,7 @@ exports.rules = {
"ordered-imports": {
options: {
"import-sources-order": "case-insensitive",
+ "module-source-path": "full",
"named-imports-order": "case-insensitive",
},
},
diff --git a/node_modules/tslint/lib/configuration.d.ts b/node_modules/tslint/lib/configuration.d.ts
index ede434408..552b5e807 100644
--- a/node_modules/tslint/lib/configuration.d.ts
+++ b/node_modules/tslint/lib/configuration.d.ts
@@ -14,11 +14,11 @@ export interface IConfigurationFile {
*/
jsRules: Map<string, Partial<IOptions>>;
/**
- * Other linter options, currently for testing. Not publicly supported.
+ * A subset of the CLI options.
*/
- linterOptions?: {
- typeCheck?: boolean;
- };
+ linterOptions?: Partial<{
+ exclude: string[];
+ }>;
/**
* Directories containing custom rules. Resolved using node module semantics.
*/
@@ -43,6 +43,7 @@ export declare const EMPTY_CONFIG: IConfigurationFile;
* @returns Load status for a TSLint configuration object
*/
export declare function findConfiguration(configFile: string | null, inputFilePath: string): IConfigurationLoadResult;
+export declare function findConfiguration(configFile: string, inputFilePath?: string): IConfigurationLoadResult;
/**
* Searches for a TSLint configuration and returns the path to it.
* Could return undefined if not configuration is found.
@@ -54,6 +55,7 @@ export declare function findConfiguration(configFile: string | null, inputFilePa
* or undefined if neither can be found.
*/
export declare function findConfigurationPath(suppliedConfigFilePath: string | null, inputFilePath: string): string | undefined;
+export declare function findConfigurationPath(suppliedConfigFilePath: string, inputFilePath?: string): string | undefined;
/**
* Used Node semantics to load a configuration file given configFilePath.
* For example:
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);
});
diff --git a/node_modules/tslint/lib/enableDisableRules.js b/node_modules/tslint/lib/enableDisableRules.js
index 27c58d5d8..9d298b4c5 100644
--- a/node_modules/tslint/lib/enableDisableRules.js
+++ b/node_modules/tslint/lib/enableDisableRules.js
@@ -40,7 +40,7 @@ function removeDisabledFailures(sourceFile, failures) {
var pos = _a.pos, end = _a.end;
var failPos = failure.getStartPosition().getPosition();
var failEnd = failure.getEndPosition().getPosition();
- return failEnd >= pos && (end === -1 || failPos <= end);
+ return failEnd >= pos && (end === -1 || failPos < end);
});
});
}
diff --git a/node_modules/tslint/lib/error.js b/node_modules/tslint/lib/error.js
index 38fd4fce9..95bc9f811 100644
--- a/node_modules/tslint/lib/error.js
+++ b/node_modules/tslint/lib/error.js
@@ -28,7 +28,8 @@ var FatalError = /** @class */ (function (_super) {
_this.message = message;
_this.innerError = innerError;
_this.name = FatalError.NAME;
- _this.stack = new Error().stack;
+ // Fix prototype chain for target ES5
+ Object.setPrototypeOf(_this, FatalError.prototype);
return _this;
}
FatalError.NAME = "FatalError";
@@ -36,7 +37,7 @@ var FatalError = /** @class */ (function (_super) {
}(Error));
exports.FatalError = FatalError;
function isError(possibleError) {
- return possibleError != null && possibleError.message !== undefined;
+ return possibleError != undefined && possibleError.message !== undefined;
}
exports.isError = isError;
function showWarningOnce(message) {
diff --git a/node_modules/tslint/lib/formatterLoader.js b/node_modules/tslint/lib/formatterLoader.js
index cda997016..a117d7551 100644
--- a/node_modules/tslint/lib/formatterLoader.js
+++ b/node_modules/tslint/lib/formatterLoader.js
@@ -30,7 +30,7 @@ function findFormatter(name, formattersDirectory) {
var camelizedName = utils_1.camelize(name + "Formatter");
// first check for core formatters
var Formatter = loadFormatter(CORE_FORMATTERS_DIRECTORY, camelizedName);
- if (Formatter != null) {
+ if (Formatter !== undefined) {
return Formatter;
}
// then check for rules within the first level of rulesDirectory
diff --git a/node_modules/tslint/lib/formatters/codeFrameFormatter.js b/node_modules/tslint/lib/formatters/codeFrameFormatter.js
index 8a74160d1..c828c5700 100644
--- a/node_modules/tslint/lib/formatters/codeFrameFormatter.js
+++ b/node_modules/tslint/lib/formatters/codeFrameFormatter.js
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
var codeFrame = require("babel-code-frame");
-var colors = require("colors");
+var chalk = require("chalk");
var Utils = require("../utils");
var Formatter = /** @class */ (function (_super) {
tslib_1.__extends(Formatter, _super);
@@ -31,6 +31,7 @@ var Formatter = /** @class */ (function (_super) {
if (typeof failures[0] === "undefined") {
return "\n";
}
+ failures = this.sortFailures(failures);
var outputLines = [];
var currentFile;
for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) {
@@ -43,15 +44,15 @@ var Formatter = /** @class */ (function (_super) {
currentFile = fileName;
}
var failureString = failure.getFailure();
- failureString = colors.red(failureString);
+ failureString = chalk.red(failureString);
// Rule
var ruleName = failure.getRuleName();
- ruleName = colors.gray("(" + ruleName + ")");
+ ruleName = chalk.gray("(" + ruleName + ")");
// Frame
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var frame = codeFrame(failure.getRawLines(), lineAndCharacter.line + 1, // babel-code-frame is 1 index
lineAndCharacter.character, {
- forceColor: colors.enabled,
+ forceColor: chalk.enabled,
highlightCode: true,
});
// Ouput
diff --git a/node_modules/tslint/lib/formatters/index.d.ts b/node_modules/tslint/lib/formatters/index.d.ts
index e954e1705..ea60b24d6 100644
--- a/node_modules/tslint/lib/formatters/index.d.ts
+++ b/node_modules/tslint/lib/formatters/index.d.ts
@@ -22,3 +22,4 @@ export { Formatter as StylishFormatter } from "./stylishFormatter";
export { Formatter as FileslistFormatter } from "./fileslistFormatter";
export { Formatter as CodeFrameFormatter } from "./codeFrameFormatter";
export { Formatter as TapFormatter } from "./tapFormatter";
+export { Formatter as JUnitFormatter } from "./junitFormatter";
diff --git a/node_modules/tslint/lib/formatters/index.js b/node_modules/tslint/lib/formatters/index.js
index 213f23ddb..fd46be3ad 100644
--- a/node_modules/tslint/lib/formatters/index.js
+++ b/node_modules/tslint/lib/formatters/index.js
@@ -32,3 +32,5 @@ var codeFrameFormatter_1 = require("./codeFrameFormatter");
exports.CodeFrameFormatter = codeFrameFormatter_1.Formatter;
var tapFormatter_1 = require("./tapFormatter");
exports.TapFormatter = tapFormatter_1.Formatter;
+var junitFormatter_1 = require("./junitFormatter");
+exports.JUnitFormatter = junitFormatter_1.Formatter;
diff --git a/node_modules/tslint/lib/formatters/junitFormatter.d.ts b/node_modules/tslint/lib/formatters/junitFormatter.d.ts
new file mode 100644
index 000000000..8c6b27056
--- /dev/null
+++ b/node_modules/tslint/lib/formatters/junitFormatter.d.ts
@@ -0,0 +1,24 @@
+/**
+ * @license
+ * Copyright 2016 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { AbstractFormatter } from "../language/formatter/abstractFormatter";
+import { IFormatterMetadata } from "../language/formatter/formatter";
+import { RuleFailure } from "../language/rule/rule";
+export declare class Formatter extends AbstractFormatter {
+ static metadata: IFormatterMetadata;
+ format(failures: RuleFailure[]): string;
+ private escapeXml(str);
+}
diff --git a/node_modules/tslint/lib/formatters/junitFormatter.js b/node_modules/tslint/lib/formatters/junitFormatter.js
new file mode 100644
index 000000000..9e47ae89c
--- /dev/null
+++ b/node_modules/tslint/lib/formatters/junitFormatter.js
@@ -0,0 +1,77 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2016 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
+var Utils = require("../utils");
+var Formatter = /** @class */ (function (_super) {
+ tslib_1.__extends(Formatter, _super);
+ function Formatter() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ /* tslint:enable:object-literal-sort-keys */
+ Formatter.prototype.format = function (failures) {
+ var output = '<?xml version="1.0" encoding="utf-8"?><testsuites package="tslint">';
+ if (failures.length !== 0) {
+ var failuresSorted = failures.sort(function (a, b) { return a.getFileName().localeCompare(b.getFileName()); });
+ var previousFilename = null;
+ for (var _i = 0, failuresSorted_1 = failuresSorted; _i < failuresSorted_1.length; _i++) {
+ var failure = failuresSorted_1[_i];
+ var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
+ var message = this.escapeXml(failure.getFailure());
+ var rule = this.escapeXml(failure.getRuleName());
+ var severity = failure.getRuleSeverity();
+ if (failure.getFileName() !== previousFilename) {
+ if (previousFilename !== null) {
+ output += "</testsuite>";
+ }
+ previousFilename = failure.getFileName();
+ output += "<testsuite name=\"" + this.escapeXml(failure.getFileName()) + "\">";
+ }
+ output += "<testcase name=\"Line " + (lineAndCharacter.line + 1) + ", ";
+ output += "Column " + (lineAndCharacter.character + 1) + ": " + rule + "\">";
+ output += "<failure type=\"" + severity + "\">" + message + "</failure>";
+ output += "</testcase>";
+ }
+ if (previousFilename !== null) {
+ output += "</testsuite>";
+ }
+ }
+ output += "</testsuites>";
+ return output;
+ };
+ Formatter.prototype.escapeXml = function (str) {
+ return str
+ .replace(/&/g, "&amp;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/'/g, "&#39;")
+ .replace(/"/g, "&quot;");
+ };
+ /* tslint:disable:object-literal-sort-keys */
+ Formatter.metadata = {
+ formatterName: "junit",
+ description: "Formats errors as through they were JUnit output.",
+ descriptionDetails: (_a = ["\n Imitates the JUnit XML Output"], _a.raw = ["\n Imitates the JUnit XML Output"], Utils.dedent(_a)),
+ sample: (_b = ["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <testsuites package=\"tslint\">\n <testsuite name=\"myFile.ts\">\n <testcase name=\"Line 1, Column 14: semicolon\">\n <failure type=\"warning\">Missing semicolon</failure>\n </testcase>\n </testsuite>\n </testsuites>\n "], _b.raw = ["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <testsuites package=\"tslint\">\n <testsuite name=\"myFile.ts\">\n <testcase name=\"Line 1, Column 14: semicolon\">\n <failure type=\"warning\">Missing semicolon</failure>\n </testcase>\n </testsuite>\n </testsuites>\n "], Utils.dedent(_b)),
+ consumer: "machine",
+ };
+ return Formatter;
+}(abstractFormatter_1.AbstractFormatter));
+exports.Formatter = Formatter;
+var _a, _b;
diff --git a/node_modules/tslint/lib/formatters/msbuildFormatter.js b/node_modules/tslint/lib/formatters/msbuildFormatter.js
index b6335e02a..9edc2d9c6 100644
--- a/node_modules/tslint/lib/formatters/msbuildFormatter.js
+++ b/node_modules/tslint/lib/formatters/msbuildFormatter.js
@@ -42,11 +42,10 @@ var Formatter = /** @class */ (function (_super) {
Formatter.metadata = {
formatterName: "msbuild",
description: "Formats errors for consumption by msbuild.",
- descriptionDetails: (_a = ["\n The output is compatible with both msbuild and Visual Studio. All failures have the\n 'warning' severity."], _a.raw = ["\n The output is compatible with both msbuild and Visual Studio. All failures have the\n 'warning' severity."], utils_1.dedent(_a)),
+ descriptionDetails: "The output is compatible with both msbuild and Visual Studio.",
sample: "myFile.ts(1,14): warning: Missing semicolon",
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
-var _a;
diff --git a/node_modules/tslint/lib/formatters/proseFormatter.js b/node_modules/tslint/lib/formatters/proseFormatter.js
index 02b33e4cd..ca73001a3 100644
--- a/node_modules/tslint/lib/formatters/proseFormatter.js
+++ b/node_modules/tslint/lib/formatters/proseFormatter.js
@@ -28,6 +28,7 @@ var Formatter = /** @class */ (function (_super) {
if (failures.length === 0 && (fixes === undefined || fixes.length === 0)) {
return "\n";
}
+ failures = this.sortFailures(failures);
var fixLines = [];
if (fixes !== undefined) {
var perFileFixes = new Map();
diff --git a/node_modules/tslint/lib/formatters/stylishFormatter.js b/node_modules/tslint/lib/formatters/stylishFormatter.js
index 7c142c9e7..d3a2603c1 100644
--- a/node_modules/tslint/lib/formatters/stylishFormatter.js
+++ b/node_modules/tslint/lib/formatters/stylishFormatter.js
@@ -18,7 +18,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
-var colors = require("colors");
+var chalk = require("chalk");
var Utils = require("../utils");
var Formatter = /** @class */ (function (_super) {
tslib_1.__extends(Formatter, _super);
@@ -27,6 +27,7 @@ var Formatter = /** @class */ (function (_super) {
}
/* tslint:enable:object-literal-sort-keys */
Formatter.prototype.format = function (failures) {
+ failures = this.sortFailures(failures);
var outputLines = this.mapToMessages(failures);
// Removes initial blank line
if (outputLines[0] === "") {
@@ -52,18 +53,18 @@ var Formatter = /** @class */ (function (_super) {
currentFile = fileName;
}
var failureString = failure.getFailure();
- failureString = colors.yellow(failureString);
+ failureString = chalk.yellow(failureString);
// Rule
var ruleName = failure.getRuleName();
ruleName = this.pad(ruleName, ruleMaxSize);
- ruleName = colors.grey(ruleName);
+ ruleName = chalk.grey(ruleName);
// Lines
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var positionTuple = lineAndCharacter.line + 1 + ":" + (lineAndCharacter.character + 1);
positionTuple = this.pad(positionTuple, positionMaxSize);
positionTuple = failure.getRuleSeverity() === "warning"
- ? colors.blue(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple)
- : colors.red(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple);
+ ? chalk.blue(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple)
+ : chalk.red(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple);
// Output
var output = positionTuple + " " + ruleName + " " + failureString;
outputLines.push(output);
@@ -101,7 +102,7 @@ var Formatter = /** @class */ (function (_super) {
Formatter.metadata = {
formatterName: "stylish",
description: "Human-readable formatter which creates stylish messages.",
- descriptionDetails: (_a = ["\n The output matches that produced by eslint's stylish formatter. Its readability\n enhanced through spacing and colouring"], _a.raw = ["\n The output matches that produced by eslint's stylish formatter. Its readability\n enhanced through spacing and colouring"], Utils.dedent(_a)),
+ descriptionDetails: (_a = ["\n The output matches what is produced by ESLint's stylish formatter.\n Its readability is enhanced through spacing and colouring."], _a.raw = ["\n The output matches what is produced by ESLint's stylish formatter.\n Its readability is enhanced through spacing and colouring."], Utils.dedent(_a)),
sample: (_b = ["\n myFile.ts\n 1:14 semicolon Missing semicolon"], _b.raw = ["\n myFile.ts\n 1:14 semicolon Missing semicolon"], Utils.dedent(_b)),
consumer: "human",
};
diff --git a/node_modules/tslint/lib/formatters/verboseFormatter.js b/node_modules/tslint/lib/formatters/verboseFormatter.js
index d681a7192..eeea7310b 100644
--- a/node_modules/tslint/lib/formatters/verboseFormatter.js
+++ b/node_modules/tslint/lib/formatters/verboseFormatter.js
@@ -25,6 +25,7 @@ var Formatter = /** @class */ (function (_super) {
}
/* tslint:enable:object-literal-sort-keys */
Formatter.prototype.format = function (failures) {
+ failures = this.sortFailures(failures);
return this.mapToMessages(failures).join("\n") + "\n";
};
Formatter.prototype.mapToMessages = function (failures) {
diff --git a/node_modules/tslint/lib/formatters/vsoFormatter.d.ts b/node_modules/tslint/lib/formatters/vsoFormatter.d.ts
index d5ebd9f2b..6227c2b8c 100644
--- a/node_modules/tslint/lib/formatters/vsoFormatter.d.ts
+++ b/node_modules/tslint/lib/formatters/vsoFormatter.d.ts
@@ -19,5 +19,5 @@ import { IFormatterMetadata } from "../language/formatter/formatter";
import { RuleFailure } from "../language/rule/rule";
export declare class Formatter extends AbstractFormatter {
static metadata: IFormatterMetadata;
- format(failures: RuleFailure[], warnings?: RuleFailure[]): string;
+ format(failures: RuleFailure[]): string;
}
diff --git a/node_modules/tslint/lib/formatters/vsoFormatter.js b/node_modules/tslint/lib/formatters/vsoFormatter.js
index 1e0b35659..b98fa428d 100644
--- a/node_modules/tslint/lib/formatters/vsoFormatter.js
+++ b/node_modules/tslint/lib/formatters/vsoFormatter.js
@@ -25,10 +25,8 @@ var Formatter = /** @class */ (function (_super) {
return _super !== null && _super.apply(this, arguments) || this;
}
/* tslint:enable:object-literal-sort-keys */
- Formatter.prototype.format = function (failures, warnings) {
- if (warnings === void 0) { warnings = []; }
- var all = failures.concat(warnings);
- var outputLines = all.map(function (failure) {
+ Formatter.prototype.format = function (failures) {
+ var outputLines = failures.map(function (failure) {
var fileName = failure.getFileName();
var failureString = failure.getFailure();
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
diff --git a/node_modules/tslint/lib/language/formatter/abstractFormatter.d.ts b/node_modules/tslint/lib/language/formatter/abstractFormatter.d.ts
index 918f13803..db244af13 100644
--- a/node_modules/tslint/lib/language/formatter/abstractFormatter.d.ts
+++ b/node_modules/tslint/lib/language/formatter/abstractFormatter.d.ts
@@ -19,4 +19,5 @@ import { IFormatter, IFormatterMetadata } from "./formatter";
export declare abstract class AbstractFormatter implements IFormatter {
static metadata: IFormatterMetadata;
abstract format(failures: RuleFailure[]): string;
+ protected sortFailures(failures: RuleFailure[]): RuleFailure[];
}
diff --git a/node_modules/tslint/lib/language/formatter/abstractFormatter.js b/node_modules/tslint/lib/language/formatter/abstractFormatter.js
index 3306c7dc0..21ecc1064 100644
--- a/node_modules/tslint/lib/language/formatter/abstractFormatter.js
+++ b/node_modules/tslint/lib/language/formatter/abstractFormatter.js
@@ -16,9 +16,13 @@
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
+var rule_1 = require("../rule/rule");
var AbstractFormatter = /** @class */ (function () {
function AbstractFormatter() {
}
+ AbstractFormatter.prototype.sortFailures = function (failures) {
+ return failures.slice().sort(rule_1.RuleFailure.compare);
+ };
return AbstractFormatter;
}());
exports.AbstractFormatter = AbstractFormatter;
diff --git a/node_modules/tslint/lib/language/formatter/formatter.d.ts b/node_modules/tslint/lib/language/formatter/formatter.d.ts
index 201054396..49eb20fbe 100644
--- a/node_modules/tslint/lib/language/formatter/formatter.d.ts
+++ b/node_modules/tslint/lib/language/formatter/formatter.d.ts
@@ -44,8 +44,8 @@ export interface FormatterConstructor {
export interface IFormatter {
/**
* Formats linter results
- * @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
+ * @param failures Linter failures that were not fixed
+ * @param fixes Fixed linter failures. Available when the `--fix` argument is used on the command line
*/
format(failures: RuleFailure[], fixes?: RuleFailure[]): string;
}
diff --git a/node_modules/tslint/lib/language/rule/rule.d.ts b/node_modules/tslint/lib/language/rule/rule.d.ts
index 1004bdc6b..d1ba8ac58 100644
--- a/node_modules/tslint/lib/language/rule/rule.d.ts
+++ b/node_modules/tslint/lib/language/rule/rule.d.ts
@@ -161,6 +161,7 @@ export declare class RuleFailure {
private endPosition;
private rawLines;
private ruleSeverity;
+ static compare(a: RuleFailure, b: RuleFailure): number;
constructor(sourceFile: ts.SourceFile, start: number, end: number, failure: string, ruleName: string, fix?: Replacement | Replacement[] | undefined);
getFileName(): string;
getRuleName(): string;
diff --git a/node_modules/tslint/lib/language/rule/rule.js b/node_modules/tslint/lib/language/rule/rule.js
index 6feae5e96..d9c251842 100644
--- a/node_modules/tslint/lib/language/rule/rule.js
+++ b/node_modules/tslint/lib/language/rule/rule.js
@@ -112,6 +112,12 @@ var RuleFailure = /** @class */ (function () {
this.rawLines = sourceFile.text;
this.ruleSeverity = "error";
}
+ RuleFailure.compare = function (a, b) {
+ if (a.fileName !== b.fileName) {
+ return a.fileName < b.fileName ? -1 : 1;
+ }
+ return a.startPosition.getPosition() - b.startPosition.getPosition();
+ };
RuleFailure.prototype.getFileName = function () {
return this.fileName;
};
diff --git a/node_modules/tslint/lib/language/utils.d.ts b/node_modules/tslint/lib/language/utils.d.ts
index dc8cfc444..ffdd0aabc 100644
--- a/node_modules/tslint/lib/language/utils.d.ts
+++ b/node_modules/tslint/lib/language/utils.d.ts
@@ -23,7 +23,8 @@ export declare function childOfKind(node: ts.Node, kind: ts.SyntaxKind): ts.Node
* @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself.
*/
export declare function someAncestor(node: ts.Node, predicate: (n: ts.Node) => boolean): boolean;
-export declare function ancestorWhere<T extends ts.Node>(node: ts.Node, predicate: (n: ts.Node) => boolean): ts.Node | undefined;
+export declare function ancestorWhere<T extends ts.Node>(node: ts.Node, predicate: (n: ts.Node) => n is T): T | undefined;
+export declare function ancestorWhere(node: ts.Node, predicate: (n: ts.Node) => boolean): ts.Node | undefined;
export declare function isAssignment(node: ts.Node): boolean;
/**
* Bitwise check for node flags.
diff --git a/node_modules/tslint/lib/language/utils.js b/node_modules/tslint/lib/language/utils.js
index 30983ec6b..e9ba81a48 100644
--- a/node_modules/tslint/lib/language/utils.js
+++ b/node_modules/tslint/lib/language/utils.js
@@ -64,13 +64,13 @@ exports.isBlockScopedVariable = isBlockScopedVariable;
function isBlockScopedBindingElement(node) {
var variableDeclaration = getBindingElementVariableDeclaration(node);
// if no variable declaration, it must be a function param, which is block scoped
- return (variableDeclaration == null) || isBlockScopedVariable(variableDeclaration);
+ return (variableDeclaration === null) || isBlockScopedVariable(variableDeclaration);
}
exports.isBlockScopedBindingElement = isBlockScopedBindingElement;
function getBindingElementVariableDeclaration(node) {
var currentParent = node.parent;
while (currentParent.kind !== ts.SyntaxKind.VariableDeclaration) {
- if (currentParent.parent == null) {
+ if (currentParent.parent === undefined) {
return null; // function parameter, no variable declaration
}
else {
@@ -92,7 +92,7 @@ exports.childOfKind = childOfKind;
* @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself.
*/
function someAncestor(node, predicate) {
- return predicate(node) || (node.parent != null && someAncestor(node.parent, predicate));
+ return predicate(node) || (node.parent !== undefined && someAncestor(node.parent, predicate));
}
exports.someAncestor = someAncestor;
function ancestorWhere(node, predicate) {
diff --git a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js b/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js
index 4adc42d04..0b270d2cb 100644
--- a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js
+++ b/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js
@@ -19,7 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var utils_1 = require("../utils");
-// tslint:disable deprecation
var scopeAwareRuleWalker_1 = require("./scopeAwareRuleWalker");
/**
* @deprecated See comment on ScopeAwareRuleWalker.
diff --git a/node_modules/tslint/lib/linter.js b/node_modules/tslint/lib/linter.js
index f67c0198c..7662ed8d4 100644
--- a/node_modules/tslint/lib/linter.js
+++ b/node_modules/tslint/lib/linter.js
@@ -38,7 +38,7 @@ var Linter = /** @class */ (function () {
if (typeof options !== "object") {
throw new Error("Unknown Linter options type: " + typeof options);
}
- if (options.configuration != null) {
+ if (options.configuration != undefined) {
throw new Error("ILinterOptions does not contain the property `configuration` as of version 4. " +
"Did you mean to pass the `IConfigurationFile` object to lint() ? ");
}
@@ -81,9 +81,7 @@ var Linter = /** @class */ (function () {
fileFailures = this.applyAllFixes(enabledRules, fileFailures, sourceFile, fileName);
}
// add rule severity to failures
- var ruleSeverityMap = new Map(enabledRules.map(
- // tslint:disable-next-line no-unnecessary-type-assertion
- function (rule) { return [rule.getOptions().ruleName, rule.getOptions().ruleSeverity]; }));
+ var ruleSeverityMap = new Map(enabledRules.map(function (rule) { return [rule.getOptions().ruleName, rule.getOptions().ruleSeverity]; }));
for (var _i = 0, fileFailures_1 = fileFailures; _i < fileFailures_1.length; _i++) {
var failure = fileFailures_1[_i];
var severity = ruleSeverityMap.get(failure.getRuleName());
@@ -210,7 +208,7 @@ var Linter = /** @class */ (function () {
}
var _a;
};
- Linter.VERSION = "5.7.0";
+ Linter.VERSION = "5.8.0";
Linter.findConfiguration = configuration_1.findConfiguration;
Linter.findConfigurationPath = configuration_1.findConfigurationPath;
Linter.getRulesDirectories = configuration_1.getRulesDirectories;
diff --git a/node_modules/tslint/lib/ruleLoader.js b/node_modules/tslint/lib/ruleLoader.js
index 152f7b641..5afc659c8 100644
--- a/node_modules/tslint/lib/ruleLoader.js
+++ b/node_modules/tslint/lib/ruleLoader.js
@@ -48,7 +48,7 @@ function loadRules(ruleOptionsList, rulesDirectories, isJs) {
if (rule.isEnabled()) {
rules.push(rule);
}
- if (Rule.metadata !== undefined && Rule.metadata.deprecationMessage !== undefined) {
+ if (Rule.metadata !== undefined && Boolean(Rule.metadata.deprecationMessage)) {
error_1.showWarningOnce(Rule.metadata.ruleName + " is deprecated. " + Rule.metadata.deprecationMessage);
}
}
diff --git a/node_modules/tslint/lib/rules/arrowParensRule.js b/node_modules/tslint/lib/rules/arrowParensRule.js
index 6fa9f5537..5af83227d 100644
--- a/node_modules/tslint/lib/rules/arrowParensRule.js
+++ b/node_modules/tslint/lib/rules/arrowParensRule.js
@@ -70,8 +70,8 @@ function walk(ctx) {
else if (ctx.options.banSingleArgParens) {
var closeParen = tsutils_1.getChildOfKind(node, ts.SyntaxKind.CloseParenToken);
ctx.addFailureAtNode(node.parameters[0], Rule.FAILURE_STRING_EXISTS, [
- Lint.Replacement.deleteText(openParen.end - 1, 1),
- Lint.Replacement.deleteText(closeParen.end - 1, 1),
+ Lint.Replacement.replaceFromTo(openParen.pos, node.parameters[0].getStart(ctx.sourceFile), " "),
+ Lint.Replacement.deleteFromTo(node.parameters[0].end, closeParen.end),
]);
}
}
diff --git a/node_modules/tslint/lib/rules/awaitPromiseRule.d.ts b/node_modules/tslint/lib/rules/awaitPromiseRule.d.ts
index d2d51d1d1..b5a31ed7b 100644
--- a/node_modules/tslint/lib/rules/awaitPromiseRule.d.ts
+++ b/node_modules/tslint/lib/rules/awaitPromiseRule.d.ts
@@ -3,5 +3,6 @@ import * as Lint from "../index";
export declare class Rule extends Lint.Rules.TypedRule {
static metadata: Lint.IRuleMetadata;
static FAILURE_STRING: string;
+ static FAILURE_FOR_AWAIT_OF: string;
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[];
}
diff --git a/node_modules/tslint/lib/rules/awaitPromiseRule.js b/node_modules/tslint/lib/rules/awaitPromiseRule.js
index 69855f49f..cb1c35b08 100644
--- a/node_modules/tslint/lib/rules/awaitPromiseRule.js
+++ b/node_modules/tslint/lib/rules/awaitPromiseRule.js
@@ -47,7 +47,8 @@ var Rule = /** @class */ (function (_super) {
requiresTypeInfo: true,
};
/* tslint:enable:object-literal-sort-keys */
- Rule.FAILURE_STRING = "'await' of non-Promise.";
+ Rule.FAILURE_STRING = "Invalid 'await' of a non-Promise value.";
+ Rule.FAILURE_FOR_AWAIT_OF = "Invalid 'for-await-of' of a non-AsyncIterable value.";
return Rule;
}(Lint.Rules.TypedRule));
exports.Rule = Rule;
@@ -55,24 +56,31 @@ function walk(ctx, tc) {
var promiseTypes = ctx.options;
return ts.forEachChild(ctx.sourceFile, cb);
function cb(node) {
- if (tsutils_1.isAwaitExpression(node) && !couldBePromise(tc.getTypeAtLocation(node.expression))) {
+ if (tsutils_1.isAwaitExpression(node) && !containsType(tc.getTypeAtLocation(node.expression), isPromiseType)) {
ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
}
+ else if (tsutils_1.isForOfStatement(node) && node.awaitModifier !== undefined &&
+ !containsType(tc.getTypeAtLocation(node.expression), isAsyncIterable)) {
+ ctx.addFailureAtNode(node.expression, Rule.FAILURE_FOR_AWAIT_OF);
+ }
return ts.forEachChild(node, cb);
}
- function couldBePromise(type) {
- if (Lint.isTypeFlagSet(type, ts.TypeFlags.Any) || isPromiseType(type)) {
- return true;
- }
- if (tsutils_1.isUnionOrIntersectionType(type)) {
- return type.types.some(couldBePromise);
- }
- var bases = type.getBaseTypes();
- return bases !== undefined && bases.some(couldBePromise);
+ function isPromiseType(name) {
+ return promiseTypes.has(name);
}
- function isPromiseType(type) {
- var target = type.target;
- return target !== undefined && target.symbol !== undefined && promiseTypes.has(target.symbol.name);
+}
+function containsType(type, predicate) {
+ if (Lint.isTypeFlagSet(type, ts.TypeFlags.Any) ||
+ tsutils_1.isTypeReference(type) && type.target.symbol !== undefined && predicate(type.target.symbol.name)) {
+ return true;
+ }
+ if (tsutils_1.isUnionOrIntersectionType(type)) {
+ return type.types.some(function (t) { return containsType(t, predicate); });
}
+ var bases = type.getBaseTypes();
+ return bases !== undefined && bases.some(function (t) { return containsType(t, predicate); });
+}
+function isAsyncIterable(name) {
+ return name === "AsyncIterable" || name === "AsyncIterableIterator";
}
var _a;
diff --git a/node_modules/tslint/lib/rules/banCommaOperatorRule.d.ts b/node_modules/tslint/lib/rules/banCommaOperatorRule.d.ts
new file mode 100644
index 000000000..cce59d100
--- /dev/null
+++ b/node_modules/tslint/lib/rules/banCommaOperatorRule.d.ts
@@ -0,0 +1,7 @@
+import * as ts from "typescript";
+import * as Lint from "../index";
+export declare class Rule extends Lint.Rules.AbstractRule {
+ static metadata: Lint.IRuleMetadata;
+ static FAILURE_STRING: string;
+ apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
+}
diff --git a/node_modules/tslint/lib/rules/banCommaOperatorRule.js b/node_modules/tslint/lib/rules/banCommaOperatorRule.js
new file mode 100644
index 000000000..2a5bcede0
--- /dev/null
+++ b/node_modules/tslint/lib/rules/banCommaOperatorRule.js
@@ -0,0 +1,53 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var tsutils_1 = require("tsutils");
+var ts = require("typescript");
+var Lint = require("../index");
+var Rule = /** @class */ (function (_super) {
+ tslib_1.__extends(Rule, _super);
+ function Rule() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ Rule.prototype.apply = function (sourceFile) {
+ return this.applyWithFunction(sourceFile, walk);
+ };
+ /* tslint:disable:object-literal-sort-keys */
+ Rule.metadata = {
+ ruleName: "ban-comma-operator",
+ description: "Bans the comma operator.",
+ options: null,
+ optionsDescription: "",
+ optionExamples: [true],
+ type: "typescript",
+ typescriptOnly: true,
+ };
+ /* tslint:enable:object-literal-sort-keys */
+ Rule.FAILURE_STRING = "Don't use the comma operator.";
+ return Rule;
+}(Lint.Rules.AbstractRule));
+exports.Rule = Rule;
+function walk(ctx) {
+ return ts.forEachChild(ctx.sourceFile, function cb(node) {
+ if (tsutils_1.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.CommaToken) {
+ ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
+ }
+ return ts.forEachChild(node, cb);
+ });
+}
diff --git a/node_modules/tslint/lib/rules/callableTypesRule.js b/node_modules/tslint/lib/rules/callableTypesRule.js
index 07bd7bd0f..8c4813225 100644
--- a/node_modules/tslint/lib/rules/callableTypesRule.js
+++ b/node_modules/tslint/lib/rules/callableTypesRule.js
@@ -48,8 +48,7 @@ var Rule = /** @class */ (function (_super) {
exports.Rule = Rule;
function walk(ctx) {
return ts.forEachChild(ctx.sourceFile, function cb(node) {
- if ((tsutils_1.isInterfaceDeclaration(node) && noSupertype(node)
- || tsutils_1.isTypeLiteralNode(node))
+ if ((tsutils_1.isInterfaceDeclaration(node) && noSupertype(node) || tsutils_1.isTypeLiteralNode(node))
&& node.members.length === 1) {
var member = node.members[0];
if (tsutils_1.isCallSignatureDeclaration(member) &&
@@ -81,6 +80,9 @@ function renderSuggestion(call, parent, sourceFile) {
var colonPos = call.type.pos - 1 - start;
var text = sourceFile.text.substring(start, call.end);
var suggestion = text.substr(0, colonPos) + " =>" + text.substr(colonPos + 1);
+ if (shouldWrapSuggestion(parent.parent)) {
+ suggestion = "(" + suggestion + ")";
+ }
if (parent.kind === ts.SyntaxKind.InterfaceDeclaration) {
if (parent.typeParameters !== undefined) {
return "type" + sourceFile.text.substring(parent.name.pos, parent.typeParameters.end + 1) + " = " + suggestion;
@@ -91,3 +93,12 @@ function renderSuggestion(call, parent, sourceFile) {
}
return suggestion.endsWith(";") ? suggestion.slice(0, -1) : suggestion;
}
+function shouldWrapSuggestion(parent) {
+ switch (parent.kind) {
+ case ts.SyntaxKind.UnionType:
+ case ts.SyntaxKind.IntersectionType:
+ return true;
+ default:
+ return false;
+ }
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts
new file mode 100644
index 000000000..57eea1745
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts
@@ -0,0 +1,26 @@
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import { Visibility } from "../completedDocsRule";
+import { Exclusion } from "./exclusion";
+export interface IBlockExclusionDescriptor {
+ visibilities?: Visibility[];
+}
+export declare class BlockExclusion extends Exclusion<IBlockExclusionDescriptor> {
+ readonly visibilities: Set<Visibility>;
+ excludes(node: ts.Node): boolean;
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js
new file mode 100644
index 000000000..fdc7dabd0
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js
@@ -0,0 +1,42 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var ts = require("typescript");
+var Lint = require("../../index");
+var completedDocsRule_1 = require("../completedDocsRule");
+var exclusion_1 = require("./exclusion");
+var BlockExclusion = /** @class */ (function (_super) {
+ tslib_1.__extends(BlockExclusion, _super);
+ function BlockExclusion() {
+ var _this = _super !== null && _super.apply(this, arguments) || this;
+ _this.visibilities = _this.createSet(_this.descriptor.visibilities);
+ return _this;
+ }
+ BlockExclusion.prototype.excludes = function (node) {
+ if (this.visibilities.has(completedDocsRule_1.ALL)) {
+ return false;
+ }
+ if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
+ return !this.visibilities.has(completedDocsRule_1.VISIBILITY_EXPORTED);
+ }
+ return !this.visibilities.has(completedDocsRule_1.VISIBILITY_INTERNAL);
+ };
+ return BlockExclusion;
+}(exclusion_1.Exclusion));
+exports.BlockExclusion = BlockExclusion;
diff --git a/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts
new file mode 100644
index 000000000..a6f24bbe7
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts
@@ -0,0 +1,30 @@
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import { Location, Privacy } from "../completedDocsRule";
+import { Exclusion } from "./exclusion";
+export interface IClassExclusionDescriptor {
+ locations?: Location[];
+ privacies?: Privacy[];
+}
+export declare class ClassExclusion extends Exclusion<IClassExclusionDescriptor> {
+ readonly locations: Set<Location>;
+ readonly privacies: Set<Privacy>;
+ excludes(node: ts.Node): boolean;
+ private shouldLocationBeDocumented(node);
+ private shouldPrivacyBeDocumented(node);
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/classExclusion.js b/node_modules/tslint/lib/rules/completed-docs/classExclusion.js
new file mode 100644
index 000000000..4c8c8ec57
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/classExclusion.js
@@ -0,0 +1,59 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var ts = require("typescript");
+var Lint = require("../../index");
+var completedDocsRule_1 = require("../completedDocsRule");
+var exclusion_1 = require("./exclusion");
+var ClassExclusion = /** @class */ (function (_super) {
+ tslib_1.__extends(ClassExclusion, _super);
+ function ClassExclusion() {
+ var _this = _super !== null && _super.apply(this, arguments) || this;
+ _this.locations = _this.createSet(_this.descriptor.locations);
+ _this.privacies = _this.createSet(_this.descriptor.privacies);
+ return _this;
+ }
+ ClassExclusion.prototype.excludes = function (node) {
+ return !(this.shouldLocationBeDocumented(node)
+ && this.shouldPrivacyBeDocumented(node));
+ };
+ ClassExclusion.prototype.shouldLocationBeDocumented = function (node) {
+ if (this.locations.has(completedDocsRule_1.ALL)) {
+ return true;
+ }
+ if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) {
+ return this.locations.has(completedDocsRule_1.LOCATION_STATIC);
+ }
+ return this.locations.has(completedDocsRule_1.LOCATION_INSTANCE);
+ };
+ ClassExclusion.prototype.shouldPrivacyBeDocumented = function (node) {
+ if (this.privacies.has(completedDocsRule_1.ALL)) {
+ return true;
+ }
+ if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword)) {
+ return this.privacies.has(completedDocsRule_1.PRIVACY_PRIVATE);
+ }
+ if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.ProtectedKeyword)) {
+ return this.privacies.has(completedDocsRule_1.PRIVACY_PROTECTED);
+ }
+ return this.privacies.has(completedDocsRule_1.PRIVACY_PUBLIC);
+ };
+ return ClassExclusion;
+}(exclusion_1.Exclusion));
+exports.ClassExclusion = ClassExclusion;
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts
new file mode 100644
index 000000000..49c905491
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts
@@ -0,0 +1,25 @@
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import { All } from "../completedDocsRule";
+import { ExclusionDescriptor } from "./exclusionDescriptors";
+export declare abstract class Exclusion<TDescriptor extends ExclusionDescriptor> {
+ protected readonly descriptor: Partial<TDescriptor>;
+ constructor(descriptor?: Partial<TDescriptor>);
+ abstract excludes(node: ts.Node): boolean;
+ protected createSet<T extends All | string>(values?: T[]): Set<T>;
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusion.js b/node_modules/tslint/lib/rules/completed-docs/exclusion.js
new file mode 100644
index 000000000..ff22207c6
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusion.js
@@ -0,0 +1,33 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var completedDocsRule_1 = require("../completedDocsRule");
+var Exclusion = /** @class */ (function () {
+ function Exclusion(descriptor) {
+ if (descriptor === void 0) { descriptor = {}; }
+ this.descriptor = descriptor;
+ }
+ Exclusion.prototype.createSet = function (values) {
+ if (values === undefined || values.length === 0) {
+ values = [completedDocsRule_1.ALL];
+ }
+ return new Set(values);
+ };
+ return Exclusion;
+}());
+exports.Exclusion = Exclusion;
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts
new file mode 100644
index 000000000..9fa377421
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts
@@ -0,0 +1,28 @@
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { DocType } from "../completedDocsRule";
+import { IBlockExclusionDescriptor } from "./blockExclusion";
+import { IClassExclusionDescriptor } from "./classExclusion";
+import { ITagExclusionDescriptor } from "./tagExclusion";
+export declare type ExclusionDescriptor = IBlockExclusionDescriptor | IClassExclusionDescriptor | ITagExclusionDescriptor;
+export declare type InputExclusionDescriptor = boolean | ExclusionDescriptor;
+export interface IExclusionDescriptors {
+ [type: string]: ExclusionDescriptor;
+}
+export declare type IInputExclusionDescriptors = DocType | {
+ [type: string]: InputExclusionDescriptor;
+};
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js
new file mode 100644
index 000000000..1c258a5da
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js
@@ -0,0 +1,18 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts
new file mode 100644
index 000000000..aacf39d73
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts
@@ -0,0 +1,8 @@
+import { DocType } from "../completedDocsRule";
+import { Exclusion } from "./exclusion";
+import { IInputExclusionDescriptors } from "./exclusionDescriptors";
+export declare class ExclusionFactory {
+ constructExclusionsMap(ruleArguments: IInputExclusionDescriptors[]): Map<DocType, Array<Exclusion<any>>>;
+ private addRequirements(exclusionsMap, descriptors);
+ private createRequirementsForDocType(docType, descriptor);
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js
new file mode 100644
index 000000000..6b8f5f35a
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js
@@ -0,0 +1,60 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var utils_1 = require("../../utils");
+var blockExclusion_1 = require("./blockExclusion");
+var classExclusion_1 = require("./classExclusion");
+var tagExclusion_1 = require("./tagExclusion");
+var ExclusionFactory = /** @class */ (function () {
+ function ExclusionFactory() {
+ }
+ ExclusionFactory.prototype.constructExclusionsMap = function (ruleArguments) {
+ var exclusionsMap = new Map();
+ for (var _i = 0, ruleArguments_1 = ruleArguments; _i < ruleArguments_1.length; _i++) {
+ var ruleArgument = ruleArguments_1[_i];
+ this.addRequirements(exclusionsMap, ruleArgument);
+ }
+ return exclusionsMap;
+ };
+ ExclusionFactory.prototype.addRequirements = function (exclusionsMap, descriptors) {
+ if (typeof descriptors === "string") {
+ exclusionsMap.set(descriptors, this.createRequirementsForDocType(descriptors, {}));
+ return;
+ }
+ for (var docType in descriptors) {
+ if (utils_1.hasOwnProperty(descriptors, docType)) {
+ exclusionsMap.set(docType, this.createRequirementsForDocType(docType, descriptors[docType]));
+ }
+ }
+ };
+ ExclusionFactory.prototype.createRequirementsForDocType = function (docType, descriptor) {
+ var requirements = [];
+ if (docType === "methods" || docType === "properties") {
+ requirements.push(new classExclusion_1.ClassExclusion(descriptor));
+ }
+ else {
+ requirements.push(new blockExclusion_1.BlockExclusion(descriptor));
+ }
+ if (descriptor.tags !== undefined) {
+ requirements.push(new tagExclusion_1.TagExclusion(descriptor));
+ }
+ return requirements;
+ };
+ return ExclusionFactory;
+}());
+exports.ExclusionFactory = ExclusionFactory;
diff --git a/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts
new file mode 100644
index 000000000..d13121323
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts
@@ -0,0 +1,34 @@
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import { Exclusion } from "./exclusion";
+export interface ITagExclusionDescriptor {
+ tags?: {
+ content: IContentTags;
+ existence: string[];
+ };
+}
+export interface IContentTags {
+ [i: string]: string;
+}
+export declare class TagExclusion extends Exclusion<ITagExclusionDescriptor> {
+ private readonly contentTags;
+ private readonly existenceTags;
+ excludes(node: ts.Node): boolean;
+ private getDocumentationNode(node);
+ private parseTagsWithContents(nodeText);
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js
new file mode 100644
index 000000000..78e9babe7
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js
@@ -0,0 +1,82 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var ts = require("typescript");
+var exclusion_1 = require("./exclusion");
+var TagExclusion = /** @class */ (function (_super) {
+ tslib_1.__extends(TagExclusion, _super);
+ function TagExclusion() {
+ var _this = _super !== null && _super.apply(this, arguments) || this;
+ _this.contentTags = _this.descriptor.tags === undefined
+ ? {}
+ : _this.descriptor.tags.content;
+ _this.existenceTags = new Set(_this.descriptor.tags !== undefined && _this.descriptor.tags.existence !== undefined
+ ? _this.descriptor.tags.existence
+ : undefined);
+ return _this;
+ }
+ TagExclusion.prototype.excludes = function (node) {
+ var documentationNode = this.getDocumentationNode(node);
+ var tagsWithContents = this.parseTagsWithContents(documentationNode.getFullText());
+ for (var _i = 0, tagsWithContents_1 = tagsWithContents; _i < tagsWithContents_1.length; _i++) {
+ var tagWithContent = tagsWithContents_1[_i];
+ if (this.existenceTags.has(tagWithContent[0])) {
+ return true;
+ }
+ var matcherBody = this.contentTags[tagWithContent[0]];
+ if (matcherBody === undefined) {
+ continue;
+ }
+ if (new RegExp(matcherBody).test(tagWithContent[1])) {
+ return true;
+ }
+ }
+ return false;
+ };
+ TagExclusion.prototype.getDocumentationNode = function (node) {
+ if (node.kind === ts.SyntaxKind.VariableDeclaration) {
+ return node.parent;
+ }
+ return node;
+ };
+ TagExclusion.prototype.parseTagsWithContents = function (nodeText) {
+ if (nodeText === undefined) {
+ return [];
+ }
+ var docMatches = nodeText.match((/\/\*\*\s*\n([^\*]*(\*[^\/])?)*\*\//));
+ if (docMatches === null || docMatches.length === 0) {
+ return [];
+ }
+ var lines = docMatches[0].match(/[\r\n\s]*\*\s*@.*[\r\n\s]/g);
+ if (lines === null) {
+ return [];
+ }
+ return lines
+ .map(function (line) {
+ var body = line.substring(line.indexOf("@"));
+ var firstSpaceIndex = body.search(/\s/);
+ return [
+ body.substring(1, firstSpaceIndex),
+ body.substring(firstSpaceIndex).trim(),
+ ];
+ });
+ };
+ return TagExclusion;
+}(exclusion_1.Exclusion));
+exports.TagExclusion = TagExclusion;
diff --git a/node_modules/tslint/lib/rules/completedDocsRule.d.ts b/node_modules/tslint/lib/rules/completedDocsRule.d.ts
index 560f436e7..67c76d562 100644
--- a/node_modules/tslint/lib/rules/completedDocsRule.d.ts
+++ b/node_modules/tslint/lib/rules/completedDocsRule.d.ts
@@ -1,16 +1,6 @@
import * as ts from "typescript";
import * as Lint from "../index";
-export interface IBlockRequirementDescriptor {
- visibilities?: Visibility[];
-}
-export interface IClassRequirementDescriptor {
- locations?: Location[];
- privacies?: Privacy[];
-}
-export declare type RequirementDescriptor = IBlockRequirementDescriptor | IClassRequirementDescriptor;
-export interface IRequirementDescriptors {
- [type: string]: RequirementDescriptor;
-}
+import { IInputExclusionDescriptors } from "./completed-docs/exclusionDescriptors";
export declare const ALL = "all";
export declare const ARGUMENT_CLASSES = "classes";
export declare const ARGUMENT_ENUMS = "enums";
@@ -22,6 +12,7 @@ export declare const ARGUMENT_NAMESPACES = "namespaces";
export declare const ARGUMENT_PROPERTIES = "properties";
export declare const ARGUMENT_TYPES = "types";
export declare const ARGUMENT_VARIABLES = "variables";
+export declare const DESCRIPTOR_TAGS = "tags";
export declare const DESCRIPTOR_LOCATIONS = "locations";
export declare const DESCRIPTOR_PRIVACIES = "privacies";
export declare const DESCRIPTOR_VISIBILITIES = "visibilities";
@@ -30,6 +21,8 @@ export declare const LOCATION_STATIC = "static";
export declare const PRIVACY_PRIVATE = "private";
export declare const PRIVACY_PROTECTED = "protected";
export declare const PRIVACY_PUBLIC = "public";
+export declare const TAGS_FOR_CONTENT = "content";
+export declare const TAGS_FOR_EXISTENCE = "exists";
export declare const VISIBILITY_EXPORTED = "exported";
export declare const VISIBILITY_INTERNAL = "internal";
export declare type All = typeof ALL;
@@ -39,10 +32,19 @@ export declare type Privacy = All | typeof PRIVACY_PRIVATE | typeof PRIVACY_PROT
export declare type Visibility = All | typeof VISIBILITY_EXPORTED | typeof VISIBILITY_INTERNAL;
export declare class Rule extends Lint.Rules.TypedRule {
static FAILURE_STRING_EXIST: string;
- static defaultArguments: DocType[];
+ static defaultArguments: IInputExclusionDescriptors;
static ARGUMENT_DESCRIPTOR_BLOCK: {
properties: {
[x: string]: {
+ properties: {
+ [x: string]: {
+ items: {
+ type: string;
+ };
+ type: string;
+ };
+ };
+ } | {
enum: string[];
type: string;
};
@@ -52,6 +54,15 @@ export declare class Rule extends Lint.Rules.TypedRule {
static ARGUMENT_DESCRIPTOR_CLASS: {
properties: {
[x: string]: {
+ properties: {
+ [x: string]: {
+ items: {
+ type: string;
+ };
+ type: string;
+ };
+ };
+ } | {
enum: string[];
type: string;
};
@@ -59,6 +70,7 @@ export declare class Rule extends Lint.Rules.TypedRule {
type: string;
};
static metadata: Lint.IRuleMetadata;
+ private readonly exclusionFactory;
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[];
- private getRequirements(ruleArguments);
+ private getExclusionsMap(ruleArguments);
}
diff --git a/node_modules/tslint/lib/rules/completedDocsRule.js b/node_modules/tslint/lib/rules/completedDocsRule.js
index 5c3bf5cf2..d64315563 100644
--- a/node_modules/tslint/lib/rules/completedDocsRule.js
+++ b/node_modules/tslint/lib/rules/completedDocsRule.js
@@ -20,7 +20,7 @@ var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
-var utils_1 = require("../utils");
+var exclusionFactory_1 = require("./completed-docs/exclusionFactory");
exports.ALL = "all";
exports.ARGUMENT_CLASSES = "classes";
exports.ARGUMENT_ENUMS = "enums";
@@ -32,6 +32,7 @@ exports.ARGUMENT_NAMESPACES = "namespaces";
exports.ARGUMENT_PROPERTIES = "properties";
exports.ARGUMENT_TYPES = "types";
exports.ARGUMENT_VARIABLES = "variables";
+exports.DESCRIPTOR_TAGS = "tags";
exports.DESCRIPTOR_LOCATIONS = "locations";
exports.DESCRIPTOR_PRIVACIES = "privacies";
exports.DESCRIPTOR_VISIBILITIES = "visibilities";
@@ -40,36 +41,76 @@ exports.LOCATION_STATIC = "static";
exports.PRIVACY_PRIVATE = "private";
exports.PRIVACY_PROTECTED = "protected";
exports.PRIVACY_PUBLIC = "public";
+exports.TAGS_FOR_CONTENT = "content";
+exports.TAGS_FOR_EXISTENCE = "exists";
exports.VISIBILITY_EXPORTED = "exported";
exports.VISIBILITY_INTERNAL = "internal";
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
- return _super !== null && _super.apply(this, arguments) || this;
+ var _this = _super !== null && _super.apply(this, arguments) || this;
+ /* tslint:enable:object-literal-sort-keys */
+ _this.exclusionFactory = new exclusionFactory_1.ExclusionFactory();
+ return _this;
}
- /* tslint:enable:object-literal-sort-keys */
Rule.prototype.applyWithProgram = function (sourceFile, program) {
var options = this.getOptions();
var completedDocsWalker = new CompletedDocsWalker(sourceFile, options, program);
- completedDocsWalker.setRequirements(this.getRequirements(options.ruleArguments));
+ completedDocsWalker.setExclusionsMap(this.getExclusionsMap(options.ruleArguments));
return this.applyWithWalker(completedDocsWalker);
};
- Rule.prototype.getRequirements = function (ruleArguments) {
+ Rule.prototype.getExclusionsMap = function (ruleArguments) {
if (ruleArguments.length === 0) {
- ruleArguments = Rule.defaultArguments;
+ ruleArguments = [Rule.defaultArguments];
}
- return Requirement.constructRequirements(ruleArguments);
+ return this.exclusionFactory.constructExclusionsMap(ruleArguments);
};
Rule.FAILURE_STRING_EXIST = "Documentation must exist for ";
- Rule.defaultArguments = [
- exports.ARGUMENT_CLASSES,
- exports.ARGUMENT_FUNCTIONS,
- exports.ARGUMENT_METHODS,
- exports.ARGUMENT_PROPERTIES,
- ];
+ Rule.defaultArguments = (_a = {},
+ _a[exports.ARGUMENT_CLASSES] = true,
+ _a[exports.ARGUMENT_FUNCTIONS] = true,
+ _a[exports.ARGUMENT_METHODS] = (_b = {},
+ _b[exports.DESCRIPTOR_TAGS] = (_c = {},
+ _c[exports.TAGS_FOR_CONTENT] = {
+ see: ".*",
+ },
+ _c[exports.TAGS_FOR_EXISTENCE] = [
+ "deprecated",
+ "inheritdoc",
+ ],
+ _c),
+ _b),
+ _a[exports.ARGUMENT_PROPERTIES] = (_d = {},
+ _d[exports.DESCRIPTOR_TAGS] = (_e = {},
+ _e[exports.TAGS_FOR_CONTENT] = {
+ see: ".*",
+ },
+ _e[exports.TAGS_FOR_EXISTENCE] = [
+ "deprecated",
+ "inheritdoc",
+ ],
+ _e),
+ _d),
+ _a);
Rule.ARGUMENT_DESCRIPTOR_BLOCK = {
- properties: (_a = {},
- _a[exports.DESCRIPTOR_VISIBILITIES] = {
+ properties: (_f = {},
+ _f[exports.DESCRIPTOR_TAGS] = {
+ properties: (_g = {},
+ _g[exports.TAGS_FOR_CONTENT] = {
+ items: {
+ type: "string",
+ },
+ type: "object",
+ },
+ _g[exports.TAGS_FOR_EXISTENCE] = {
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ _g),
+ },
+ _f[exports.DESCRIPTOR_VISIBILITIES] = {
enum: [
exports.ALL,
exports.VISIBILITY_EXPORTED,
@@ -77,12 +118,28 @@ var Rule = /** @class */ (function (_super) {
],
type: "string",
},
- _a),
+ _f),
type: "object",
};
Rule.ARGUMENT_DESCRIPTOR_CLASS = {
- properties: (_b = {},
- _b[exports.DESCRIPTOR_LOCATIONS] = {
+ properties: (_h = {},
+ _h[exports.DESCRIPTOR_TAGS] = {
+ properties: (_j = {},
+ _j[exports.TAGS_FOR_CONTENT] = {
+ items: {
+ type: "string",
+ },
+ type: "object",
+ },
+ _j[exports.TAGS_FOR_EXISTENCE] = {
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ _j),
+ },
+ _h[exports.DESCRIPTOR_LOCATIONS] = {
enum: [
exports.ALL,
exports.LOCATION_INSTANCE,
@@ -90,7 +147,7 @@ var Rule = /** @class */ (function (_super) {
],
type: "string",
},
- _b[exports.DESCRIPTOR_PRIVACIES] = {
+ _h[exports.DESCRIPTOR_PRIVACIES] = {
enum: [
exports.ALL,
exports.PRIVACY_PRIVATE,
@@ -99,36 +156,46 @@ var Rule = /** @class */ (function (_super) {
],
type: "string",
},
- _b),
+ _h),
type: "object",
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "completed-docs",
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 * `\"", "\"`\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 * \\`\"", "\"\\`\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_ENUM_MEMBERS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_INTERFACES, exports.ARGUMENT_METHODS, exports.ARGUMENT_NAMESPACES, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_TYPES, exports.ARGUMENT_VARIABLES)),
+ optionsDescription: (_k = ["\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 * Other types may specify `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * All types may also provide `\"", "\"`\n with members specifying tags that allow the docs to not have a body.\n * `\"", "\"`: Object mapping tags to `RegExp` bodies content allowed to count as complete docs.\n * `\"", "\"`: Array of tags that must only exist to count as complete docs.\n\n Types that may be enabled are:\n\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`"], _k.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 * Other types may specify \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * All types may also provide \\`\"", "\"\\`\n with members specifying tags that allow the docs to not have a body.\n * \\`\"", "\"\\`: Object mapping tags to \\`RegExp\\` bodies content allowed to count as complete docs.\n * \\`\"", "\"\\`: Array of tags that must only exist to count as complete docs.\n\n Types that may be enabled are:\n\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`"], Lint.Utils.dedent(_k, Object.keys(Rule.defaultArguments).join(", "), 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.DESCRIPTOR_TAGS, exports.TAGS_FOR_CONTENT, exports.TAGS_FOR_EXISTENCE, exports.ARGUMENT_CLASSES, exports.ARGUMENT_ENUMS, exports.ARGUMENT_ENUM_MEMBERS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_INTERFACES, exports.ARGUMENT_METHODS, exports.ARGUMENT_NAMESPACES, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_TYPES, exports.ARGUMENT_VARIABLES)),
options: {
type: "array",
items: {
anyOf: [
{
- enum: Rule.defaultArguments,
+ options: [
+ 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,
+ ],
type: "string",
},
{
type: "object",
- properties: (_d = {},
- _d[exports.ARGUMENT_CLASSES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
- _d[exports.ARGUMENT_ENUMS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
- _d[exports.ARGUMENT_ENUM_MEMBERS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
- _d[exports.ARGUMENT_FUNCTIONS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
- _d[exports.ARGUMENT_INTERFACES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
- _d[exports.ARGUMENT_METHODS] = Rule.ARGUMENT_DESCRIPTOR_CLASS,
- _d[exports.ARGUMENT_NAMESPACES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
- _d[exports.ARGUMENT_PROPERTIES] = Rule.ARGUMENT_DESCRIPTOR_CLASS,
- _d[exports.ARGUMENT_TYPES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
- _d[exports.ARGUMENT_VARIABLES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
- _d),
+ properties: (_l = {},
+ _l[exports.ARGUMENT_CLASSES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
+ _l[exports.ARGUMENT_ENUMS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
+ _l[exports.ARGUMENT_ENUM_MEMBERS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
+ _l[exports.ARGUMENT_FUNCTIONS] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
+ _l[exports.ARGUMENT_INTERFACES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
+ _l[exports.ARGUMENT_METHODS] = Rule.ARGUMENT_DESCRIPTOR_CLASS,
+ _l[exports.ARGUMENT_NAMESPACES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
+ _l[exports.ARGUMENT_PROPERTIES] = Rule.ARGUMENT_DESCRIPTOR_CLASS,
+ _l[exports.ARGUMENT_TYPES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
+ _l[exports.ARGUMENT_VARIABLES] = Rule.ARGUMENT_DESCRIPTOR_BLOCK,
+ _l),
},
],
},
@@ -138,118 +205,38 @@ var Rule = /** @class */ (function (_super) {
[true, exports.ARGUMENT_ENUMS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_METHODS],
[
true,
- (_e = {},
- _e[exports.ARGUMENT_ENUMS] = true,
- _e[exports.ARGUMENT_FUNCTIONS] = (_f = {},
- _f[exports.DESCRIPTOR_VISIBILITIES] = [exports.VISIBILITY_EXPORTED],
- _f),
- _e[exports.ARGUMENT_METHODS] = (_g = {},
- _g[exports.DESCRIPTOR_LOCATIONS] = exports.LOCATION_INSTANCE,
- _g[exports.DESCRIPTOR_PRIVACIES] = [exports.PRIVACY_PUBLIC, exports.PRIVACY_PROTECTED],
- _g),
- _e),
+ (_m = {},
+ _m[exports.ARGUMENT_ENUMS] = true,
+ _m[exports.ARGUMENT_FUNCTIONS] = (_o = {},
+ _o[exports.DESCRIPTOR_VISIBILITIES] = [exports.VISIBILITY_EXPORTED],
+ _o),
+ _m[exports.ARGUMENT_METHODS] = (_p = {},
+ _p[exports.DESCRIPTOR_LOCATIONS] = exports.LOCATION_INSTANCE,
+ _p[exports.DESCRIPTOR_PRIVACIES] = [exports.PRIVACY_PUBLIC, exports.PRIVACY_PROTECTED],
+ _p),
+ _m[exports.DESCRIPTOR_TAGS] = (_q = {},
+ _q[exports.TAGS_FOR_CONTENT] = {
+ see: ["#.*"],
+ },
+ _q[exports.TAGS_FOR_EXISTENCE] = ["inheritdoc"],
+ _q),
+ _m),
],
],
type: "style",
typescriptOnly: false,
+ requiresTypeInfo: true,
};
return Rule;
}(Lint.Rules.TypedRule));
exports.Rule = Rule;
-var Requirement = /** @class */ (function () {
- // tslint:disable-next-line no-object-literal-type-assertion
- function Requirement(descriptor) {
- if (descriptor === void 0) { descriptor = {}; }
- this.descriptor = descriptor;
- }
- Requirement.constructRequirements = function (ruleArguments) {
- var requirements = new Map();
- for (var _i = 0, ruleArguments_1 = ruleArguments; _i < ruleArguments_1.length; _i++) {
- var ruleArgument = ruleArguments_1[_i];
- Requirement.addRequirements(requirements, ruleArgument);
- }
- return requirements;
- };
- Requirement.addRequirements = function (requirements, descriptor) {
- if (typeof descriptor === "string") {
- requirements.set(descriptor, new BlockRequirement());
- return;
- }
- for (var type in descriptor) {
- if (utils_1.hasOwnProperty(descriptor, type)) {
- requirements.set(type, (type === "methods" || type === "properties")
- ? new ClassRequirement(descriptor[type])
- : new BlockRequirement(descriptor[type]));
- }
- }
- };
- Requirement.prototype.createSet = function (values) {
- if (values === undefined || values.length === 0) {
- values = [exports.ALL];
- }
- return new Set(values);
- };
- return Requirement;
-}());
-var BlockRequirement = /** @class */ (function (_super) {
- tslib_1.__extends(BlockRequirement, _super);
- function BlockRequirement() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.visibilities = _this.createSet(_this.descriptor.visibilities);
- return _this;
- }
- BlockRequirement.prototype.shouldNodeBeDocumented = function (node) {
- if (this.visibilities.has(exports.ALL)) {
- return true;
- }
- if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
- return this.visibilities.has(exports.VISIBILITY_EXPORTED);
- }
- return this.visibilities.has(exports.VISIBILITY_INTERNAL);
- };
- return BlockRequirement;
-}(Requirement));
-var ClassRequirement = /** @class */ (function (_super) {
- tslib_1.__extends(ClassRequirement, _super);
- function ClassRequirement() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.locations = _this.createSet(_this.descriptor.locations);
- _this.privacies = _this.createSet(_this.descriptor.privacies);
- return _this;
- }
- ClassRequirement.prototype.shouldNodeBeDocumented = function (node) {
- return this.shouldLocationBeDocumented(node) && this.shouldPrivacyBeDocumented(node);
- };
- ClassRequirement.prototype.shouldLocationBeDocumented = function (node) {
- if (this.locations.has(exports.ALL)) {
- return true;
- }
- if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) {
- return this.locations.has(exports.LOCATION_STATIC);
- }
- return this.locations.has(exports.LOCATION_INSTANCE);
- };
- ClassRequirement.prototype.shouldPrivacyBeDocumented = function (node) {
- if (this.privacies.has(exports.ALL)) {
- return true;
- }
- if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword)) {
- return this.privacies.has(exports.PRIVACY_PRIVATE);
- }
- if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.ProtectedKeyword)) {
- return this.privacies.has(exports.PRIVACY_PROTECTED);
- }
- return this.privacies.has(exports.PRIVACY_PUBLIC);
- };
- return ClassRequirement;
-}(Requirement));
var CompletedDocsWalker = /** @class */ (function (_super) {
tslib_1.__extends(CompletedDocsWalker, _super);
function CompletedDocsWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
- CompletedDocsWalker.prototype.setRequirements = function (requirements) {
- this.requirements = requirements;
+ CompletedDocsWalker.prototype.setExclusionsMap = function (exclusionsMap) {
+ this.exclusionsMap = exclusionsMap;
};
CompletedDocsWalker.prototype.visitClassDeclaration = function (node) {
this.checkNode(node, exports.ARGUMENT_CLASSES);
@@ -293,6 +280,29 @@ var CompletedDocsWalker = /** @class */ (function (_super) {
this.checkVariable(node);
_super.prototype.visitVariableDeclaration.call(this, node);
};
+ CompletedDocsWalker.prototype.checkNode = function (node, nodeType, requirementNode) {
+ if (requirementNode === void 0) { requirementNode = node; }
+ var name = node.name;
+ if (name === undefined) {
+ return;
+ }
+ var exclusions = this.exclusionsMap.get(nodeType);
+ if (exclusions === undefined) {
+ return;
+ }
+ for (var _i = 0, exclusions_1 = exclusions; _i < exclusions_1.length; _i++) {
+ var exclusion = exclusions_1[_i];
+ if (exclusion.excludes(requirementNode)) {
+ return;
+ }
+ }
+ var symbol = this.getTypeChecker().getSymbolAtLocation(name);
+ if (symbol === undefined) {
+ return;
+ }
+ var comments = symbol.getDocumentationComment();
+ this.checkComments(node, this.describeNode(nodeType), comments, requirementNode);
+ };
CompletedDocsWalker.prototype.checkVariable = function (node) {
// Only check variables in variable declaration lists
// and not variables in catch clauses and for loops.
@@ -312,26 +322,6 @@ var CompletedDocsWalker = /** @class */ (function (_super) {
this.checkNode(node, exports.ARGUMENT_VARIABLES, statement);
}
};
- CompletedDocsWalker.prototype.checkNode = function (node, nodeType, requirementNode) {
- if (requirementNode === void 0) { requirementNode = node; }
- var name = node.name;
- if (name === undefined) {
- return;
- }
- var requirement = this.requirements.get(nodeType);
- if (requirement === undefined || !requirement.shouldNodeBeDocumented(requirementNode)) {
- return;
- }
- var symbol = this.getTypeChecker().getSymbolAtLocation(name);
- if (symbol === undefined) {
- return;
- }
- var comments = symbol.getDocumentationComment();
- this.checkComments(node, this.describeNode(nodeType), comments, requirementNode);
- };
- CompletedDocsWalker.prototype.describeNode = function (nodeType) {
- return nodeType.replace("-", " ");
- };
CompletedDocsWalker.prototype.checkComments = function (node, nodeDescriptor, comments, requirementNode) {
if (comments.map(function (comment) { return comment.text; }).join("").trim() === "") {
this.addDocumentationFailure(node, nodeDescriptor, requirementNode);
@@ -356,9 +346,12 @@ var CompletedDocsWalker = /** @class */ (function (_super) {
var alias = CompletedDocsWalker.modifierAliases[description];
return alias !== undefined ? alias : description;
};
+ CompletedDocsWalker.prototype.describeNode = function (nodeType) {
+ return nodeType.replace("-", " ");
+ };
CompletedDocsWalker.modifierAliases = {
export: "exported",
};
return CompletedDocsWalker;
}(Lint.ProgramAwareRuleWalker));
-var _a, _b, _c, _d, _e, _f, _g;
+var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
diff --git a/node_modules/tslint/lib/rules/curlyRule.js b/node_modules/tslint/lib/rules/curlyRule.js
index dbd14038d..906201a12 100644
--- a/node_modules/tslint/lib/rules/curlyRule.js
+++ b/node_modules/tslint/lib/rules/curlyRule.js
@@ -61,6 +61,7 @@ var Rule = /** @class */ (function (_super) {
],
type: "functionality",
typescriptOnly: false,
+ hasFix: true,
};
/* tslint:enable:object-literal-sort-keys */
Rule.FAILURE_STRING_AS_NEEDED = "Block contains only one statement; remove the curly braces.";
@@ -120,11 +121,33 @@ var CurlyWalker = /** @class */ (function (_super) {
};
CurlyWalker.prototype.checkStatement = function (statement, node, childIndex, end) {
if (end === void 0) { end = statement.end; }
+ var sameLine = tsutils_1.isSameLine(this.sourceFile, statement.pos, statement.end);
if (statement.kind !== ts.SyntaxKind.Block &&
- !(this.options.ignoreSameLine && tsutils_1.isSameLine(this.sourceFile, statement.pos, statement.end))) {
+ !(this.options.ignoreSameLine && sameLine)) {
var token = node.getChildAt(childIndex, this.sourceFile);
var tokenText = ts.tokenToString(token.kind);
- this.addFailure(token.end - tokenText.length, end, Rule.FAILURE_STRING_FACTORY(tokenText));
+ this.addFailure(token.end - tokenText.length, end, Rule.FAILURE_STRING_FACTORY(tokenText), this.createMissingBraceFix(statement, node, sameLine));
+ }
+ };
+ /** Generate the necessary replacement to add braces to a statement that needs them. */
+ CurlyWalker.prototype.createMissingBraceFix = function (statement, node, sameLine) {
+ if (sameLine) {
+ return [
+ Lint.Replacement.appendText(statement.getStart(), "{ "),
+ Lint.Replacement.appendText(statement.getEnd(), " }"),
+ ];
+ }
+ else {
+ var match = /\n([\t ])/.exec(node.getFullText(this.sourceFile)); // determine which character to use (tab or space)
+ var indentation = match === null ?
+ "" :
+ // indentation should match start of statement
+ match[1].repeat(ts.getLineAndCharacterOfPosition(this.sourceFile, node.getStart(this.sourceFile)).character);
+ var maybeCarriageReturn = this.sourceFile.text[this.sourceFile.getLineEndOfPosition(node.pos) - 1] === "\r" ? "\r" : "";
+ return [
+ Lint.Replacement.appendText(this.sourceFile.getLineEndOfPosition(statement.pos), " {"),
+ Lint.Replacement.appendText(statement.getEnd(), maybeCarriageReturn + "\n" + indentation + "}"),
+ ];
}
};
return CurlyWalker;
diff --git a/node_modules/tslint/lib/rules/deprecationRule.js b/node_modules/tslint/lib/rules/deprecationRule.js
index ef6180125..bcd8a7da4 100644
--- a/node_modules/tslint/lib/rules/deprecationRule.js
+++ b/node_modules/tslint/lib/rules/deprecationRule.js
@@ -88,16 +88,17 @@ function isDeclaration(identifier) {
case ts.SyntaxKind.GetAccessor:
case ts.SyntaxKind.SetAccessor:
case ts.SyntaxKind.EnumDeclaration:
+ case ts.SyntaxKind.ModuleDeclaration:
return true;
case ts.SyntaxKind.VariableDeclaration:
- case ts.SyntaxKind.TypeAliasDeclaration:
case ts.SyntaxKind.Parameter:
- case ts.SyntaxKind.ModuleDeclaration:
case ts.SyntaxKind.PropertyDeclaration:
- case ts.SyntaxKind.PropertyAssignment:
case ts.SyntaxKind.EnumMember:
case ts.SyntaxKind.ImportEqualsDeclaration:
return parent.name === identifier;
+ case ts.SyntaxKind.PropertyAssignment:
+ return parent.name === identifier &&
+ !tsutils_1.isReassignmentTarget(identifier.parent.parent);
case ts.SyntaxKind.BindingElement:
// return true for `b` in `const {a: b} = obj"`
return parent.name === identifier &&
@@ -112,7 +113,9 @@ function getCallExpresion(node) {
node = parent;
parent = node.parent;
}
- return tsutils_1.isTaggedTemplateExpression(parent) || tsutils_1.isCallExpression(parent) && parent.expression === node ? parent : undefined;
+ return tsutils_1.isTaggedTemplateExpression(parent) || (tsutils_1.isCallExpression(parent) || tsutils_1.isNewExpression(parent)) && parent.expression === node
+ ? parent
+ : undefined;
}
function getDeprecation(node, tc) {
var callExpression = getCallExpresion(node);
@@ -122,7 +125,18 @@ function getDeprecation(node, tc) {
return result;
}
}
- var symbol = tc.getSymbolAtLocation(node);
+ var symbol;
+ var parent = node.parent;
+ if (parent.kind === ts.SyntaxKind.BindingElement) {
+ symbol = tc.getTypeAtLocation(parent.parent).getProperty(node.text);
+ }
+ else if (tsutils_1.isPropertyAssignment(parent) && parent.name === node ||
+ tsutils_1.isShorthandPropertyAssignment(parent) && parent.name === node && tsutils_1.isReassignmentTarget(node)) {
+ symbol = tc.getPropertySymbolOfDestructuringAssignment(node);
+ }
+ else {
+ symbol = tc.getSymbolAtLocation(node);
+ }
if (symbol !== undefined && Lint.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)) {
symbol = tc.getAliasedSymbol(symbol);
}
@@ -184,15 +198,12 @@ function getDeprecationFromDeclarations(declarations) {
return undefined;
}
function getDeprecationFromDeclaration(declaration) {
- for (var _i = 0, _a = declaration.getChildren(); _i < _a.length; _i++) {
- var child = _a[_i];
- if (!tsutils_1.isJsDoc(child)) {
- break;
- }
- if (child.tags === undefined) {
+ for (var _i = 0, _a = tsutils_1.getJsDoc(declaration); _i < _a.length; _i++) {
+ var comment = _a[_i];
+ if (comment.tags === undefined) {
continue;
}
- for (var _b = 0, _c = child.tags; _b < _c.length; _b++) {
+ for (var _b = 0, _c = comment.tags; _b < _c.length; _b++) {
var tag = _c[_b];
if (tag.tagName.text === "deprecated") {
return tag.comment === undefined ? "" : tag.comment;
diff --git a/node_modules/tslint/lib/rules/importBlacklistRule.js b/node_modules/tslint/lib/rules/importBlacklistRule.js
index c99110b96..c79242cfa 100644
--- a/node_modules/tslint/lib/rules/importBlacklistRule.js
+++ b/node_modules/tslint/lib/rules/importBlacklistRule.js
@@ -18,7 +18,6 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
-var ts = require("typescript");
var Lint = require("../index");
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
@@ -29,7 +28,7 @@ var Rule = /** @class */ (function (_super) {
return _super.prototype.isEnabled.call(this) && this.ruleArguments.length > 0;
};
Rule.prototype.apply = function (sourceFile) {
- return this.applyWithWalker(new ImportBlacklistWalker(sourceFile, this.ruleName, this.ruleArguments));
+ return this.applyWithFunction(sourceFile, walk, this.ruleArguments);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
@@ -52,40 +51,12 @@ var Rule = /** @class */ (function (_super) {
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
-var ImportBlacklistWalker = /** @class */ (function (_super) {
- tslib_1.__extends(ImportBlacklistWalker, _super);
- function ImportBlacklistWalker() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ImportBlacklistWalker.prototype.walk = function (sourceFile) {
- var _this = this;
- var findRequire = function (node) {
- if (tsutils_1.isCallExpression(node) && node.arguments.length === 1 &&
- tsutils_1.isIdentifier(node.expression) && node.expression.text === "require") {
- _this.checkForBannedImport(node.arguments[0]);
- }
- return ts.forEachChild(node, findRequire);
- };
- for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
- var statement = _a[_i];
- if (tsutils_1.isImportDeclaration(statement)) {
- this.checkForBannedImport(statement.moduleSpecifier);
- }
- else if (tsutils_1.isImportEqualsDeclaration(statement)) {
- if (tsutils_1.isExternalModuleReference(statement.moduleReference) && statement.moduleReference.expression !== undefined) {
- this.checkForBannedImport(statement.moduleReference.expression);
- }
- }
- else {
- ts.forEachChild(statement, findRequire);
- }
- }
- };
- ImportBlacklistWalker.prototype.checkForBannedImport = function (expression) {
- if (tsutils_1.isTextualLiteral(expression) && this.options.indexOf(expression.text) !== -1) {
- this.addFailure(expression.getStart(this.sourceFile) + 1, expression.end - 1, Rule.FAILURE_STRING);
+function walk(ctx) {
+ for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 31 /* All */); _i < _a.length; _i++) {
+ var name = _a[_i];
+ if (ctx.options.indexOf(name.text) !== -1) {
+ ctx.addFailure(name.getStart(ctx.sourceFile) + 1, name.end - 1, Rule.FAILURE_STRING);
}
- };
- return ImportBlacklistWalker;
-}(Lint.AbstractWalker));
+ }
+}
var _a, _b;
diff --git a/node_modules/tslint/lib/rules/jsdocFormatRule.js b/node_modules/tslint/lib/rules/jsdocFormatRule.js
index 329cf2538..b75550a6d 100644
--- a/node_modules/tslint/lib/rules/jsdocFormatRule.js
+++ b/node_modules/tslint/lib/rules/jsdocFormatRule.js
@@ -20,23 +20,34 @@ var tslib_1 = require("tslib");
var utils = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
+var OPTION_CHECK_MULTILINE_START = "check-multiline-start";
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
- return this.applyWithFunction(sourceFile, walk);
+ return this.applyWithFunction(sourceFile, walk, {
+ firstLineOfMultiline: this.ruleArguments.indexOf(OPTION_CHECK_MULTILINE_START) !== -1,
+ });
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "jsdoc-format",
description: "Enforces basic format rules for JSDoc comments.",
- descriptionDetails: (_a = ["\n The following rules are enforced for JSDoc comments (comments starting with `/**`):\n\n * each line contains an asterisk and asterisks must be aligned\n * each asterisk must be followed by either a space or a newline (except for the first and the last)\n * the only characters before the asterisk on each line must be whitespace characters\n * one line comments must start with `/** ` and end with `*/`"], _a.raw = ["\n The following rules are enforced for JSDoc comments (comments starting with \\`/**\\`):\n\n * each line contains an asterisk and asterisks must be aligned\n * each asterisk must be followed by either a space or a newline (except for the first and the last)\n * the only characters before the asterisk on each line must be whitespace characters\n * one line comments must start with \\`/** \\` and end with \\`*/\\`"], Lint.Utils.dedent(_a)),
+ descriptionDetails: (_a = ["\n The following rules are enforced for JSDoc comments (comments starting with `/**`):\n\n * each line contains an asterisk and asterisks must be aligned\n * each asterisk must be followed by either a space or a newline (except for the first and the last)\n * the only characters before the asterisk on each line must be whitespace characters\n * one line comments must start with `/** ` and end with `*/`\n * multiline comments don't allow text after `/** ` in the first line (with option `\"", "\"`)\n "], _a.raw = ["\n The following rules are enforced for JSDoc comments (comments starting with \\`/**\\`):\n\n * each line contains an asterisk and asterisks must be aligned\n * each asterisk must be followed by either a space or a newline (except for the first and the last)\n * the only characters before the asterisk on each line must be whitespace characters\n * one line comments must start with \\`/** \\` and end with \\`*/\\`\n * multiline comments don't allow text after \\`/** \\` in the first line (with option \\`\"", "\"\\`)\n "], Lint.Utils.dedent(_a, OPTION_CHECK_MULTILINE_START)),
rationale: "Helps maintain a consistent, readable style for JSDoc comments.",
- optionsDescription: "Not configurable.",
- options: null,
- optionExamples: [true],
+ optionsDescription: (_b = ["\n You can optionally specify the option `\"", "\"` to enforce the first line of a\n multiline JSDoc comment to be empty.\n "], _b.raw = ["\n You can optionally specify the option \\`\"", "\"\\` to enforce the first line of a\n multiline JSDoc comment to be empty.\n "], Lint.Utils.dedent(_b, OPTION_CHECK_MULTILINE_START)),
+ options: {
+ type: "array",
+ minItems: 0,
+ maxItems: 1,
+ items: {
+ type: "string",
+ enum: [OPTION_CHECK_MULTILINE_START],
+ },
+ },
+ optionExamples: [true, [true, OPTION_CHECK_MULTILINE_START]],
type: "style",
typescriptOnly: false,
};
@@ -62,6 +73,10 @@ function walk(ctx) {
return;
}
var alignColumn = getAlignColumn(ctx.sourceFile, pos + 1);
+ if (ctx.options.firstLineOfMultiline && /\S/.test(firstLine)) {
+ // first line of multiline JSDoc should be empty, i.e. only contain whitespace
+ ctx.addFailureAt(pos, firstLine.length + 3, Rule.FORMAT_FAILURE_STRING);
+ }
var lineStart = pos + firstLine.length + 4; // +3 for the comment start "/**" and +1 for the newline
var endIndex = lines.length - 1;
for (var i = 1; i < endIndex; ++i) {
@@ -93,4 +108,4 @@ function getAlignColumn(sourceFile, pos) {
? result.character - 1
: result.character;
}
-var _a;
+var _a, _b;
diff --git a/node_modules/tslint/lib/rules/maxClassesPerFileRule.js b/node_modules/tslint/lib/rules/maxClassesPerFileRule.js
index c5921368b..74092147c 100644
--- a/node_modules/tslint/lib/rules/maxClassesPerFileRule.js
+++ b/node_modules/tslint/lib/rules/maxClassesPerFileRule.js
@@ -20,6 +20,7 @@ var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
+var OPTION_EXCLUDE_CLASS_EXPRESSIONS = "exclude-class-expressions";
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
@@ -33,14 +34,17 @@ var Rule = /** @class */ (function (_super) {
Rule.prototype.apply = function (sourceFile) {
var argument = this.ruleArguments[0];
var maxClasses = isNaN(argument) || argument > 0 ? argument : 1;
- return this.applyWithFunction(sourceFile, walk, { maxClasses: maxClasses });
+ return this.applyWithFunction(sourceFile, walk, {
+ excludeClassExpressions: this.ruleArguments.indexOf(OPTION_EXCLUDE_CLASS_EXPRESSIONS) !== -1,
+ maxClasses: maxClasses,
+ });
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "max-classes-per-file",
description: (_a = ["\n A file may not contain more than the specified number of classes"], _a.raw = ["\n A file may not contain more than the specified number of classes"], Lint.Utils.dedent(_a)),
rationale: (_b = ["\n Ensures that files have a single responsibility so that that classes each exist in their own files"], _b.raw = ["\n Ensures that files have a single responsibility so that that classes each exist in their own files"], Lint.Utils.dedent(_b)),
- optionsDescription: (_c = ["\n The one required argument is an integer indicating the maximum number of classes that can appear in a file."], _c.raw = ["\n The one required argument is an integer indicating the maximum number of classes that can appear in a file."], Lint.Utils.dedent(_c)),
+ optionsDescription: (_c = ["\n The one required argument is an integer indicating the maximum number of classes that can appear in a\n file. An optional argument `\"exclude-class-expressions\"` can be provided to exclude class expressions\n from the overall class count."], _c.raw = ["\n The one required argument is an integer indicating the maximum number of classes that can appear in a\n file. An optional argument \\`\"exclude-class-expressions\"\\` can be provided to exclude class expressions\n from the overall class count."], Lint.Utils.dedent(_c)),
options: {
type: "array",
items: [
@@ -48,12 +52,16 @@ var Rule = /** @class */ (function (_super) {
type: "number",
minimum: 1,
},
+ {
+ type: "string",
+ enum: [OPTION_EXCLUDE_CLASS_EXPRESSIONS],
+ },
],
additionalItems: false,
minLength: 1,
maxLength: 2,
},
- optionExamples: [[true, 1], [true, 5]],
+ optionExamples: [[true, 1], [true, 5, OPTION_EXCLUDE_CLASS_EXPRESSIONS]],
type: "maintainability",
typescriptOnly: false,
};
@@ -61,10 +69,10 @@ var Rule = /** @class */ (function (_super) {
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
- var sourceFile = ctx.sourceFile, maxClasses = ctx.options.maxClasses;
+ var sourceFile = ctx.sourceFile, _a = ctx.options, maxClasses = _a.maxClasses, excludeClassExpressions = _a.excludeClassExpressions;
var classes = 0;
return ts.forEachChild(sourceFile, function cb(node) {
- if (tsutils_1.isClassLikeDeclaration(node)) {
+ if (tsutils_1.isClassDeclaration(node) || (!excludeClassExpressions && tsutils_1.isClassExpression(node))) {
classes++;
if (classes > maxClasses) {
ctx.addFailureAtNode(node, Rule.FAILURE_STRING(maxClasses));
diff --git a/node_modules/tslint/lib/rules/memberAccessRule.js b/node_modules/tslint/lib/rules/memberAccessRule.js
index 599a0952e..abb843b04 100644
--- a/node_modules/tslint/lib/rules/memberAccessRule.js
+++ b/node_modules/tslint/lib/rules/memberAccessRule.js
@@ -24,6 +24,7 @@ var Lint = require("../index");
var OPTION_NO_PUBLIC = "no-public";
var OPTION_CHECK_ACCESSOR = "check-accessor";
var OPTION_CHECK_CONSTRUCTOR = "check-constructor";
+var OPTION_CHECK_PARAMETER_PROPERTY = "check-parameter-property";
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
@@ -38,16 +39,18 @@ var Rule = /** @class */ (function (_super) {
var noPublic = options.indexOf(OPTION_NO_PUBLIC) !== -1;
var checkAccessor = options.indexOf(OPTION_CHECK_ACCESSOR) !== -1;
var checkConstructor = options.indexOf(OPTION_CHECK_CONSTRUCTOR) !== -1;
+ var checkParameterProperty = options.indexOf(OPTION_CHECK_PARAMETER_PROPERTY) !== -1;
if (noPublic) {
- if (checkAccessor || checkConstructor) {
+ if (checkAccessor || checkConstructor || checkParameterProperty) {
error_1.showWarningOnce("Warning: " + this.ruleName + " - If 'no-public' is present, it should be the only option.");
return [];
}
- checkAccessor = checkConstructor = true;
+ checkAccessor = checkConstructor = checkParameterProperty = true;
}
return this.applyWithFunction(sourceFile, walk, {
checkAccessor: checkAccessor,
checkConstructor: checkConstructor,
+ checkParameterProperty: checkParameterProperty,
noPublic: noPublic,
});
};
@@ -56,15 +59,15 @@ var Rule = /** @class */ (function (_super) {
ruleName: "member-access",
description: "Requires explicit visibility declarations for class members.",
rationale: "Explicit visibility declarations can make code more readable and accessible for those new to TS.",
- optionsDescription: (_a = ["\n These arguments may be optionally provided:\n\n * `\"no-public\"` forbids public accessibility to be specified, because this is the default.\n * `\"check-accessor\"` enforces explicit visibility on get/set accessors\n * `\"check-constructor\"` enforces explicit visibility on constructors"], _a.raw = ["\n These arguments may be optionally provided:\n\n * \\`\"no-public\"\\` forbids public accessibility to be specified, because this is the default.\n * \\`\"check-accessor\"\\` enforces explicit visibility on get/set accessors\n * \\`\"check-constructor\"\\` enforces explicit visibility on constructors"], Lint.Utils.dedent(_a)),
+ optionsDescription: (_a = ["\n These arguments may be optionally provided:\n\n * `\"no-public\"` forbids public accessibility to be specified, because this is the default.\n * `\"check-accessor\"` enforces explicit visibility on get/set accessors\n * `\"check-constructor\"` enforces explicit visibility on constructors\n * `\"check-parameter-property\"` enforces explicit visibility on parameter properties"], _a.raw = ["\n These arguments may be optionally provided:\n\n * \\`\"no-public\"\\` forbids public accessibility to be specified, because this is the default.\n * \\`\"check-accessor\"\\` enforces explicit visibility on get/set accessors\n * \\`\"check-constructor\"\\` enforces explicit visibility on constructors\n * \\`\"check-parameter-property\"\\` enforces explicit visibility on parameter properties"], Lint.Utils.dedent(_a)),
options: {
type: "array",
items: {
type: "string",
- enum: [OPTION_NO_PUBLIC, OPTION_CHECK_ACCESSOR, OPTION_CHECK_CONSTRUCTOR],
+ enum: [OPTION_NO_PUBLIC, OPTION_CHECK_ACCESSOR, OPTION_CHECK_CONSTRUCTOR, OPTION_CHECK_PARAMETER_PROPERTY],
},
minLength: 0,
- maxLength: 3,
+ maxLength: 4,
},
optionExamples: [true, [true, OPTION_NO_PUBLIC], [true, OPTION_CHECK_ACCESSOR]],
type: "typescript",
@@ -77,7 +80,7 @@ var Rule = /** @class */ (function (_super) {
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
- var _a = ctx.options, noPublic = _a.noPublic, checkAccessor = _a.checkAccessor, checkConstructor = _a.checkConstructor;
+ var _a = ctx.options, noPublic = _a.noPublic, checkAccessor = _a.checkAccessor, checkConstructor = _a.checkConstructor, checkParameterProperty = _a.checkParameterProperty;
return ts.forEachChild(ctx.sourceFile, function recur(node) {
if (tsutils_1.isClassLikeDeclaration(node)) {
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -85,6 +88,14 @@ function walk(ctx) {
if (shouldCheck(child)) {
check(child);
}
+ if (checkParameterProperty && tsutils_1.isConstructorDeclaration(child) && child.body !== undefined) {
+ for (var _b = 0, _c = child.parameters; _b < _c.length; _b++) {
+ var param = _c[_b];
+ if (tsutils_1.isParameterProperty(param)) {
+ check(param);
+ }
+ }
+ }
}
}
return ts.forEachChild(node, recur);
@@ -109,8 +120,13 @@ function walk(ctx) {
}
var publicKeyword = tsutils_1.getModifier(node, ts.SyntaxKind.PublicKeyword);
if (noPublic && publicKeyword !== undefined) {
- var start = publicKeyword.end - "public".length;
- ctx.addFailure(start, publicKeyword.end, Rule.FAILURE_STRING_NO_PUBLIC, Lint.Replacement.deleteFromTo(start, tsutils_1.getNextToken(publicKeyword, ctx.sourceFile).getStart(ctx.sourceFile)));
+ var readonlyKeyword = tsutils_1.getModifier(node, ts.SyntaxKind.ReadonlyKeyword);
+ // public is not optional for parameter property without the readonly modifier
+ var isPublicOptional = node.kind !== ts.SyntaxKind.Parameter || readonlyKeyword !== undefined;
+ if (isPublicOptional) {
+ var start = publicKeyword.end - "public".length;
+ ctx.addFailure(start, publicKeyword.end, Rule.FAILURE_STRING_NO_PUBLIC, Lint.Replacement.deleteFromTo(start, tsutils_1.getNextToken(publicKeyword, ctx.sourceFile).getStart(ctx.sourceFile)));
+ }
}
if (!noPublic && publicKeyword === undefined) {
var nameNode = node.kind === ts.SyntaxKind.Constructor
@@ -137,6 +153,8 @@ function typeToString(node) {
return "get property accessor";
case ts.SyntaxKind.SetAccessor:
return "set property accessor";
+ case ts.SyntaxKind.Parameter:
+ return "parameter property";
default:
throw new Error("unhandled node type " + ts.SyntaxKind[node.kind]);
}
diff --git a/node_modules/tslint/lib/rules/memberOrderingRule.js b/node_modules/tslint/lib/rules/memberOrderingRule.js
index f5b6d0683..e2e35a548 100644
--- a/node_modules/tslint/lib/rules/memberOrderingRule.js
+++ b/node_modules/tslint/lib/rules/memberOrderingRule.js
@@ -152,9 +152,12 @@ var Rule = /** @class */ (function (_super) {
[true, { order: "fields-first" }],
[true, {
order: [
- "static-field",
- "instance-field",
- "constructor",
+ "public-static-field",
+ "public-instance-field",
+ "public-constructor",
+ "private-static-field",
+ "private-instance-field",
+ "private-constructor",
"public-instance-method",
"protected-instance-method",
"private-instance-method",
@@ -340,7 +343,7 @@ function parseOptions(options) {
return { order: order, alphabetize: alphabetize };
}
function getOptionsJson(allOptions) {
- if (allOptions == null || allOptions.length === 0 || allOptions[0] == null) {
+ if (allOptions == undefined || allOptions.length === 0 || allOptions[0] == undefined) {
throw new Error("Got empty options");
}
var firstOption = allOptions[0];
diff --git a/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.js b/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.js
index 18d780e31..2634398da 100644
--- a/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.js
+++ b/node_modules/tslint/lib/rules/noAngleBracketTypeAssertionRule.js
@@ -48,13 +48,26 @@ exports.Rule = Rule;
function walk(ctx) {
return ts.forEachChild(ctx.sourceFile, function cb(node) {
if (tsutils_1.isTypeAssertion(node)) {
+ var expression = node.expression;
var start = node.getStart(ctx.sourceFile);
+ var addParens = needsParens(node);
+ var replaceText = " as " + node.type.getText(ctx.sourceFile) + (addParens ? ")" : "");
+ while (tsutils_1.isTypeAssertion(expression)) {
+ replaceText = " as " + expression.type.getText(ctx.sourceFile) + replaceText;
+ expression = expression.expression;
+ }
ctx.addFailure(start, node.end, Rule.FAILURE_STRING, [
- Lint.Replacement.appendText(node.end, " as " + node.type.getText(ctx.sourceFile)),
- Lint.Replacement.deleteFromTo(start, node.expression.getStart(ctx.sourceFile)),
+ Lint.Replacement.appendText(node.end, replaceText),
+ Lint.Replacement.replaceFromTo(start, expression.getStart(ctx.sourceFile), addParens ? "(" : ""),
]);
+ return cb(expression);
}
return ts.forEachChild(node, cb);
});
}
+function needsParens(node) {
+ var parent = node.parent;
+ return tsutils_1.isBinaryExpression(parent) &&
+ (parent.operatorToken.kind === ts.SyntaxKind.AmpersandToken || parent.operatorToken.kind === ts.SyntaxKind.BarToken);
+}
var _a;
diff --git a/node_modules/tslint/lib/rules/noConditionalAssignmentRule.d.ts b/node_modules/tslint/lib/rules/noConditionalAssignmentRule.d.ts
index 06b7c4bbe..cce59d100 100644
--- a/node_modules/tslint/lib/rules/noConditionalAssignmentRule.d.ts
+++ b/node_modules/tslint/lib/rules/noConditionalAssignmentRule.d.ts
@@ -1,19 +1,3 @@
-/**
- * @license
- * Copyright 2015 Palantir Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
import * as ts from "typescript";
import * as Lint from "../index";
export declare class Rule extends Lint.Rules.AbstractRule {
diff --git a/node_modules/tslint/lib/rules/noConditionalAssignmentRule.js b/node_modules/tslint/lib/rules/noConditionalAssignmentRule.js
index f437d1a63..30e77aa84 100644
--- a/node_modules/tslint/lib/rules/noConditionalAssignmentRule.js
+++ b/node_modules/tslint/lib/rules/noConditionalAssignmentRule.js
@@ -17,6 +17,7 @@
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
+var tsutils_1 = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
var Rule = /** @class */ (function (_super) {
@@ -25,14 +26,13 @@ var Rule = /** @class */ (function (_super) {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
- var walker = new NoConditionalAssignmentWalker(sourceFile, this.getOptions());
- return this.applyWithWalker(walker);
+ return this.applyWithFunction(sourceFile, walk);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "no-conditional-assignment",
description: "Disallows any type of assignment in conditionals.",
- descriptionDetails: "This applies to `do-while`, `for`, `if`, and `while` statements.",
+ descriptionDetails: "This applies to `do-while`, `for`, `if`, and `while` statements and conditional (ternary) expressions.",
rationale: (_a = ["\n Assignments in conditionals are often typos:\n for example `if (var1 = var2)` instead of `if (var1 == var2)`.\n They also can be an indicator of overly clever code which decreases maintainability."], _a.raw = ["\n Assignments in conditionals are often typos:\n for example \\`if (var1 = var2)\\` instead of \\`if (var1 == var2)\\`.\n They also can be an indicator of overly clever code which decreases maintainability."], Lint.Utils.dedent(_a)),
optionsDescription: "Not configurable.",
options: null,
@@ -45,55 +45,74 @@ var Rule = /** @class */ (function (_super) {
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
-var NoConditionalAssignmentWalker = /** @class */ (function (_super) {
- tslib_1.__extends(NoConditionalAssignmentWalker, _super);
- function NoConditionalAssignmentWalker() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.isInConditional = false;
- return _this;
- }
- NoConditionalAssignmentWalker.prototype.visitIfStatement = function (node) {
- this.validateConditionalExpression(node.expression);
- _super.prototype.visitIfStatement.call(this, node);
- };
- NoConditionalAssignmentWalker.prototype.visitWhileStatement = function (node) {
- this.validateConditionalExpression(node.expression);
- _super.prototype.visitWhileStatement.call(this, node);
- };
- NoConditionalAssignmentWalker.prototype.visitDoStatement = function (node) {
- this.validateConditionalExpression(node.expression);
- _super.prototype.visitDoStatement.call(this, node);
- };
- NoConditionalAssignmentWalker.prototype.visitForStatement = function (node) {
- if (node.condition != null) {
- this.validateConditionalExpression(node.condition);
+function walk(ctx) {
+ var checking = 0;
+ return ts.forEachChild(ctx.sourceFile, cb);
+ function cb(node) {
+ var kind = node.kind;
+ if (!tsutils_1.isNodeKind(kind)) {
+ return; // return early for tokens
}
- _super.prototype.visitForStatement.call(this, node);
- };
- NoConditionalAssignmentWalker.prototype.visitBinaryExpression = function (expression) {
- if (this.isInConditional) {
- this.checkForAssignment(expression);
- }
- _super.prototype.visitBinaryExpression.call(this, expression);
- };
- NoConditionalAssignmentWalker.prototype.validateConditionalExpression = function (expression) {
- this.isInConditional = true;
- if (expression.kind === ts.SyntaxKind.BinaryExpression) {
- // check for simple assignment in a conditional, like `if (a = 1) {`
- this.checkForAssignment(expression);
+ switch (kind) {
+ case ts.SyntaxKind.ConditionalExpression:
+ check(node.condition);
+ cb(node.whenTrue);
+ cb(node.whenFalse);
+ return;
+ case ts.SyntaxKind.IfStatement:
+ check(node.expression);
+ cb(node.thenStatement);
+ maybeCallback(cb, node.elseStatement);
+ return;
+ case ts.SyntaxKind.DoStatement:
+ case ts.SyntaxKind.WhileStatement:
+ check(node.expression);
+ cb(node.statement);
+ return;
+ case ts.SyntaxKind.ForStatement:
+ maybeCallback(cb, node.initializer);
+ maybeCallback(check, node.condition);
+ maybeCallback(cb, node.incrementor);
+ cb(node.statement);
+ return;
}
- // walk the children of the conditional expression for nested assignments, like `if ((a = 1) && (b == 1)) {`
- this.walkChildren(expression);
- this.isInConditional = false;
- };
- NoConditionalAssignmentWalker.prototype.checkForAssignment = function (expression) {
- if (isAssignmentToken(expression.operatorToken)) {
- this.addFailureAtNode(expression, Rule.FAILURE_STRING);
+ if (checking !== 0) {
+ switch (kind) {
+ case ts.SyntaxKind.BinaryExpression:
+ if (tsutils_1.isAssignmentKind(node.operatorToken.kind)) {
+ ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
+ }
+ cb(node.left);
+ cb(node.right);
+ return;
+ case ts.SyntaxKind.ParenthesizedExpression:
+ case ts.SyntaxKind.NonNullExpression:
+ case ts.SyntaxKind.AsExpression:
+ case ts.SyntaxKind.TypeAssertionExpression:
+ return cb(node.expression);
+ case ts.SyntaxKind.PrefixUnaryExpression:
+ return cb(node.operand);
+ default:
+ return noCheck(node);
+ }
}
- };
- return NoConditionalAssignmentWalker;
-}(Lint.RuleWalker));
-function isAssignmentToken(token) {
- return token.kind >= ts.SyntaxKind.FirstAssignment && token.kind <= ts.SyntaxKind.LastAssignment;
+ return ts.forEachChild(node, cb);
+ }
+ function check(node) {
+ ++checking;
+ cb(node);
+ --checking;
+ }
+ function noCheck(node) {
+ var old = checking;
+ checking = 0;
+ ts.forEachChild(node, cb);
+ checking = old;
+ }
+}
+function maybeCallback(cb, node) {
+ if (node !== undefined) {
+ cb(node);
+ }
}
var _a;
diff --git a/node_modules/tslint/lib/rules/noDuplicateImportsRule.js b/node_modules/tslint/lib/rules/noDuplicateImportsRule.js
index f8bd79d04..af7c741f8 100644
--- a/node_modules/tslint/lib/rules/noDuplicateImportsRule.js
+++ b/node_modules/tslint/lib/rules/noDuplicateImportsRule.js
@@ -18,7 +18,6 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
-var ts = require("typescript");
var Lint = require("../index");
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
@@ -29,7 +28,7 @@ var Rule = /** @class */ (function (_super) {
return "Multiple imports from '" + module + "' can be combined into one.";
};
Rule.prototype.apply = function (sourceFile) {
- return this.applyWithWalker(new NoDuplicateImportsWalker(sourceFile, this.ruleName, undefined));
+ return this.applyWithFunction(sourceFile, walk);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
@@ -45,37 +44,16 @@ var Rule = /** @class */ (function (_super) {
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
-var NoDuplicateImportsWalker = /** @class */ (function (_super) {
- tslib_1.__extends(NoDuplicateImportsWalker, _super);
- function NoDuplicateImportsWalker() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.seenImports = new Set();
- return _this;
- }
- NoDuplicateImportsWalker.prototype.walk = function (sourceFile) {
- this.checkStatements(sourceFile.statements);
- };
- NoDuplicateImportsWalker.prototype.checkStatements = function (statements) {
- for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
- var statement = statements_1[_i];
- if (tsutils_1.isImportDeclaration(statement)) {
- this.checkImport(statement);
- }
- else if (this.sourceFile.isDeclarationFile && tsutils_1.isModuleDeclaration(statement) &&
- statement.body !== undefined && statement.name.kind === ts.SyntaxKind.StringLiteral) {
- // module augmentations in declaration files can contain imports
- this.checkStatements(statement.body.statements);
- }
+function walk(ctx) {
+ var seen = new Set();
+ for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 1 /* ImportDeclaration */); _i < _a.length; _i++) {
+ var _b = _a[_i], text = _b.text, parent = _b.parent;
+ if (seen.has(text)) {
+ ctx.addFailureAtNode(parent, Rule.FAILURE_STRING(text));
}
- };
- NoDuplicateImportsWalker.prototype.checkImport = function (statement) {
- if (tsutils_1.isTextualLiteral(statement.moduleSpecifier)) {
- if (this.seenImports.has(statement.moduleSpecifier.text)) {
- return this.addFailureAtNode(statement, Rule.FAILURE_STRING(statement.moduleSpecifier.text));
- }
- this.seenImports.add(statement.moduleSpecifier.text);
+ else {
+ seen.add(text);
}
- };
- return NoDuplicateImportsWalker;
-}(Lint.AbstractWalker));
+ }
+}
var _a, _b;
diff --git a/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.d.ts b/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.d.ts
new file mode 100644
index 000000000..af720ee58
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.d.ts
@@ -0,0 +1,23 @@
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import * as Lint from "../index";
+export declare class Rule extends Lint.Rules.AbstractRule {
+ static metadata: Lint.IRuleMetadata;
+ static readonly FAILURE_STRING_FACTORY: (text: string) => string;
+ apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
+}
diff --git a/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.js b/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.js
new file mode 100644
index 000000000..18b026a9d
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noDuplicateSwitchCaseRule.js
@@ -0,0 +1,65 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var ts = require("typescript");
+var Lint = require("../index");
+var Rule = /** @class */ (function (_super) {
+ tslib_1.__extends(Rule, _super);
+ function Rule() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ Rule.prototype.apply = function (sourceFile) {
+ return this.applyWithFunction(sourceFile, walk);
+ };
+ Rule.metadata = {
+ description: "Prevents duplicate cases in switch statements.",
+ optionExamples: [true],
+ options: null,
+ optionsDescription: "",
+ ruleName: "no-duplicate-switch-case",
+ type: "functionality",
+ typescriptOnly: false,
+ };
+ Rule.FAILURE_STRING_FACTORY = function (text) { return "Duplicate switch case: '" + text + "'."; };
+ return Rule;
+}(Lint.Rules.AbstractRule));
+exports.Rule = Rule;
+function walk(ctx) {
+ ts.forEachChild(ctx.sourceFile, function cb(node) {
+ if (node.kind === ts.SyntaxKind.CaseBlock) {
+ visitCaseBlock(node);
+ }
+ ts.forEachChild(node, cb);
+ });
+ function visitCaseBlock(node) {
+ var previousCases = new Set();
+ for (var _i = 0, _a = node.clauses; _i < _a.length; _i++) {
+ var clause = _a[_i];
+ if (clause.kind === ts.SyntaxKind.DefaultClause) {
+ continue;
+ }
+ var text = clause.expression.getText(ctx.sourceFile);
+ if (!previousCases.has(text)) {
+ previousCases.add(text);
+ continue;
+ }
+ ctx.addFailureAtNode(clause.expression, Rule.FAILURE_STRING_FACTORY(text));
+ }
+ }
+}
diff --git a/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js b/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js
index ae42d72e6..f23f3aade 100644
--- a/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js
+++ b/node_modules/tslint/lib/rules/noEmptyInterfaceRule.js
@@ -48,11 +48,20 @@ function walk(ctx) {
return ts.forEachChild(ctx.sourceFile, function cb(node) {
if (tsutils_1.isInterfaceDeclaration(node) &&
node.members.length === 0 &&
- (node.heritageClauses === undefined ||
- // allow interfaces that extend 2 or more interfaces
- node.heritageClauses[0].types.length < 2)) {
+ (node.heritageClauses === undefined || extendsOneTypeWithoutTypeArguments(node.heritageClauses[0]))) {
return ctx.addFailureAtNode(node.name, node.heritageClauses !== undefined ? Rule.FAILURE_STRING_FOR_EXTENDS : Rule.FAILURE_STRING);
}
return ts.forEachChild(node, cb);
});
}
+function extendsOneTypeWithoutTypeArguments(_a) {
+ var types = _a.types;
+ switch (types.length) {
+ case 0:
+ return true; // don't crash on empty extends list
+ case 1:
+ return types[0].typeArguments === undefined; // allow interfaces that provide type arguments for the extended type
+ default:
+ return false; // allow interfaces extending more than one types
+ }
+}
diff --git a/node_modules/tslint/lib/rules/noImplicitDependenciesRule.d.ts b/node_modules/tslint/lib/rules/noImplicitDependenciesRule.d.ts
new file mode 100644
index 000000000..ac0e6994f
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noImplicitDependenciesRule.d.ts
@@ -0,0 +1,7 @@
+import * as ts from "typescript";
+import * as Lint from "../index";
+export declare class Rule extends Lint.Rules.AbstractRule {
+ static metadata: Lint.IRuleMetadata;
+ static FAILURE_STRING_FACTORY(module: string): string;
+ apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
+}
diff --git a/node_modules/tslint/lib/rules/noImplicitDependenciesRule.js b/node_modules/tslint/lib/rules/noImplicitDependenciesRule.js
new file mode 100644
index 000000000..212baf8ae
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noImplicitDependenciesRule.js
@@ -0,0 +1,132 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var builtins = require("builtin-modules");
+var fs = require("fs");
+var path = require("path");
+var tsutils_1 = require("tsutils");
+var ts = require("typescript");
+var Lint = require("../index");
+var OPTION_DEV = "dev";
+var OPTION_OPTIONAL = "optional";
+var Rule = /** @class */ (function (_super) {
+ tslib_1.__extends(Rule, _super);
+ function Rule() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ /* tslint:enable:object-literal-sort-keys */
+ Rule.FAILURE_STRING_FACTORY = function (module) {
+ return "Module '" + module + "' is not listed as dependency in package.json";
+ };
+ Rule.prototype.apply = function (sourceFile) {
+ return this.applyWithFunction(sourceFile, walk, {
+ dev: this.ruleArguments.indexOf(OPTION_DEV) !== -1,
+ optional: this.ruleArguments.indexOf(OPTION_OPTIONAL) !== -1,
+ });
+ };
+ /* tslint:disable:object-literal-sort-keys */
+ Rule.metadata = {
+ ruleName: "no-implicit-dependencies",
+ description: "Disallows importing modules that are not listed as dependency in the project's package.json",
+ descriptionDetails: (_a = ["\n Disallows importing transient dependencies and modules installed above your package's root directory.\n "], _a.raw = ["\n Disallows importing transient dependencies and modules installed above your package's root directory.\n "], Lint.Utils.dedent(_a)),
+ optionsDescription: (_b = ["\n By default the rule looks at `\"dependencies\"` and `\"peerDependencies\"`.\n By adding the `\"", "\"` option the rule looks at `\"devDependencies\"` instead of `\"peerDependencies\"`.\n By adding the `\"", "\"` option the rule also looks at `\"optionalDependencies\"`.\n "], _b.raw = ["\n By default the rule looks at \\`\"dependencies\"\\` and \\`\"peerDependencies\"\\`.\n By adding the \\`\"", "\"\\` option the rule looks at \\`\"devDependencies\"\\` instead of \\`\"peerDependencies\"\\`.\n By adding the \\`\"", "\"\\` option the rule also looks at \\`\"optionalDependencies\"\\`.\n "], Lint.Utils.dedent(_b, OPTION_DEV, OPTION_OPTIONAL)),
+ options: {
+ type: "array",
+ items: {
+ type: "string",
+ enum: [OPTION_DEV, OPTION_OPTIONAL],
+ },
+ minItems: 0,
+ maxItems: 2,
+ },
+ optionExamples: [true, [true, OPTION_DEV], [true, OPTION_OPTIONAL]],
+ type: "functionality",
+ typescriptOnly: false,
+ };
+ return Rule;
+}(Lint.Rules.AbstractRule));
+exports.Rule = Rule;
+function walk(ctx) {
+ var options = ctx.options;
+ var dependencies;
+ for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 31 /* All */); _i < _a.length; _i++) {
+ var name = _a[_i];
+ if (!ts.isExternalModuleNameRelative(name.text)) {
+ var packageName = getPackageName(name.text);
+ if (builtins.indexOf(packageName) === -1 && !hasDependency(packageName)) {
+ ctx.addFailureAtNode(name, Rule.FAILURE_STRING_FACTORY(packageName));
+ }
+ }
+ }
+ function hasDependency(module) {
+ if (dependencies === undefined) {
+ dependencies = getDependencies(ctx.sourceFile.fileName, options);
+ }
+ return dependencies.has(module);
+ }
+}
+function getPackageName(name) {
+ var parts = name.split(/\//g);
+ if (name[0] !== "@") {
+ return parts[0];
+ }
+ return parts[0] + "/" + parts[1];
+}
+function getDependencies(fileName, options) {
+ var result = new Set();
+ var packageJsonPath = findPackageJson(path.resolve(path.dirname(fileName)));
+ if (packageJsonPath !== undefined) {
+ // don't use require here to avoid caching
+ // remove BOM from file content before parsing
+ var content = JSON.parse(fs.readFileSync(packageJsonPath, "utf8").replace(/^\uFEFF/, ""));
+ if (content.dependencies !== undefined) {
+ addDependencies(result, content.dependencies);
+ }
+ if (!options.dev && content.peerDependencies !== undefined) {
+ addDependencies(result, content.peerDependencies);
+ }
+ if (options.dev && content.devDependencies !== undefined) {
+ addDependencies(result, content.devDependencies);
+ }
+ if (options.optional && content.optionalDependencies !== undefined) {
+ addDependencies(result, content.optionalDependencies);
+ }
+ }
+ return result;
+}
+function addDependencies(result, dependencies) {
+ for (var name in dependencies) {
+ if (dependencies.hasOwnProperty(name)) {
+ result.add(name);
+ }
+ }
+}
+function findPackageJson(current) {
+ var prev;
+ do {
+ var fileName = path.join(current, "package.json");
+ if (fs.existsSync(fileName)) {
+ return fileName;
+ }
+ prev = current;
+ current = path.dirname(current);
+ } while (prev !== current);
+ return undefined;
+}
+var _a, _b;
diff --git a/node_modules/tslint/lib/rules/noInvalidThisRule.d.ts b/node_modules/tslint/lib/rules/noInvalidThisRule.d.ts
index 43c9599c8..a664f16a5 100644
--- a/node_modules/tslint/lib/rules/noInvalidThisRule.d.ts
+++ b/node_modules/tslint/lib/rules/noInvalidThisRule.d.ts
@@ -1,21 +1,5 @@
-/**
- * @license
- * Copyright 2016 Palantir Technologies, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
import * as ts from "typescript";
-import * as Lint from "../index";
+import * as Lint from "..";
export declare class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata;
static FAILURE_STRING_OUTSIDE: string;
diff --git a/node_modules/tslint/lib/rules/noInvalidThisRule.js b/node_modules/tslint/lib/rules/noInvalidThisRule.js
index b9b04a842..49333d54f 100644
--- a/node_modules/tslint/lib/rules/noInvalidThisRule.js
+++ b/node_modules/tslint/lib/rules/noInvalidThisRule.js
@@ -17,8 +17,9 @@
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
+var tsutils_1 = require("tsutils");
var ts = require("typescript");
-var Lint = require("../index");
+var Lint = require("..");
var OPTION_FUNCTION_IN_METHOD = "check-function-in-method";
var DEPRECATED_OPTION_FUNCTION_IN_METHOD = "no-this-in-function-in-method";
var Rule = /** @class */ (function (_super) {
@@ -75,6 +76,9 @@ function walk(ctx) {
break;
case ts.SyntaxKind.FunctionDeclaration:
case ts.SyntaxKind.FunctionExpression:
+ if (node.parameters.some(tsutils_1.isThisParameter)) {
+ return;
+ }
if (inClass) {
inFunctionInClass = true;
ts.forEachChild(node, cb);
diff --git a/node_modules/tslint/lib/rules/noNonNullAssertionRule.js b/node_modules/tslint/lib/rules/noNonNullAssertionRule.js
index f0c2d20f3..dc657fc53 100644
--- a/node_modules/tslint/lib/rules/noNonNullAssertionRule.js
+++ b/node_modules/tslint/lib/rules/noNonNullAssertionRule.js
@@ -30,7 +30,7 @@ var Rule = /** @class */ (function (_super) {
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "no-non-null-assertion",
- description: "Disallows non-null assertions.",
+ description: "Disallows non-null assertions using the `!` postfix operator.",
rationale: "Using non-null assertion cancels the benefits of the strict null checking mode.",
optionsDescription: "Not configurable.",
options: null,
diff --git a/node_modules/tslint/lib/rules/noRedundantJsdocRule.d.ts b/node_modules/tslint/lib/rules/noRedundantJsdocRule.d.ts
new file mode 100644
index 000000000..5d51fdd37
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noRedundantJsdocRule.d.ts
@@ -0,0 +1,9 @@
+import * as ts from "typescript";
+import * as Lint from "../index";
+export declare class Rule extends Lint.Rules.AbstractRule {
+ static metadata: Lint.IRuleMetadata;
+ static FAILURE_STRING_REDUNDANT_TYPE: string;
+ static FAILURE_STRING_REDUNDANT_TAG(tagName: string): string;
+ static FAILURE_STRING_NO_COMMENT(tagName: string): string;
+ apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
+}
diff --git a/node_modules/tslint/lib/rules/noRedundantJsdocRule.js b/node_modules/tslint/lib/rules/noRedundantJsdocRule.js
new file mode 100644
index 000000000..398162132
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noRedundantJsdocRule.js
@@ -0,0 +1,133 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var tsutils_1 = require("tsutils");
+var ts = require("typescript");
+var Lint = require("../index");
+var Rule = /** @class */ (function (_super) {
+ tslib_1.__extends(Rule, _super);
+ function Rule() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ Rule.FAILURE_STRING_REDUNDANT_TAG = function (tagName) {
+ return "JSDoc tag '@" + tagName + "' is redundant in TypeScript code.";
+ };
+ Rule.FAILURE_STRING_NO_COMMENT = function (tagName) {
+ return "'@" + tagName + "' is redundant in TypeScript code if it has no description.";
+ };
+ Rule.prototype.apply = function (sourceFile) {
+ return this.applyWithFunction(sourceFile, walk);
+ };
+ /* tslint:disable:object-literal-sort-keys */
+ Rule.metadata = {
+ ruleName: "no-redundant-jsdoc",
+ description: "Forbids JSDoc which duplicates TypeScript functionality.",
+ optionsDescription: "Not configurable.",
+ options: null,
+ optionExamples: [true],
+ type: "style",
+ typescriptOnly: true,
+ };
+ /* tslint:enable:object-literal-sort-keys */
+ Rule.FAILURE_STRING_REDUNDANT_TYPE = "Type annotation in JSDoc is redundant in TypeScript code.";
+ return Rule;
+}(Lint.Rules.AbstractRule));
+exports.Rule = Rule;
+function walk(ctx) {
+ var sourceFile = ctx.sourceFile;
+ // Intentionally exclude EndOfFileToken: it can have JSDoc, but it is only relevant in JavaScript files
+ return sourceFile.statements.forEach(function cb(node) {
+ if (tsutils_1.canHaveJsDoc(node)) {
+ for (var _i = 0, _a = tsutils_1.getJsDoc(node, sourceFile); _i < _a.length; _i++) {
+ var tags = _a[_i].tags;
+ if (tags !== undefined) {
+ for (var _b = 0, tags_1 = tags; _b < tags_1.length; _b++) {
+ var tag = tags_1[_b];
+ checkTag(tag);
+ }
+ }
+ }
+ }
+ return ts.forEachChild(node, cb);
+ });
+ function checkTag(tag) {
+ switch (tag.kind) {
+ case ts.SyntaxKind.JSDocTag:
+ if (redundantTags.has(tag.tagName.text)) {
+ ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_REDUNDANT_TAG(tag.tagName.text));
+ }
+ break;
+ case ts.SyntaxKind.JSDocAugmentsTag:
+ // OK
+ break;
+ case ts.SyntaxKind.JSDocTemplateTag:
+ case ts.SyntaxKind.JSDocTypeTag:
+ case ts.SyntaxKind.JSDocTypedefTag:
+ case ts.SyntaxKind.JSDocPropertyTag:
+ // Always redundant
+ ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_REDUNDANT_TAG(tag.tagName.text));
+ break;
+ case ts.SyntaxKind.JSDocReturnTag:
+ case ts.SyntaxKind.JSDocParameterTag: {
+ var _a = tag, typeExpression = _a.typeExpression, comment = _a.comment;
+ if (typeExpression !== undefined) {
+ ctx.addFailureAtNode(typeExpression, Rule.FAILURE_STRING_REDUNDANT_TYPE);
+ }
+ if (comment === "") {
+ // Redundant if no documentation
+ ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_NO_COMMENT(tag.tagName.text));
+ }
+ break;
+ }
+ default:
+ throw new Error("Unexpected tag kind: " + ts.SyntaxKind[tag.kind]);
+ }
+ }
+}
+var redundantTags = new Set([
+ "abstract",
+ "access",
+ "class",
+ "constant",
+ "constructs",
+ "default",
+ "enum",
+ "exports",
+ "function",
+ "global",
+ "implements",
+ "interface",
+ "instance",
+ "member",
+ "memberof",
+ "mixes",
+ "mixin",
+ "module",
+ "name",
+ "namespace",
+ "override",
+ "private",
+ "property",
+ "protected",
+ "public",
+ "readonly",
+ "requires",
+ "static",
+ "this",
+]);
diff --git a/node_modules/tslint/lib/rules/noReferenceImportRule.js b/node_modules/tslint/lib/rules/noReferenceImportRule.js
index 8579b5eee..108addd75 100644
--- a/node_modules/tslint/lib/rules/noReferenceImportRule.js
+++ b/node_modules/tslint/lib/rules/noReferenceImportRule.js
@@ -18,7 +18,6 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
-var ts = require("typescript");
var Lint = require("../index");
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
@@ -30,7 +29,7 @@ var Rule = /** @class */ (function (_super) {
return "No need to reference \"" + moduleReference + "\", since it is imported.";
};
Rule.prototype.apply = function (sourceFile) {
- return this.applyWithWalker(new NoReferenceImportWalker(sourceFile, this.ruleName, undefined));
+ return this.applyWithFunction(sourceFile, walk);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
@@ -44,55 +43,15 @@ var Rule = /** @class */ (function (_super) {
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
-var NoReferenceImportWalker = /** @class */ (function (_super) {
- tslib_1.__extends(NoReferenceImportWalker, _super);
- function NoReferenceImportWalker() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.imports = new Set();
- return _this;
+function walk(ctx) {
+ if (ctx.sourceFile.typeReferenceDirectives.length === 0) {
+ return;
}
- NoReferenceImportWalker.prototype.walk = function (sourceFile) {
- if (sourceFile.typeReferenceDirectives.length === 0) {
- return;
+ var imports = new Set(tsutils_1.findImports(ctx.sourceFile, 3 /* AllStaticImports */).map(function (name) { return name.text; }));
+ for (var _i = 0, _a = ctx.sourceFile.typeReferenceDirectives; _i < _a.length; _i++) {
+ var ref = _a[_i];
+ if (imports.has(ref.fileName)) {
+ ctx.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING(ref.fileName));
}
- this.findImports(sourceFile.statements);
- for (var _i = 0, _a = sourceFile.typeReferenceDirectives; _i < _a.length; _i++) {
- var ref = _a[_i];
- if (this.imports.has(ref.fileName)) {
- this.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING(ref.fileName));
- }
- }
- };
- NoReferenceImportWalker.prototype.findImports = function (statements) {
- for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
- var statement = statements_1[_i];
- if (tsutils_1.isImportDeclaration(statement)) {
- this.addImport(statement.moduleSpecifier);
- }
- else if (tsutils_1.isImportEqualsDeclaration(statement)) {
- if (statement.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference &&
- statement.moduleReference.expression !== undefined) {
- this.addImport(statement.moduleReference.expression);
- }
- }
- else if (tsutils_1.isModuleDeclaration(statement) && statement.body !== undefined && this.sourceFile.isDeclarationFile) {
- // There can't be any imports in a module augmentation or namespace
- this.findImportsInModule(statement.body);
- }
- }
- };
- NoReferenceImportWalker.prototype.findImportsInModule = function (body) {
- if (body.kind === ts.SyntaxKind.ModuleBlock) {
- return this.findImports(body.statements);
- }
- else if (body.kind === ts.SyntaxKind.ModuleDeclaration && body.body !== undefined) {
- return this.findImportsInModule(body.body);
- }
- };
- NoReferenceImportWalker.prototype.addImport = function (specifier) {
- if (tsutils_1.isStringLiteral(specifier)) {
- this.imports.add(specifier.text);
- }
- };
- return NoReferenceImportWalker;
-}(Lint.AbstractWalker));
+ }
+}
diff --git a/node_modules/tslint/lib/rules/noRequireImportsRule.js b/node_modules/tslint/lib/rules/noRequireImportsRule.js
index 77c7d155f..7fd8037f2 100644
--- a/node_modules/tslint/lib/rules/noRequireImportsRule.js
+++ b/node_modules/tslint/lib/rules/noRequireImportsRule.js
@@ -18,7 +18,6 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
-var ts = require("typescript");
var Lint = require("../index");
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
@@ -45,17 +44,8 @@ var Rule = /** @class */ (function (_super) {
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
- return ts.forEachChild(ctx.sourceFile, function cb(node) {
- if (tsutils_1.isCallExpression(node)) {
- if (node.arguments.length !== 0 &&
- tsutils_1.isIdentifier(node.expression) && node.expression.text === "require") {
- ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
- }
- }
- else if (tsutils_1.isImportEqualsDeclaration(node) &&
- node.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference) {
- ctx.addFailureAtNode(node.moduleReference, Rule.FAILURE_STRING);
- }
- return ts.forEachChild(node, cb);
- });
+ for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 18 /* AllRequireLike */); _i < _a.length; _i++) {
+ var name = _a[_i];
+ ctx.addFailureAtNode(name.parent, Rule.FAILURE_STRING);
+ }
}
diff --git a/node_modules/tslint/lib/rules/noReturnAwaitRule.d.ts b/node_modules/tslint/lib/rules/noReturnAwaitRule.d.ts
new file mode 100644
index 000000000..cce59d100
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noReturnAwaitRule.d.ts
@@ -0,0 +1,7 @@
+import * as ts from "typescript";
+import * as Lint from "../index";
+export declare class Rule extends Lint.Rules.AbstractRule {
+ static metadata: Lint.IRuleMetadata;
+ static FAILURE_STRING: string;
+ apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
+}
diff --git a/node_modules/tslint/lib/rules/noReturnAwaitRule.js b/node_modules/tslint/lib/rules/noReturnAwaitRule.js
new file mode 100644
index 000000000..67cc188ad
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noReturnAwaitRule.js
@@ -0,0 +1,110 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var tsutils_1 = require("tsutils");
+var ts = require("typescript");
+var Lint = require("../index");
+var Rule = /** @class */ (function (_super) {
+ tslib_1.__extends(Rule, _super);
+ function Rule() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ Rule.prototype.apply = function (sourceFile) {
+ return this.applyWithFunction(sourceFile, walk);
+ };
+ /* tslint:disable:object-literal-sort-keys */
+ Rule.metadata = {
+ ruleName: "no-return-await",
+ description: "Disallows unnecessary `return await`.",
+ rationale: (_a = ["\n An async function always wraps the return value in a Promise.\n Using `return await` just adds extra time before the overreaching promise is resolved without changing the semantics.\n "], _a.raw = ["\n An async function always wraps the return value in a Promise.\n Using \\`return await\\` just adds extra time before the overreaching promise is resolved without changing the semantics.\n "], Lint.Utils.dedent(_a)),
+ optionsDescription: "Not configurable.",
+ options: null,
+ optionExamples: [true],
+ type: "functionality",
+ typescriptOnly: false,
+ hasFix: true,
+ };
+ /* tslint:enable:object-literal-sort-keys */
+ Rule.FAILURE_STRING = "Unnecessary 'await'.";
+ return Rule;
+}(Lint.Rules.AbstractRule));
+exports.Rule = Rule;
+function walk(ctx) {
+ return ts.forEachChild(ctx.sourceFile, function cb(node) {
+ if (node.kind === ts.SyntaxKind.AwaitExpression && isUnnecessaryAwait(node)) {
+ var expression = node.expression;
+ var keywordStart = expression.pos - "await".length;
+ ctx.addFailure(keywordStart, expression.pos, Rule.FAILURE_STRING, Lint.Replacement.deleteFromTo(keywordStart, expression.getStart(ctx.sourceFile)));
+ }
+ return ts.forEachChild(node, cb);
+ });
+}
+function isUnnecessaryAwait(node) {
+ while (true) {
+ var parent = node.parent;
+ outer: switch (parent.kind) {
+ case ts.SyntaxKind.ArrowFunction:
+ return true;
+ case ts.SyntaxKind.ReturnStatement:
+ return !isInsideTryBlock(parent.parent);
+ case ts.SyntaxKind.ParenthesizedExpression:
+ break;
+ case ts.SyntaxKind.ConditionalExpression:
+ if (parent.condition === node) {
+ return false;
+ }
+ break;
+ case ts.SyntaxKind.BinaryExpression:
+ if (parent.right === node) {
+ switch (parent.operatorToken.kind) {
+ case ts.SyntaxKind.AmpersandAmpersandToken:
+ case ts.SyntaxKind.BarBarToken:
+ case ts.SyntaxKind.CommaToken:
+ break outer;
+ }
+ }
+ return false;
+ default:
+ return false;
+ }
+ node = parent;
+ }
+}
+function isInsideTryBlock(node) {
+ while (node.parent !== undefined) {
+ if (tsutils_1.isFunctionScopeBoundary(node)) {
+ return false;
+ }
+ if (tsutils_1.isTryStatement(node.parent)) {
+ if (
+ // statements inside the try block always have an error handler, either catch or finally
+ node.parent.tryBlock === node ||
+ // statement inside the catch block only have an error handler if there is a finally block
+ node.parent.finallyBlock !== undefined && node.parent.catchClause === node) {
+ return true;
+ }
+ node = node.parent.parent;
+ }
+ else {
+ node = node.parent;
+ }
+ }
+ return false;
+}
+var _a;
diff --git a/node_modules/tslint/lib/rules/noShadowedVariableRule.js b/node_modules/tslint/lib/rules/noShadowedVariableRule.js
index 6ca830085..c2db583c6 100644
--- a/node_modules/tslint/lib/rules/noShadowedVariableRule.js
+++ b/node_modules/tslint/lib/rules/noShadowedVariableRule.js
@@ -37,7 +37,7 @@ var Rule = /** @class */ (function (_super) {
ruleName: "no-shadowed-variable",
description: "Disallows shadowing variable declarations.",
rationale: "Shadowing a variable masks access to it and obscures to what value an identifier actually refers.",
- optionsDescription: (_a = ["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are `\"class\"`, `\"enum\"`, `\"function\"`, `\"import\"`, `\"interface\"`, `\"namespace\"`, `\"typeAlias\"`\n and `\"typeParameter\"`. Just set the value to `false` for the check you want to disable.\n All checks default to `true`, i.e. are enabled by default.\n Not that you cannot disable variables and parameters.\n "], _a.raw = ["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are \\`\"class\"\\`, \\`\"enum\"\\`, \\`\"function\"\\`, \\`\"import\"\\`, \\`\"interface\"\\`, \\`\"namespace\"\\`, \\`\"typeAlias\"\\`\n and \\`\"typeParameter\"\\`. Just set the value to \\`false\\` for the check you want to disable.\n All checks default to \\`true\\`, i.e. are enabled by default.\n Not that you cannot disable variables and parameters.\n "], Lint.Utils.dedent(_a)),
+ optionsDescription: (_a = ["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are `\"class\"`, `\"enum\"`, `\"function\"`, `\"import\"`, `\"interface\"`, `\"namespace\"`, `\"typeAlias\"`\n and `\"typeParameter\"`. Just set the value to `false` for the check you want to disable.\n All checks default to `true`, i.e. are enabled by default.\n Note that you cannot disable variables and parameters.\n "], _a.raw = ["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are \\`\"class\"\\`, \\`\"enum\"\\`, \\`\"function\"\\`, \\`\"import\"\\`, \\`\"interface\"\\`, \\`\"namespace\"\\`, \\`\"typeAlias\"\\`\n and \\`\"typeParameter\"\\`. Just set the value to \\`false\\` for the check you want to disable.\n All checks default to \\`true\\`, i.e. are enabled by default.\n Note that you cannot disable variables and parameters.\n "], Lint.Utils.dedent(_a)),
options: {
type: "object",
properties: {
diff --git a/node_modules/tslint/lib/rules/noStringLiteralRule.js b/node_modules/tslint/lib/rules/noStringLiteralRule.js
index 7774cbcb2..c543aa4d8 100644
--- a/node_modules/tslint/lib/rules/noStringLiteralRule.js
+++ b/node_modules/tslint/lib/rules/noStringLiteralRule.js
@@ -50,9 +50,11 @@ function walk(ctx) {
if (tsutils_1.isElementAccessExpression(node)) {
var argument = node.argumentExpression;
if (argument !== undefined && tsutils_1.isStringLiteral(argument) && tsutils_1.isValidPropertyAccess(argument.text)) {
+ // for compatibility with typescript@<2.5.0 to avoid fixing expr['__foo'] to expr.___foo
+ var propertyName = ts.unescapeIdentifier(argument.text); // tslint:disable-line:deprecation
ctx.addFailureAtNode(argument, Rule.FAILURE_STRING,
// expr['foo'] -> expr.foo
- Lint.Replacement.replaceFromTo(node.expression.end, node.end, "." + argument.text));
+ Lint.Replacement.replaceFromTo(node.expression.end, node.end, "." + propertyName));
}
}
return ts.forEachChild(node, cb);
diff --git a/node_modules/tslint/lib/rules/noSubmoduleImportsRule.js b/node_modules/tslint/lib/rules/noSubmoduleImportsRule.js
index 37e661b1f..d0ae3c619 100644
--- a/node_modules/tslint/lib/rules/noSubmoduleImportsRule.js
+++ b/node_modules/tslint/lib/rules/noSubmoduleImportsRule.js
@@ -26,7 +26,7 @@ var Rule = /** @class */ (function (_super) {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
- return this.applyWithWalker(new NoSubmoduleImportsWalker(sourceFile, this.ruleName, this.ruleArguments));
+ return this.applyWithFunction(sourceFile, walk, this.ruleArguments);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
@@ -48,61 +48,27 @@ var Rule = /** @class */ (function (_super) {
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
-var NoSubmoduleImportsWalker = /** @class */ (function (_super) {
- tslib_1.__extends(NoSubmoduleImportsWalker, _super);
- function NoSubmoduleImportsWalker() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- NoSubmoduleImportsWalker.prototype.walk = function (sourceFile) {
- var _this = this;
- var findDynamicImport = function (node) {
- if (tsutils_1.isCallExpression(node) && node.arguments.length === 1 &&
- (tsutils_1.isIdentifier(node.expression) && node.expression.text === "require" ||
- node.expression.kind === ts.SyntaxKind.ImportKeyword)) {
- _this.checkForBannedImport(node.arguments[0]);
- }
- return ts.forEachChild(node, findDynamicImport);
- };
- for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
- var statement = _a[_i];
- if (tsutils_1.isImportDeclaration(statement)) {
- this.checkForBannedImport(statement.moduleSpecifier);
- }
- else if (tsutils_1.isImportEqualsDeclaration(statement)) {
- if (tsutils_1.isExternalModuleReference(statement.moduleReference) && statement.moduleReference.expression !== undefined) {
- this.checkForBannedImport(statement.moduleReference.expression);
- }
- }
- else {
- ts.forEachChild(statement, findDynamicImport);
- }
+function walk(ctx) {
+ for (var _i = 0, _a = tsutils_1.findImports(ctx.sourceFile, 31 /* All */); _i < _a.length; _i++) {
+ var name = _a[_i];
+ // TODO remove assertion on upgrade to typescript@2.5.2
+ if (!ts.isExternalModuleNameRelative(name.text) &&
+ isSubmodulePath(name.text) &&
+ !isWhitelisted(name.text, ctx.options)) {
+ ctx.addFailureAtNode(name, Rule.FAILURE_STRING);
}
- };
- NoSubmoduleImportsWalker.prototype.checkForBannedImport = function (expression) {
- if (tsutils_1.isTextualLiteral(expression) &&
- // TODO remove assertion on upgrade to typescript@2.5.2
- !ts.isExternalModuleNameRelative(expression.text) &&
- isSubmodulePath(expression.text)) {
- /*
- * A submodule is being imported.
- * Check if its path contains any
- * of the whitelist packages.
- */
- for (var _i = 0, _a = this.options; _i < _a.length; _i++) {
- var option = _a[_i];
- if (expression.text === option || expression.text.startsWith(option + "/")) {
- return;
- }
- }
- this.addFailureAtNode(expression, Rule.FAILURE_STRING);
+ }
+}
+function isWhitelisted(path, whitelist) {
+ for (var _i = 0, whitelist_1 = whitelist; _i < whitelist_1.length; _i++) {
+ var option = whitelist_1[_i];
+ if (path === option || path.startsWith(option + "/")) {
+ return true;
}
- };
- return NoSubmoduleImportsWalker;
-}(Lint.AbstractWalker));
-function isScopedPath(path) {
- return path[0] === "@";
+ }
+ return false;
}
function isSubmodulePath(path) {
- return path.split("/").length > (isScopedPath(path) ? 2 : 1);
+ return path.split("/").length > (path[0] === "@" ? 2 : 1);
}
var _a, _b;
diff --git a/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js b/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js
index 3531bc9ae..5ad6cbe8a 100644
--- a/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js
+++ b/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js
@@ -24,6 +24,7 @@ var noConsecutiveBlankLinesRule_1 = require("./noConsecutiveBlankLinesRule");
var OPTION_IGNORE_COMMENTS = "ignore-comments";
var OPTION_IGNORE_JSDOC = "ignore-jsdoc";
var OPTION_IGNORE_TEMPLATE_STRINGS = "ignore-template-strings";
+var OPTION_IGNORE_BLANK_LINES = "ignore-blank-lines";
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
@@ -32,6 +33,7 @@ var Rule = /** @class */ (function (_super) {
Rule.prototype.apply = function (sourceFile) {
var ignoreComments = this.ruleArguments.indexOf(OPTION_IGNORE_COMMENTS) !== -1;
return this.applyWithFunction(sourceFile, walk, {
+ ignoreBlankLines: this.ruleArguments.indexOf(OPTION_IGNORE_BLANK_LINES) !== -1,
ignoreComments: ignoreComments,
ignoreJsDoc: ignoreComments || this.ruleArguments.indexOf(OPTION_IGNORE_JSDOC) !== -1,
ignoreTemplates: this.ruleArguments.indexOf(OPTION_IGNORE_TEMPLATE_STRINGS) !== -1,
@@ -42,13 +44,13 @@ var Rule = /** @class */ (function (_super) {
ruleName: "no-trailing-whitespace",
description: "Disallows trailing whitespace at the end of a line.",
rationale: "Keeps version control diffs clean as it prevents accidental whitespace from being committed.",
- optionsDescription: (_a = ["\n Possible settings are:\n\n * `\"", "\"`: Allows trailing whitespace in template strings.\n * `\"", "\"`: Allows trailing whitespace in comments.\n * `\"", "\"`: Allows trailing whitespace only in JSDoc comments."], _a.raw = ["\n Possible settings are:\n\n * \\`\"", "\"\\`: Allows trailing whitespace in template strings.\n * \\`\"", "\"\\`: Allows trailing whitespace in comments.\n * \\`\"", "\"\\`: Allows trailing whitespace only in JSDoc comments."], Lint.Utils.dedent(_a, OPTION_IGNORE_TEMPLATE_STRINGS, OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC)),
+ optionsDescription: (_a = ["\n Possible settings are:\n\n * `\"", "\"`: Allows trailing whitespace in template strings.\n * `\"", "\"`: Allows trailing whitespace in comments.\n * `\"", "\"`: Allows trailing whitespace only in JSDoc comments.\n * `\"", "\"`: Allows trailing whitespace on empty lines."], _a.raw = ["\n Possible settings are:\n\n * \\`\"", "\"\\`: Allows trailing whitespace in template strings.\n * \\`\"", "\"\\`: Allows trailing whitespace in comments.\n * \\`\"", "\"\\`: Allows trailing whitespace only in JSDoc comments.\n * \\`\"", "\"\\`: Allows trailing whitespace on empty lines."], Lint.Utils.dedent(_a, OPTION_IGNORE_TEMPLATE_STRINGS, OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC, OPTION_IGNORE_BLANK_LINES)),
hasFix: true,
options: {
type: "array",
items: {
type: "string",
- enum: [OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC, OPTION_IGNORE_TEMPLATE_STRINGS],
+ enum: [OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC, OPTION_IGNORE_TEMPLATE_STRINGS, OPTION_IGNORE_BLANK_LINES],
},
},
optionExamples: [
@@ -70,8 +72,9 @@ function walk(ctx) {
var text = sourceFile.text;
for (var _i = 0, _a = tsutils_1.getLineRanges(sourceFile); _i < _a.length; _i++) {
var line = _a[_i];
+ // \s matches any whitespace character (equal to [\r\n\t\f\v ])
var match = text.substr(line.pos, line.contentLength).match(/\s+$/);
- if (match !== null) {
+ if (match !== null && !(ctx.options.ignoreBlankLines && match.index === 0)) {
possibleFailures.push({
end: line.pos + line.contentLength,
pos: line.pos + match.index,
diff --git a/node_modules/tslint/lib/rules/noUnboundMethodRule.js b/node_modules/tslint/lib/rules/noUnboundMethodRule.js
index a60eb6335..153550c57 100644
--- a/node_modules/tslint/lib/rules/noUnboundMethodRule.js
+++ b/node_modules/tslint/lib/rules/noUnboundMethodRule.js
@@ -96,6 +96,7 @@ function isSafeUse(node) {
case ts.SyntaxKind.WhileStatement:
case ts.SyntaxKind.DoStatement:
case ts.SyntaxKind.ForStatement:
+ case ts.SyntaxKind.PrefixUnaryExpression:
return true;
default:
return false;
diff --git a/node_modules/tslint/lib/rules/noUnnecessaryClassRule.d.ts b/node_modules/tslint/lib/rules/noUnnecessaryClassRule.d.ts
new file mode 100644
index 000000000..afaa33e43
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noUnnecessaryClassRule.d.ts
@@ -0,0 +1,25 @@
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import * as Lint from "../index";
+export declare class Rule extends Lint.Rules.AbstractRule {
+ static metadata: Lint.IRuleMetadata;
+ static FAILURE_CONSTRUCTOR_ONLY: string;
+ static FAILURE_STATIC_ONLY: string;
+ static FAILURE_EMPTY_CLASS: string;
+ apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
+}
diff --git a/node_modules/tslint/lib/rules/noUnnecessaryClassRule.js b/node_modules/tslint/lib/rules/noUnnecessaryClassRule.js
new file mode 100644
index 000000000..fff8b5ed1
--- /dev/null
+++ b/node_modules/tslint/lib/rules/noUnnecessaryClassRule.js
@@ -0,0 +1,113 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var ts = require("typescript");
+var Lint = require("../index");
+var tsutils_1 = require("tsutils");
+var OPTION__ALLOW_CONSTRUCTOR_ONLY = "allow-constructor-only";
+var OPTION__ALLOW_EMPTY_CLASS = "allow-empty-class";
+var OPTION__ALLOW_STATIC_ONLY = "allow-static-only";
+function parseOptions(options) {
+ return {
+ allowConstructorOnly: options.indexOf(OPTION__ALLOW_CONSTRUCTOR_ONLY) !== -1,
+ allowEmptyClass: options.indexOf(OPTION__ALLOW_EMPTY_CLASS) !== -1,
+ allowStaticOnly: options.indexOf(OPTION__ALLOW_STATIC_ONLY) !== -1,
+ };
+}
+var Rule = /** @class */ (function (_super) {
+ tslib_1.__extends(Rule, _super);
+ function Rule() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ Rule.prototype.apply = function (sourceFile) {
+ return this.applyWithWalker(new NoUnnecessaryClassWalker(sourceFile, this.ruleName, parseOptions(this.ruleArguments)));
+ };
+ /* tslint:disable:object-literal-sort-keys */
+ Rule.metadata = {
+ ruleName: "no-unnecessary-class",
+ description: (_a = ["\n Disallows classes that are not strictly necessary."], _a.raw = ["\n Disallows classes that are not strictly necessary."], Lint.Utils.dedent(_a)),
+ rationale: (_b = ["\n Users who come from a Java-style OO language may wrap\n their utility functions in an extra class, instead of\n putting them at the top level."], _b.raw = ["\n Users who come from a Java-style OO language may wrap\n their utility functions in an extra class, instead of\n putting them at the top level."], Lint.Utils.dedent(_b)),
+ optionsDescription: (_c = ["\n Three arguments may be optionally provided:\n\n * `\"allow-constructor-only\"` ignores classes whose members are constructors.\n * `\"allow-empty-class\"` ignores `class DemoClass {}`.\n * `\"allow-static-only\"` ignores classes whose members are static."], _c.raw = ["\n Three arguments may be optionally provided:\n\n * \\`\"allow-constructor-only\"\\` ignores classes whose members are constructors.\n * \\`\"allow-empty-class\"\\` ignores \\`class DemoClass {}\\`.\n * \\`\"allow-static-only\"\\` ignores classes whose members are static."], Lint.Utils.dedent(_c)),
+ options: {
+ type: "array",
+ items: {
+ type: "string",
+ },
+ minLength: 0,
+ maxLength: 3,
+ },
+ optionExamples: [true, ["allow-empty-class", "allow-constructor-only"]],
+ type: "functionality",
+ typescriptOnly: false,
+ };
+ /* tslint:enable:object-literal-sort-keys */
+ Rule.FAILURE_CONSTRUCTOR_ONLY = "Every member of this class is a constructor. Use functions instead.";
+ Rule.FAILURE_STATIC_ONLY = "Every member of this class is static. Use namespaces or plain objects instead.";
+ Rule.FAILURE_EMPTY_CLASS = "This class has no members.";
+ return Rule;
+}(Lint.Rules.AbstractRule));
+exports.Rule = Rule;
+var NoUnnecessaryClassWalker = /** @class */ (function (_super) {
+ tslib_1.__extends(NoUnnecessaryClassWalker, _super);
+ function NoUnnecessaryClassWalker() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ NoUnnecessaryClassWalker.prototype.walk = function (sourceFile) {
+ var _this = this;
+ var checkIfUnnecessaryClass = function (node) {
+ if (tsutils_1.isClassDeclaration(node) && !hasExtendsClause(node)) {
+ _this.checkMembers(node);
+ }
+ return ts.forEachChild(node, checkIfUnnecessaryClass);
+ };
+ ts.forEachChild(sourceFile, checkIfUnnecessaryClass);
+ };
+ NoUnnecessaryClassWalker.prototype.checkMembers = function (node) {
+ if (node.members.length === 0) {
+ if (!this.options.allowEmptyClass) {
+ this.addFailureAtNode(tsutils_1.getChildOfKind(node, ts.SyntaxKind.ClassKeyword), Rule.FAILURE_EMPTY_CLASS);
+ }
+ return;
+ }
+ var allMembersAreConstructors = node.members.every(tsutils_1.isConstructorDeclaration);
+ if (allMembersAreConstructors &&
+ !this.options.allowConstructorOnly &&
+ !node.members.some(isConstructorWithShorthandProps)) {
+ this.addFailureAtNode(tsutils_1.getChildOfKind(node, ts.SyntaxKind.ClassKeyword, this.sourceFile), Rule.FAILURE_CONSTRUCTOR_ONLY);
+ }
+ if (!allMembersAreConstructors &&
+ !this.options.allowStaticOnly &&
+ !node.members.some(isNonStaticMember)) {
+ this.addFailureAtNode(tsutils_1.getChildOfKind(node, ts.SyntaxKind.ClassKeyword, this.sourceFile), Rule.FAILURE_STATIC_ONLY);
+ }
+ };
+ return NoUnnecessaryClassWalker;
+}(Lint.AbstractWalker));
+function isNonStaticMember(member) {
+ return (isConstructorWithShorthandProps(member) ||
+ (!tsutils_1.isConstructorDeclaration(member) && !tsutils_1.hasModifier(member.modifiers, ts.SyntaxKind.StaticKeyword)));
+}
+function hasExtendsClause(declaration) {
+ return (declaration.heritageClauses !== undefined &&
+ declaration.heritageClauses[0].token === ts.SyntaxKind.ExtendsKeyword);
+}
+function isConstructorWithShorthandProps(member) {
+ return tsutils_1.isConstructorDeclaration(member) && member.parameters.some(tsutils_1.isParameterProperty);
+}
+var _a, _b, _c;
diff --git a/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.js b/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.js
index ff2858c41..a9a32b362 100644
--- a/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.js
+++ b/node_modules/tslint/lib/rules/noUnnecessaryQualifierRule.js
@@ -103,7 +103,7 @@ function walk(ctx, checker) {
}
function symbolIsNamespaceInScope(symbol) {
var symbolDeclarations = symbol.getDeclarations();
- if (symbolDeclarations == null) {
+ if (symbolDeclarations === undefined) {
return false;
}
else if (symbolDeclarations.some(function (decl) { return namespacesInScope.some(function (ns) { return ns === decl; }); })) {
diff --git a/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.js b/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.js
index 97a06adfc..6af6a0d60 100644
--- a/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.js
+++ b/node_modules/tslint/lib/rules/noUnnecessaryTypeAssertionRule.js
@@ -26,14 +26,20 @@ var Rule = /** @class */ (function (_super) {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.applyWithProgram = function (sourceFile, program) {
- return this.applyWithWalker(new Walker(sourceFile, this.ruleName, program.getTypeChecker()));
+ return this.applyWithWalker(new Walker(sourceFile, this.ruleName, this.ruleArguments, program.getTypeChecker()));
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "no-unnecessary-type-assertion",
description: "Warns if a type assertion does not change the type of an expression.",
- options: null,
- optionsDescription: "Not configurable",
+ options: {
+ type: "list",
+ listType: {
+ type: "array",
+ items: { type: "string" },
+ },
+ },
+ optionsDescription: "A list of whitelisted assertion types to ignore",
type: "typescript",
hasFix: true,
typescriptOnly: true,
@@ -46,8 +52,8 @@ var Rule = /** @class */ (function (_super) {
exports.Rule = Rule;
var Walker = /** @class */ (function (_super) {
tslib_1.__extends(Walker, _super);
- function Walker(sourceFile, ruleName, checker) {
- var _this = _super.call(this, sourceFile, ruleName, undefined) || this;
+ function Walker(sourceFile, ruleName, options, checker) {
+ var _this = _super.call(this, sourceFile, ruleName, options) || this;
_this.checker = checker;
return _this;
}
@@ -65,6 +71,9 @@ var Walker = /** @class */ (function (_super) {
return ts.forEachChild(sourceFile, cb);
};
Walker.prototype.verifyCast = function (node) {
+ if (tsutils_1.isAssertionExpression(node) && this.options.indexOf(node.type.getText(this.sourceFile)) !== -1) {
+ return;
+ }
var castType = this.checker.getTypeAtLocation(node);
if (castType === undefined) {
return;
@@ -72,7 +81,12 @@ var Walker = /** @class */ (function (_super) {
if (node.kind !== ts.SyntaxKind.NonNullExpression &&
(tsutils_1.isTypeFlagSet(castType, ts.TypeFlags.Literal) ||
tsutils_1.isObjectType(castType) &&
- tsutils_1.isObjectFlagSet(castType, ts.ObjectFlags.Tuple))) {
+ tsutils_1.isObjectFlagSet(castType, ts.ObjectFlags.Tuple)) ||
+ // Sometimes tuple types don't have ObjectFlags.Tuple set, like when
+ // they're being matched against an inferred type. So, in addition,
+ // check if any properties are numbers, which implies that this is
+ // likely a tuple type.
+ (castType.getProperties().some(function (symbol) { return !isNaN(Number(symbol.name)); }))) {
// It's not always safe to remove a cast to a literal type or tuple
// type, as those types are sometimes widened without the cast.
return;
diff --git a/node_modules/tslint/lib/rules/noUnsafeAnyRule.js b/node_modules/tslint/lib/rules/noUnsafeAnyRule.js
index 3ff493ce9..c0a36360a 100644
--- a/node_modules/tslint/lib/rules/noUnsafeAnyRule.js
+++ b/node_modules/tslint/lib/rules/noUnsafeAnyRule.js
@@ -26,7 +26,7 @@ var Rule = /** @class */ (function (_super) {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.applyWithProgram = function (sourceFile, program) {
- return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker());
+ return this.applyWithWalker(new NoUnsafeAnyWalker(sourceFile, this.ruleName, program.getTypeChecker()));
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
@@ -44,229 +44,319 @@ var Rule = /** @class */ (function (_super) {
return Rule;
}(Lint.Rules.TypedRule));
exports.Rule = Rule;
-function walk(ctx, checker) {
- if (ctx.sourceFile.isDeclarationFile) {
- // Not possible in a declaration file.
- return;
+var NoUnsafeAnyWalker = /** @class */ (function (_super) {
+ tslib_1.__extends(NoUnsafeAnyWalker, _super);
+ function NoUnsafeAnyWalker(sourceFile, ruleName, checker) {
+ var _this = _super.call(this, sourceFile, ruleName, undefined) || this;
+ _this.checker = checker;
+ /** Wraps `visitNode` with the correct `this` binding and discards the return value to prevent `forEachChild` from returning early */
+ _this.visitNodeCallback = function (node) { return void _this.visitNode(node); };
+ return _this;
}
- return ts.forEachChild(ctx.sourceFile, cb);
- /** @param anyOk If true, this node will be allowed to be of type *any*. (But its children might not.) */
- function cb(node, anyOk) {
+ NoUnsafeAnyWalker.prototype.walk = function (sourceFile) {
+ if (sourceFile.isDeclarationFile) {
+ return; // Not possible in a declaration file.
+ }
+ sourceFile.statements.forEach(this.visitNodeCallback);
+ };
+ NoUnsafeAnyWalker.prototype.visitNode = function (node, anyOk) {
switch (node.kind) {
case ts.SyntaxKind.ParenthesizedExpression:
// Don't warn on a parenthesized expression, warn on its contents.
- return cb(node.expression, anyOk);
- case ts.SyntaxKind.Parameter: {
- var _a = node, type = _a.type, initializer = _a.initializer;
- // TODO handle destructuring
- if (initializer !== undefined) {
- return cb(initializer, /*anyOk*/ type !== undefined && type.kind === ts.SyntaxKind.AnyKeyword);
- }
- return;
- }
+ return this.visitNode(node.expression, anyOk);
case ts.SyntaxKind.LabeledStatement:
// Ignore label
- return cb(node.statement);
- case ts.SyntaxKind.BreakStatement: // Ignore label
+ return this.visitNode(node.statement);
+ // ignore labels
+ case ts.SyntaxKind.BreakStatement:
case ts.SyntaxKind.ContinueStatement:
// Ignore types
case ts.SyntaxKind.InterfaceDeclaration:
case ts.SyntaxKind.TypeAliasDeclaration:
- case ts.SyntaxKind.QualifiedName:
- case ts.SyntaxKind.TypePredicate:
- case ts.SyntaxKind.TypeOfExpression:
+ case ts.SyntaxKind.TypeParameter:
+ case ts.SyntaxKind.IndexSignature:
// Ignore imports
case ts.SyntaxKind.ImportEqualsDeclaration:
case ts.SyntaxKind.ImportDeclaration:
case ts.SyntaxKind.ExportDeclaration:
- // These show as type "any" if in type position.
- case ts.SyntaxKind.NumericLiteral:
- case ts.SyntaxKind.StringLiteral:
- return;
+ case ts.SyntaxKind.ExportAssignment:
+ return false;
+ case ts.SyntaxKind.ThisKeyword:
+ case ts.SyntaxKind.Identifier:
+ return anyOk ? false : this.check(node);
// Recurse through these, but ignore the immediate child because it is allowed to be 'any'.
case ts.SyntaxKind.DeleteExpression:
case ts.SyntaxKind.ExpressionStatement:
case ts.SyntaxKind.TypeAssertionExpression:
case ts.SyntaxKind.AsExpression:
case ts.SyntaxKind.TemplateSpan: // Allow stringification (works on all values). Note: tagged templates handled differently.
- case ts.SyntaxKind.ThrowStatement: {
- var expression = node.expression;
- return cb(expression, /*anyOk*/ true);
- }
+ case ts.SyntaxKind.ThrowStatement:
+ case ts.SyntaxKind.TypeOfExpression:
+ case ts.SyntaxKind.VoidExpression:
+ return this.visitNode(node.expression, true);
case ts.SyntaxKind.PropertyAssignment: {
- // Only check RHS.
- var _b = node, name = _b.name, initializer = _b.initializer;
- // The LHS will be 'any' if the RHS is, so just handle the RHS.
- // Still need to check the LHS in case it is a computed key.
- cb(name, /*anyOk*/ true);
- cb(initializer);
- return;
+ var _a = node, name = _a.name, initializer = _a.initializer;
+ this.visitNode(name, /*anyOk*/ true);
+ if (tsutils_1.isReassignmentTarget(node.parent)) {
+ return this.visitNode(initializer, true);
+ }
+ return this.checkContextualType(initializer, true);
+ }
+ case ts.SyntaxKind.ShorthandPropertyAssignment: {
+ var _b = node, name = _b.name, objectAssignmentInitializer = _b.objectAssignmentInitializer;
+ if (objectAssignmentInitializer !== undefined) {
+ return this.checkContextualType(objectAssignmentInitializer);
+ }
+ return this.checkContextualType(name, true);
}
case ts.SyntaxKind.PropertyDeclaration: {
var _c = node, name = _c.name, initializer = _c.initializer;
- if (initializer !== undefined) {
- return cb(initializer, /*anyOk*/ isNodeAny(name, checker));
- }
- return;
+ this.visitNode(name, true);
+ return initializer !== undefined &&
+ this.visitNode(initializer, isPropertyAny(node, this.checker));
}
+ case ts.SyntaxKind.ComputedPropertyName:
+ return this.visitNode(node.expression, true);
case ts.SyntaxKind.TaggedTemplateExpression: {
var _d = node, tag = _d.tag, template = _d.template;
- cb(tag);
if (template.kind === ts.SyntaxKind.TemplateExpression) {
for (var _i = 0, _e = template.templateSpans; _i < _e.length; _i++) {
var expression = _e[_i].expression;
- checkContextual(expression);
+ this.checkContextualType(expression);
}
}
// Also check the template expression itself
- check();
- return;
+ if (this.visitNode(tag)) {
+ return true;
+ }
+ return anyOk ? false : this.check(node);
}
case ts.SyntaxKind.CallExpression:
case ts.SyntaxKind.NewExpression: {
var _f = node, expression = _f.expression, args = _f.arguments;
- cb(expression);
if (args !== undefined) {
for (var _g = 0, args_1 = args; _g < args_1.length; _g++) {
var arg = args_1[_g];
- checkContextual(arg);
+ this.checkContextualType(arg);
}
}
+ if (this.visitNode(expression)) {
+ return true;
+ }
// Also check the call expression itself
- check();
- return;
+ return anyOk ? false : this.check(node);
}
case ts.SyntaxKind.PropertyAccessExpression:
// Don't warn for right hand side; this is redundant if we warn for the access itself.
- cb(node.expression);
- check();
- return;
- case ts.SyntaxKind.VariableDeclaration:
- return checkVariableDeclaration(node);
- case ts.SyntaxKind.BinaryExpression:
- return checkBinaryExpression(node);
+ if (this.visitNode(node.expression)) {
+ return true;
+ }
+ return anyOk ? false : this.check(node);
+ case ts.SyntaxKind.ElementAccessExpression: {
+ var _h = node, expression = _h.expression, argumentExpression = _h.argumentExpression;
+ if (argumentExpression !== undefined) {
+ this.visitNode(argumentExpression, true);
+ }
+ if (this.visitNode(expression)) {
+ return true;
+ }
+ return anyOk ? false : this.check(node);
+ }
case ts.SyntaxKind.ReturnStatement: {
var expression = node.expression;
- if (expression !== undefined) {
- return checkContextual(expression);
- }
- return;
+ return expression !== undefined && this.checkContextualType(expression, true);
}
case ts.SyntaxKind.SwitchStatement: {
- var _h = node, expression = _h.expression, clauses = _h.caseBlock.clauses;
+ var _j = node, expression = _j.expression, clauses = _j.caseBlock.clauses;
// Allow `switch (x) {}` where `x` is any
- cb(expression, /*anyOk*/ true);
- for (var _j = 0, clauses_1 = clauses; _j < clauses_1.length; _j++) {
- var clause = clauses_1[_j];
+ this.visitNode(expression, /*anyOk*/ true);
+ for (var _k = 0, clauses_1 = clauses; _k < clauses_1.length; _k++) {
+ var clause = clauses_1[_k];
if (clause.kind === ts.SyntaxKind.CaseClause) {
// Allow `case x:` where `x` is any
- cb(clause.expression, /*anyOk*/ true);
+ this.visitNode(clause.expression, /*anyOk*/ true);
}
- for (var _k = 0, _l = clause.statements; _k < _l.length; _k++) {
- var statement = _l[_k];
- cb(statement);
+ for (var _l = 0, _m = clause.statements; _l < _m.length; _l++) {
+ var statement = _m[_l];
+ this.visitNode(statement);
}
}
- break;
+ return false;
}
case ts.SyntaxKind.ModuleDeclaration: {
// In `declare global { ... }`, don't mark `global` as unsafe any.
var body = node.body;
- if (body !== undefined) {
- cb(body);
- }
- return;
+ return body !== undefined && this.visitNode(body);
}
case ts.SyntaxKind.IfStatement: {
- var _m = node, expression = _m.expression, thenStatement = _m.thenStatement, elseStatement = _m.elseStatement;
- cb(expression, true); // allow truthyness check
- cb(thenStatement);
- if (elseStatement !== undefined) {
- cb(elseStatement);
- }
- return;
+ var _o = node, expression = _o.expression, thenStatement = _o.thenStatement, elseStatement = _o.elseStatement;
+ this.visitNode(expression, true); // allow truthyness check
+ this.visitNode(thenStatement);
+ return elseStatement !== undefined && this.visitNode(elseStatement);
}
case ts.SyntaxKind.PrefixUnaryExpression: {
- var _o = node, operator = _o.operator, operand = _o.operand;
- cb(operand, operator === ts.SyntaxKind.ExclamationToken); // allow falsyness check
- check();
- return;
+ var _p = node, operator = _p.operator, operand = _p.operand;
+ this.visitNode(operand, operator === ts.SyntaxKind.ExclamationToken); // allow falsyness check
+ return false;
}
case ts.SyntaxKind.ForStatement: {
- var _p = node, initializer = _p.initializer, condition = _p.condition, incrementor = _p.incrementor, statement = _p.statement;
+ var _q = node, initializer = _q.initializer, condition = _q.condition, incrementor = _q.incrementor, statement = _q.statement;
if (initializer !== undefined) {
- cb(initializer);
+ this.visitNode(initializer, true);
}
if (condition !== undefined) {
- cb(condition, true);
+ this.visitNode(condition, true);
} // allow truthyness check
if (incrementor !== undefined) {
- cb(incrementor);
+ this.visitNode(incrementor, true);
}
- return cb(statement);
+ return this.visitNode(statement);
}
case ts.SyntaxKind.DoStatement:
case ts.SyntaxKind.WhileStatement:
- cb(node.statement);
- return cb(node.expression, true);
- default:
- if (!(tsutils_1.isExpression(node) && check())) {
- return ts.forEachChild(node, cb);
+ this.visitNode(node.expression, true);
+ return this.visitNode(node.statement);
+ case ts.SyntaxKind.ConditionalExpression: {
+ var _r = node, condition = _r.condition, whenTrue = _r.whenTrue, whenFalse = _r.whenFalse;
+ this.visitNode(condition, true);
+ var left = this.visitNode(whenTrue, anyOk);
+ return this.visitNode(whenFalse, anyOk) || left;
+ }
+ case ts.SyntaxKind.VariableDeclaration:
+ case ts.SyntaxKind.Parameter:
+ return this.checkVariableOrParameterDeclaration(node);
+ case ts.SyntaxKind.BinaryExpression:
+ return this.checkBinaryExpression(node, anyOk);
+ case ts.SyntaxKind.AwaitExpression:
+ this.visitNode(node.expression);
+ return anyOk ? false : this.check(node);
+ case ts.SyntaxKind.YieldExpression:
+ return this.checkYieldExpression(node, anyOk);
+ case ts.SyntaxKind.ClassExpression:
+ case ts.SyntaxKind.ClassDeclaration:
+ this.checkClassLikeDeclaration(node);
+ return false;
+ case ts.SyntaxKind.ArrayLiteralExpression: {
+ for (var _s = 0, _t = node.elements; _s < _t.length; _s++) {
+ var element = _t[_s];
+ this.checkContextualType(element, true);
}
- return;
- }
- function check() {
- var isUnsafe = !anyOk && isNodeAny(node, checker);
- if (isUnsafe) {
- ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
+ return false;
}
- return isUnsafe;
+ case ts.SyntaxKind.JsxExpression:
+ return node.expression !== undefined &&
+ this.checkContextualType(node.expression);
}
- }
- /** OK for this value to be 'any' if that's its contextual type. */
- function checkContextual(arg) {
- return cb(arg, /*anyOk*/ isAny(checker.getContextualType(arg)));
- }
- // Allow `const x = foo;` and `const x: any = foo`, but not `const x: Foo = foo;`.
- function checkVariableDeclaration(_a) {
- var type = _a.type, initializer = _a.initializer;
- // Always allow the LHS to be `any`. Just don't allow RHS to be `any` when LHS isn't.
- // TODO: handle destructuring
- if (initializer !== undefined) {
- return cb(initializer, /*anyOk*/ type === undefined || type.kind === ts.SyntaxKind.AnyKeyword);
+ if (tsutils_1.isTypeNodeKind(node.kind) || tsutils_1.isTokenKind(node.kind)) {
+ return false;
}
- return;
- }
- function checkBinaryExpression(node) {
- var _a = node, left = _a.left, right = _a.right, operatorToken = _a.operatorToken;
- // Allow equality since all values support equality.
- if (Lint.getEqualsKind(operatorToken) !== undefined) {
- return;
+ return ts.forEachChild(node, this.visitNodeCallback);
+ };
+ NoUnsafeAnyWalker.prototype.check = function (node) {
+ if (!isNodeAny(node, this.checker)) {
+ return false;
}
- switch (operatorToken.kind) {
- case ts.SyntaxKind.InstanceOfKeyword:// Allow test
- return cb(right);
+ this.addFailureAtNode(node, Rule.FAILURE_STRING);
+ return true;
+ };
+ NoUnsafeAnyWalker.prototype.checkContextualType = function (node, allowIfNoContextualType) {
+ var type = this.checker.getContextualType(node);
+ return this.visitNode(node, type === undefined && allowIfNoContextualType || isAny(type));
+ };
+ // Allow `const x = foo;` and `const x: any = foo`, but not `const x: Foo = foo;`.
+ NoUnsafeAnyWalker.prototype.checkVariableOrParameterDeclaration = function (_a) {
+ var name = _a.name, type = _a.type, initializer = _a.initializer;
+ this.checkBindingName(name);
+ // Always allow the LHS to be `any`. Just don't allow RHS to be `any` when LHS isn't.
+ return initializer !== undefined &&
+ this.visitNode(initializer,
+ /*anyOk*/
+ name.kind === ts.SyntaxKind.Identifier && (type === undefined || type.kind === ts.SyntaxKind.AnyKeyword) ||
+ type !== undefined && type.kind === ts.SyntaxKind.AnyKeyword);
+ };
+ NoUnsafeAnyWalker.prototype.checkBinaryExpression = function (node, anyOk) {
+ var allowAnyLeft = false;
+ var allowAnyRight = false;
+ switch (node.operatorToken.kind) {
+ case ts.SyntaxKind.ExclamationEqualsEqualsToken:
+ case ts.SyntaxKind.ExclamationEqualsToken:
+ case ts.SyntaxKind.EqualsEqualsEqualsToken:
+ case ts.SyntaxKind.EqualsEqualsToken:
case ts.SyntaxKind.CommaToken: // Allow `any, any`
case ts.SyntaxKind.BarBarToken: // Allow `any || any`
case ts.SyntaxKind.AmpersandAmpersandToken:// Allow `any && any`
- cb(left, /*anyOk*/ true);
- return cb(right, /*anyOk*/ true);
+ allowAnyLeft = allowAnyRight = true;
+ break;
+ case ts.SyntaxKind.InstanceOfKeyword:// Allow test
+ allowAnyLeft = true;
+ break;
case ts.SyntaxKind.EqualsToken:
// Allow assignment if the lhs is also *any*.
- // TODO: handle destructuring
- cb(right, /*anyOk*/ isNodeAny(left, checker));
- return;
+ allowAnyLeft = true;
+ allowAnyRight = isNodeAny(node.left, this.checker);
+ break;
case ts.SyntaxKind.PlusToken: // Allow implicit stringification
case ts.SyntaxKind.PlusEqualsToken:
- var anyOk = isStringLike(left, checker)
- || (isStringLike(right, checker) && operatorToken.kind === ts.SyntaxKind.PlusToken);
- cb(left, anyOk);
- return cb(right, anyOk);
- default:
- cb(left);
- return cb(right);
+ allowAnyLeft = allowAnyRight = isStringLike(node.left, this.checker)
+ || (isStringLike(node.right, this.checker) && node.operatorToken.kind === ts.SyntaxKind.PlusToken);
+ }
+ this.visitNode(node.left, allowAnyLeft);
+ this.visitNode(node.right, allowAnyRight);
+ return anyOk ? false : this.check(node);
+ };
+ NoUnsafeAnyWalker.prototype.checkYieldExpression = function (node, anyOk) {
+ if (node.expression !== undefined) {
+ this.checkContextualType(node.expression, true);
+ }
+ if (anyOk) {
+ return false;
+ }
+ this.addFailureAtNode(node, Rule.FAILURE_STRING);
+ return true;
+ };
+ NoUnsafeAnyWalker.prototype.checkClassLikeDeclaration = function (node) {
+ if (node.decorators !== undefined) {
+ node.decorators.forEach(this.visitNodeCallback);
+ }
+ if (node.heritageClauses !== undefined) {
+ node.heritageClauses.forEach(this.visitNodeCallback);
+ }
+ return node.members.forEach(this.visitNodeCallback);
+ };
+ NoUnsafeAnyWalker.prototype.checkBindingName = function (node) {
+ if (node.kind !== ts.SyntaxKind.Identifier) {
+ if (isNodeAny(node, this.checker)) {
+ this.addFailureAtNode(node, Rule.FAILURE_STRING);
+ }
+ for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
+ var element = _a[_i];
+ if (element.kind !== ts.SyntaxKind.OmittedExpression) {
+ if (element.propertyName !== undefined && element.propertyName.kind === ts.SyntaxKind.ComputedPropertyName) {
+ this.visitNode(element.propertyName.expression);
+ }
+ this.checkBindingName(element.name);
+ if (element.initializer !== undefined) {
+ this.checkContextualType(element.initializer);
+ }
+ }
+ }
+ }
+ };
+ return NoUnsafeAnyWalker;
+}(Lint.AbstractWalker));
+/** Check if property has no type annotation in this class and the base class */
+function isPropertyAny(node, checker) {
+ if (!isNodeAny(node.name, checker) || node.name.kind === ts.SyntaxKind.ComputedPropertyName) {
+ return false;
+ }
+ for (var _i = 0, _a = checker.getBaseTypes(checker.getTypeAtLocation(node.parent)); _i < _a.length; _i++) {
+ var base = _a[_i];
+ var prop = base.getProperty(node.name.text);
+ if (prop !== undefined && prop.declarations !== undefined) {
+ return isAny(checker.getTypeOfSymbolAtLocation(prop, prop.declarations[0]));
}
}
+ return true;
}
function isNodeAny(node, checker) {
return isAny(checker.getTypeAtLocation(node));
diff --git a/node_modules/tslint/lib/rules/noUnusedVariableRule.js b/node_modules/tslint/lib/rules/noUnusedVariableRule.js
index 02506f434..b7b9f6fe4 100644
--- a/node_modules/tslint/lib/rules/noUnusedVariableRule.js
+++ b/node_modules/tslint/lib/rules/noUnusedVariableRule.js
@@ -29,19 +29,15 @@ var Rule = /** @class */ (function (_super) {
}
/* tslint:enable:object-literal-sort-keys */
Rule.prototype.applyWithProgram = function (sourceFile, program) {
- var x = program.getCompilerOptions();
- if (x.noUnusedLocals && x.noUnusedParameters) {
- console.warn("WARNING: 'no-unused-variable' lint rule does not need to be set if " +
- "the 'no-unused-locals' and 'no-unused-parameters' compiler options are enabled.");
- }
return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments), program);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "no-unused-variable",
description: (_a = ["Disallows unused imports, variables, functions and\n private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals\n options, but does not interrupt code compilation."], _a.raw = ["Disallows unused imports, variables, functions and\n private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals\n options, but does not interrupt code compilation."], Lint.Utils.dedent(_a)),
+ descriptionDetails: (_b = ["\n In addition to avoiding compilation errors, this rule may still be useful if you\n wish to have `tslint` automatically remove unused imports, variables, functions,\n and private class members, when using TSLint's `--fix` option."], _b.raw = ["\n In addition to avoiding compilation errors, this rule may still be useful if you\n wish to have \\`tslint\\` automatically remove unused imports, variables, functions,\n and private class members, when using TSLint's \\`--fix\\` option."], Lint.Utils.dedent(_b)),
hasFix: true,
- optionsDescription: (_b = ["\n Three optional arguments may be optionally provided:\n\n * `\"check-parameters\"` disallows unused function and constructor parameters.\n * NOTE: this option is experimental and does not work with classes\n that use abstract method declarations, among other things.\n * `{\"ignore-pattern\": \"pattern\"}` where pattern is a case-sensitive regexp.\n Variable names that match the pattern will be ignored."], _b.raw = ["\n Three optional arguments may be optionally provided:\n\n * \\`\"check-parameters\"\\` disallows unused function and constructor parameters.\n * NOTE: this option is experimental and does not work with classes\n that use abstract method declarations, among other things.\n * \\`{\"ignore-pattern\": \"pattern\"}\\` where pattern is a case-sensitive regexp.\n Variable names that match the pattern will be ignored."], Lint.Utils.dedent(_b)),
+ optionsDescription: (_c = ["\n Three optional arguments may be optionally provided:\n\n * `\"check-parameters\"` disallows unused function and constructor parameters.\n * NOTE: this option is experimental and does not work with classes\n that use abstract method declarations, among other things.\n * `{\"ignore-pattern\": \"pattern\"}` where pattern is a case-sensitive regexp.\n Variable names and imports that match the pattern will be ignored."], _c.raw = ["\n Three optional arguments may be optionally provided:\n\n * \\`\"check-parameters\"\\` disallows unused function and constructor parameters.\n * NOTE: this option is experimental and does not work with classes\n that use abstract method declarations, among other things.\n * \\`{\"ignore-pattern\": \"pattern\"}\\` where pattern is a case-sensitive regexp.\n Variable names and imports that match the pattern will be ignored."], Lint.Utils.dedent(_c)),
options: {
type: "array",
items: {
@@ -78,7 +74,7 @@ function parseOptions(options) {
if (typeof o === "object") {
// tslint:disable-next-line no-unsafe-any
var ignore = o[OPTION_IGNORE_PATTERN];
- if (ignore != null) {
+ if (ignore != undefined) {
ignorePattern = new RegExp(ignore);
break;
}
@@ -104,6 +100,12 @@ function walk(ctx, program) {
continue;
}
var failure = ts.flattenDiagnosticMessageText(diag.messageText, "\n");
+ if (ignorePattern !== undefined) {
+ var varName = /'(.*)'/.exec(failure)[1];
+ if (ignorePattern.test(varName)) {
+ continue;
+ }
+ }
if (kind === 0 /* VARIABLE_OR_PARAMETER */) {
var importName = findImport(diag.start, sourceFile);
if (importName !== undefined) {
@@ -117,12 +119,6 @@ function walk(ctx, program) {
continue;
}
}
- if (ignorePattern !== undefined) {
- var varName = /'(.*)'/.exec(failure)[1];
- if (ignorePattern.test(varName)) {
- continue;
- }
- }
ctx.addFailureAt(diag.start, diag.length, failure);
}
if (importSpecifierFailures.size !== 0) {
@@ -375,4 +371,4 @@ function makeUnusedCheckedProgram(program, checkParameters) {
return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
}
}
-var _a, _b;
+var _a, _b, _c;
diff --git a/node_modules/tslint/lib/rules/noVarRequiresRule.js b/node_modules/tslint/lib/rules/noVarRequiresRule.js
index 25e212b3a..9a8dfb694 100644
--- a/node_modules/tslint/lib/rules/noVarRequiresRule.js
+++ b/node_modules/tslint/lib/rules/noVarRequiresRule.js
@@ -17,8 +17,6 @@
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
-// tslint:disable deprecation
-// (https://github.com/palantir/tslint/pull/2341)
var ts = require("typescript");
var Lint = require("../index");
var Rule = /** @class */ (function (_super) {
@@ -46,6 +44,7 @@ var Rule = /** @class */ (function (_super) {
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
+// tslint:disable-next-line:deprecation
var NoVarRequiresWalker = /** @class */ (function (_super) {
tslib_1.__extends(NoVarRequiresWalker, _super);
function NoVarRequiresWalker() {
diff --git a/node_modules/tslint/lib/rules/objectLiteralShorthandRule.d.ts b/node_modules/tslint/lib/rules/objectLiteralShorthandRule.d.ts
index 8d990f416..94e0c80a5 100644
--- a/node_modules/tslint/lib/rules/objectLiteralShorthandRule.d.ts
+++ b/node_modules/tslint/lib/rules/objectLiteralShorthandRule.d.ts
@@ -1,8 +1,9 @@
import * as ts from "typescript";
-import * as Lint from "../index";
+import * as Lint from "..";
export declare class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata;
static LONGHAND_PROPERTY: string;
static LONGHAND_METHOD: string;
+ static SHORTHAND_ASSIGNMENT: string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
}
diff --git a/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js b/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js
index 78d9d3bc9..59ac30d76 100644
--- a/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js
+++ b/node_modules/tslint/lib/rules/objectLiteralShorthandRule.js
@@ -19,33 +19,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
var ts = require("typescript");
-var Lint = require("../index");
+var Lint = require("..");
+var OPTION_NEVER = "never";
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
- return this.applyWithFunction(sourceFile, walk);
+ return this.applyWithFunction(sourceFile, this.ruleArguments.indexOf(OPTION_NEVER) === -1
+ ? enforceShorthandWalker
+ : disallowShorthandWalker);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "object-literal-shorthand",
- description: "Enforces use of ES6 object literal shorthand when possible.",
+ description: "Enforces/disallows use of ES6 object literal shorthand.",
hasFix: true,
- optionsDescription: "Not configurable.",
- options: null,
- optionExamples: [true],
+ optionsDescription: (_a = ["\n If the 'never' option is provided, any shorthand object literal syntax will cause a failure."], _a.raw = ["\n If the \\'never\\' option is provided, any shorthand object literal syntax will cause a failure."], Lint.Utils.dedent(_a)),
+ options: {
+ type: "string",
+ enum: [OPTION_NEVER],
+ },
+ optionExamples: [true, [true, OPTION_NEVER]],
type: "style",
typescriptOnly: false,
};
/* tslint:enable:object-literal-sort-keys */
Rule.LONGHAND_PROPERTY = "Expected property shorthand in object literal ";
Rule.LONGHAND_METHOD = "Expected method shorthand in object literal ";
+ Rule.SHORTHAND_ASSIGNMENT = "Shorthand property assignments have been disallowed.";
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
-function walk(ctx) {
+function disallowShorthandWalker(ctx) {
+ return ts.forEachChild(ctx.sourceFile, function cb(node) {
+ if (tsutils_1.isShorthandPropertyAssignment(node)) {
+ ctx.addFailureAtNode(node.name, Rule.SHORTHAND_ASSIGNMENT, Lint.Replacement.appendText(node.getStart(ctx.sourceFile), node.name.text + ": "));
+ }
+ else if (tsutils_1.isMethodDeclaration(node) && node.parent.kind === ts.SyntaxKind.ObjectLiteralExpression) {
+ ctx.addFailureAtNode(node.name, Rule.SHORTHAND_ASSIGNMENT, fixShorthandMethodDeclaration(node, ctx.sourceFile));
+ }
+ return ts.forEachChild(node, cb);
+ });
+}
+function enforceShorthandWalker(ctx) {
return ts.forEachChild(ctx.sourceFile, function cb(node) {
if (tsutils_1.isPropertyAssignment(node)) {
if (node.name.kind === ts.SyntaxKind.Identifier &&
@@ -57,12 +75,17 @@ function walk(ctx) {
// allow named function expressions
node.initializer.name === undefined) {
var _a = handleLonghandMethod(node.name, node.initializer, ctx.sourceFile), name = _a[0], fix = _a[1];
- ctx.addFailureAtNode(node, Rule.LONGHAND_METHOD + "('{" + name + "() {...}}').", fix);
+ ctx.addFailure(node.getStart(ctx.sourceFile), tsutils_1.getChildOfKind(node.initializer, ts.SyntaxKind.OpenParenToken, ctx.sourceFile).pos, Rule.LONGHAND_METHOD + "('{" + name + "() {...}}').", fix);
}
}
return ts.forEachChild(node, cb);
});
}
+function fixShorthandMethodDeclaration(node, sourceFile) {
+ var isGenerator = node.asteriskToken !== undefined;
+ var isAsync = tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword);
+ return Lint.Replacement.replaceFromTo(node.getStart(sourceFile), node.name.end, node.name.getText(sourceFile) + ":" + (isAsync ? " async" : "") + " function" + (isGenerator ? "*" : ""));
+}
function handleLonghandMethod(name, initializer, sourceFile) {
var nameStart = name.getStart(sourceFile);
var fix = Lint.Replacement.deleteFromTo(name.end, tsutils_1.getChildOfKind(initializer, ts.SyntaxKind.OpenParenToken).pos);
@@ -78,3 +101,4 @@ function handleLonghandMethod(name, initializer, sourceFile) {
}
return [prefix + sourceFile.text.substring(nameStart, name.end), fix];
}
+var _a;
diff --git a/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.js b/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.js
index ab8a4c332..70d7c5e49 100644
--- a/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.js
+++ b/node_modules/tslint/lib/rules/objectLiteralSortKeysRule.js
@@ -48,9 +48,9 @@ var Rule = /** @class */ (function (_super) {
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "object-literal-sort-keys",
- description: "Checks ordering of keys in object literals.",
+ description: (_a = ["\n Checks ordering of keys in object literals.\n\n When using the default alphabetical ordering, additional blank lines may be used to group\n object properties together while keeping the elements within each group in alphabetical order.\n "], _a.raw = ["\n Checks ordering of keys in object literals.\n\n When using the default alphabetical ordering, additional blank lines may be used to group\n object properties together while keeping the elements within each group in alphabetical order.\n "], Lint.Utils.dedent(_a)),
rationale: "Useful in preventing merge conflicts",
- optionsDescription: (_a = ["\n By default, this rule checks that keys are in alphabetical order.\n The following may optionally be passed:\n\n * \"", "\" will to compare keys in a case insensitive way.\n * \"", " will prefer to use the key ordering of the contextual type of the object literal, as in:\n\n interface I { foo: number; bar: number; }\n const obj: I = { foo: 1, bar: 2 };\n\n If a contextual type is not found, alphabetical ordering will be used instead.\n "], _a.raw = ["\n By default, this rule checks that keys are in alphabetical order.\n The following may optionally be passed:\n\n * \"", "\" will to compare keys in a case insensitive way.\n * \"", " will prefer to use the key ordering of the contextual type of the object literal, as in:\n\n interface I { foo: number; bar: number; }\n const obj: I = { foo: 1, bar: 2 };\n\n If a contextual type is not found, alphabetical ordering will be used instead.\n "], Lint.Utils.dedent(_a, OPTION_IGNORE_CASE, OPTION_MATCH_DECLARATION_ORDER)),
+ optionsDescription: (_b = ["\n By default, this rule checks that keys are in alphabetical order.\n The following may optionally be passed:\n\n * \"", "\" will to compare keys in a case insensitive way.\n * \"", "\" will prefer to use the key ordering of the contextual type of the object literal, as in:\n\n interface I { foo: number; bar: number; }\n const obj: I = { foo: 1, bar: 2 };\n\n If a contextual type is not found, alphabetical ordering will be used instead.\n "], _b.raw = ["\n By default, this rule checks that keys are in alphabetical order.\n The following may optionally be passed:\n\n * \"", "\" will to compare keys in a case insensitive way.\n * \"", "\" will prefer to use the key ordering of the contextual type of the object literal, as in:\n\n interface I { foo: number; bar: number; }\n const obj: I = { foo: 1, bar: 2 };\n\n If a contextual type is not found, alphabetical ordering will be used instead.\n "], Lint.Utils.dedent(_b, OPTION_IGNORE_CASE, OPTION_MATCH_DECLARATION_ORDER)),
options: {
type: "string",
enum: [OPTION_IGNORE_CASE, OPTION_MATCH_DECLARATION_ORDER],
@@ -112,7 +112,7 @@ function walk(ctx, checker) {
property.name.kind === ts.SyntaxKind.StringLiteral) {
var key = ignoreCase ? property.name.text.toLowerCase() : property.name.text;
// comparison with undefined is expected
- if (lastKey > key) {
+ if (lastKey > key && !hasBlankLineBefore(ctx.sourceFile, property)) {
ctx.addFailureAtNode(property.name, Rule.FAILURE_STRING_ALPHABETICAL(property.name.text));
return; // only show warning on first out-of-order property
}
@@ -137,7 +137,7 @@ function walk(ctx, checker) {
for (; memberIndex !== members.length; memberIndex++) {
var memberName = members[memberIndex].name;
if (memberName.kind !== ts.SyntaxKind.ComputedPropertyName && propName === memberName.text) {
- continue outer; // tslint:disable-line no-unsafe-any (fixed in tslint 5.4)
+ continue outer;
}
}
// This We didn't find the member we were looking for past the previous member,
@@ -148,6 +148,22 @@ function walk(ctx, checker) {
}
}
}
+function hasBlankLineBefore(sourceFile, element) {
+ var comments = ts.getLeadingCommentRanges(sourceFile.text, element.pos);
+ if (comments === undefined) {
+ comments = []; // it will be easier to work with an empty array down below...
+ }
+ var elementStart = comments.length > 0 ? comments[comments.length - 1].end : element.getFullStart();
+ // either the element itself, or one of its leading comments must have an extra new line before them
+ return hasDoubleNewLine(sourceFile, elementStart) || comments.some(function (comment) {
+ var commentLine = ts.getLineAndCharacterOfPosition(sourceFile, comment.pos).line;
+ var commentLineStartPosition = ts.getPositionOfLineAndCharacter(sourceFile, commentLine, 0);
+ return hasDoubleNewLine(sourceFile, commentLineStartPosition - 4);
+ });
+}
+function hasDoubleNewLine(sourceFile, position) {
+ return /(\r\n|\r|\n){2}/.test(sourceFile.text.slice(position, position + 4));
+}
function getTypeName(t) {
var parent = t.parent;
return t.kind === ts.SyntaxKind.InterfaceDeclaration
@@ -168,4 +184,4 @@ function getContextualType(node, checker) {
var decl = declarations[0];
return tsutils_1.isInterfaceDeclaration(decl) || tsutils_1.isTypeLiteralNode(decl) ? decl : undefined;
}
-var _a;
+var _a, _b;
diff --git a/node_modules/tslint/lib/rules/oneLineRule.d.ts b/node_modules/tslint/lib/rules/oneLineRule.d.ts
index 435a5db6d..73a63c253 100644
--- a/node_modules/tslint/lib/rules/oneLineRule.d.ts
+++ b/node_modules/tslint/lib/rules/oneLineRule.d.ts
@@ -2,10 +2,6 @@ import * as ts from "typescript";
import * as Lint from "../index";
export declare class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata;
- static BRACE_FAILURE_STRING: string;
- static CATCH_FAILURE_STRING: string;
- static ELSE_FAILURE_STRING: string;
- static FINALLY_FAILURE_STRING: string;
static WHITESPACE_FAILURE_STRING: string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
}
diff --git a/node_modules/tslint/lib/rules/oneLineRule.js b/node_modules/tslint/lib/rules/oneLineRule.js
index dcbd2169d..5d271ae91 100644
--- a/node_modules/tslint/lib/rules/oneLineRule.js
+++ b/node_modules/tslint/lib/rules/oneLineRule.js
@@ -31,8 +31,13 @@ var Rule = /** @class */ (function (_super) {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
- var oneLineWalker = new OneLineWalker(sourceFile, this.getOptions());
- return this.applyWithWalker(oneLineWalker);
+ return this.applyWithWalker(new OneLineWalker(sourceFile, this.ruleName, {
+ brace: this.ruleArguments.indexOf(OPTION_BRACE) !== -1,
+ catch: this.ruleArguments.indexOf(OPTION_CATCH) !== -1,
+ else: this.ruleArguments.indexOf(OPTION_ELSE) !== -1,
+ finally: this.ruleArguments.indexOf(OPTION_FINALLY) !== -1,
+ whitespace: this.ruleArguments.indexOf(OPTION_WHITESPACE) !== -1,
+ }));
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
@@ -51,12 +56,9 @@ var Rule = /** @class */ (function (_super) {
optionExamples: [[true, OPTION_CATCH, OPTION_FINALLY, OPTION_ELSE]],
type: "style",
typescriptOnly: false,
+ hasFix: true,
};
/* tslint:enable:object-literal-sort-keys */
- Rule.BRACE_FAILURE_STRING = "misplaced opening brace";
- Rule.CATCH_FAILURE_STRING = "misplaced 'catch'";
- Rule.ELSE_FAILURE_STRING = "misplaced 'else'";
- Rule.FINALLY_FAILURE_STRING = "misplaced 'finally'";
Rule.WHITESPACE_FAILURE_STRING = "missing whitespace";
return Rule;
}(Lint.Rules.AbstractRule));
@@ -66,204 +68,84 @@ var OneLineWalker = /** @class */ (function (_super) {
function OneLineWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
- OneLineWalker.prototype.visitIfStatement = function (node) {
- var thenStatement = node.thenStatement;
- var thenIsBlock = thenStatement.kind === ts.SyntaxKind.Block;
- if (thenIsBlock) {
- var expressionCloseParen = node.getChildAt(3);
- var thenOpeningBrace = thenStatement.getChildAt(0);
- this.handleOpeningBrace(expressionCloseParen, thenOpeningBrace);
- }
- var elseStatement = node.elseStatement;
- if (elseStatement != null) {
- // find the else keyword
- var elseKeyword = Lint.childOfKind(node, ts.SyntaxKind.ElseKeyword);
- if (elseStatement.kind === ts.SyntaxKind.Block) {
- var elseOpeningBrace = elseStatement.getChildAt(0);
- this.handleOpeningBrace(elseKeyword, elseOpeningBrace);
- }
- if (thenIsBlock && this.hasOption(OPTION_ELSE)) {
- var thenStatementEndLine = this.getLineAndCharacterOfPosition(thenStatement.getEnd()).line;
- var elseKeywordLine = this.getLineAndCharacterOfPosition(elseKeyword.getStart()).line;
- if (thenStatementEndLine !== elseKeywordLine) {
- this.addFailureAtNode(elseKeyword, Rule.ELSE_FAILURE_STRING);
+ OneLineWalker.prototype.walk = function (sourceFile) {
+ var _this = this;
+ var cb = function (node) {
+ switch (node.kind) {
+ case ts.SyntaxKind.Block:
+ if (!tsutils_1.isBlockLike(node.parent)) {
+ _this.check({ pos: node.pos, end: node.statements.pos });
+ }
+ break;
+ case ts.SyntaxKind.CaseBlock:
+ _this.check({ pos: node.pos, end: node.clauses.pos });
+ break;
+ case ts.SyntaxKind.ModuleBlock:
+ _this.check({ pos: node.pos, end: node.statements.pos });
+ break;
+ case ts.SyntaxKind.EnumDeclaration:
+ _this.check({ pos: node.name.end, end: node.members.pos });
+ break;
+ case ts.SyntaxKind.InterfaceDeclaration:
+ case ts.SyntaxKind.ClassDeclaration:
+ case ts.SyntaxKind.ClassExpression: {
+ _this.check(tsutils_1.getChildOfKind(node, ts.SyntaxKind.OpenBraceToken, sourceFile));
+ break;
}
- }
- }
- _super.prototype.visitIfStatement.call(this, node);
- };
- OneLineWalker.prototype.visitCatchClause = function (node) {
- var catchClosingParen = Lint.childOfKind(node, ts.SyntaxKind.CloseParenToken);
- var catchOpeningBrace = node.block.getChildAt(0);
- this.handleOpeningBrace(catchClosingParen, catchOpeningBrace);
- _super.prototype.visitCatchClause.call(this, node);
- };
- OneLineWalker.prototype.visitTryStatement = function (node) {
- var catchClause = node.catchClause;
- var finallyBlock = node.finallyBlock;
- var finallyKeyword = Lint.childOfKind(node, ts.SyntaxKind.FinallyKeyword);
- // "visit" try block
- var tryKeyword = node.getChildAt(0);
- var tryBlock = node.tryBlock;
- var tryOpeningBrace = tryBlock.getChildAt(0);
- this.handleOpeningBrace(tryKeyword, tryOpeningBrace);
- if (this.hasOption(OPTION_CATCH) && catchClause != null) {
- var tryClosingBrace = node.tryBlock.getChildAt(node.tryBlock.getChildCount() - 1);
- var catchKeyword = catchClause.getChildAt(0);
- var tryClosingBraceLine = this.getLineAndCharacterOfPosition(tryClosingBrace.getEnd()).line;
- var catchKeywordLine = this.getLineAndCharacterOfPosition(catchKeyword.getStart()).line;
- if (tryClosingBraceLine !== catchKeywordLine) {
- this.addFailureAtNode(catchKeyword, Rule.CATCH_FAILURE_STRING);
- }
- }
- if (finallyBlock != null && finallyKeyword != null) {
- var finallyOpeningBrace = finallyBlock.getChildAt(0);
- this.handleOpeningBrace(finallyKeyword, finallyOpeningBrace);
- if (this.hasOption(OPTION_FINALLY)) {
- var previousBlock = catchClause != null ? catchClause.block : node.tryBlock;
- var closingBrace = previousBlock.getChildAt(previousBlock.getChildCount() - 1);
- var closingBraceLine = this.getLineAndCharacterOfPosition(closingBrace.getEnd()).line;
- var finallyKeywordLine = this.getLineAndCharacterOfPosition(finallyKeyword.getStart()).line;
- if (closingBraceLine !== finallyKeywordLine) {
- this.addFailureAtNode(finallyKeyword, Rule.FINALLY_FAILURE_STRING);
+ case ts.SyntaxKind.IfStatement: {
+ var _a = node, thenStatement = _a.thenStatement, elseStatement = _a.elseStatement;
+ if (elseStatement !== undefined && thenStatement.kind === ts.SyntaxKind.Block) {
+ _this.check({ pos: thenStatement.end, end: elseStatement.pos }, "else");
+ }
+ break;
+ }
+ case ts.SyntaxKind.TryStatement: {
+ var _b = node, finallyBlock = _b.finallyBlock, catchClause = _b.catchClause, tryBlock = _b.tryBlock;
+ if (catchClause !== undefined) {
+ _this.check(catchClause.getChildAt(0, sourceFile), "catch");
+ if (finallyBlock !== undefined) {
+ _this.check({ pos: catchClause.end, end: finallyBlock.pos }, "finally");
+ }
+ }
+ else if (finallyBlock !== undefined) {
+ _this.check({ pos: tryBlock.end, end: finallyBlock.pos }, "finally");
+ }
+ break;
+ }
+ case ts.SyntaxKind.BinaryExpression: {
+ var _c = node, operatorToken = _c.operatorToken, right = _c.right;
+ if (operatorToken.kind === ts.SyntaxKind.EqualsToken && tsutils_1.isObjectLiteralExpression(right)) {
+ _this.check({ pos: right.pos, end: right.properties.pos });
+ }
+ break;
+ }
+ case ts.SyntaxKind.VariableDeclaration: {
+ var initializer = node.initializer;
+ if (initializer !== undefined && tsutils_1.isObjectLiteralExpression(initializer)) {
+ _this.check({ pos: initializer.pos, end: initializer.properties.pos });
+ }
+ break;
+ }
+ case ts.SyntaxKind.TypeAliasDeclaration: {
+ var type = node.type;
+ if (type.kind === ts.SyntaxKind.MappedType || type.kind === ts.SyntaxKind.TypeLiteral) {
+ _this.check(type.getChildAt(0, sourceFile));
+ }
}
}
+ return ts.forEachChild(node, cb);
+ };
+ return ts.forEachChild(sourceFile, cb);
+ };
+ OneLineWalker.prototype.check = function (range, kind) {
+ var tokenStart = range.end - (kind === undefined ? 1 : kind.length);
+ if (this.options[kind === undefined ? "brace" : kind] && !tsutils_1.isSameLine(this.sourceFile, range.pos, tokenStart)) {
+ this.addFailure(tokenStart, range.end, "misplaced " + (kind === undefined ? "opening brace" : "'" + kind + "'"), Lint.Replacement.replaceFromTo(range.pos, tokenStart, this.options.whitespace ? " " : ""));
}
- _super.prototype.visitTryStatement.call(this, node);
- };
- OneLineWalker.prototype.visitForStatement = function (node) {
- this.handleIterationStatement(node);
- _super.prototype.visitForStatement.call(this, node);
- };
- OneLineWalker.prototype.visitForInStatement = function (node) {
- this.handleIterationStatement(node);
- _super.prototype.visitForInStatement.call(this, node);
- };
- OneLineWalker.prototype.visitWhileStatement = function (node) {
- this.handleIterationStatement(node);
- _super.prototype.visitWhileStatement.call(this, node);
- };
- OneLineWalker.prototype.visitBinaryExpression = function (node) {
- var rightkind = node.right.kind;
- var opkind = node.operatorToken.kind;
- if (opkind === ts.SyntaxKind.EqualsToken && rightkind === ts.SyntaxKind.ObjectLiteralExpression) {
- var equalsToken = node.getChildAt(1);
- var openBraceToken = node.right.getChildAt(0);
- this.handleOpeningBrace(equalsToken, openBraceToken);
- }
- _super.prototype.visitBinaryExpression.call(this, node);
- };
- OneLineWalker.prototype.visitVariableDeclaration = function (node) {
- var initializer = node.initializer;
- if (initializer != null && initializer.kind === ts.SyntaxKind.ObjectLiteralExpression) {
- var equalsToken = Lint.childOfKind(node, ts.SyntaxKind.EqualsToken);
- var openBraceToken = initializer.getChildAt(0);
- this.handleOpeningBrace(equalsToken, openBraceToken);
- }
- _super.prototype.visitVariableDeclaration.call(this, node);
- };
- OneLineWalker.prototype.visitDoStatement = function (node) {
- var doKeyword = node.getChildAt(0);
- var statement = node.statement;
- if (statement.kind === ts.SyntaxKind.Block) {
- var openBraceToken = statement.getChildAt(0);
- this.handleOpeningBrace(doKeyword, openBraceToken);
- }
- _super.prototype.visitDoStatement.call(this, node);
- };
- OneLineWalker.prototype.visitModuleDeclaration = function (node) {
- var nameNode = node.name;
- var body = node.body;
- if (body != null && body.kind === ts.SyntaxKind.ModuleBlock) {
- var openBraceToken = body.getChildAt(0);
- this.handleOpeningBrace(nameNode, openBraceToken);
- }
- _super.prototype.visitModuleDeclaration.call(this, node);
- };
- OneLineWalker.prototype.visitEnumDeclaration = function (node) {
- var nameNode = node.name;
- var openBraceToken = Lint.childOfKind(node, ts.SyntaxKind.OpenBraceToken);
- this.handleOpeningBrace(nameNode, openBraceToken);
- _super.prototype.visitEnumDeclaration.call(this, node);
- };
- OneLineWalker.prototype.visitSwitchStatement = function (node) {
- var closeParenToken = node.getChildAt(3);
- var openBraceToken = node.caseBlock.getChildAt(0);
- this.handleOpeningBrace(closeParenToken, openBraceToken);
- _super.prototype.visitSwitchStatement.call(this, node);
- };
- OneLineWalker.prototype.visitInterfaceDeclaration = function (node) {
- this.handleClassLikeDeclaration(node);
- _super.prototype.visitInterfaceDeclaration.call(this, node);
- };
- OneLineWalker.prototype.visitClassDeclaration = function (node) {
- this.handleClassLikeDeclaration(node);
- _super.prototype.visitClassDeclaration.call(this, node);
- };
- OneLineWalker.prototype.visitFunctionDeclaration = function (node) {
- this.handleFunctionLikeDeclaration(node);
- _super.prototype.visitFunctionDeclaration.call(this, node);
- };
- OneLineWalker.prototype.visitMethodDeclaration = function (node) {
- this.handleFunctionLikeDeclaration(node);
- _super.prototype.visitMethodDeclaration.call(this, node);
- };
- OneLineWalker.prototype.visitConstructorDeclaration = function (node) {
- this.handleFunctionLikeDeclaration(node);
- _super.prototype.visitConstructorDeclaration.call(this, node);
- };
- OneLineWalker.prototype.visitArrowFunction = function (node) {
- var body = node.body;
- if (body != null && body.kind === ts.SyntaxKind.Block) {
- var arrowToken = Lint.childOfKind(node, ts.SyntaxKind.EqualsGreaterThanToken);
- var openBraceToken = body.getChildAt(0);
- this.handleOpeningBrace(arrowToken, openBraceToken);
- }
- _super.prototype.visitArrowFunction.call(this, node);
- };
- OneLineWalker.prototype.handleFunctionLikeDeclaration = function (node) {
- var body = node.body;
- if (body != null && body.kind === ts.SyntaxKind.Block) {
- var openBraceToken = body.getChildAt(0);
- if (node.type != null) {
- this.handleOpeningBrace(node.type, openBraceToken);
- }
- else {
- var closeParenToken = Lint.childOfKind(node, ts.SyntaxKind.CloseParenToken);
- this.handleOpeningBrace(closeParenToken, openBraceToken);
- }
- }
- };
- OneLineWalker.prototype.handleClassLikeDeclaration = function (node) {
- var openBraceToken = Lint.childOfKind(node, ts.SyntaxKind.OpenBraceToken);
- this.handleOpeningBrace(tsutils_1.getPreviousToken(openBraceToken), openBraceToken);
- };
- OneLineWalker.prototype.handleIterationStatement = function (node) {
- // last child is the statement, second to last child is the close paren
- var closeParenToken = node.getChildAt(node.getChildCount() - 2);
- var statement = node.statement;
- if (statement.kind === ts.SyntaxKind.Block) {
- var openBraceToken = statement.getChildAt(0);
- this.handleOpeningBrace(closeParenToken, openBraceToken);
- }
- };
- OneLineWalker.prototype.handleOpeningBrace = function (previousNode, openBraceToken) {
- if (previousNode == null || openBraceToken == null) {
- return;
- }
- var previousNodeLine = this.getLineAndCharacterOfPosition(previousNode.getEnd()).line;
- var openBraceLine = this.getLineAndCharacterOfPosition(openBraceToken.getStart()).line;
- var failure;
- if (this.hasOption(OPTION_BRACE) && previousNodeLine !== openBraceLine) {
- failure = Rule.BRACE_FAILURE_STRING;
- }
- else if (this.hasOption(OPTION_WHITESPACE) && previousNode.getEnd() === openBraceToken.getStart()) {
- failure = Rule.WHITESPACE_FAILURE_STRING;
- }
- if (failure !== undefined) {
- this.addFailureAtNode(openBraceToken, failure);
+ else if (this.options.whitespace && range.pos === tokenStart) {
+ this.addFailure(tokenStart, range.end, Rule.WHITESPACE_FAILURE_STRING, Lint.Replacement.appendText(range.pos, " "));
}
};
return OneLineWalker;
-}(Lint.RuleWalker));
+}(Lint.AbstractWalker));
var _a;
diff --git a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js b/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js
index 36239c5b8..7af04a45b 100644
--- a/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js
+++ b/node_modules/tslint/lib/rules/onlyArrowFunctionsRule.js
@@ -84,14 +84,11 @@ function walk(ctx) {
}
/** Generator functions and functions using `this` are allowed. */
function functionIsExempt(node) {
- return node.asteriskToken !== undefined || hasThisParameter(node) || node.body !== undefined && usesThisInBody(node.body) === true;
+ return node.asteriskToken !== undefined ||
+ node.parameters.length !== 0 && utils.isThisParameter(node.parameters[0]) ||
+ node.body !== undefined && ts.forEachChild(node, usesThis) === true;
}
-function hasThisParameter(node) {
- var first = node.parameters[0];
- return first !== undefined && first.name.kind === ts.SyntaxKind.Identifier &&
- first.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword;
-}
-function usesThisInBody(node) {
- return node.kind === ts.SyntaxKind.ThisKeyword || !utils.hasOwnThisReference(node) && ts.forEachChild(node, usesThisInBody);
+function usesThis(node) {
+ return node.kind === ts.SyntaxKind.ThisKeyword || !utils.hasOwnThisReference(node) && ts.forEachChild(node, usesThis);
}
var _a;
diff --git a/node_modules/tslint/lib/rules/orderedImportsRule.d.ts b/node_modules/tslint/lib/rules/orderedImportsRule.d.ts
index 3f2362e71..ab1329ea4 100644
--- a/node_modules/tslint/lib/rules/orderedImportsRule.d.ts
+++ b/node_modules/tslint/lib/rules/orderedImportsRule.d.ts
@@ -2,6 +2,7 @@ import * as ts from "typescript";
import * as Lint from "../index";
export declare class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata;
+ static IMPORT_SOURCES_NOT_GROUPED: string;
static IMPORT_SOURCES_UNORDERED: string;
static NAMED_IMPORTS_UNORDERED: string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
diff --git a/node_modules/tslint/lib/rules/orderedImportsRule.js b/node_modules/tslint/lib/rules/orderedImportsRule.js
index c40d197b1..4f7c5f0da 100644
--- a/node_modules/tslint/lib/rules/orderedImportsRule.js
+++ b/node_modules/tslint/lib/rules/orderedImportsRule.js
@@ -31,13 +31,16 @@ var Rule = /** @class */ (function (_super) {
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "ordered-imports",
- description: "Requires that import statements be alphabetized.",
- descriptionDetails: (_a = ["\n Enforce a consistent ordering for ES6 imports:\n - Named imports must be alphabetized (i.e. \"import {A, B, C} from \"foo\";\")\n - The exact ordering can be controlled by the named-imports-order option.\n - \"longName as name\" imports are ordered by \"longName\".\n - Import sources must be alphabetized within groups, i.e.:\n import * as foo from \"a\";\n import * as bar from \"b\";\n - Groups of imports are delineated by blank lines. You can use these to group imports\n however you like, e.g. by first- vs. third-party or thematically."], _a.raw = ["\n Enforce a consistent ordering for ES6 imports:\n - Named imports must be alphabetized (i.e. \"import {A, B, C} from \"foo\";\")\n - The exact ordering can be controlled by the named-imports-order option.\n - \"longName as name\" imports are ordered by \"longName\".\n - Import sources must be alphabetized within groups, i.e.:\n import * as foo from \"a\";\n import * as bar from \"b\";\n - Groups of imports are delineated by blank lines. You can use these to group imports\n however you like, e.g. by first- vs. third-party or thematically."], Lint.Utils.dedent(_a)),
+ description: "Requires that import statements be alphabetized and grouped.",
+ descriptionDetails: (_a = ["\n Enforce a consistent ordering for ES6 imports:\n - Named imports must be alphabetized (i.e. \"import {A, B, C} from \"foo\";\")\n - The exact ordering can be controlled by the named-imports-order option.\n - \"longName as name\" imports are ordered by \"longName\".\n - Import sources must be alphabetized within groups, i.e.:\n import * as foo from \"a\";\n import * as bar from \"b\";\n - Groups of imports are delineated by blank lines. You can use these to group imports\n however you like, e.g. by first- vs. third-party or thematically or can you can\n enforce a grouping of third-party, parent directories and the current directory."], _a.raw = ["\n Enforce a consistent ordering for ES6 imports:\n - Named imports must be alphabetized (i.e. \"import {A, B, C} from \"foo\";\")\n - The exact ordering can be controlled by the named-imports-order option.\n - \"longName as name\" imports are ordered by \"longName\".\n - Import sources must be alphabetized within groups, i.e.:\n import * as foo from \"a\";\n import * as bar from \"b\";\n - Groups of imports are delineated by blank lines. You can use these to group imports\n however you like, e.g. by first- vs. third-party or thematically or can you can\n enforce a grouping of third-party, parent directories and the current directory."], Lint.Utils.dedent(_a)),
hasFix: true,
- optionsDescription: (_b = ["\n You may set the `\"import-sources-order\"` option to control the ordering of source\n imports (the `\"foo\"` in `import {A, B, C} from \"foo\"`).\n\n Possible values for `\"import-sources-order\"` are:\n\n * `\"case-insensitive'`: Correct order is `\"Bar\"`, `\"baz\"`, `\"Foo\"`. (This is the default.)\n * `\"lowercase-first\"`: Correct order is `\"baz\"`, `\"Bar\"`, `\"Foo\"`.\n * `\"lowercase-last\"`: Correct order is `\"Bar\"`, `\"Foo\"`, `\"baz\"`.\n * `\"any\"`: Allow any order.\n\n You may set the `\"named-imports-order\"` option to control the ordering of named\n imports (the `{A, B, C}` in `import {A, B, C} from \"foo\"`).\n\n Possible values for `\"named-imports-order\"` are:\n\n * `\"case-insensitive'`: Correct order is `{A, b, C}`. (This is the default.)\n * `\"lowercase-first\"`: Correct order is `{b, A, C}`.\n * `\"lowercase-last\"`: Correct order is `{A, C, b}`.\n * `\"any\"`: Allow any order.\n\n "], _b.raw = ["\n You may set the \\`\"import-sources-order\"\\` option to control the ordering of source\n imports (the \\`\"foo\"\\` in \\`import {A, B, C} from \"foo\"\\`).\n\n Possible values for \\`\"import-sources-order\"\\` are:\n\n * \\`\"case-insensitive'\\`: Correct order is \\`\"Bar\"\\`, \\`\"baz\"\\`, \\`\"Foo\"\\`. (This is the default.)\n * \\`\"lowercase-first\"\\`: Correct order is \\`\"baz\"\\`, \\`\"Bar\"\\`, \\`\"Foo\"\\`.\n * \\`\"lowercase-last\"\\`: Correct order is \\`\"Bar\"\\`, \\`\"Foo\"\\`, \\`\"baz\"\\`.\n * \\`\"any\"\\`: Allow any order.\n\n You may set the \\`\"named-imports-order\"\\` option to control the ordering of named\n imports (the \\`{A, B, C}\\` in \\`import {A, B, C} from \"foo\"\\`).\n\n Possible values for \\`\"named-imports-order\"\\` are:\n\n * \\`\"case-insensitive'\\`: Correct order is \\`{A, b, C}\\`. (This is the default.)\n * \\`\"lowercase-first\"\\`: Correct order is \\`{b, A, C}\\`.\n * \\`\"lowercase-last\"\\`: Correct order is \\`{A, C, b}\\`.\n * \\`\"any\"\\`: Allow any order.\n\n "], Lint.Utils.dedent(_b)),
+ optionsDescription: (_b = ["\n You may set the `\"import-sources-order\"` option to control the ordering of source\n imports (the `\"foo\"` in `import {A, B, C} from \"foo\"`).\n\n Possible values for `\"import-sources-order\"` are:\n\n * `\"case-insensitive'`: Correct order is `\"Bar\"`, `\"baz\"`, `\"Foo\"`. (This is the default.)\n * `\"lowercase-first\"`: Correct order is `\"baz\"`, `\"Bar\"`, `\"Foo\"`.\n * `\"lowercase-last\"`: Correct order is `\"Bar\"`, `\"Foo\"`, `\"baz\"`.\n * `\"any\"`: Allow any order.\n\n You may set the `\"grouped-imports\"` option to control the grouping of source\n imports (the `\"foo\"` in `import {A, B, C} from \"foo\"`).\n\n Possible values for `\"grouped-imports\"` are:\n\n * `false`: Do not enforce grouping. (This is the default.)\n * `true`: Group source imports by `\"bar\"`, `\"../baz\"`, `\"./foo\"`.\n\n You may set the `\"named-imports-order\"` option to control the ordering of named\n imports (the `{A, B, C}` in `import {A, B, C} from \"foo\"`).\n\n Possible values for `\"named-imports-order\"` are:\n\n * `\"case-insensitive'`: Correct order is `{A, b, C}`. (This is the default.)\n * `\"lowercase-first\"`: Correct order is `{b, A, C}`.\n * `\"lowercase-last\"`: Correct order is `{A, C, b}`.\n * `\"any\"`: Allow any order.\n\n You may set the `\"module-source-path\"` option to control the ordering of imports based full path\n or just the module name\n\n Possible values for `\"module-source-path\"` are:\n\n * `\"full'`: Correct order is `\"./a/Foo\"`, `\"./b/baz\"`, `\"./c/Bar\"`. (This is the default.)\n * `\"basename\"`: Correct order is `\"./c/Bar\"`, `\"./b/baz\"`, `\"./a/Foo\"`.\n\n "], _b.raw = ["\n You may set the \\`\"import-sources-order\"\\` option to control the ordering of source\n imports (the \\`\"foo\"\\` in \\`import {A, B, C} from \"foo\"\\`).\n\n Possible values for \\`\"import-sources-order\"\\` are:\n\n * \\`\"case-insensitive'\\`: Correct order is \\`\"Bar\"\\`, \\`\"baz\"\\`, \\`\"Foo\"\\`. (This is the default.)\n * \\`\"lowercase-first\"\\`: Correct order is \\`\"baz\"\\`, \\`\"Bar\"\\`, \\`\"Foo\"\\`.\n * \\`\"lowercase-last\"\\`: Correct order is \\`\"Bar\"\\`, \\`\"Foo\"\\`, \\`\"baz\"\\`.\n * \\`\"any\"\\`: Allow any order.\n\n You may set the \\`\"grouped-imports\"\\` option to control the grouping of source\n imports (the \\`\"foo\"\\` in \\`import {A, B, C} from \"foo\"\\`).\n\n Possible values for \\`\"grouped-imports\"\\` are:\n\n * \\`false\\`: Do not enforce grouping. (This is the default.)\n * \\`true\\`: Group source imports by \\`\"bar\"\\`, \\`\"../baz\"\\`, \\`\"./foo\"\\`.\n\n You may set the \\`\"named-imports-order\"\\` option to control the ordering of named\n imports (the \\`{A, B, C}\\` in \\`import {A, B, C} from \"foo\"\\`).\n\n Possible values for \\`\"named-imports-order\"\\` are:\n\n * \\`\"case-insensitive'\\`: Correct order is \\`{A, b, C}\\`. (This is the default.)\n * \\`\"lowercase-first\"\\`: Correct order is \\`{b, A, C}\\`.\n * \\`\"lowercase-last\"\\`: Correct order is \\`{A, C, b}\\`.\n * \\`\"any\"\\`: Allow any order.\n\n You may set the \\`\"module-source-path\"\\` option to control the ordering of imports based full path\n or just the module name\n\n Possible values for \\`\"module-source-path\"\\` are:\n\n * \\`\"full'\\`: Correct order is \\`\"./a/Foo\"\\`, \\`\"./b/baz\"\\`, \\`\"./c/Bar\"\\`. (This is the default.)\n * \\`\"basename\"\\`: Correct order is \\`\"./c/Bar\"\\`, \\`\"./b/baz\"\\`, \\`\"./a/Foo\"\\`.\n\n "], Lint.Utils.dedent(_b)),
options: {
type: "object",
properties: {
+ "grouped-imports": {
+ type: "boolean",
+ },
"import-sources-order": {
type: "string",
enum: ["case-insensitive", "lowercase-first", "lowercase-last", "any"],
@@ -46,6 +49,10 @@ var Rule = /** @class */ (function (_super) {
type: "string",
enum: ["case-insensitive", "lowercase-first", "lowercase-last", "any"],
},
+ "module-source-path": {
+ type: "string",
+ enum: ["full", "basename"],
+ },
},
additionalProperties: false,
},
@@ -57,6 +64,7 @@ var Rule = /** @class */ (function (_super) {
typescriptOnly: false,
};
/* tslint:enable:object-literal-sort-keys */
+ Rule.IMPORT_SOURCES_NOT_GROUPED = "Import sources of different groups must be sorted by: libraries, parent directories, current directory.";
Rule.IMPORT_SOURCES_UNORDERED = "Import sources within a group must be alphabetized.";
Rule.NAMED_IMPORTS_UNORDERED = "Named imports must be alphabetized.";
return Rule;
@@ -67,12 +75,31 @@ var TRANSFORMS = new Map([
["case-insensitive", function (x) { return x.toLowerCase(); }],
["lowercase-first", flipCase],
["lowercase-last", function (x) { return x; }],
+ ["full", function (x) { return x; }],
+ ["basename", function (x) {
+ if (!ts.isExternalModuleNameRelative(x)) {
+ return x;
+ }
+ var splitIndex = x.lastIndexOf("/");
+ if (splitIndex === -1) {
+ return x;
+ }
+ return x.substr(splitIndex + 1);
+ }],
]);
+var ImportType;
+(function (ImportType) {
+ ImportType[ImportType["LIBRARY_IMPORT"] = 1] = "LIBRARY_IMPORT";
+ ImportType[ImportType["PARENT_DIRECTORY_IMPORT"] = 2] = "PARENT_DIRECTORY_IMPORT";
+ ImportType[ImportType["CURRENT_DIRECTORY_IMPORT"] = 3] = "CURRENT_DIRECTORY_IMPORT";
+})(ImportType || (ImportType = {}));
function parseOptions(ruleArguments) {
var optionSet = ruleArguments[0];
- var _a = optionSet === undefined ? {} : optionSet, _b = _a["import-sources-order"], sources = _b === void 0 ? "case-insensitive" : _b, _c = _a["named-imports-order"], named = _c === void 0 ? "case-insensitive" : _c;
+ var _a = optionSet === undefined ? {} : optionSet, _b = _a["grouped-imports"], isGrouped = _b === void 0 ? false : _b, _c = _a["import-sources-order"], sources = _c === void 0 ? "case-insensitive" : _c, _d = _a["named-imports-order"], named = _d === void 0 ? "case-insensitive" : _d, _e = _a["module-source-path"], path = _e === void 0 ? "full" : _e;
return {
+ groupedImports: isGrouped,
importSourcesOrderTransform: TRANSFORMS.get(sources),
+ moduleSourcePath: TRANSFORMS.get(path),
namedImportsOrderTransform: TRANSFORMS.get(named),
};
}
@@ -80,15 +107,26 @@ var Walker = /** @class */ (function (_super) {
tslib_1.__extends(Walker, _super);
function Walker() {
var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.currentImportsBlock = new ImportsBlock();
+ _this.importsBlocks = [new ImportsBlock()];
+ _this.nextType = ImportType.LIBRARY_IMPORT;
return _this;
}
+ Object.defineProperty(Walker.prototype, "currentImportsBlock", {
+ get: function () {
+ return this.importsBlocks[this.importsBlocks.length - 1];
+ },
+ enumerable: true,
+ configurable: true
+ });
Walker.prototype.walk = function (sourceFile) {
for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
var statement = _a[_i];
this.checkStatement(statement);
}
this.endBlock();
+ if (this.options.groupedImports) {
+ this.checkBlocksGrouping();
+ }
};
Walker.prototype.checkStatement = function (statement) {
if (!(tsutils_1.isImportDeclaration(statement) || tsutils_1.isImportEqualsDeclaration(statement)) ||
@@ -138,9 +176,10 @@ var Walker = /** @class */ (function (_super) {
this.checkSource(source, node);
};
Walker.prototype.checkSource = function (source, node) {
+ var currentSource = this.options.moduleSourcePath(source);
var previousSource = this.currentImportsBlock.getLastImportSource();
- this.currentImportsBlock.addImportDeclaration(this.sourceFile, node, source);
- if (previousSource !== null && compare(source, previousSource) === -1) {
+ this.currentImportsBlock.addImportDeclaration(this.sourceFile, node, currentSource);
+ if (previousSource !== null && compare(currentSource, previousSource) === -1) {
this.lastFix = [];
this.addFailureAtNode(node, Rule.IMPORT_SOURCES_UNORDERED, this.lastFix);
}
@@ -153,7 +192,7 @@ var Walker = /** @class */ (function (_super) {
}
this.lastFix = undefined;
}
- this.currentImportsBlock = new ImportsBlock();
+ this.importsBlocks.push(new ImportsBlock());
};
Walker.prototype.checkNamedImports = function (node) {
var _this = this;
@@ -175,6 +214,79 @@ var Walker = /** @class */ (function (_super) {
this.addFailure(a.getStart(), b.getEnd(), Rule.NAMED_IMPORTS_UNORDERED, this.lastFix);
}
};
+ Walker.prototype.checkBlocksGrouping = function () {
+ this.importsBlocks.some(this.checkBlockGroups, this);
+ };
+ Walker.prototype.checkBlockGroups = function (importsBlock) {
+ var oddImportDeclaration = this.getOddImportDeclaration(importsBlock);
+ if (oddImportDeclaration !== undefined) {
+ this.addFailureAtNode(oddImportDeclaration.node, Rule.IMPORT_SOURCES_NOT_GROUPED, this.getReplacements());
+ return true;
+ }
+ return false;
+ };
+ Walker.prototype.getOddImportDeclaration = function (importsBlock) {
+ var importDeclarations = importsBlock.getImportDeclarations();
+ if (importDeclarations.length === 0) {
+ return undefined;
+ }
+ var type = importDeclarations[0].type;
+ if (type < this.nextType) {
+ return importDeclarations[0];
+ }
+ else {
+ this.nextType = type;
+ return importDeclarations.find(function (importDeclaration) { return importDeclaration.type !== type; });
+ }
+ };
+ Walker.prototype.getReplacements = function () {
+ var importDeclarationsList = this.importsBlocks
+ .map(function (block) { return block.getImportDeclarations(); })
+ .filter(function (imports) { return imports.length > 0; });
+ var allImportDeclarations = (_a = []).concat.apply(_a, importDeclarationsList);
+ var replacements = this.getReplacementsForExistingImports(importDeclarationsList);
+ var startOffset = allImportDeclarations.length === 0 ? 0 : allImportDeclarations[0].nodeStartOffset;
+ replacements.push(Lint.Replacement.appendText(startOffset, this.getGroupedImports(allImportDeclarations)));
+ return replacements;
+ var _a;
+ };
+ Walker.prototype.getReplacementsForExistingImports = function (importDeclarationsList) {
+ var _this = this;
+ return importDeclarationsList.map(function (items, index) {
+ var start = items[0].nodeStartOffset;
+ if (index > 0) {
+ var prevItems = importDeclarationsList[index - 1];
+ var last = prevItems[prevItems.length - 1];
+ if (/[\r\n]+/.test(_this.sourceFile.text.slice(last.nodeEndOffset, start))) {
+ // remove whitespace between blocks
+ start = last.nodeEndOffset;
+ }
+ }
+ return Lint.Replacement.deleteFromTo(start, items[items.length - 1].nodeEndOffset);
+ });
+ };
+ Walker.prototype.getGroupedImports = function (importDeclarations) {
+ return [ImportType.LIBRARY_IMPORT, ImportType.PARENT_DIRECTORY_IMPORT, ImportType.CURRENT_DIRECTORY_IMPORT]
+ .map(function (type) {
+ var imports = importDeclarations.filter(function (importDeclaration) { return importDeclaration.type === type; });
+ return getSortedImportDeclarationsAsText(imports);
+ })
+ .filter(function (text) { return text.length > 0; })
+ .join(this.getEolChar());
+ };
+ Walker.prototype.getEolChar = function () {
+ var lineEnd = this.sourceFile.getLineEndOfPosition(0);
+ var newLine;
+ if (lineEnd > 0) {
+ if (lineEnd > 1 && this.sourceFile.text[lineEnd - 1] === "\r") {
+ newLine = "\r\n";
+ }
+ else if (this.sourceFile.text[lineEnd] === "\n") {
+ newLine = "\n";
+ }
+ }
+ return newLine === undefined ? ts.sys.newLine : newLine;
+ };
return Walker;
}(Lint.AbstractWalker));
var ImportsBlock = /** @class */ (function () {
@@ -185,6 +297,7 @@ var ImportsBlock = /** @class */ (function () {
var start = this.getStartOffset(node);
var end = this.getEndOffset(sourceFile, node);
var text = sourceFile.text.substring(start, end);
+ var type = this.getImportType(sourcePath);
if (start > node.getStart() || end === 0) {
// skip block if any statements don't end with a newline to simplify implementation
this.importDeclarations = [];
@@ -196,12 +309,16 @@ var ImportsBlock = /** @class */ (function () {
nodeStartOffset: start,
sourcePath: sourcePath,
text: text,
+ type: type,
});
};
+ ImportsBlock.prototype.getImportDeclarations = function () {
+ return this.importDeclarations;
+ };
// replaces the named imports on the most recent import declaration
ImportsBlock.prototype.replaceNamedImports = function (fileOffset, length, replacement) {
var importDeclaration = this.getLastImportDeclaration();
- if (importDeclaration == null) {
+ if (importDeclaration === undefined) {
// nothing to replace. This can happen if the block is skipped
return;
}
@@ -223,8 +340,7 @@ var ImportsBlock = /** @class */ (function () {
if (this.importDeclarations.length === 0) {
return undefined;
}
- var sortedDeclarations = sortByKey(this.importDeclarations.slice(), function (x) { return x.sourcePath; });
- var fixedText = sortedDeclarations.map(function (x) { return x.text; }).join("");
+ var fixedText = getSortedImportDeclarationsAsText(this.importDeclarations);
var start = this.importDeclarations[0].nodeStartOffset;
var end = this.getLastImportDeclaration().nodeEndOffset;
return new Lint.Replacement(start, end - start, fixedText);
@@ -243,6 +359,19 @@ var ImportsBlock = /** @class */ (function () {
ImportsBlock.prototype.getLastImportDeclaration = function () {
return this.importDeclarations[this.importDeclarations.length - 1];
};
+ ImportsBlock.prototype.getImportType = function (sourcePath) {
+ if (sourcePath.charAt(0) === ".") {
+ if (sourcePath.charAt(1) === ".") {
+ return ImportType.PARENT_DIRECTORY_IMPORT;
+ }
+ else {
+ return ImportType.CURRENT_DIRECTORY_IMPORT;
+ }
+ }
+ else {
+ return ImportType.LIBRARY_IMPORT;
+ }
+ };
return ImportsBlock;
}());
// Convert aBcD --> AbCd
@@ -267,7 +396,6 @@ function findUnsortedPair(xs, transform) {
}
return undefined;
}
-// tslint:disable-next-line no-unsafe-any (fixed in 5.3)
function compare(a, b) {
function isLow(value) {
return value[0] === "." || value[0] === "/";
@@ -293,6 +421,10 @@ function removeQuotes(value) {
}
return value;
}
+function getSortedImportDeclarationsAsText(importDeclarations) {
+ var sortedDeclarations = sortByKey(importDeclarations.slice(), function (x) { return x.sourcePath; });
+ return sortedDeclarations.map(function (x) { return x.text; }).join("");
+}
function sortByKey(xs, getSortKey) {
return xs.slice().sort(function (a, b) { return compare(getSortKey(a), getSortKey(b)); });
}
diff --git a/node_modules/tslint/lib/rules/preferConstRule.js b/node_modules/tslint/lib/rules/preferConstRule.js
index 6bb1a3cd0..42f1e6ce4 100644
--- a/node_modules/tslint/lib/rules/preferConstRule.js
+++ b/node_modules/tslint/lib/rules/preferConstRule.js
@@ -33,7 +33,8 @@ var Rule = /** @class */ (function (_super) {
};
Rule.prototype.apply = function (sourceFile) {
var options = {
- destructuringAll: this.ruleArguments.length !== 0 && this.ruleArguments[0].destructuring === OPTION_DESTRUCTURING_ALL,
+ destructuringAll: this.ruleArguments.length !== 0 &&
+ this.ruleArguments[0].destructuring === OPTION_DESTRUCTURING_ALL,
};
var preferConstWalker = new PreferConstWalker(sourceFile, this.ruleName, options);
return this.applyWithWalker(preferConstWalker);
diff --git a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.d.ts b/node_modules/tslint/lib/rules/restrictPlusOperandsRule.d.ts
index 21b50bfe4..222faaa7f 100644
--- a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.d.ts
+++ b/node_modules/tslint/lib/rules/restrictPlusOperandsRule.d.ts
@@ -3,5 +3,6 @@ import * as Lint from "../index";
export declare class Rule extends Lint.Rules.TypedRule {
static metadata: Lint.IRuleMetadata;
static INVALID_TYPES_ERROR: string;
+ static SUGGEST_TEMPLATE_LITERALS: string;
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[];
}
diff --git a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js b/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js
index 1974ce47a..c2b8bdb96 100644
--- a/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js
+++ b/node_modules/tslint/lib/rules/restrictPlusOperandsRule.js
@@ -41,6 +41,7 @@ var Rule = /** @class */ (function (_super) {
};
/* tslint:enable:object-literal-sort-keys */
Rule.INVALID_TYPES_ERROR = "Operands of '+' operation must either be both strings or both numbers";
+ Rule.SUGGEST_TEMPLATE_LITERALS = ", consider using template literals";
return Rule;
}(Lint.Rules.TypedRule));
exports.Rule = Rule;
@@ -50,7 +51,12 @@ function walk(ctx, tc) {
var leftType = getBaseTypeOfLiteralType(tc.getTypeAtLocation(node.left));
var rightType = getBaseTypeOfLiteralType(tc.getTypeAtLocation(node.right));
if (leftType === "invalid" || rightType === "invalid" || leftType !== rightType) {
- return ctx.addFailureAtNode(node, Rule.INVALID_TYPES_ERROR);
+ if (leftType === "string" || rightType === "string") {
+ return ctx.addFailureAtNode(node, Rule.INVALID_TYPES_ERROR + Rule.SUGGEST_TEMPLATE_LITERALS);
+ }
+ else {
+ return ctx.addFailureAtNode(node, Rule.INVALID_TYPES_ERROR);
+ }
}
}
return ts.forEachChild(node, cb);
diff --git a/node_modules/tslint/lib/rules/returnUndefinedRule.js b/node_modules/tslint/lib/rules/returnUndefinedRule.js
index 7cc14c04e..e117a1b3d 100644
--- a/node_modules/tslint/lib/rules/returnUndefinedRule.js
+++ b/node_modules/tslint/lib/rules/returnUndefinedRule.js
@@ -64,7 +64,9 @@ function walk(ctx, checker) {
}
var returnKindFromType = getReturnKind(functionReturningFrom, checker);
if (returnKindFromType !== undefined && returnKindFromType !== actualReturnKind) {
- ctx.addFailureAtNode(node, returnKindFromType === ReturnKind.Void ? Rule.FAILURE_STRING_VOID_RETURN : Rule.FAILURE_STRING_VALUE_RETURN);
+ ctx.addFailureAtNode(node, returnKindFromType === ReturnKind.Void
+ ? Rule.FAILURE_STRING_VOID_RETURN
+ : Rule.FAILURE_STRING_VALUE_RETURN);
}
}
}
@@ -92,24 +94,28 @@ function getReturnKind(node, checker) {
case ts.SyntaxKind.GetAccessor:
return ReturnKind.Value;
}
- var contextual = isFunctionExpressionLike(node) ? tryGetReturnType(checker.getContextualType(node), checker) : undefined;
+ var contextual = isFunctionExpressionLike(node) && node.type === undefined
+ ? tryGetReturnType(checker.getContextualType(node), checker)
+ : undefined;
var returnType = contextual !== undefined ? contextual : tryGetReturnType(checker.getTypeAtLocation(node), checker);
- if (returnType === undefined) {
+ if (returnType === undefined || Lint.isTypeFlagSet(returnType, ts.TypeFlags.Any)) {
return undefined;
}
- else if (isEffectivelyVoid(returnType)) {
+ if ((Lint.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) ? isEffectivelyVoidPromise : isEffectivelyVoid)(returnType)) {
return ReturnKind.Void;
}
- else if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)) {
- // Would need access to `checker.getPromisedTypeOfPromise` to do this properly.
- // Assume that the return type is the global Promise (since this is an async function) and get its type argument.
- var typeArguments = returnType.typeArguments;
- if (typeArguments !== undefined && typeArguments.length === 1) {
- return isEffectivelyVoid(typeArguments[0]) ? ReturnKind.Void : ReturnKind.Value;
- }
- }
return ReturnKind.Value;
}
+/** True for `void`, `undefined`, Promise<void>, or `void | undefined | Promise<void>`. */
+function isEffectivelyVoidPromise(type) {
+ // Would need access to `checker.getPromisedTypeOfPromise` to do this properly.
+ // Assume that the return type is the global Promise (since this is an async function) and get its type argument.
+ // tslint:disable-next-line no-bitwise
+ return Lint.isTypeFlagSet(type, ts.TypeFlags.Void | ts.TypeFlags.Undefined) ||
+ tsutils_1.isUnionType(type) && type.types.every(isEffectivelyVoidPromise) ||
+ tsutils_1.isTypeReference(type) && type.typeArguments !== undefined && type.typeArguments.length === 1 &&
+ isEffectivelyVoidPromise(type.typeArguments[0]);
+}
/** True for `void`, `undefined`, or `void | undefined`. */
function isEffectivelyVoid(type) {
// tslint:disable-next-line no-bitwise
@@ -124,8 +130,7 @@ function tryGetReturnType(fnType, checker) {
if (sigs.length !== 1) {
return undefined;
}
- var ret = checker.getReturnTypeOfSignature(sigs[0]);
- return Lint.isTypeFlagSet(ret, ts.TypeFlags.Any) ? undefined : ret;
+ return checker.getReturnTypeOfSignature(sigs[0]);
}
function isFunctionLike(node) {
switch (node.kind) {
diff --git a/node_modules/tslint/lib/rules/semicolonRule.js b/node_modules/tslint/lib/rules/semicolonRule.js
index a6e0dfb85..6901842f4 100644
--- a/node_modules/tslint/lib/rules/semicolonRule.js
+++ b/node_modules/tslint/lib/rules/semicolonRule.js
@@ -23,6 +23,7 @@ var Lint = require("../index");
var OPTION_ALWAYS = "always";
var OPTION_NEVER = "never";
var OPTION_IGNORE_BOUND_CLASS_METHODS = "ignore-bound-class-methods";
+var OPTION_STRICT_BOUND_CLASS_METHODS = "strict-bound-class-methods";
var OPTION_IGNORE_INTERFACES = "ignore-interfaces";
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
@@ -31,7 +32,11 @@ var Rule = /** @class */ (function (_super) {
}
Rule.prototype.apply = function (sourceFile) {
var options = {
- boundClassMethods: this.ruleArguments.indexOf(OPTION_IGNORE_BOUND_CLASS_METHODS) === -1,
+ boundClassMethods: this.ruleArguments.indexOf(OPTION_STRICT_BOUND_CLASS_METHODS) !== -1
+ ? 2 /* Strict */
+ : this.ruleArguments.indexOf(OPTION_IGNORE_BOUND_CLASS_METHODS) !== -1
+ ? 1 /* Ignore */
+ : 0 /* Default */,
interfaces: this.ruleArguments.indexOf(OPTION_IGNORE_INTERFACES) === -1,
};
var Walker = this.ruleArguments.indexOf(OPTION_NEVER) === -1 ? SemicolonAlwaysWalker : SemicolonNeverWalker;
@@ -42,7 +47,7 @@ var Rule = /** @class */ (function (_super) {
ruleName: "semicolon",
description: "Enforces consistent semicolon usage at the end of every statement.",
hasFix: true,
- optionsDescription: (_a = ["\n One of the following arguments must be provided:\n\n * `\"", "\"` enforces semicolons at the end of every statement.\n * `\"", "\"` disallows semicolons at the end of every statement except for when they are necessary.\n\n The following arguments may be optionally provided:\n\n * `\"", "\"` skips checking semicolons at the end of interface members.\n * `\"", "\"` skips checking semicolons at the end of bound class methods."], _a.raw = ["\n One of the following arguments must be provided:\n\n * \\`\"", "\"\\` enforces semicolons at the end of every statement.\n * \\`\"", "\"\\` disallows semicolons at the end of every statement except for when they are necessary.\n\n The following arguments may be optionally provided:\n\n * \\`\"", "\"\\` skips checking semicolons at the end of interface members.\n * \\`\"", "\"\\` skips checking semicolons at the end of bound class methods."], Lint.Utils.dedent(_a, OPTION_ALWAYS, OPTION_NEVER, OPTION_IGNORE_INTERFACES, OPTION_IGNORE_BOUND_CLASS_METHODS)),
+ optionsDescription: (_a = ["\n One of the following arguments must be provided:\n\n * `\"", "\"` enforces semicolons at the end of every statement.\n * `\"", "\"` disallows semicolons at the end of every statement except for when they are necessary.\n\n The following arguments may be optionally provided:\n\n * `\"", "\"` skips checking semicolons at the end of interface members.\n * `\"", "\"` skips checking semicolons at the end of bound class methods.\n * `\"", "\"` disables any special handling of bound class methods and treats them as any\n other assignment. This option overrides `\"", "\"`.\n "], _a.raw = ["\n One of the following arguments must be provided:\n\n * \\`\"", "\"\\` enforces semicolons at the end of every statement.\n * \\`\"", "\"\\` disallows semicolons at the end of every statement except for when they are necessary.\n\n The following arguments may be optionally provided:\n\n * \\`\"", "\"\\` skips checking semicolons at the end of interface members.\n * \\`\"", "\"\\` skips checking semicolons at the end of bound class methods.\n * \\`\"", "\"\\` disables any special handling of bound class methods and treats them as any\n other assignment. This option overrides \\`\"", "\"\\`.\n "], Lint.Utils.dedent(_a, OPTION_ALWAYS, OPTION_NEVER, OPTION_IGNORE_INTERFACES, OPTION_IGNORE_BOUND_CLASS_METHODS, OPTION_STRICT_BOUND_CLASS_METHODS, OPTION_IGNORE_BOUND_CLASS_METHODS)),
options: {
type: "array",
items: [
@@ -160,10 +165,11 @@ var SemicolonWalker = /** @class */ (function (_super) {
};
SemicolonWalker.prototype.visitPropertyDeclaration = function (node) {
// check if this is a multi-line arrow function
- if (node.initializer !== undefined &&
+ if (this.options.boundClassMethods !== 2 /* Strict */ &&
+ node.initializer !== undefined &&
node.initializer.kind === ts.SyntaxKind.ArrowFunction &&
!utils.isSameLine(this.sourceFile, node.getStart(this.sourceFile), node.end)) {
- if (this.options.boundClassMethods) {
+ if (this.options.boundClassMethods === 0 /* Default */) {
this.checkUnnecessary(node);
}
}
diff --git a/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.js b/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.js
index 712868566..7e3282b8c 100644
--- a/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.js
+++ b/node_modules/tslint/lib/rules/spaceBeforeFunctionParenRule.js
@@ -99,14 +99,18 @@ function walk(ctx) {
function getOption(node, options) {
switch (node.kind) {
case ts.SyntaxKind.ArrowFunction:
- return Lint.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) ? options.asyncArrow : undefined;
+ return !hasTypeParameters(node) && Lint.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)
+ ? options.asyncArrow : undefined;
case ts.SyntaxKind.Constructor:
return options.constructor;
case ts.SyntaxKind.FunctionDeclaration:
// name is optional for function declaration which is default export (TS will emit error in other cases).
// Can be handled in the same way as function expression.
- case ts.SyntaxKind.FunctionExpression:
- return node.name !== undefined ? options.named : options.anonymous;
+ case ts.SyntaxKind.FunctionExpression: {
+ var functionName = node.name;
+ var hasName = functionName !== undefined && functionName.text !== "";
+ return hasName ? options.named : !hasTypeParameters(node) ? options.anonymous : undefined;
+ }
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.MethodSignature:
case ts.SyntaxKind.GetAccessor:
@@ -116,4 +120,7 @@ function getOption(node, options) {
return undefined;
}
}
+function hasTypeParameters(node) {
+ return node.typeParameters !== undefined;
+}
var _a;
diff --git a/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.js b/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.js
index 5cc1e4b39..605d85929 100644
--- a/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.js
+++ b/node_modules/tslint/lib/rules/strictBooleanExpressionsRule.js
@@ -25,7 +25,7 @@ var OPTION_ALLOW_STRING = "allow-string";
var OPTION_ALLOW_NUMBER = "allow-number";
var OPTION_ALLOW_MIX = "allow-mix";
var OPTION_ALLOW_BOOLEAN_OR_UNDEFINED = "allow-boolean-or-undefined";
-// tslint:disable object-literal-sort-keys switch-default
+// tslint:disable object-literal-sort-keys
var Rule = /** @class */ (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
diff --git a/node_modules/tslint/lib/rules/trailingCommaRule.d.ts b/node_modules/tslint/lib/rules/trailingCommaRule.d.ts
index 10b449342..ac23c5939 100644
--- a/node_modules/tslint/lib/rules/trailingCommaRule.d.ts
+++ b/node_modules/tslint/lib/rules/trailingCommaRule.d.ts
@@ -3,6 +3,7 @@ import * as Lint from "../index";
export declare class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata;
static FAILURE_STRING_NEVER: string;
+ static FAILURE_STRING_FORBIDDEN: string;
static FAILURE_STRING_ALWAYS: string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
isEnabled(): boolean;
diff --git a/node_modules/tslint/lib/rules/trailingCommaRule.js b/node_modules/tslint/lib/rules/trailingCommaRule.js
index e183e4ea4..784bc9a58 100644
--- a/node_modules/tslint/lib/rules/trailingCommaRule.js
+++ b/node_modules/tslint/lib/rules/trailingCommaRule.js
@@ -20,7 +20,7 @@ var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
-var defaultOptions = fillOptions("ignore"); // tslint:disable-line no-unnecessary-type-assertion
+var defaultOptions = fillOptions("ignore");
function fillOptions(value) {
return {
arrays: value,
@@ -32,10 +32,10 @@ function fillOptions(value) {
};
}
function normalizeOptions(options) {
- return { multiline: normalize(options.multiline), singleline: normalize(options.singleline) };
- function normalize(value) {
- return typeof value === "string" ? fillOptions(value) : tslib_1.__assign({}, defaultOptions, value);
- }
+ return { multiline: normalize(options.multiline), singleline: normalize(options.singleline), specCompliant: !!options.esSpecCompliant };
+}
+function normalize(value) {
+ return typeof value === "string" ? fillOptions(value) : tslib_1.__assign({}, defaultOptions, value);
}
/* tslint:disable:object-literal-sort-keys */
var metadataOptionShape = {
@@ -71,12 +71,13 @@ var Rule = /** @class */ (function (_super) {
ruleName: "trailing-comma",
description: (_a = ["\n Requires or disallows trailing commas in array and object literals, destructuring assignments, function typings,\n named imports and exports and function parameters."], _a.raw = ["\n Requires or disallows trailing commas in array and object literals, destructuring assignments, function typings,\n named imports and exports and function parameters."], Lint.Utils.dedent(_a)),
hasFix: true,
- optionsDescription: (_b = ["\n One argument which is an object with the keys `multiline` and `singleline`.\n Both can be set to a string (`\"always\"` or `\"never\"`) or an object.\n\n The object can contain any of the following keys: `\"arrays\"`, `\"objects\"`, `\"functions\"`,\n `\"imports\"`, `\"exports\"`, and `\"typeLiterals\"`; each key can have one of the following\n values: `\"always\"`, `\"never\"`, and `\"ignore\"`. Any missing keys will default to `\"ignore\"`.\n\n * `\"multiline\"` checks multi-line object literals.\n * `\"singleline\"` checks single-line object literals.\n\n An array is considered \"multiline\" if its closing bracket is on a line\n after the last array element. The same general logic is followed for\n object literals, function typings, named import statements\n and function parameters."], _b.raw = ["\n One argument which is an object with the keys \\`multiline\\` and \\`singleline\\`.\n Both can be set to a string (\\`\"always\"\\` or \\`\"never\"\\`) or an object.\n\n The object can contain any of the following keys: \\`\"arrays\"\\`, \\`\"objects\"\\`, \\`\"functions\"\\`,\n \\`\"imports\"\\`, \\`\"exports\"\\`, and \\`\"typeLiterals\"\\`; each key can have one of the following\n values: \\`\"always\"\\`, \\`\"never\"\\`, and \\`\"ignore\"\\`. Any missing keys will default to \\`\"ignore\"\\`.\n\n * \\`\"multiline\"\\` checks multi-line object literals.\n * \\`\"singleline\"\\` checks single-line object literals.\n\n An array is considered \"multiline\" if its closing bracket is on a line\n after the last array element. The same general logic is followed for\n object literals, function typings, named import statements\n and function parameters."], Lint.Utils.dedent(_b)),
+ optionsDescription: (_b = ["\n One argument which is an object with the keys `multiline` and `singleline`.\n Both can be set to a string (`\"always\"` or `\"never\"`) or an object.\n\n The object can contain any of the following keys: `\"arrays\"`, `\"objects\"`, `\"functions\"`,\n `\"imports\"`, `\"exports\"`, and `\"typeLiterals\"`; each key can have one of the following\n values: `\"always\"`, `\"never\"`, and `\"ignore\"`. Any missing keys will default to `\"ignore\"`.\n\n * `\"multiline\"` checks multi-line object literals.\n * `\"singleline\"` checks single-line object literals.\n\n An array is considered \"multiline\" if its closing bracket is on a line\n after the last array element. The same general logic is followed for\n object literals, function typings, named import statements\n and function parameters.\n\n To align this rule with the ECMAScript specification that is implemented in modern JavaScript VMs,\n there is a third option `esSpecCompliant`. Set this option to `true` to disallow trailing comma on\n object and array rest and rest parameters.\n "], _b.raw = ["\n One argument which is an object with the keys \\`multiline\\` and \\`singleline\\`.\n Both can be set to a string (\\`\"always\"\\` or \\`\"never\"\\`) or an object.\n\n The object can contain any of the following keys: \\`\"arrays\"\\`, \\`\"objects\"\\`, \\`\"functions\"\\`,\n \\`\"imports\"\\`, \\`\"exports\"\\`, and \\`\"typeLiterals\"\\`; each key can have one of the following\n values: \\`\"always\"\\`, \\`\"never\"\\`, and \\`\"ignore\"\\`. Any missing keys will default to \\`\"ignore\"\\`.\n\n * \\`\"multiline\"\\` checks multi-line object literals.\n * \\`\"singleline\"\\` checks single-line object literals.\n\n An array is considered \"multiline\" if its closing bracket is on a line\n after the last array element. The same general logic is followed for\n object literals, function typings, named import statements\n and function parameters.\n\n To align this rule with the ECMAScript specification that is implemented in modern JavaScript VMs,\n there is a third option \\`esSpecCompliant\\`. Set this option to \\`true\\` to disallow trailing comma on\n object and array rest and rest parameters.\n "], Lint.Utils.dedent(_b)),
options: {
type: "object",
properties: {
multiline: metadataOptionShape,
singleline: metadataOptionShape,
+ esSpecCompliant: { type: "boolean" },
},
additionalProperties: false,
},
@@ -91,6 +92,7 @@ var Rule = /** @class */ (function (_super) {
functions: "never",
typeLiterals: "ignore",
},
+ esSpecCompliant: true,
},
],
],
@@ -99,6 +101,7 @@ var Rule = /** @class */ (function (_super) {
};
/* tslint:enable:object-literal-sort-keys */
Rule.FAILURE_STRING_NEVER = "Unnecessary trailing comma";
+ Rule.FAILURE_STRING_FORBIDDEN = "Forbidden trailing comma";
Rule.FAILURE_STRING_ALWAYS = "Missing trailing comma";
return Rule;
}(Lint.Rules.AbstractRule));
@@ -113,23 +116,25 @@ var TrailingCommaWalker = /** @class */ (function (_super) {
var cb = function (node) {
switch (node.kind) {
case ts.SyntaxKind.ArrayLiteralExpression:
+ _this.checkList(node.elements, node.end, "arrays", isArrayRest);
+ break;
case ts.SyntaxKind.ArrayBindingPattern:
- _this.checkList(node.elements, node.end, "arrays");
+ _this.checkList(node.elements, node.end, "arrays", isDestructuringRest);
break;
case ts.SyntaxKind.ObjectBindingPattern:
- _this.checkList(node.elements, node.end, "objects");
+ _this.checkList(node.elements, node.end, "objects", isDestructuringRest);
break;
case ts.SyntaxKind.NamedImports:
- _this.checkList(node.elements, node.end, "imports");
+ _this.checkList(node.elements, node.end, "imports", noRest);
break;
case ts.SyntaxKind.NamedExports:
- _this.checkList(node.elements, node.end, "exports");
+ _this.checkList(node.elements, node.end, "exports", noRest);
break;
case ts.SyntaxKind.ObjectLiteralExpression:
- _this.checkList(node.properties, node.end, "objects");
+ _this.checkList(node.properties, node.end, "objects", isObjectRest);
break;
case ts.SyntaxKind.EnumDeclaration:
- _this.checkList(node.members, node.end, "objects");
+ _this.checkList(node.members, node.end, "objects", noRest);
break;
case ts.SyntaxKind.NewExpression:
if (node.arguments === undefined) {
@@ -137,9 +142,14 @@ var TrailingCommaWalker = /** @class */ (function (_super) {
}
// falls through
case ts.SyntaxKind.CallExpression:
- _this.checkList(node.arguments, node.end, "functions");
+ _this.checkList(node.arguments, node.end, "functions", noRest);
break;
case ts.SyntaxKind.ArrowFunction:
+ // don't check arrow functions without parens around the parameter
+ if (tsutils_1.getChildOfKind(node, ts.SyntaxKind.OpenParenToken, _this.sourceFile) === undefined) {
+ break;
+ }
+ // falls through
case ts.SyntaxKind.Constructor:
case ts.SyntaxKind.FunctionDeclaration:
case ts.SyntaxKind.FunctionExpression:
@@ -150,7 +160,7 @@ var TrailingCommaWalker = /** @class */ (function (_super) {
case ts.SyntaxKind.ConstructorType:
case ts.SyntaxKind.FunctionType:
case ts.SyntaxKind.CallSignature:
- _this.checkListWithEndToken(node, node.parameters, ts.SyntaxKind.CloseParenToken, "functions");
+ _this.checkList(node.parameters, tsutils_1.getChildOfKind(node, ts.SyntaxKind.CloseParenToken, _this.sourceFile).end, "functions", isRestParameter);
break;
case ts.SyntaxKind.TypeLiteral:
_this.checkTypeLiteral(node);
@@ -176,26 +186,24 @@ var TrailingCommaWalker = /** @class */ (function (_super) {
}
// The trailing comma is part of the last member and therefore not present as hasTrailingComma on the NodeArray
var hasTrailingComma = sourceText[members.end - 1] === ",";
- return this.checkComma(hasTrailingComma, members, node.end, "typeLiterals");
+ return this.checkComma(hasTrailingComma, members, node.end, "typeLiterals", noRest);
};
- TrailingCommaWalker.prototype.checkListWithEndToken = function (node, list, closeTokenKind, optionKey) {
+ TrailingCommaWalker.prototype.checkList = function (list, closeElementPos, optionKey, isRest) {
if (list.length === 0) {
return;
}
- var token = tsutils_1.getChildOfKind(node, closeTokenKind, this.sourceFile);
- if (token !== undefined) {
- return this.checkComma(list.hasTrailingComma, list, token.end, optionKey);
- }
+ return this.checkComma(list.hasTrailingComma, list, closeElementPos, optionKey, isRest);
};
- TrailingCommaWalker.prototype.checkList = function (list, closeElementPos, optionKey) {
- if (list.length === 0) {
+ /* Expects `list.length !== 0` */
+ TrailingCommaWalker.prototype.checkComma = function (hasTrailingComma, list, closeTokenPos, optionKey, isRest) {
+ var last = list[list.length - 1];
+ if (this.options.specCompliant && isRest(last)) {
+ if (hasTrailingComma) {
+ this.addFailureAt(list.end - 1, 1, Rule.FAILURE_STRING_FORBIDDEN, Lint.Replacement.deleteText(list.end - 1, 1));
+ }
return;
}
- return this.checkComma(list.hasTrailingComma, list, closeElementPos, optionKey);
- };
- /* Expects `list.length !== 0` */
- TrailingCommaWalker.prototype.checkComma = function (hasTrailingComma, list, closeTokenPos, optionKey) {
- var options = tsutils_1.isSameLine(this.sourceFile, list[list.length - 1].end, closeTokenPos)
+ var options = tsutils_1.isSameLine(this.sourceFile, last.end, closeTokenPos)
? this.options.singleline
: this.options.multiline;
var option = options[optionKey];
@@ -208,4 +216,19 @@ var TrailingCommaWalker = /** @class */ (function (_super) {
};
return TrailingCommaWalker;
}(Lint.AbstractWalker));
+function isRestParameter(node) {
+ return node.dotDotDotToken !== undefined;
+}
+function isDestructuringRest(node) {
+ return node.kind === ts.SyntaxKind.BindingElement && node.dotDotDotToken !== undefined;
+}
+function isObjectRest(node) {
+ return node.kind === ts.SyntaxKind.SpreadAssignment && tsutils_1.isReassignmentTarget(node.expression);
+}
+function isArrayRest(node) {
+ return node.kind === ts.SyntaxKind.SpreadElement && tsutils_1.isReassignmentTarget(node);
+}
+function noRest() {
+ return false;
+}
var _a, _b;
diff --git a/node_modules/tslint/lib/rules/typeofCompareRule.js b/node_modules/tslint/lib/rules/typeofCompareRule.js
index 7734d9afd..7668784df 100644
--- a/node_modules/tslint/lib/rules/typeofCompareRule.js
+++ b/node_modules/tslint/lib/rules/typeofCompareRule.js
@@ -38,6 +38,9 @@ var Rule = /** @class */ (function (_super) {
optionExamples: [true],
type: "functionality",
typescriptOnly: false,
+ deprecationMessage: ts.versionMajorMinor === "2.1"
+ ? "Starting from TypeScript 2.2 the compiler includes this check which makes this rule redundant."
+ : "",
};
/* tslint:enable:object-literal-sort-keys */
Rule.FAILURE_STRING = "'typeof' expression must be compared to one of: " + Array.from(LEGAL_TYPEOF_RESULTS).map(function (x) { return "\"" + x + "\""; }).join(", ");
diff --git a/node_modules/tslint/lib/rules/variableNameRule.js b/node_modules/tslint/lib/rules/variableNameRule.js
index b095c75a8..ce17c71ea 100644
--- a/node_modules/tslint/lib/rules/variableNameRule.js
+++ b/node_modules/tslint/lib/rules/variableNameRule.js
@@ -126,7 +126,7 @@ function walk(ctx) {
if (initializer !== undefined && isAlias(text, initializer)) {
return;
}
- if (!isCamelCase(text, options) && !utils_1.isUpperCase(text)) {
+ if (text.length !== 0 && !isCamelCase(text, options) && !utils_1.isUpperCase(text)) {
ctx.addFailureAtNode(name, formatFailure());
}
}
diff --git a/node_modules/tslint/lib/rules/whitespaceRule.js b/node_modules/tslint/lib/rules/whitespaceRule.js
index 67a8bdfb9..baae7ec33 100644
--- a/node_modules/tslint/lib/rules/whitespaceRule.js
+++ b/node_modules/tslint/lib/rules/whitespaceRule.js
@@ -59,6 +59,7 @@ var Rule = /** @class */ (function (_super) {
optionExamples: [[true, "check-branch", "check-operator", "check-typecast"]],
type: "style",
typescriptOnly: false,
+ hasFix: true,
};
Rule.FAILURE_STRING_MISSING = "missing whitespace";
Rule.FAILURE_STRING_INVALID = "invalid whitespace";
diff --git a/node_modules/tslint/lib/runner.d.ts b/node_modules/tslint/lib/runner.d.ts
index c544d4f03..80b0430de 100644
--- a/node_modules/tslint/lib/runner.d.ts
+++ b/node_modules/tslint/lib/runner.d.ts
@@ -6,7 +6,7 @@ export interface Options {
/**
* Exclude globs from path expansion.
*/
- exclude?: string | string[];
+ exclude: string[];
/**
* File paths to lint.
*/
diff --git a/node_modules/tslint/lib/runner.js b/node_modules/tslint/lib/runner.js
index d8d138a7f..b21019592 100644
--- a/node_modules/tslint/lib/runner.js
+++ b/node_modules/tslint/lib/runner.js
@@ -38,7 +38,7 @@ function run(options, logger) {
case 1: return [2 /*return*/, _a.sent()];
case 2:
error_2 = _a.sent();
- if (error_2.name === error_1.FatalError.NAME) {
+ if (error_2 instanceof error_1.FatalError) {
logger.error(error_2.message);
return [2 /*return*/, 1 /* FatalError */];
}
@@ -138,7 +138,7 @@ function resolveGlobs(files, ignore, outputAbsolutePaths) {
}
function doLinting(options, files, program, logger) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
- var possibleConfigAbsolutePath, linter, lastFolder, configFile, _i, files_1, file, contents, folder;
+ var possibleConfigAbsolutePath, linter, lastFolder, configFile, isFileExcluded, _i, files_1, file, contents, folder;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
@@ -149,6 +149,13 @@ function doLinting(options, files, program, logger) {
formattersDirectory: options.formattersDirectory,
rulesDirectory: options.rulesDirectory,
}, program);
+ isFileExcluded = function (filepath) {
+ if (configFile === undefined || configFile.linterOptions == undefined || configFile.linterOptions.exclude == undefined) {
+ return false;
+ }
+ var fullPath = path.resolve(filepath);
+ return configFile.linterOptions.exclude.some(function (pattern) { return new minimatch_1.Minimatch(pattern).match(fullPath); });
+ };
_i = 0, files_1 = files;
_a.label = 1;
case 1:
@@ -166,7 +173,9 @@ function doLinting(options, files, program, logger) {
configFile = configuration_1.findConfiguration(possibleConfigAbsolutePath, folder).results;
lastFolder = folder;
}
- linter.lint(file, contents, configFile);
+ if (!isFileExcluded(file)) {
+ linter.lint(file, contents, configFile);
+ }
}
_a.label = 3;
case 3:
diff --git a/node_modules/tslint/lib/test.js b/node_modules/tslint/lib/test.js
index bca549b33..10cb4eba0 100644
--- a/node_modules/tslint/lib/test.js
+++ b/node_modules/tslint/lib/test.js
@@ -16,7 +16,7 @@
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
-var colors = require("colors");
+var chalk = require("chalk");
var diff = require("diff");
var fs = require("fs");
var glob = require("glob");
@@ -67,9 +67,8 @@ function runTest(testDirectory, rulesDirectory) {
var fileText = isEncodingRule ? utils_1.readBufferWithDetectedEncoding(fs.readFileSync(fileToLint)) : fs.readFileSync(fileToLint, "utf-8");
var tsVersionRequirement = parse.getTypescriptVersionRequirement(fileText);
if (tsVersionRequirement !== undefined) {
- var tsVersion = new semver.SemVer(ts.version);
// remove prerelease suffix when matching to allow testing with nightly builds
- if (!semver.satisfies(tsVersion.major + "." + tsVersion.minor + "." + tsVersion.patch, tsVersionRequirement)) {
+ if (!semver.satisfies(parse.getNormalizedTypescriptVersion(), tsVersionRequirement)) {
results.results[fileToLint] = {
requirement: tsVersionRequirement,
skipped: true,
@@ -80,6 +79,7 @@ function runTest(testDirectory, rulesDirectory) {
var lineBreak = fileText.search(/\n/);
fileText = lineBreak === -1 ? "" : fileText.substr(lineBreak + 1);
}
+ fileText = parse.preprocessDirectives(fileText);
var fileTextWithoutMarkup = parse.removeErrorMarkup(fileText);
var errorsFromMarkup = parse.parseErrorsFromMarkup(fileText);
var program = void 0;
@@ -91,15 +91,14 @@ function runTest(testDirectory, rulesDirectory) {
getDefaultLibFileName: function () { return ts.getDefaultLibFileName(compilerOptions); },
getDirectories: function (dir) { return fs.readdirSync(dir); },
getNewLine: function () { return "\n"; },
- getSourceFile: function (filenameToGet) {
- var target = compilerOptions.target === undefined ? ts.ScriptTarget.ES5 : compilerOptions.target;
- if (filenameToGet === ts.getDefaultLibFileName(compilerOptions)) {
- var fileContent = fs.readFileSync(ts.getDefaultLibFilePath(compilerOptions), "utf8");
- return ts.createSourceFile(filenameToGet, fileContent, target);
- }
- else if (utils_1.denormalizeWinPath(filenameToGet) === fileCompileName) {
+ getSourceFile: function (filenameToGet, target) {
+ if (utils_1.denormalizeWinPath(filenameToGet) === fileCompileName) {
return ts.createSourceFile(filenameToGet, fileTextWithoutMarkup, target, true);
}
+ if (path.basename(filenameToGet) === filenameToGet) {
+ // resolve path of lib.xxx.d.ts
+ filenameToGet = path.join(path.dirname(ts.getDefaultLibFilePath(compilerOptions)), filenameToGet);
+ }
var text = fs.readFileSync(filenameToGet, "utf8");
return ts.createSourceFile(filenameToGet, text, target, true);
},
@@ -180,7 +179,7 @@ function consoleTestResultsHandler(testResults) {
exports.consoleTestResultsHandler = consoleTestResultsHandler;
function consoleTestResultHandler(testResult) {
// needed to get colors to show up when passing through Grunt
- colors.enabled = true;
+ chalk.enabled = true;
var didAllTestsPass = true;
for (var _i = 0, _a = Object.keys(testResult.results); _i < _a.length; _i++) {
var fileName = _a[_i];
@@ -188,7 +187,7 @@ function consoleTestResultHandler(testResult) {
process.stdout.write(fileName + ":");
/* tslint:disable:no-console */
if (results.skipped) {
- console.log(colors.yellow(" Skipped, requires typescript " + results.requirement));
+ console.log(chalk.yellow(" Skipped, requires typescript " + results.requirement));
}
else {
var markupDiffResults = diff.diffLines(results.markupFromMarkup, results.markupFromLinter);
@@ -196,10 +195,10 @@ function consoleTestResultHandler(testResult) {
var didMarkupTestPass = !markupDiffResults.some(function (hunk) { return hunk.added === true || hunk.removed === true; });
var didFixesTestPass = !fixesDiffResults.some(function (hunk) { return hunk.added === true || hunk.removed === true; });
if (didMarkupTestPass && didFixesTestPass) {
- console.log(colors.green(" Passed"));
+ console.log(chalk.green(" Passed"));
}
else {
- console.log(colors.red(" Failed!"));
+ console.log(chalk.red(" Failed!"));
didAllTestsPass = false;
if (!didMarkupTestPass) {
displayDiffResults(markupDiffResults, MARKUP_FILE_EXTENSION);
@@ -216,16 +215,16 @@ function consoleTestResultHandler(testResult) {
exports.consoleTestResultHandler = consoleTestResultHandler;
function displayDiffResults(diffResults, extension) {
/* tslint:disable:no-console */
- console.log(colors.green("Expected (from " + extension + " file)"));
- console.log(colors.red("Actual (from TSLint)"));
+ console.log(chalk.green("Expected (from " + extension + " file)"));
+ console.log(chalk.red("Actual (from TSLint)"));
for (var _i = 0, diffResults_1 = diffResults; _i < diffResults_1.length; _i++) {
var diffResult = diffResults_1[_i];
- var color = colors.grey;
+ var color = chalk.grey;
if (diffResult.added) {
- color = colors.green.underline;
+ color = chalk.green.underline;
}
else if (diffResult.removed) {
- color = colors.red.underline;
+ color = chalk.red.underline;
}
process.stdout.write(color(diffResult.value));
}
diff --git a/node_modules/tslint/lib/tslint-cli.js b/node_modules/tslint/lib/tslint-cli.js
index 1d9f6ccd9..d2b38d7d9 100644
--- a/node_modules/tslint/lib/tslint-cli.js
+++ b/node_modules/tslint/lib/tslint-cli.js
@@ -106,8 +106,8 @@ var options = [
{
name: "type-check",
type: "boolean",
- describe: "check for type errors before linting the project",
- description: (_k = ["\n Checks for type errors before linting a project. --project must be\n specified in order to enable type checking."], _k.raw = ["\n Checks for type errors before linting a project. --project must be\n specified in order to enable type checking."], utils_1.dedent(_k)),
+ describe: "(deprecated) check for type errors before linting the project",
+ description: (_k = ["\n (deprecated) Checks for type errors before linting a project.\n --project must be specified in order to enable type checking."], _k.raw = ["\n (deprecated) Checks for type errors before linting a project.\n --project must be specified in order to enable type checking."], utils_1.dedent(_k)),
},
];
var builtinOptions = [
@@ -155,12 +155,15 @@ if (!(argv.init || argv.test !== undefined || argv.project !== undefined || comm
console.error("No files specified. Use --project to lint a project folder.");
process.exit(1);
}
-if (argv.typeCheck && argv.project === undefined) {
- console.error("--project must be specified in order to enable type checking.");
- process.exit(1);
+if (argv.typeCheck) {
+ console.warn("--type-check is deprecated. You only need --project to enable rule which need type information.");
+ if (argv.project === undefined) {
+ console.error("--project must be specified in order to enable type checking.");
+ process.exit(1);
+ }
}
var log;
-if (argv.out != null) {
+if (argv.out != undefined) {
var outputStream_1 = fs.createWriteStream(argv.out, {
flags: "w+",
mode: 420,
@@ -170,7 +173,6 @@ if (argv.out != null) {
else {
log = console.log;
}
-// tslint:disable-next-line no-floating-promises
runner_1.run({
config: argv.config,
exclude: argv.exclude,
@@ -189,7 +191,8 @@ runner_1.run({
}, {
log: log,
error: function (m) { return console.error(m); },
-}).then(function (rc) {
+})
+ .then(function (rc) {
process.exitCode = rc;
}).catch(function (e) {
console.error(e);
diff --git a/node_modules/tslint/lib/utils.js b/node_modules/tslint/lib/utils.js
index 2bd5c8ca2..df04f51fd 100644
--- a/node_modules/tslint/lib/utils.js
+++ b/node_modules/tslint/lib/utils.js
@@ -23,7 +23,7 @@ function arrayify(arg) {
if (Array.isArray(arg)) {
return arg;
}
- else if (arg != null) {
+ else if (arg != undefined) {
return [arg];
}
else {
@@ -36,7 +36,7 @@ exports.arrayify = arrayify;
* Enforces the invariant that the input is an object.
*/
function objectify(arg) {
- if (typeof arg === "object" && arg != null) {
+ if (typeof arg === "object" && arg != undefined) {
return arg;
}
else {
diff --git a/node_modules/tslint/lib/verify/lines.js b/node_modules/tslint/lib/verify/lines.js
index 3b15c0875..9fb0f5ef2 100644
--- a/node_modules/tslint/lib/verify/lines.js
+++ b/node_modules/tslint/lib/verify/lines.js
@@ -86,12 +86,12 @@ exports.ZERO_LENGTH_ERROR = "~nil";
*/
function parseLine(text) {
var multilineErrorMatch = text.match(multilineErrorRegex);
- if (multilineErrorMatch != null) {
+ if (multilineErrorMatch !== null) {
var startErrorCol = text.indexOf("~");
return new MultilineErrorLine(startErrorCol);
}
var endErrorMatch = text.match(endErrorRegex);
- if (endErrorMatch != null) {
+ if (endErrorMatch !== null) {
var squiggles = endErrorMatch[1], message = endErrorMatch[2];
var startErrorCol = text.indexOf("~");
var zeroLengthError = (squiggles === exports.ZERO_LENGTH_ERROR);
@@ -99,7 +99,7 @@ function parseLine(text) {
return new EndErrorLine(startErrorCol, endErrorCol, message);
}
var messageSubstitutionMatch = text.match(messageSubstitutionRegex);
- if (messageSubstitutionMatch != null) {
+ if (messageSubstitutionMatch !== null) {
var key = messageSubstitutionMatch[1], message = messageSubstitutionMatch[2];
return new MessageSubstitutionLine(key, message);
}
@@ -117,7 +117,7 @@ exports.parseLine = parseLine;
*/
function printLine(line, code) {
if (line instanceof ErrorLine) {
- if (code == null) {
+ if (code === undefined) {
throw new Error("Must supply argument for code parameter when line is an ErrorLine");
}
var leadingSpaces = " ".repeat(line.startCol);
diff --git a/node_modules/tslint/lib/verify/lintError.d.ts b/node_modules/tslint/lib/verify/lintError.d.ts
index c00b4b535..a1b9f821a 100644
--- a/node_modules/tslint/lib/verify/lintError.d.ts
+++ b/node_modules/tslint/lib/verify/lintError.d.ts
@@ -1,4 +1,3 @@
-import { Error } from "../error";
export interface PositionInFile {
line: number;
col: number;
diff --git a/node_modules/tslint/lib/verify/lintError.js b/node_modules/tslint/lib/verify/lintError.js
index d784537c1..b57661299 100644
--- a/node_modules/tslint/lib/verify/lintError.js
+++ b/node_modules/tslint/lib/verify/lintError.js
@@ -15,7 +15,6 @@
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
-var error_1 = require("../error");
function errorComparator(err1, err2) {
if (err1.startPos.line !== err2.startPos.line) {
return err1.startPos.line - err2.startPos.line;
@@ -35,6 +34,6 @@ function errorComparator(err1, err2) {
}
exports.errorComparator = errorComparator;
function lintSyntaxError(message) {
- return new error_1.Error("Lint File Syntax Error: " + message);
+ return new Error("Lint File Syntax Error: " + message);
}
exports.lintSyntaxError = lintSyntaxError;
diff --git a/node_modules/tslint/lib/verify/parse.d.ts b/node_modules/tslint/lib/verify/parse.d.ts
index db31418a1..12e9535e8 100644
--- a/node_modules/tslint/lib/verify/parse.d.ts
+++ b/node_modules/tslint/lib/verify/parse.d.ts
@@ -1,5 +1,7 @@
import { LintError } from "./lintError";
export declare function getTypescriptVersionRequirement(text: string): string | undefined;
+export declare function getNormalizedTypescriptVersion(): string;
+export declare function preprocessDirectives(text: string): string;
/**
* Takes the full text of a .lint file and returns the contents of the file
* with all error markup removed
diff --git a/node_modules/tslint/lib/verify/parse.js b/node_modules/tslint/lib/verify/parse.js
index 1d475efd3..528f68cc8 100644
--- a/node_modules/tslint/lib/verify/parse.js
+++ b/node_modules/tslint/lib/verify/parse.js
@@ -15,6 +15,7 @@
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
+var semver = require("semver");
var ts = require("typescript");
var util_1 = require("util");
var utils_1 = require("../utils");
@@ -30,6 +31,54 @@ function getTypescriptVersionRequirement(text) {
return undefined;
}
exports.getTypescriptVersionRequirement = getTypescriptVersionRequirement;
+function getNormalizedTypescriptVersion() {
+ var tsVersion = new semver.SemVer(ts.version);
+ // remove prerelease suffix when matching to allow testing with nightly builds
+ return tsVersion.major + "." + tsVersion.minor + "." + tsVersion.patch;
+}
+exports.getNormalizedTypescriptVersion = getNormalizedTypescriptVersion;
+function preprocessDirectives(text) {
+ if (!/^#(?:if|else|endif)\b/m.test(text)) {
+ return text; // If there are no directives, just return the input unchanged
+ }
+ var tsVersion = getNormalizedTypescriptVersion();
+ var lines = text.split(/\n/);
+ var result = [];
+ var collecting = true;
+ var state = 0 /* Initial */;
+ for (var _i = 0, lines_2 = lines; _i < lines_2.length; _i++) {
+ var line = lines_2[_i];
+ if (line.startsWith("#if typescript")) {
+ if (state !== 0 /* Initial */) {
+ throw lintError_1.lintSyntaxError("#if directives cannot be nested");
+ }
+ state = 1 /* If */;
+ collecting = semver.satisfies(tsVersion, line.slice("#if typescript".length).trim());
+ }
+ else if (/^#else\s*$/.test(line)) {
+ if (state !== 1 /* If */) {
+ throw lintError_1.lintSyntaxError("unexpected #else");
+ }
+ state = 2 /* Else */;
+ collecting = !collecting;
+ }
+ else if (/^#endif\s*$/.test(line)) {
+ if (state === 0 /* Initial */) {
+ throw lintError_1.lintSyntaxError("unexpected #endif");
+ }
+ state = 0 /* Initial */;
+ collecting = true;
+ }
+ else if (collecting) {
+ result.push(line);
+ }
+ }
+ if (state !== 0 /* Initial */) {
+ throw lintError_1.lintSyntaxError("expected #endif");
+ }
+ return result.join("\n");
+}
+exports.preprocessDirectives = preprocessDirectives;
/**
* Takes the full text of a .lint file and returns the contents of the file
* with all error markup removed
@@ -193,8 +242,8 @@ exports.createMarkupFromErrors = createMarkupFromErrors;
/* tslint:enable:object-literal-sort-keys */
function createCodeLineNoToErrorsMap(lines) {
var errorLinesForCodeLine = [];
- for (var _i = 0, lines_2 = lines; _i < lines_2.length; _i++) {
- var line = lines_2[_i];
+ for (var _i = 0, lines_3 = lines; _i < lines_3.length; _i++) {
+ var line = lines_3[_i];
if (line instanceof lines_1.CodeLine) {
errorLinesForCodeLine.push([]);
}
diff --git a/node_modules/tslint/node_modules/chalk/index.js b/node_modules/tslint/node_modules/chalk/index.js
new file mode 100644
index 000000000..05e62b346
--- /dev/null
+++ b/node_modules/tslint/node_modules/chalk/index.js
@@ -0,0 +1,228 @@
+'use strict';
+const escapeStringRegexp = require('escape-string-regexp');
+const ansiStyles = require('ansi-styles');
+const supportsColor = require('supports-color');
+
+const template = require('./templates.js');
+
+const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
+
+// `supportsColor.level` → `ansiStyles.color[name]` mapping
+const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
+
+// `color-convert` models to exclude from the Chalk API due to conflicts and such
+const skipModels = new Set(['gray']);
+
+const styles = Object.create(null);
+
+function applyOptions(obj, options) {
+ options = options || {};
+
+ // Detect level if not set manually
+ const scLevel = supportsColor ? supportsColor.level : 0;
+ obj.level = options.level === undefined ? scLevel : options.level;
+ obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
+}
+
+function Chalk(options) {
+ // We check for this.template here since calling `chalk.constructor()`
+ // by itself will have a `this` of a previously constructed chalk object
+ if (!this || !(this instanceof Chalk) || this.template) {
+ const chalk = {};
+ applyOptions(chalk, options);
+
+ chalk.template = function () {
+ const args = [].slice.call(arguments);
+ return chalkTag.apply(null, [chalk.template].concat(args));
+ };
+
+ Object.setPrototypeOf(chalk, Chalk.prototype);
+ Object.setPrototypeOf(chalk.template, chalk);
+
+ chalk.template.constructor = Chalk;
+
+ return chalk.template;
+ }
+
+ applyOptions(this, options);
+}
+
+// Use bright blue on Windows as the normal blue color is illegible
+if (isSimpleWindowsTerm) {
+ ansiStyles.blue.open = '\u001B[94m';
+}
+
+for (const key of Object.keys(ansiStyles)) {
+ ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
+
+ styles[key] = {
+ get() {
+ const codes = ansiStyles[key];
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
+ }
+ };
+}
+
+styles.visible = {
+ get() {
+ return build.call(this, this._styles || [], true, 'visible');
+ }
+};
+
+ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
+for (const model of Object.keys(ansiStyles.color.ansi)) {
+ if (skipModels.has(model)) {
+ continue;
+ }
+
+ styles[model] = {
+ get() {
+ const level = this.level;
+ return function () {
+ const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
+ const codes = {
+ open,
+ close: ansiStyles.color.close,
+ closeRe: ansiStyles.color.closeRe
+ };
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
+ };
+ }
+ };
+}
+
+ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
+for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
+ if (skipModels.has(model)) {
+ continue;
+ }
+
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
+ styles[bgModel] = {
+ get() {
+ const level = this.level;
+ return function () {
+ const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
+ const codes = {
+ open,
+ close: ansiStyles.bgColor.close,
+ closeRe: ansiStyles.bgColor.closeRe
+ };
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
+ };
+ }
+ };
+}
+
+const proto = Object.defineProperties(() => {}, styles);
+
+function build(_styles, _empty, key) {
+ const builder = function () {
+ return applyStyle.apply(builder, arguments);
+ };
+
+ builder._styles = _styles;
+ builder._empty = _empty;
+
+ const self = this;
+
+ Object.defineProperty(builder, 'level', {
+ enumerable: true,
+ get() {
+ return self.level;
+ },
+ set(level) {
+ self.level = level;
+ }
+ });
+
+ Object.defineProperty(builder, 'enabled', {
+ enumerable: true,
+ get() {
+ return self.enabled;
+ },
+ set(enabled) {
+ self.enabled = enabled;
+ }
+ });
+
+ // See below for fix regarding invisible grey/dim combination on Windows
+ builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
+
+ // `__proto__` is used because we must return a function, but there is
+ // no way to create a function with a different prototype
+ builder.__proto__ = proto; // eslint-disable-line no-proto
+
+ return builder;
+}
+
+function applyStyle() {
+ // Support varags, but simply cast to string in case there's only one arg
+ const args = arguments;
+ const argsLen = args.length;
+ let str = String(arguments[0]);
+
+ if (argsLen === 0) {
+ return '';
+ }
+
+ if (argsLen > 1) {
+ // Don't slice `arguments`, it prevents V8 optimizations
+ for (let a = 1; a < argsLen; a++) {
+ str += ' ' + args[a];
+ }
+ }
+
+ if (!this.enabled || this.level <= 0 || !str) {
+ return this._empty ? '' : str;
+ }
+
+ // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
+ // see https://github.com/chalk/chalk/issues/58
+ // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
+ const originalDim = ansiStyles.dim.open;
+ if (isSimpleWindowsTerm && this.hasGrey) {
+ ansiStyles.dim.open = '';
+ }
+
+ for (const code of this._styles.slice().reverse()) {
+ // Replace any instances already present with a re-opening code
+ // otherwise only the part of the string until said closing code
+ // will be colored, and the rest will simply be 'plain'.
+ str = code.open + str.replace(code.closeRe, code.open) + code.close;
+
+ // Close the styling before a linebreak and reopen
+ // after next line to fix a bleed issue on macOS
+ // https://github.com/chalk/chalk/pull/92
+ str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
+ }
+
+ // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
+ ansiStyles.dim.open = originalDim;
+
+ return str;
+}
+
+function chalkTag(chalk, strings) {
+ if (!Array.isArray(strings)) {
+ // If chalk() was called by itself or with a string,
+ // return the string itself as a string.
+ return [].slice.call(arguments, 1).join(' ');
+ }
+
+ const args = [].slice.call(arguments, 2);
+ const parts = [strings.raw[0]];
+
+ for (let i = 1; i < strings.length; i++) {
+ parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
+ parts.push(String(strings.raw[i]));
+ }
+
+ return template(chalk, parts.join(''));
+}
+
+Object.defineProperties(Chalk.prototype, styles);
+
+module.exports = Chalk(); // eslint-disable-line new-cap
+module.exports.supportsColor = supportsColor;
+module.exports.default = module.exports; // For TypeScript
diff --git a/node_modules/tslint/node_modules/chalk/license b/node_modules/tslint/node_modules/chalk/license
new file mode 100644
index 000000000..e7af2f771
--- /dev/null
+++ b/node_modules/tslint/node_modules/chalk/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/tslint/node_modules/chalk/package.json b/node_modules/tslint/node_modules/chalk/package.json
new file mode 100644
index 000000000..69889f0cd
--- /dev/null
+++ b/node_modules/tslint/node_modules/chalk/package.json
@@ -0,0 +1,66 @@
+{
+ "name": "chalk",
+ "version": "2.3.0",
+ "description": "Terminal string styling done right",
+ "license": "MIT",
+ "repository": "chalk/chalk",
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && tsc --project types && nyc ava",
+ "bench": "matcha benchmark.js",
+ "coveralls": "nyc report --reporter=text-lcov | coveralls"
+ },
+ "files": [
+ "index.js",
+ "templates.js",
+ "types/index.d.ts"
+ ],
+ "keywords": [
+ "color",
+ "colour",
+ "colors",
+ "terminal",
+ "console",
+ "cli",
+ "string",
+ "str",
+ "ansi",
+ "style",
+ "styles",
+ "tty",
+ "formatting",
+ "rgb",
+ "256",
+ "shell",
+ "xterm",
+ "log",
+ "logging",
+ "command-line",
+ "text"
+ ],
+ "dependencies": {
+ "ansi-styles": "^3.1.0",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^4.0.0"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "coveralls": "^3.0.0",
+ "execa": "^0.8.0",
+ "import-fresh": "^2.0.0",
+ "matcha": "^0.7.0",
+ "nyc": "^11.0.2",
+ "resolve-from": "^4.0.0",
+ "typescript": "^2.5.3",
+ "xo": "*"
+ },
+ "types": "types/index.d.ts",
+ "xo": {
+ "envs": [
+ "node",
+ "mocha"
+ ]
+ }
+}
diff --git a/node_modules/tslint/node_modules/chalk/readme.md b/node_modules/tslint/node_modules/chalk/readme.md
new file mode 100644
index 000000000..9bb2e65e8
--- /dev/null
+++ b/node_modules/tslint/node_modules/chalk/readme.md
@@ -0,0 +1,309 @@
+<h1 align="center">
+ <br>
+ <br>
+ <img width="320" src="https://cdn.rawgit.com/chalk/chalk/19935d6484811c5e468817f846b7b3d417d7bf4a/logo.svg" alt="chalk">
+ <br>
+ <br>
+ <br>
+</h1>
+
+> Terminal string styling done right
+
+[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](https://github.com/sindresorhus/awesome-nodejs)
+
+### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0)
+
+![](https://github.com/chalk/ansi-styles/raw/master/screenshot.png)
+
+
+## Highlights
+
+- Expressive API
+- Highly performant
+- Ability to nest styles
+- [256/Truecolor color support](#256-and-truecolor-color-support)
+- Auto-detects color support
+- Doesn't extend `String.prototype`
+- Clean and focused
+- Actively maintained
+- [Used by ~17,000 packages](https://www.npmjs.com/browse/depended/chalk) as of June 20th, 2017
+
+
+## Install
+
+```console
+$ npm install chalk
+```
+
+
+## Usage
+
+```js
+const chalk = require('chalk');
+
+console.log(chalk.blue('Hello world!'));
+```
+
+Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
+
+```js
+const chalk = require('chalk');
+const log = console.log;
+
+// Combine styled and normal strings
+log(chalk.blue('Hello') + 'World' + chalk.red('!'));
+
+// Compose multiple styles using the chainable API
+log(chalk.blue.bgRed.bold('Hello world!'));
+
+// Pass in multiple arguments
+log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
+
+// Nest styles
+log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
+
+// Nest styles of the same type even (color, underline, background)
+log(chalk.green(
+ 'I am a green line ' +
+ chalk.blue.underline.bold('with a blue substring') +
+ ' that becomes green again!'
+));
+
+// ES2015 template literal
+log(`
+CPU: ${chalk.red('90%')}
+RAM: ${chalk.green('40%')}
+DISK: ${chalk.yellow('70%')}
+`);
+
+// ES2015 tagged template literal
+log(chalk`
+CPU: {red ${cpu.totalPercent}%}
+RAM: {green ${ram.used / ram.total * 100}%}
+DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
+`);
+
+// Use RGB colors in terminal emulators that support it.
+log(chalk.keyword('orange')('Yay for orange colored text!'));
+log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
+log(chalk.hex('#DEADED').bold('Bold gray!'));
+```
+
+Easily define your own themes:
+
+```js
+const chalk = require('chalk');
+
+const error = chalk.bold.red;
+const warning = chalk.keyword('orange');
+
+console.log(error('Error!'));
+console.log(warning('Warning!'));
+```
+
+Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
+
+```js
+const name = 'Sindre';
+console.log(chalk.green('Hello %s'), name);
+//=> 'Hello Sindre'
+```
+
+
+## API
+
+### chalk.`<style>[.<style>...](string, [string...])`
+
+Example: `chalk.red.bold.underline('Hello', 'world');`
+
+Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
+
+Multiple arguments will be separated by space.
+
+### chalk.enabled
+
+Color support is automatically detected, as is the level (see `chalk.level`). However, if you'd like to simply enable/disable Chalk, you can do so via the `.enabled` property.
+
+Chalk is enabled by default unless expicitly disabled via the constructor or `chalk.level` is `0`.
+
+If you need to change this in a reusable module, create a new instance:
+
+```js
+const ctx = new chalk.constructor({enabled: false});
+```
+
+### chalk.level
+
+Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
+
+If you need to change this in a reusable module, create a new instance:
+
+```js
+const ctx = new chalk.constructor({level: 0});
+```
+
+Levels are as follows:
+
+0. All colors disabled
+1. Basic color support (16 colors)
+2. 256 color support
+3. Truecolor support (16 million colors)
+
+### chalk.supportsColor
+
+Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
+
+Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add the environment variable `FORCE_COLOR=1` to forcefully enable color or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
+
+Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
+
+
+## Styles
+
+### Modifiers
+
+- `reset`
+- `bold`
+- `dim`
+- `italic` *(Not widely supported)*
+- `underline`
+- `inverse`
+- `hidden`
+- `strikethrough` *(Not widely supported)*
+- `visible` (Text is emitted only if enabled)
+
+### Colors
+
+- `black`
+- `red`
+- `green`
+- `yellow`
+- `blue` *(On Windows the bright version is used since normal blue is illegible)*
+- `magenta`
+- `cyan`
+- `white`
+- `gray` ("bright black")
+- `redBright`
+- `greenBright`
+- `yellowBright`
+- `blueBright`
+- `magentaBright`
+- `cyanBright`
+- `whiteBright`
+
+### Background colors
+
+- `bgBlack`
+- `bgRed`
+- `bgGreen`
+- `bgYellow`
+- `bgBlue`
+- `bgMagenta`
+- `bgCyan`
+- `bgWhite`
+- `bgBlackBright`
+- `bgRedBright`
+- `bgGreenBright`
+- `bgYellowBright`
+- `bgBlueBright`
+- `bgMagentaBright`
+- `bgCyanBright`
+- `bgWhiteBright`
+
+
+## Tagged template literal
+
+Chalk can be used as a [tagged template literal](http://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
+
+```js
+const chalk = require('chalk');
+
+const miles = 18;
+const calculateFeet = miles => miles * 5280;
+
+console.log(chalk`
+ There are {bold 5280 feet} in a mile.
+ In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
+`);
+```
+
+Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
+
+Template styles are chained exactly like normal Chalk styles. The following two statements are equivalent:
+
+```js
+console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
+console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
+```
+
+Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
+
+All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
+
+
+## 256 and Truecolor color support
+
+Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
+
+Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
+
+Examples:
+
+- `chalk.hex('#DEADED').underline('Hello, world!')`
+- `chalk.keyword('orange')('Some orange text')`
+- `chalk.rgb(15, 100, 204).inverse('Hello!')`
+
+Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
+
+- `chalk.bgHex('#DEADED').underline('Hello, world!')`
+- `chalk.bgKeyword('orange')('Some orange text')`
+- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
+
+The following color models can be used:
+
+- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
+- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
+- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
+- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
+- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 1, 1).bold('Orange!')`
+- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hsl(32, 0, 50).bold('Orange!')`
+- `ansi16`
+- `ansi256`
+
+
+## Windows
+
+If you're on Windows, do yourself a favor and use [`cmder`](http://cmder.net/) instead of `cmd.exe`.
+
+
+## Origin story
+
+[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
+
+
+## Related
+
+- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
+- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
+- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
+- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
+- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
+- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
+- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
+- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
+- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
+- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
+- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
+- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
+- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
+
+
+## Maintainers
+
+- [Sindre Sorhus](https://github.com/sindresorhus)
+- [Josh Junon](https://github.com/qix-)
+
+
+## License
+
+MIT
diff --git a/node_modules/tslint/node_modules/chalk/templates.js b/node_modules/tslint/node_modules/chalk/templates.js
new file mode 100644
index 000000000..dbdf9b221
--- /dev/null
+++ b/node_modules/tslint/node_modules/chalk/templates.js
@@ -0,0 +1,128 @@
+'use strict';
+const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
+const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
+const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
+const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
+
+const ESCAPES = new Map([
+ ['n', '\n'],
+ ['r', '\r'],
+ ['t', '\t'],
+ ['b', '\b'],
+ ['f', '\f'],
+ ['v', '\v'],
+ ['0', '\0'],
+ ['\\', '\\'],
+ ['e', '\u001B'],
+ ['a', '\u0007']
+]);
+
+function unescape(c) {
+ if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
+ return String.fromCharCode(parseInt(c.slice(1), 16));
+ }
+
+ return ESCAPES.get(c) || c;
+}
+
+function parseArguments(name, args) {
+ const results = [];
+ const chunks = args.trim().split(/\s*,\s*/g);
+ let matches;
+
+ for (const chunk of chunks) {
+ if (!isNaN(chunk)) {
+ results.push(Number(chunk));
+ } else if ((matches = chunk.match(STRING_REGEX))) {
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
+ } else {
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
+ }
+ }
+
+ return results;
+}
+
+function parseStyle(style) {
+ STYLE_REGEX.lastIndex = 0;
+
+ const results = [];
+ let matches;
+
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
+ const name = matches[1];
+
+ if (matches[2]) {
+ const args = parseArguments(name, matches[2]);
+ results.push([name].concat(args));
+ } else {
+ results.push([name]);
+ }
+ }
+
+ return results;
+}
+
+function buildStyle(chalk, styles) {
+ const enabled = {};
+
+ for (const layer of styles) {
+ for (const style of layer.styles) {
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
+ }
+ }
+
+ let current = chalk;
+ for (const styleName of Object.keys(enabled)) {
+ if (Array.isArray(enabled[styleName])) {
+ if (!(styleName in current)) {
+ throw new Error(`Unknown Chalk style: ${styleName}`);
+ }
+
+ if (enabled[styleName].length > 0) {
+ current = current[styleName].apply(current, enabled[styleName]);
+ } else {
+ current = current[styleName];
+ }
+ }
+ }
+
+ return current;
+}
+
+module.exports = (chalk, tmp) => {
+ const styles = [];
+ const chunks = [];
+ let chunk = [];
+
+ // eslint-disable-next-line max-params
+ tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
+ if (escapeChar) {
+ chunk.push(unescape(escapeChar));
+ } else if (style) {
+ const str = chunk.join('');
+ chunk = [];
+ chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
+ styles.push({inverse, styles: parseStyle(style)});
+ } else if (close) {
+ if (styles.length === 0) {
+ throw new Error('Found extraneous } in Chalk template literal');
+ }
+
+ chunks.push(buildStyle(chalk, styles)(chunk.join('')));
+ chunk = [];
+ styles.pop();
+ } else {
+ chunk.push(chr);
+ }
+ });
+
+ chunks.push(chunk.join(''));
+
+ if (styles.length > 0) {
+ const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
+ throw new Error(errMsg);
+ }
+
+ return chunks.join('');
+};
diff --git a/node_modules/tslint/node_modules/chalk/types/index.d.ts b/node_modules/tslint/node_modules/chalk/types/index.d.ts
new file mode 100644
index 000000000..b4e4dc57e
--- /dev/null
+++ b/node_modules/tslint/node_modules/chalk/types/index.d.ts
@@ -0,0 +1,97 @@
+// Type definitions for Chalk
+// Definitions by: Thomas Sauer <https://github.com/t-sauer>
+
+export const enum Level {
+ None = 0,
+ Basic = 1,
+ Ansi256 = 2,
+ TrueColor = 3
+}
+
+export interface ChalkOptions {
+ enabled?: boolean;
+ level?: Level;
+}
+
+export interface ChalkConstructor {
+ new (options?: ChalkOptions): Chalk;
+ (options?: ChalkOptions): Chalk;
+}
+
+export interface ColorSupport {
+ level: Level;
+ hasBasic: boolean;
+ has256: boolean;
+ has16m: boolean;
+}
+
+export interface Chalk {
+ (...text: string[]): string;
+ (text: TemplateStringsArray, ...placeholders: string[]): string;
+ constructor: ChalkConstructor;
+ enabled: boolean;
+ level: Level;
+ rgb(r: number, g: number, b: number): this;
+ hsl(h: number, s: number, l: number): this;
+ hsv(h: number, s: number, v: number): this;
+ hwb(h: number, w: number, b: number): this;
+ bgHex(color: string): this;
+ bgKeyword(color: string): this;
+ bgRgb(r: number, g: number, b: number): this;
+ bgHsl(h: number, s: number, l: number): this;
+ bgHsv(h: number, s: number, v: number): this;
+ bgHwb(h: number, w: number, b: number): this;
+ hex(color: string): this;
+ keyword(color: string): this;
+
+ readonly reset: this;
+ readonly bold: this;
+ readonly dim: this;
+ readonly italic: this;
+ readonly underline: this;
+ readonly inverse: this;
+ readonly hidden: this;
+ readonly strikethrough: this;
+
+ readonly visible: this;
+
+ readonly black: this;
+ readonly red: this;
+ readonly green: this;
+ readonly yellow: this;
+ readonly blue: this;
+ readonly magenta: this;
+ readonly cyan: this;
+ readonly white: this;
+ readonly gray: this;
+ readonly grey: this;
+ readonly blackBright: this;
+ readonly redBright: this;
+ readonly greenBright: this;
+ readonly yellowBright: this;
+ readonly blueBright: this;
+ readonly magentaBright: this;
+ readonly cyanBright: this;
+ readonly whiteBright: this;
+
+ readonly bgBlack: this;
+ readonly bgRed: this;
+ readonly bgGreen: this;
+ readonly bgYellow: this;
+ readonly bgBlue: this;
+ readonly bgMagenta: this;
+ readonly bgCyan: this;
+ readonly bgWhite: this;
+ readonly bgBlackBright: this;
+ readonly bgRedBright: this;
+ readonly bgGreenBright: this;
+ readonly bgYellowBright: this;
+ readonly bgBlueBright: this;
+ readonly bgMagentaBright: this;
+ readonly bgCyanBright: this;
+ readonly bgWhiteBright: this;
+}
+
+declare const chalk: Chalk & { supportsColor: ColorSupport };
+
+export default chalk
diff --git a/node_modules/tslint/node_modules/commander/CHANGELOG.md b/node_modules/tslint/node_modules/commander/CHANGELOG.md
new file mode 100644
index 000000000..e55813269
--- /dev/null
+++ b/node_modules/tslint/node_modules/commander/CHANGELOG.md
@@ -0,0 +1,326 @@
+
+2.12.2 / 2017-11-28
+==================
+
+ * fix: typings are not shipped
+
+2.12.1 / 2017-11-23
+==================
+
+ * Move @types/node to dev dependency
+
+2.12.0 / 2017-11-22
+==================
+
+ * add attributeName() method to Option objects
+ * Documentation updated for options with --no prefix
+ * typings: `outputHelp` takes a string as the first parameter
+ * typings: use overloads
+ * feat(typings): update to match js api
+ * Print default value in option help
+ * Fix translation error
+ * Fail when using same command and alias (#491)
+ * feat(typings): add help callback
+ * fix bug when description is add after command with options (#662)
+ * Format js code
+ * Rename History.md to CHANGELOG.md (#668)
+ * feat(typings): add typings to support TypeScript (#646)
+ * use current node
+
+2.11.0 / 2017-07-03
+==================
+
+ * Fix help section order and padding (#652)
+ * feature: support for signals to subcommands (#632)
+ * Fixed #37, --help should not display first (#447)
+ * Fix translation errors. (#570)
+ * Add package-lock.json
+ * Remove engines
+ * Upgrade package version
+ * Prefix events to prevent conflicts between commands and options (#494)
+ * Removing dependency on graceful-readlink
+ * Support setting name in #name function and make it chainable
+ * Add .vscode directory to .gitignore (Visual Studio Code metadata)
+ * Updated link to ruby commander in readme files
+
+2.10.0 / 2017-06-19
+==================
+
+ * Update .travis.yml. drop support for older node.js versions.
+ * Fix require arguments in README.md
+ * On SemVer you do not start from 0.0.1
+ * Add missing semi colon in readme
+ * Add save param to npm install
+ * node v6 travis test
+ * Update Readme_zh-CN.md
+ * Allow literal '--' to be passed-through as an argument
+ * Test subcommand alias help
+ * link build badge to master branch
+ * Support the alias of Git style sub-command
+ * added keyword commander for better search result on npm
+ * Fix Sub-Subcommands
+ * test node.js stable
+ * Fixes TypeError when a command has an option called `--description`
+ * Update README.md to make it beginner friendly and elaborate on the difference between angled and square brackets.
+ * Add chinese Readme file
+
+2.9.0 / 2015-10-13
+==================
+
+ * Add option `isDefault` to set default subcommand #415 @Qix-
+ * Add callback to allow filtering or post-processing of help text #434 @djulien
+ * Fix `undefined` text in help information close #414 #416 @zhiyelee
+
+2.8.1 / 2015-04-22
+==================
+
+ * Back out `support multiline description` Close #396 #397
+
+2.8.0 / 2015-04-07
+==================
+
+ * Add `process.execArg` support, execution args like `--harmony` will be passed to sub-commands #387 @DigitalIO @zhiyelee
+ * Fix bug in Git-style sub-commands #372 @zhiyelee
+ * Allow commands to be hidden from help #383 @tonylukasavage
+ * When git-style sub-commands are in use, yet none are called, display help #382 @claylo
+ * Add ability to specify arguments syntax for top-level command #258 @rrthomas
+ * Support multiline descriptions #208 @zxqfox
+
+2.7.1 / 2015-03-11
+==================
+
+ * Revert #347 (fix collisions when option and first arg have same name) which causes a bug in #367.
+
+2.7.0 / 2015-03-09
+==================
+
+ * Fix git-style bug when installed globally. Close #335 #349 @zhiyelee
+ * Fix collisions when option and first arg have same name. Close #346 #347 @tonylukasavage
+ * Add support for camelCase on `opts()`. Close #353 @nkzawa
+ * Add node.js 0.12 and io.js to travis.yml
+ * Allow RegEx options. #337 @palanik
+ * Fixes exit code when sub-command failing. Close #260 #332 @pirelenito
+ * git-style `bin` files in $PATH make sense. Close #196 #327 @zhiyelee
+
+2.6.0 / 2014-12-30
+==================
+
+ * added `Command#allowUnknownOption` method. Close #138 #318 @doozr @zhiyelee
+ * Add application description to the help msg. Close #112 @dalssoft
+
+2.5.1 / 2014-12-15
+==================
+
+ * fixed two bugs incurred by variadic arguments. Close #291 @Quentin01 #302 @zhiyelee
+
+2.5.0 / 2014-10-24
+==================
+
+ * add support for variadic arguments. Closes #277 @whitlockjc
+
+2.4.0 / 2014-10-17
+==================
+
+ * fixed a bug on executing the coercion function of subcommands option. Closes #270
+ * added `Command.prototype.name` to retrieve command name. Closes #264 #266 @tonylukasavage
+ * added `Command.prototype.opts` to retrieve all the options as a simple object of key-value pairs. Closes #262 @tonylukasavage
+ * fixed a bug on subcommand name. Closes #248 @jonathandelgado
+ * fixed function normalize doesn’t honor option terminator. Closes #216 @abbr
+
+2.3.0 / 2014-07-16
+==================
+
+ * add command alias'. Closes PR #210
+ * fix: Typos. Closes #99
+ * fix: Unused fs module. Closes #217
+
+2.2.0 / 2014-03-29
+==================
+
+ * add passing of previous option value
+ * fix: support subcommands on windows. Closes #142
+ * Now the defaultValue passed as the second argument of the coercion function.
+
+2.1.0 / 2013-11-21
+==================
+
+ * add: allow cflag style option params, unit test, fixes #174
+
+2.0.0 / 2013-07-18
+==================
+
+ * remove input methods (.prompt, .confirm, etc)
+
+1.3.2 / 2013-07-18
+==================
+
+ * add support for sub-commands to co-exist with the original command
+
+1.3.1 / 2013-07-18
+==================
+
+ * add quick .runningCommand hack so you can opt-out of other logic when running a sub command
+
+1.3.0 / 2013-07-09
+==================
+
+ * add EACCES error handling
+ * fix sub-command --help
+
+1.2.0 / 2013-06-13
+==================
+
+ * allow "-" hyphen as an option argument
+ * support for RegExp coercion
+
+1.1.1 / 2012-11-20
+==================
+
+ * add more sub-command padding
+ * fix .usage() when args are present. Closes #106
+
+1.1.0 / 2012-11-16
+==================
+
+ * add git-style executable subcommand support. Closes #94
+
+1.0.5 / 2012-10-09
+==================
+
+ * fix `--name` clobbering. Closes #92
+ * fix examples/help. Closes #89
+
+1.0.4 / 2012-09-03
+==================
+
+ * add `outputHelp()` method.
+
+1.0.3 / 2012-08-30
+==================
+
+ * remove invalid .version() defaulting
+
+1.0.2 / 2012-08-24
+==================
+
+ * add `--foo=bar` support [arv]
+ * fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus]
+
+1.0.1 / 2012-08-03
+==================
+
+ * fix issue #56
+ * fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())
+
+1.0.0 / 2012-07-05
+==================
+
+ * add support for optional option descriptions
+ * add defaulting of `.version()` to package.json's version
+
+0.6.1 / 2012-06-01
+==================
+
+ * Added: append (yes or no) on confirmation
+ * Added: allow node.js v0.7.x
+
+0.6.0 / 2012-04-10
+==================
+
+ * Added `.prompt(obj, callback)` support. Closes #49
+ * Added default support to .choose(). Closes #41
+ * Fixed the choice example
+
+0.5.1 / 2011-12-20
+==================
+
+ * Fixed `password()` for recent nodes. Closes #36
+
+0.5.0 / 2011-12-04
+==================
+
+ * Added sub-command option support [itay]
+
+0.4.3 / 2011-12-04
+==================
+
+ * Fixed custom help ordering. Closes #32
+
+0.4.2 / 2011-11-24
+==================
+
+ * Added travis support
+ * Fixed: line-buffered input automatically trimmed. Closes #31
+
+0.4.1 / 2011-11-18
+==================
+
+ * Removed listening for "close" on --help
+
+0.4.0 / 2011-11-15
+==================
+
+ * Added support for `--`. Closes #24
+
+0.3.3 / 2011-11-14
+==================
+
+ * Fixed: wait for close event when writing help info [Jerry Hamlet]
+
+0.3.2 / 2011-11-01
+==================
+
+ * Fixed long flag definitions with values [felixge]
+
+0.3.1 / 2011-10-31
+==================
+
+ * Changed `--version` short flag to `-V` from `-v`
+ * Changed `.version()` so it's configurable [felixge]
+
+0.3.0 / 2011-10-31
+==================
+
+ * Added support for long flags only. Closes #18
+
+0.2.1 / 2011-10-24
+==================
+
+ * "node": ">= 0.4.x < 0.7.0". Closes #20
+
+0.2.0 / 2011-09-26
+==================
+
+ * Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]
+
+0.1.0 / 2011-08-24
+==================
+
+ * Added support for custom `--help` output
+
+0.0.5 / 2011-08-18
+==================
+
+ * Changed: when the user enters nothing prompt for password again
+ * Fixed issue with passwords beginning with numbers [NuckChorris]
+
+0.0.4 / 2011-08-15
+==================
+
+ * Fixed `Commander#args`
+
+0.0.3 / 2011-08-15
+==================
+
+ * Added default option value support
+
+0.0.2 / 2011-08-15
+==================
+
+ * Added mask support to `Command#password(str[, mask], fn)`
+ * Added `Command#password(str, fn)`
+
+0.0.1 / 2010-01-03
+==================
+
+ * Initial release
diff --git a/node_modules/tslint/node_modules/commander/LICENSE b/node_modules/tslint/node_modules/commander/LICENSE
new file mode 100644
index 000000000..10f997ab1
--- /dev/null
+++ b/node_modules/tslint/node_modules/commander/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/tslint/node_modules/commander/Readme.md b/node_modules/tslint/node_modules/commander/Readme.md
new file mode 100644
index 000000000..acd31c616
--- /dev/null
+++ b/node_modules/tslint/node_modules/commander/Readme.md
@@ -0,0 +1,370 @@
+# Commander.js
+
+
+[![Build Status](https://api.travis-ci.org/tj/commander.js.svg?branch=master)](http://travis-ci.org/tj/commander.js)
+[![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
+[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
+[![Join the chat at https://gitter.im/tj/commander.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
+ The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/commander-rb/commander).
+ [API documentation](http://tj.github.com/commander.js/)
+
+
+## Installation
+
+ $ npm install commander --save
+
+## Option parsing
+
+ Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.
+
+```js
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var program = require('commander');
+
+program
+ .version('0.1.0')
+ .option('-p, --peppers', 'Add peppers')
+ .option('-P, --pineapple', 'Add pineapple')
+ .option('-b, --bbq-sauce', 'Add bbq sauce')
+ .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
+ .parse(process.argv);
+
+console.log('you ordered a pizza with:');
+if (program.peppers) console.log(' - peppers');
+if (program.pineapple) console.log(' - pineapple');
+if (program.bbqSauce) console.log(' - bbq');
+console.log(' - %s cheese', program.cheese);
+```
+
+ Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc.
+
+Note that multi-word options starting with `--no` prefix negate the boolean value of the following word. For example, `--no-sauce` sets the value of `program.sauce` to false.
+
+```js
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var program = require('commander');
+
+program
+ .option('--no-sauce', 'Remove sauce')
+ .parse(process.argv);
+
+console.log('you ordered a pizza');
+if (program.sauce) console.log(' with sauce');
+else console.log(' without sauce');
+```
+
+## Coercion
+
+```js
+function range(val) {
+ return val.split('..').map(Number);
+}
+
+function list(val) {
+ return val.split(',');
+}
+
+function collect(val, memo) {
+ memo.push(val);
+ return memo;
+}
+
+function increaseVerbosity(v, total) {
+ return total + 1;
+}
+
+program
+ .version('0.1.0')
+ .usage('[options] <file ...>')
+ .option('-i, --integer <n>', 'An integer argument', parseInt)
+ .option('-f, --float <n>', 'A float argument', parseFloat)
+ .option('-r, --range <a>..<b>', 'A range', range)
+ .option('-l, --list <items>', 'A list', list)
+ .option('-o, --optional [value]', 'An optional value')
+ .option('-c, --collect [value]', 'A repeatable value', collect, [])
+ .option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
+ .parse(process.argv);
+
+console.log(' int: %j', program.integer);
+console.log(' float: %j', program.float);
+console.log(' optional: %j', program.optional);
+program.range = program.range || [];
+console.log(' range: %j..%j', program.range[0], program.range[1]);
+console.log(' list: %j', program.list);
+console.log(' collect: %j', program.collect);
+console.log(' verbosity: %j', program.verbose);
+console.log(' args: %j', program.args);
+```
+
+## Regular Expression
+```js
+program
+ .version('0.1.0')
+ .option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')
+ .option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)
+ .parse(process.argv);
+
+console.log(' size: %j', program.size);
+console.log(' drink: %j', program.drink);
+```
+
+## Variadic arguments
+
+ The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to
+ append `...` to the argument name. Here is an example:
+
+```js
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var program = require('commander');
+
+program
+ .version('0.1.0')
+ .command('rmdir <dir> [otherDirs...]')
+ .action(function (dir, otherDirs) {
+ console.log('rmdir %s', dir);
+ if (otherDirs) {
+ otherDirs.forEach(function (oDir) {
+ console.log('rmdir %s', oDir);
+ });
+ }
+ });
+
+program.parse(process.argv);
+```
+
+ An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed
+ to your action as demonstrated above.
+
+## Specify the argument syntax
+
+```js
+#!/usr/bin/env node
+
+var program = require('commander');
+
+program
+ .version('0.1.0')
+ .arguments('<cmd> [env]')
+ .action(function (cmd, env) {
+ cmdValue = cmd;
+ envValue = env;
+ });
+
+program.parse(process.argv);
+
+if (typeof cmdValue === 'undefined') {
+ console.error('no command given!');
+ process.exit(1);
+}
+console.log('command:', cmdValue);
+console.log('environment:', envValue || "no environment given");
+```
+Angled brackets (e.g. `<cmd>`) indicate required input. Square brackets (e.g. `[env]`) indicate optional input.
+
+## Git-style sub-commands
+
+```js
+// file: ./examples/pm
+var program = require('commander');
+
+program
+ .version('0.1.0')
+ .command('install [name]', 'install one or more packages')
+ .command('search [query]', 'search with optional query')
+ .command('list', 'list packages installed', {isDefault: true})
+ .parse(process.argv);
+```
+
+When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
+The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.
+
+Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the option from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified.
+
+If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
+
+### `--harmony`
+
+You can enable `--harmony` option in two ways:
+* Use `#! /usr/bin/env node --harmony` in the sub-commands scripts. Note some os version don’t support this pattern.
+* Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning sub-command process.
+
+## Automated --help
+
+ The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:
+
+```
+ $ ./examples/pizza --help
+
+ Usage: pizza [options]
+
+ An application for pizzas ordering
+
+ Options:
+
+ -h, --help output usage information
+ -V, --version output the version number
+ -p, --peppers Add peppers
+ -P, --pineapple Add pineapple
+ -b, --bbq Add bbq sauce
+ -c, --cheese <type> Add the specified type of cheese [marble]
+ -C, --no-cheese You do not want any cheese
+
+```
+
+## Custom help
+
+ You can display arbitrary `-h, --help` information
+ by listening for "--help". Commander will automatically
+ exit once you are done so that the remainder of your program
+ does not execute causing undesired behaviours, for example
+ in the following executable "stuff" will not output when
+ `--help` is used.
+
+```js
+#!/usr/bin/env node
+
+/**
+ * Module dependencies.
+ */
+
+var program = require('commander');
+
+program
+ .version('0.1.0')
+ .option('-f, --foo', 'enable some foo')
+ .option('-b, --bar', 'enable some bar')
+ .option('-B, --baz', 'enable some baz');
+
+// must be before .parse() since
+// node's emit() is immediate
+
+program.on('--help', function(){
+ console.log(' Examples:');
+ console.log('');
+ console.log(' $ custom-help --help');
+ console.log(' $ custom-help -h');
+ console.log('');
+});
+
+program.parse(process.argv);
+
+console.log('stuff');
+```
+
+Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:
+
+```
+
+Usage: custom-help [options]
+
+Options:
+
+ -h, --help output usage information
+ -V, --version output the version number
+ -f, --foo enable some foo
+ -b, --bar enable some bar
+ -B, --baz enable some baz
+
+Examples:
+
+ $ custom-help --help
+ $ custom-help -h
+
+```
+
+## .outputHelp(cb)
+
+Output help information without exiting.
+Optional callback cb allows post-processing of help text before it is displayed.
+
+If you want to display help by default (e.g. if no command was provided), you can use something like:
+
+```js
+var program = require('commander');
+var colors = require('colors');
+
+program
+ .version('0.1.0')
+ .command('getstream [url]', 'get stream URL')
+ .parse(process.argv);
+
+if (!process.argv.slice(2).length) {
+ program.outputHelp(make_red);
+}
+
+function make_red(txt) {
+ return colors.red(txt); //display the help text in red on the console
+}
+```
+
+## .help(cb)
+
+ Output help information and exit immediately.
+ Optional callback cb allows post-processing of help text before it is displayed.
+
+## Examples
+
+```js
+var program = require('commander');
+
+program
+ .version('0.1.0')
+ .option('-C, --chdir <path>', 'change the working directory')
+ .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
+ .option('-T, --no-tests', 'ignore test hook');
+
+program
+ .command('setup [env]')
+ .description('run setup commands for all envs')
+ .option("-s, --setup_mode [mode]", "Which setup mode to use")
+ .action(function(env, options){
+ var mode = options.setup_mode || "normal";
+ env = env || 'all';
+ console.log('setup for %s env(s) with %s mode', env, mode);
+ });
+
+program
+ .command('exec <cmd>')
+ .alias('ex')
+ .description('execute the given remote cmd')
+ .option("-e, --exec_mode <mode>", "Which exec mode to use")
+ .action(function(cmd, options){
+ console.log('exec "%s" using %s mode', cmd, options.exec_mode);
+ }).on('--help', function() {
+ console.log(' Examples:');
+ console.log();
+ console.log(' $ deploy exec sequential');
+ console.log(' $ deploy exec async');
+ console.log();
+ });
+
+program
+ .command('*')
+ .action(function(env){
+ console.log('deploying "%s"', env);
+ });
+
+program.parse(process.argv);
+```
+
+More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
+
+## License
+
+MIT
diff --git a/node_modules/tslint/node_modules/commander/index.js b/node_modules/tslint/node_modules/commander/index.js
new file mode 100644
index 000000000..cb82f55b9
--- /dev/null
+++ b/node_modules/tslint/node_modules/commander/index.js
@@ -0,0 +1,1158 @@
+/**
+ * Module dependencies.
+ */
+
+var EventEmitter = require('events').EventEmitter;
+var spawn = require('child_process').spawn;
+var path = require('path');
+var dirname = path.dirname;
+var basename = path.basename;
+var fs = require('fs');
+
+/**
+ * Expose the root command.
+ */
+
+exports = module.exports = new Command();
+
+/**
+ * Expose `Command`.
+ */
+
+exports.Command = Command;
+
+/**
+ * Expose `Option`.
+ */
+
+exports.Option = Option;
+
+/**
+ * Initialize a new `Option` with the given `flags` and `description`.
+ *
+ * @param {String} flags
+ * @param {String} description
+ * @api public
+ */
+
+function Option(flags, description) {
+ this.flags = flags;
+ this.required = ~flags.indexOf('<');
+ this.optional = ~flags.indexOf('[');
+ this.bool = !~flags.indexOf('-no-');
+ flags = flags.split(/[ ,|]+/);
+ if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
+ this.long = flags.shift();
+ this.description = description || '';
+}
+
+/**
+ * Return option name.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Option.prototype.name = function() {
+ return this.long
+ .replace('--', '')
+ .replace('no-', '');
+};
+
+/**
+ * Return option name, in a camelcase format that can be used
+ * as a object attribute key.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Option.prototype.attributeName = function() {
+ return camelcase( this.name() );
+};
+
+/**
+ * Check if `arg` matches the short or long flag.
+ *
+ * @param {String} arg
+ * @return {Boolean}
+ * @api private
+ */
+
+Option.prototype.is = function(arg) {
+ return arg == this.short || arg == this.long;
+};
+
+/**
+ * Initialize a new `Command`.
+ *
+ * @param {String} name
+ * @api public
+ */
+
+function Command(name) {
+ this.commands = [];
+ this.options = [];
+ this._execs = {};
+ this._allowUnknownOption = false;
+ this._args = [];
+ this._name = name || '';
+}
+
+/**
+ * Inherit from `EventEmitter.prototype`.
+ */
+
+Command.prototype.__proto__ = EventEmitter.prototype;
+
+/**
+ * Add command `name`.
+ *
+ * The `.action()` callback is invoked when the
+ * command `name` is specified via __ARGV__,
+ * and the remaining arguments are applied to the
+ * function for access.
+ *
+ * When the `name` is "*" an un-matched command
+ * will be passed as the first arg, followed by
+ * the rest of __ARGV__ remaining.
+ *
+ * Examples:
+ *
+ * program
+ * .version('0.0.1')
+ * .option('-C, --chdir <path>', 'change the working directory')
+ * .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
+ * .option('-T, --no-tests', 'ignore test hook')
+ *
+ * program
+ * .command('setup')
+ * .description('run remote setup commands')
+ * .action(function() {
+ * console.log('setup');
+ * });
+ *
+ * program
+ * .command('exec <cmd>')
+ * .description('run the given remote command')
+ * .action(function(cmd) {
+ * console.log('exec "%s"', cmd);
+ * });
+ *
+ * program
+ * .command('teardown <dir> [otherDirs...]')
+ * .description('run teardown commands')
+ * .action(function(dir, otherDirs) {
+ * console.log('dir "%s"', dir);
+ * if (otherDirs) {
+ * otherDirs.forEach(function (oDir) {
+ * console.log('dir "%s"', oDir);
+ * });
+ * }
+ * });
+ *
+ * program
+ * .command('*')
+ * .description('deploy the given env')
+ * .action(function(env) {
+ * console.log('deploying "%s"', env);
+ * });
+ *
+ * program.parse(process.argv);
+ *
+ * @param {String} name
+ * @param {String} [desc] for git-style sub-commands
+ * @return {Command} the new command
+ * @api public
+ */
+
+Command.prototype.command = function(name, desc, opts) {
+ if(typeof desc === 'object' && desc !== null){
+ opts = desc;
+ desc = null;
+ }
+ opts = opts || {};
+ var args = name.split(/ +/);
+ var cmd = new Command(args.shift());
+
+ if (desc) {
+ cmd.description(desc);
+ this.executables = true;
+ this._execs[cmd._name] = true;
+ if (opts.isDefault) this.defaultExecutable = cmd._name;
+ }
+ cmd._noHelp = !!opts.noHelp;
+ this.commands.push(cmd);
+ cmd.parseExpectedArgs(args);
+ cmd.parent = this;
+
+ if (desc) return this;
+ return cmd;
+};
+
+/**
+ * Define argument syntax for the top-level command.
+ *
+ * @api public
+ */
+
+Command.prototype.arguments = function (desc) {
+ return this.parseExpectedArgs(desc.split(/ +/));
+};
+
+/**
+ * Add an implicit `help [cmd]` subcommand
+ * which invokes `--help` for the given command.
+ *
+ * @api private
+ */
+
+Command.prototype.addImplicitHelpCommand = function() {
+ this.command('help [cmd]', 'display help for [cmd]');
+};
+
+/**
+ * Parse expected `args`.
+ *
+ * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
+ *
+ * @param {Array} args
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.parseExpectedArgs = function(args) {
+ if (!args.length) return;
+ var self = this;
+ args.forEach(function(arg) {
+ var argDetails = {
+ required: false,
+ name: '',
+ variadic: false
+ };
+
+ switch (arg[0]) {
+ case '<':
+ argDetails.required = true;
+ argDetails.name = arg.slice(1, -1);
+ break;
+ case '[':
+ argDetails.name = arg.slice(1, -1);
+ break;
+ }
+
+ if (argDetails.name.length > 3 && argDetails.name.slice(-3) === '...') {
+ argDetails.variadic = true;
+ argDetails.name = argDetails.name.slice(0, -3);
+ }
+ if (argDetails.name) {
+ self._args.push(argDetails);
+ }
+ });
+ return this;
+};
+
+/**
+ * Register callback `fn` for the command.
+ *
+ * Examples:
+ *
+ * program
+ * .command('help')
+ * .description('display verbose help')
+ * .action(function() {
+ * // output help here
+ * });
+ *
+ * @param {Function} fn
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.action = function(fn) {
+ var self = this;
+ var listener = function(args, unknown) {
+ // Parse any so-far unknown options
+ args = args || [];
+ unknown = unknown || [];
+
+ var parsed = self.parseOptions(unknown);
+
+ // Output help if necessary
+ outputHelpIfNecessary(self, parsed.unknown);
+
+ // If there are still any unknown options, then we simply
+ // die, unless someone asked for help, in which case we give it
+ // to them, and then we die.
+ if (parsed.unknown.length > 0) {
+ self.unknownOption(parsed.unknown[0]);
+ }
+
+ // Leftover arguments need to be pushed back. Fixes issue #56
+ if (parsed.args.length) args = parsed.args.concat(args);
+
+ self._args.forEach(function(arg, i) {
+ if (arg.required && null == args[i]) {
+ self.missingArgument(arg.name);
+ } else if (arg.variadic) {
+ if (i !== self._args.length - 1) {
+ self.variadicArgNotLast(arg.name);
+ }
+
+ args[i] = args.splice(i);
+ }
+ });
+
+ // Always append ourselves to the end of the arguments,
+ // to make sure we match the number of arguments the user
+ // expects
+ if (self._args.length) {
+ args[self._args.length] = self;
+ } else {
+ args.push(self);
+ }
+
+ fn.apply(self, args);
+ };
+ var parent = this.parent || this;
+ var name = parent === this ? '*' : this._name;
+ parent.on('command:' + name, listener);
+ if (this._alias) parent.on('command:' + this._alias, listener);
+ return this;
+};
+
+/**
+ * Define option with `flags`, `description` and optional
+ * coercion `fn`.
+ *
+ * The `flags` string should contain both the short and long flags,
+ * separated by comma, a pipe or space. The following are all valid
+ * all will output this way when `--help` is used.
+ *
+ * "-p, --pepper"
+ * "-p|--pepper"
+ * "-p --pepper"
+ *
+ * Examples:
+ *
+ * // simple boolean defaulting to false
+ * program.option('-p, --pepper', 'add pepper');
+ *
+ * --pepper
+ * program.pepper
+ * // => Boolean
+ *
+ * // simple boolean defaulting to true
+ * program.option('-C, --no-cheese', 'remove cheese');
+ *
+ * program.cheese
+ * // => true
+ *
+ * --no-cheese
+ * program.cheese
+ * // => false
+ *
+ * // required argument
+ * program.option('-C, --chdir <path>', 'change the working directory');
+ *
+ * --chdir /tmp
+ * program.chdir
+ * // => "/tmp"
+ *
+ * // optional argument
+ * program.option('-c, --cheese [type]', 'add cheese [marble]');
+ *
+ * @param {String} flags
+ * @param {String} description
+ * @param {Function|*} [fn] or default
+ * @param {*} [defaultValue]
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.option = function(flags, description, fn, defaultValue) {
+ var self = this
+ , option = new Option(flags, description)
+ , oname = option.name()
+ , name = option.attributeName();
+
+ // default as 3rd arg
+ if (typeof fn != 'function') {
+ if (fn instanceof RegExp) {
+ var regex = fn;
+ fn = function(val, def) {
+ var m = regex.exec(val);
+ return m ? m[0] : def;
+ }
+ }
+ else {
+ defaultValue = fn;
+ fn = null;
+ }
+ }
+
+ // preassign default value only for --no-*, [optional], or <required>
+ if (false == option.bool || option.optional || option.required) {
+ // when --no-* we make sure default is true
+ if (false == option.bool) defaultValue = true;
+ // preassign only if we have a default
+ if (undefined !== defaultValue) {
+ self[name] = defaultValue;
+ option.defaultValue = defaultValue;
+ }
+ }
+
+ // register the option
+ this.options.push(option);
+
+ // when it's passed assign the value
+ // and conditionally invoke the callback
+ this.on('option:' + oname, function(val) {
+ // coercion
+ if (null !== val && fn) val = fn(val, undefined === self[name]
+ ? defaultValue
+ : self[name]);
+
+ // unassigned or bool
+ if ('boolean' == typeof self[name] || 'undefined' == typeof self[name]) {
+ // if no value, bool true, and we have a default, then use it!
+ if (null == val) {
+ self[name] = option.bool
+ ? defaultValue || true
+ : false;
+ } else {
+ self[name] = val;
+ }
+ } else if (null !== val) {
+ // reassign
+ self[name] = val;
+ }
+ });
+
+ return this;
+};
+
+/**
+ * Allow unknown options on the command line.
+ *
+ * @param {Boolean} arg if `true` or omitted, no error will be thrown
+ * for unknown options.
+ * @api public
+ */
+Command.prototype.allowUnknownOption = function(arg) {
+ this._allowUnknownOption = arguments.length === 0 || arg;
+ return this;
+};
+
+/**
+ * Parse `argv`, settings options and invoking commands when defined.
+ *
+ * @param {Array} argv
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.parse = function(argv) {
+ // implicit help
+ if (this.executables) this.addImplicitHelpCommand();
+
+ // store raw args
+ this.rawArgs = argv;
+
+ // guess name
+ this._name = this._name || basename(argv[1], '.js');
+
+ // github-style sub-commands with no sub-command
+ if (this.executables && argv.length < 3 && !this.defaultExecutable) {
+ // this user needs help
+ argv.push('--help');
+ }
+
+ // process argv
+ var parsed = this.parseOptions(this.normalize(argv.slice(2)));
+ var args = this.args = parsed.args;
+
+ var result = this.parseArgs(this.args, parsed.unknown);
+
+ // executable sub-commands
+ var name = result.args[0];
+
+ var aliasCommand = null;
+ // check alias of sub commands
+ if (name) {
+ aliasCommand = this.commands.filter(function(command) {
+ return command.alias() === name;
+ })[0];
+ }
+
+ if (this._execs[name] && typeof this._execs[name] != "function") {
+ return this.executeSubCommand(argv, args, parsed.unknown);
+ } else if (aliasCommand) {
+ // is alias of a subCommand
+ args[0] = aliasCommand._name;
+ return this.executeSubCommand(argv, args, parsed.unknown);
+ } else if (this.defaultExecutable) {
+ // use the default subcommand
+ args.unshift(this.defaultExecutable);
+ return this.executeSubCommand(argv, args, parsed.unknown);
+ }
+
+ return result;
+};
+
+/**
+ * Execute a sub-command executable.
+ *
+ * @param {Array} argv
+ * @param {Array} args
+ * @param {Array} unknown
+ * @api private
+ */
+
+Command.prototype.executeSubCommand = function(argv, args, unknown) {
+ args = args.concat(unknown);
+
+ if (!args.length) this.help();
+ if ('help' == args[0] && 1 == args.length) this.help();
+
+ // <cmd> --help
+ if ('help' == args[0]) {
+ args[0] = args[1];
+ args[1] = '--help';
+ }
+
+ // executable
+ var f = argv[1];
+ // name of the subcommand, link `pm-install`
+ var bin = basename(f, '.js') + '-' + args[0];
+
+
+ // In case of globally installed, get the base dir where executable
+ // subcommand file should be located at
+ var baseDir
+ , link = fs.lstatSync(f).isSymbolicLink() ? fs.readlinkSync(f) : f;
+
+ // when symbolink is relative path
+ if (link !== f && link.charAt(0) !== '/') {
+ link = path.join(dirname(f), link)
+ }
+ baseDir = dirname(link);
+
+ // prefer local `./<bin>` to bin in the $PATH
+ var localBin = path.join(baseDir, bin);
+
+ // whether bin file is a js script with explicit `.js` extension
+ var isExplicitJS = false;
+ if (exists(localBin + '.js')) {
+ bin = localBin + '.js';
+ isExplicitJS = true;
+ } else if (exists(localBin)) {
+ bin = localBin;
+ }
+
+ args = args.slice(1);
+
+ var proc;
+ if (process.platform !== 'win32') {
+ if (isExplicitJS) {
+ args.unshift(bin);
+ // add executable arguments to spawn
+ args = (process.execArgv || []).concat(args);
+
+ proc = spawn(process.argv[0], args, { stdio: 'inherit', customFds: [0, 1, 2] });
+ } else {
+ proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
+ }
+ } else {
+ args.unshift(bin);
+ proc = spawn(process.execPath, args, { stdio: 'inherit'});
+ }
+
+ var signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];
+ signals.forEach(function(signal) {
+ process.on(signal, function(){
+ if ((proc.killed === false) && (proc.exitCode === null)){
+ proc.kill(signal);
+ }
+ });
+ });
+ proc.on('close', process.exit.bind(process));
+ proc.on('error', function(err) {
+ if (err.code == "ENOENT") {
+ console.error('\n %s(1) does not exist, try --help\n', bin);
+ } else if (err.code == "EACCES") {
+ console.error('\n %s(1) not executable. try chmod or run with root\n', bin);
+ }
+ process.exit(1);
+ });
+
+ // Store the reference to the child process
+ this.runningCommand = proc;
+};
+
+/**
+ * Normalize `args`, splitting joined short flags. For example
+ * the arg "-abc" is equivalent to "-a -b -c".
+ * This also normalizes equal sign and splits "--abc=def" into "--abc def".
+ *
+ * @param {Array} args
+ * @return {Array}
+ * @api private
+ */
+
+Command.prototype.normalize = function(args) {
+ var ret = []
+ , arg
+ , lastOpt
+ , index;
+
+ for (var i = 0, len = args.length; i < len; ++i) {
+ arg = args[i];
+ if (i > 0) {
+ lastOpt = this.optionFor(args[i-1]);
+ }
+
+ if (arg === '--') {
+ // Honor option terminator
+ ret = ret.concat(args.slice(i));
+ break;
+ } else if (lastOpt && lastOpt.required) {
+ ret.push(arg);
+ } else if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) {
+ arg.slice(1).split('').forEach(function(c) {
+ ret.push('-' + c);
+ });
+ } else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) {
+ ret.push(arg.slice(0, index), arg.slice(index + 1));
+ } else {
+ ret.push(arg);
+ }
+ }
+
+ return ret;
+};
+
+/**
+ * Parse command `args`.
+ *
+ * When listener(s) are available those
+ * callbacks are invoked, otherwise the "*"
+ * event is emitted and those actions are invoked.
+ *
+ * @param {Array} args
+ * @return {Command} for chaining
+ * @api private
+ */
+
+Command.prototype.parseArgs = function(args, unknown) {
+ var name;
+
+ if (args.length) {
+ name = args[0];
+ if (this.listeners('command:' + name).length) {
+ this.emit('command:' + args.shift(), args, unknown);
+ } else {
+ this.emit('command:*', args);
+ }
+ } else {
+ outputHelpIfNecessary(this, unknown);
+
+ // If there were no args and we have unknown options,
+ // then they are extraneous and we need to error.
+ if (unknown.length > 0) {
+ this.unknownOption(unknown[0]);
+ }
+ }
+
+ return this;
+};
+
+/**
+ * Return an option matching `arg` if any.
+ *
+ * @param {String} arg
+ * @return {Option}
+ * @api private
+ */
+
+Command.prototype.optionFor = function(arg) {
+ for (var i = 0, len = this.options.length; i < len; ++i) {
+ if (this.options[i].is(arg)) {
+ return this.options[i];
+ }
+ }
+};
+
+/**
+ * Parse options from `argv` returning `argv`
+ * void of these options.
+ *
+ * @param {Array} argv
+ * @return {Array}
+ * @api public
+ */
+
+Command.prototype.parseOptions = function(argv) {
+ var args = []
+ , len = argv.length
+ , literal
+ , option
+ , arg;
+
+ var unknownOptions = [];
+
+ // parse options
+ for (var i = 0; i < len; ++i) {
+ arg = argv[i];
+
+ // literal args after --
+ if (literal) {
+ args.push(arg);
+ continue;
+ }
+
+ if ('--' == arg) {
+ literal = true;
+ continue;
+ }
+
+ // find matching Option
+ option = this.optionFor(arg);
+
+ // option is defined
+ if (option) {
+ // requires arg
+ if (option.required) {
+ arg = argv[++i];
+ if (null == arg) return this.optionMissingArgument(option);
+ this.emit('option:' + option.name(), arg);
+ // optional arg
+ } else if (option.optional) {
+ arg = argv[i+1];
+ if (null == arg || ('-' == arg[0] && '-' != arg)) {
+ arg = null;
+ } else {
+ ++i;
+ }
+ this.emit('option:' + option.name(), arg);
+ // bool
+ } else {
+ this.emit('option:' + option.name());
+ }
+ continue;
+ }
+
+ // looks like an option
+ if (arg.length > 1 && '-' == arg[0]) {
+ unknownOptions.push(arg);
+
+ // If the next argument looks like it might be
+ // an argument for this option, we pass it on.
+ // If it isn't, then it'll simply be ignored
+ if (argv[i+1] && '-' != argv[i+1][0]) {
+ unknownOptions.push(argv[++i]);
+ }
+ continue;
+ }
+
+ // arg
+ args.push(arg);
+ }
+
+ return { args: args, unknown: unknownOptions };
+};
+
+/**
+ * Return an object containing options as key-value pairs
+ *
+ * @return {Object}
+ * @api public
+ */
+Command.prototype.opts = function() {
+ var result = {}
+ , len = this.options.length;
+
+ for (var i = 0 ; i < len; i++) {
+ var key = this.options[i].attributeName();
+ result[key] = key === 'version' ? this._version : this[key];
+ }
+ return result;
+};
+
+/**
+ * Argument `name` is missing.
+ *
+ * @param {String} name
+ * @api private
+ */
+
+Command.prototype.missingArgument = function(name) {
+ console.error();
+ console.error(" error: missing required argument `%s'", name);
+ console.error();
+ process.exit(1);
+};
+
+/**
+ * `Option` is missing an argument, but received `flag` or nothing.
+ *
+ * @param {String} option
+ * @param {String} flag
+ * @api private
+ */
+
+Command.prototype.optionMissingArgument = function(option, flag) {
+ console.error();
+ if (flag) {
+ console.error(" error: option `%s' argument missing, got `%s'", option.flags, flag);
+ } else {
+ console.error(" error: option `%s' argument missing", option.flags);
+ }
+ console.error();
+ process.exit(1);
+};
+
+/**
+ * Unknown option `flag`.
+ *
+ * @param {String} flag
+ * @api private
+ */
+
+Command.prototype.unknownOption = function(flag) {
+ if (this._allowUnknownOption) return;
+ console.error();
+ console.error(" error: unknown option `%s'", flag);
+ console.error();
+ process.exit(1);
+};
+
+/**
+ * Variadic argument with `name` is not the last argument as required.
+ *
+ * @param {String} name
+ * @api private
+ */
+
+Command.prototype.variadicArgNotLast = function(name) {
+ console.error();
+ console.error(" error: variadic arguments must be last `%s'", name);
+ console.error();
+ process.exit(1);
+};
+
+/**
+ * Set the program version to `str`.
+ *
+ * This method auto-registers the "-V, --version" flag
+ * which will print the version number when passed.
+ *
+ * @param {String} str
+ * @param {String} [flags]
+ * @return {Command} for chaining
+ * @api public
+ */
+
+Command.prototype.version = function(str, flags) {
+ if (0 == arguments.length) return this._version;
+ this._version = str;
+ flags = flags || '-V, --version';
+ this.option(flags, 'output the version number');
+ this.on('option:version', function() {
+ process.stdout.write(str + '\n');
+ process.exit(0);
+ });
+ return this;
+};
+
+/**
+ * Set the description to `str`.
+ *
+ * @param {String} str
+ * @return {String|Command}
+ * @api public
+ */
+
+Command.prototype.description = function(str) {
+ if (0 === arguments.length) return this._description;
+ this._description = str;
+ return this;
+};
+
+/**
+ * Set an alias for the command
+ *
+ * @param {String} alias
+ * @return {String|Command}
+ * @api public
+ */
+
+Command.prototype.alias = function(alias) {
+ var command = this;
+ if(this.commands.length !== 0) {
+ command = this.commands[this.commands.length - 1]
+ }
+
+ if (arguments.length === 0) return command._alias;
+
+ if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');
+
+ command._alias = alias;
+ return this;
+};
+
+/**
+ * Set / get the command usage `str`.
+ *
+ * @param {String} str
+ * @return {String|Command}
+ * @api public
+ */
+
+Command.prototype.usage = function(str) {
+ var args = this._args.map(function(arg) {
+ return humanReadableArgName(arg);
+ });
+
+ var usage = '[options]'
+ + (this.commands.length ? ' [command]' : '')
+ + (this._args.length ? ' ' + args.join(' ') : '');
+
+ if (0 == arguments.length) return this._usage || usage;
+ this._usage = str;
+
+ return this;
+};
+
+/**
+ * Get or set the name of the command
+ *
+ * @param {String} str
+ * @return {String|Command}
+ * @api public
+ */
+
+Command.prototype.name = function(str) {
+ if (0 === arguments.length) return this._name;
+ this._name = str;
+ return this;
+};
+
+/**
+ * Return the largest option length.
+ *
+ * @return {Number}
+ * @api private
+ */
+
+Command.prototype.largestOptionLength = function() {
+ return this.options.reduce(function(max, option) {
+ return Math.max(max, option.flags.length);
+ }, 0);
+};
+
+/**
+ * Return help for options.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Command.prototype.optionHelp = function() {
+ var width = this.largestOptionLength();
+
+ // Append the help information
+ return this.options.map(function(option) {
+ return pad(option.flags, width) + ' ' + option.description
+ + (option.defaultValue !== undefined ? ' (default: ' + option.defaultValue + ')' : '');
+ }).concat([pad('-h, --help', width) + ' ' + 'output usage information'])
+ .join('\n');
+};
+
+/**
+ * Return command help documentation.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Command.prototype.commandHelp = function() {
+ if (!this.commands.length) return '';
+
+ var commands = this.commands.filter(function(cmd) {
+ return !cmd._noHelp;
+ }).map(function(cmd) {
+ var args = cmd._args.map(function(arg) {
+ return humanReadableArgName(arg);
+ }).join(' ');
+
+ return [
+ cmd._name
+ + (cmd._alias ? '|' + cmd._alias : '')
+ + (cmd.options.length ? ' [options]' : '')
+ + ' ' + args
+ , cmd._description
+ ];
+ });
+
+ var width = commands.reduce(function(max, command) {
+ return Math.max(max, command[0].length);
+ }, 0);
+
+ return [
+ ''
+ , ' Commands:'
+ , ''
+ , commands.map(function(cmd) {
+ var desc = cmd[1] ? ' ' + cmd[1] : '';
+ return pad(cmd[0], width) + desc;
+ }).join('\n').replace(/^/gm, ' ')
+ , ''
+ ].join('\n');
+};
+
+/**
+ * Return program help documentation.
+ *
+ * @return {String}
+ * @api private
+ */
+
+Command.prototype.helpInformation = function() {
+ var desc = [];
+ if (this._description) {
+ desc = [
+ ' ' + this._description
+ , ''
+ ];
+ }
+
+ var cmdName = this._name;
+ if (this._alias) {
+ cmdName = cmdName + '|' + this._alias;
+ }
+ var usage = [
+ ''
+ ,' Usage: ' + cmdName + ' ' + this.usage()
+ , ''
+ ];
+
+ var cmds = [];
+ var commandHelp = this.commandHelp();
+ if (commandHelp) cmds = [commandHelp];
+
+ var options = [
+ ''
+ , ' Options:'
+ , ''
+ , '' + this.optionHelp().replace(/^/gm, ' ')
+ , ''
+ ];
+
+ return usage
+ .concat(desc)
+ .concat(options)
+ .concat(cmds)
+ .join('\n');
+};
+
+/**
+ * Output help information for this command
+ *
+ * @api public
+ */
+
+Command.prototype.outputHelp = function(cb) {
+ if (!cb) {
+ cb = function(passthru) {
+ return passthru;
+ }
+ }
+ process.stdout.write(cb(this.helpInformation()));
+ this.emit('--help');
+};
+
+/**
+ * Output help information and exit.
+ *
+ * @api public
+ */
+
+Command.prototype.help = function(cb) {
+ this.outputHelp(cb);
+ process.exit();
+};
+
+/**
+ * Camel-case the given `flag`
+ *
+ * @param {String} flag
+ * @return {String}
+ * @api private
+ */
+
+function camelcase(flag) {
+ return flag.split('-').reduce(function(str, word) {
+ return str + word[0].toUpperCase() + word.slice(1);
+ });
+}
+
+/**
+ * Pad `str` to `width`.
+ *
+ * @param {String} str
+ * @param {Number} width
+ * @return {String}
+ * @api private
+ */
+
+function pad(str, width) {
+ var len = Math.max(0, width - str.length);
+ return str + Array(len + 1).join(' ');
+}
+
+/**
+ * Output help information if necessary
+ *
+ * @param {Command} command to output help for
+ * @param {Array} array of options to search for -h or --help
+ * @api private
+ */
+
+function outputHelpIfNecessary(cmd, options) {
+ options = options || [];
+ for (var i = 0; i < options.length; i++) {
+ if (options[i] == '--help' || options[i] == '-h') {
+ cmd.outputHelp();
+ process.exit(0);
+ }
+ }
+}
+
+/**
+ * Takes an argument an returns its human readable equivalent for help usage.
+ *
+ * @param {Object} arg
+ * @return {String}
+ * @api private
+ */
+
+function humanReadableArgName(arg) {
+ var nameOutput = arg.name + (arg.variadic === true ? '...' : '');
+
+ return arg.required
+ ? '<' + nameOutput + '>'
+ : '[' + nameOutput + ']'
+}
+
+// for versions before node v0.8 when there weren't `fs.existsSync`
+function exists(file) {
+ try {
+ if (fs.statSync(file).isFile()) {
+ return true;
+ }
+ } catch (e) {
+ return false;
+ }
+}
+
diff --git a/node_modules/tslint/node_modules/commander/package.json b/node_modules/tslint/node_modules/commander/package.json
new file mode 100644
index 000000000..04b3c69b5
--- /dev/null
+++ b/node_modules/tslint/node_modules/commander/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "commander",
+ "version": "2.12.2",
+ "description": "the complete solution for node.js command-line programs",
+ "keywords": [
+ "commander",
+ "command",
+ "option",
+ "parser"
+ ],
+ "author": "TJ Holowaychuk <tj@vision-media.ca>",
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/tj/commander.js.git"
+ },
+ "scripts": {
+ "test": "make test && npm run test-typings",
+ "test-typings": "node_modules/typescript/bin/tsc -p tsconfig.json"
+ },
+ "main": "index",
+ "files": [
+ "index.js",
+ "typings/index.d.ts"
+ ],
+ "dependencies": {},
+ "devDependencies": {
+ "@types/node": "^7.0.48",
+ "should": "^11.2.1",
+ "sinon": "^2.4.1",
+ "typescript": "^2.6.2"
+ },
+ "typings": "typings/index.d.ts"
+}
diff --git a/node_modules/tslint/node_modules/commander/typings/index.d.ts b/node_modules/tslint/node_modules/commander/typings/index.d.ts
new file mode 100644
index 000000000..f36f5a7c4
--- /dev/null
+++ b/node_modules/tslint/node_modules/commander/typings/index.d.ts
@@ -0,0 +1,295 @@
+// Project: https://github.com/visionmedia/commander.js
+// Definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>
+
+declare class Option {
+ flags: string;
+ required: boolean;
+ optional: boolean;
+ bool: boolean;
+ short?: string;
+ long: string;
+ description: string;
+
+ /**
+ * Initialize a new `Option` with the given `flags` and `description`.
+ *
+ * @param {string} flags
+ * @param {string} [description]
+ */
+ constructor(flags: string, description?: string);
+}
+
+declare class Command extends NodeJS.EventEmitter {
+ [key: string]: any;
+
+ args: string[];
+
+ /**
+ * Initialize a new `Command`.
+ *
+ * @param {string} [name]
+ */
+ constructor(name?: string);
+
+ /**
+ * Set the program version to `str`.
+ *
+ * This method auto-registers the "-V, --version" flag
+ * which will print the version number when passed.
+ *
+ * @param {string} str
+ * @param {string} [flags]
+ * @returns {Command} for chaining
+ */
+ version(str: string, flags?: string): Command;
+
+ /**
+ * Add command `name`.
+ *
+ * The `.action()` callback is invoked when the
+ * command `name` is specified via __ARGV__,
+ * and the remaining arguments are applied to the
+ * function for access.
+ *
+ * When the `name` is "*" an un-matched command
+ * will be passed as the first arg, followed by
+ * the rest of __ARGV__ remaining.
+ *
+ * @example
+ * program
+ * .version('0.0.1')
+ * .option('-C, --chdir <path>', 'change the working directory')
+ * .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
+ * .option('-T, --no-tests', 'ignore test hook')
+ *
+ * program
+ * .command('setup')
+ * .description('run remote setup commands')
+ * .action(function() {
+ * console.log('setup');
+ * });
+ *
+ * program
+ * .command('exec <cmd>')
+ * .description('run the given remote command')
+ * .action(function(cmd) {
+ * console.log('exec "%s"', cmd);
+ * });
+ *
+ * program
+ * .command('teardown <dir> [otherDirs...]')
+ * .description('run teardown commands')
+ * .action(function(dir, otherDirs) {
+ * console.log('dir "%s"', dir);
+ * if (otherDirs) {
+ * otherDirs.forEach(function (oDir) {
+ * console.log('dir "%s"', oDir);
+ * });
+ * }
+ * });
+ *
+ * program
+ * .command('*')
+ * .description('deploy the given env')
+ * .action(function(env) {
+ * console.log('deploying "%s"', env);
+ * });
+ *
+ * program.parse(process.argv);
+ *
+ * @param {string} name
+ * @param {string} [desc] for git-style sub-commands
+ * @param {CommandOptions} [opts] command options
+ * @returns {Command} the new command
+ */
+ command(name: string, desc?: string, opts?: commander.CommandOptions): Command;
+
+ /**
+ * Define argument syntax for the top-level command.
+ *
+ * @param {string} desc
+ * @returns {Command} for chaining
+ */
+ arguments(desc: string): Command;
+
+ /**
+ * Parse expected `args`.
+ *
+ * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
+ *
+ * @param {string[]} args
+ * @returns {Command} for chaining
+ */
+ parseExpectedArgs(args: string[]): Command;
+ /**
+ * Register callback `fn` for the command.
+ *
+ * @example
+ * program
+ * .command('help')
+ * .description('display verbose help')
+ * .action(function() {
+ * // output help here
+ * });
+ *
+ * @param {(...args: any[]) => void} fn
+ * @returns {Command} for chaining
+ */
+ action(fn: (...args: any[]) => void): Command;
+
+ /**
+ * Define option with `flags`, `description` and optional
+ * coercion `fn`.
+ *
+ * The `flags` string should contain both the short and long flags,
+ * separated by comma, a pipe or space. The following are all valid
+ * all will output this way when `--help` is used.
+ *
+ * "-p, --pepper"
+ * "-p|--pepper"
+ * "-p --pepper"
+ *
+ * @example
+ * // simple boolean defaulting to false
+ * program.option('-p, --pepper', 'add pepper');
+ *
+ * --pepper
+ * program.pepper
+ * // => Boolean
+ *
+ * // simple boolean defaulting to true
+ * program.option('-C, --no-cheese', 'remove cheese');
+ *
+ * program.cheese
+ * // => true
+ *
+ * --no-cheese
+ * program.cheese
+ * // => false
+ *
+ * // required argument
+ * program.option('-C, --chdir <path>', 'change the working directory');
+ *
+ * --chdir /tmp
+ * program.chdir
+ * // => "/tmp"
+ *
+ * // optional argument
+ * program.option('-c, --cheese [type]', 'add cheese [marble]');
+ *
+ * @param {string} flags
+ * @param {string} [description]
+ * @param {((arg1: any, arg2: any) => void) | RegExp} [fn] function or default
+ * @param {*} [defaultValue]
+ * @returns {Command} for chaining
+ */
+ option(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;
+ option(flags: string, description?: string, defaultValue?: any): Command;
+
+ /**
+ * Allow unknown options on the command line.
+ *
+ * @param {boolean} [arg] if `true` or omitted, no error will be thrown for unknown options.
+ * @returns {Command} for chaining
+ */
+ allowUnknownOption(arg?: boolean): Command;
+
+ /**
+ * Parse `argv`, settings options and invoking commands when defined.
+ *
+ * @param {string[]} argv
+ * @returns {Command} for chaining
+ */
+ parse(argv: string[]): Command;
+
+ /**
+ * Parse options from `argv` returning `argv` void of these options.
+ *
+ * @param {string[]} argv
+ * @returns {ParseOptionsResult}
+ */
+ parseOptions(argv: string[]): commander.ParseOptionsResult;
+
+ /**
+ * Return an object containing options as key-value pairs
+ *
+ * @returns {{[key: string]: string}}
+ */
+ opts(): { [key: string]: string };
+
+ /**
+ * Set the description to `str`.
+ *
+ * @param {string} str
+ * @return {(Command | string)}
+ */
+ description(str: string): Command;
+ description(): string;
+
+ /**
+ * Set an alias for the command.
+ *
+ * @param {string} alias
+ * @return {(Command | string)}
+ */
+ alias(alias: string): Command;
+ alias(): string;
+
+ /**
+ * Set or get the command usage.
+ *
+ * @param {string} str
+ * @return {(Command | string)}
+ */
+ usage(str: string): Command;
+ usage(): string;
+
+ /**
+ * Set the name of the command.
+ *
+ * @param {string} str
+ * @return {Command}
+ */
+ name(str: string): Command;
+
+ /**
+ * Get the name of the command.
+ *
+ * @return {string}
+ */
+ name(): string;
+
+ /**
+ * Output help information for this command.
+ *
+ * @param {(str: string) => string} [cb]
+ */
+ outputHelp(cb?: (str: string) => string): void;
+
+ /** Output help information and exit. */
+ help(): void;
+}
+
+declare namespace commander {
+
+ interface CommandOptions {
+ noHelp?: boolean;
+ isDefault?: boolean;
+ }
+
+ interface ParseOptionsResult {
+ args: string[];
+ unknown: string[];
+ }
+
+ interface CommanderStatic extends Command {
+ Command: typeof Command;
+ Option: typeof Option;
+ CommandOptions: CommandOptions;
+ ParseOptionsResult: ParseOptionsResult;
+ }
+
+}
+
+declare const commander: commander.CommanderStatic;
+export = commander; \ No newline at end of file
diff --git a/node_modules/tslint/node_modules/resolve/.editorconfig b/node_modules/tslint/node_modules/resolve/.editorconfig
new file mode 100644
index 000000000..ac29adef0
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/.editorconfig
@@ -0,0 +1,20 @@
+root = true
+
+[*]
+indent_style = tab
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+max_line_length = 120
+
+[CHANGELOG.md]
+indent_style = space
+indent_size = 2
+
+[*.json]
+max_line_length = off
+
+[Makefile]
+max_line_length = off
diff --git a/node_modules/tslint/node_modules/resolve/.eslintignore b/node_modules/tslint/node_modules/resolve/.eslintignore
new file mode 100644
index 000000000..3c3629e64
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/.eslintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/node_modules/tslint/node_modules/resolve/.eslintrc b/node_modules/tslint/node_modules/resolve/.eslintrc
new file mode 100644
index 000000000..9db19a4f8
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/.eslintrc
@@ -0,0 +1,30 @@
+{
+ "extends": "@ljharb",
+ "root": true,
+ "rules": {
+ "array-bracket-newline": 0,
+ "array-element-newline": 0,
+ "indent": [2, 4],
+ "strict": 0,
+ "complexity": 0,
+ "consistent-return": 0,
+ "curly": 0,
+ "dot-notation": [2, { "allowKeywords": true }],
+ "func-name-matching": 0,
+ "func-style": 0,
+ "global-require": 0,
+ "id-length": [2, { "min": 1, "max": 30 }],
+ "max-nested-callbacks": 0,
+ "max-params": 0,
+ "max-statements-per-line": [2, { "max": 2 }],
+ "max-statements": 0,
+ "no-magic-numbers": 0,
+ "no-console": 0,
+ "no-shadow": 0,
+ "no-unused-vars": [2, { "vars": "all", "args": "none" }],
+ "no-use-before-define": 0,
+ "object-curly-newline": 0,
+ "operator-linebreak": [2, "before"],
+ "sort-keys": 0,
+ }
+}
diff --git a/node_modules/tslint/node_modules/resolve/.travis.yml b/node_modules/tslint/node_modules/resolve/.travis.yml
new file mode 100644
index 000000000..099f694ee
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/.travis.yml
@@ -0,0 +1,173 @@
+language: node_js
+os:
+ - linux
+node_js:
+ - "8.8"
+ - "7.10"
+ - "6.11"
+ - "5.12"
+ - "4.8"
+ - "iojs-v3.3"
+ - "iojs-v2.5"
+ - "iojs-v1.8"
+ - "0.12"
+ - "0.10"
+ - "0.8"
+before_install:
+ - 'nvm install-latest-npm'
+install:
+ - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
+script:
+ - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi'
+ - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi'
+ - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi'
+ - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'
+sudo: false
+env:
+ - TEST=true
+matrix:
+ fast_finish: true
+ include:
+ - node_js: "node"
+ env: PRETEST=true
+ - node_js: "8.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.10"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.11"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.10"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v3.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v3.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v3.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "0.11"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "0.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "0.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "0.4"
+ env: TEST=true ALLOW_FAILURE=true
+ allow_failures:
+ - os: osx
+ - env: TEST=true ALLOW_FAILURE=true
diff --git a/node_modules/tslint/node_modules/resolve/LICENSE b/node_modules/tslint/node_modules/resolve/LICENSE
new file mode 100644
index 000000000..ee27ba4b4
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/LICENSE
@@ -0,0 +1,18 @@
+This software is released under the MIT license:
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/tslint/node_modules/resolve/appveyor.yml b/node_modules/tslint/node_modules/resolve/appveyor.yml
new file mode 100644
index 000000000..f54a1b609
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/appveyor.yml
@@ -0,0 +1,44 @@
+version: 1.0.{build}
+skip_branch_with_pr: true
+build: off
+
+environment:
+ matrix:
+ - nodejs_version: "7"
+ - nodejs_version: "6"
+ - nodejs_version: "5"
+ - nodejs_version: "4"
+ - nodejs_version: "3"
+ - nodejs_version: "2"
+ - nodejs_version: "1"
+ - nodejs_version: "0.12"
+ - nodejs_version: "0.10"
+ - nodejs_version: "0.8"
+ - nodejs_version: "0.6"
+matrix:
+ # fast_finish: true
+ allow_failures:
+ - nodejs_version: "0.6"
+
+platform:
+ - x86
+ - x64
+
+# Install scripts. (runs after repo cloning)
+install:
+ # Get the latest stable version of Node.js or io.js
+ - ps: Install-Product node $env:nodejs_version $env:platform
+ - IF %nodejs_version% EQU 0.6 npm -g install npm@1.3
+ - IF %nodejs_version% EQU 0.8 npm -g install npm@2
+ - set PATH=%APPDATA%\npm;%PATH%
+ #- IF %nodejs_version% NEQ 0.6 AND %nodejs_version% NEQ 0.8 npm -g install npm
+ # install modules
+ - npm install
+
+# Post-install test scripts.
+test_script:
+ # Output useful info for debugging.
+ - node --version
+ - npm --version
+ # run tests
+ - npm run tests-only
diff --git a/node_modules/tslint/node_modules/resolve/example/async.js b/node_modules/tslint/node_modules/resolve/example/async.js
new file mode 100644
index 000000000..20e65dc28
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/example/async.js
@@ -0,0 +1,5 @@
+var resolve = require('../');
+resolve('tap', { basedir: __dirname }, function (err, res) {
+ if (err) console.error(err);
+ else console.log(res);
+});
diff --git a/node_modules/tslint/node_modules/resolve/example/sync.js b/node_modules/tslint/node_modules/resolve/example/sync.js
new file mode 100644
index 000000000..54b2cc100
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/example/sync.js
@@ -0,0 +1,3 @@
+var resolve = require('../');
+var res = resolve.sync('tap', { basedir: __dirname });
+console.log(res);
diff --git a/node_modules/tslint/node_modules/resolve/index.js b/node_modules/tslint/node_modules/resolve/index.js
new file mode 100644
index 000000000..eb6ba89e6
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/index.js
@@ -0,0 +1,8 @@
+var core = require('./lib/core');
+var async = require('./lib/async');
+async.core = core;
+async.isCore = function isCore(x) { return core[x]; };
+async.sync = require('./lib/sync');
+
+exports = async;
+module.exports = async;
diff --git a/node_modules/tslint/node_modules/resolve/lib/async.js b/node_modules/tslint/node_modules/resolve/lib/async.js
new file mode 100644
index 000000000..ef1bde782
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/lib/async.js
@@ -0,0 +1,203 @@
+var core = require('./core');
+var fs = require('fs');
+var path = require('path');
+var caller = require('./caller.js');
+var nodeModulesPaths = require('./node-modules-paths.js');
+
+module.exports = function resolve(x, options, callback) {
+ var cb = callback;
+ var opts = options || {};
+ if (typeof opts === 'function') {
+ cb = opts;
+ opts = {};
+ }
+ if (typeof x !== 'string') {
+ var err = new TypeError('Path must be a string.');
+ return process.nextTick(function () {
+ cb(err);
+ });
+ }
+
+ var isFile = opts.isFile || function (file, cb) {
+ fs.stat(file, function (err, stat) {
+ if (!err) {
+ return cb(null, stat.isFile() || stat.isFIFO());
+ }
+ if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
+ return cb(err);
+ });
+ };
+ var readFile = opts.readFile || fs.readFile;
+
+ var extensions = opts.extensions || ['.js'];
+ var y = opts.basedir || path.dirname(caller());
+
+ opts.paths = opts.paths || [];
+
+ if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
+ var res = path.resolve(y, x);
+ if (x === '..' || x.slice(-1) === '/') res += '/';
+ if (/\/$/.test(x) && res === y) {
+ loadAsDirectory(res, opts.package, onfile);
+ } else loadAsFile(res, opts.package, onfile);
+ } else loadNodeModules(x, y, function (err, n, pkg) {
+ if (err) cb(err);
+ else if (n) cb(null, n, pkg);
+ else if (core[x]) return cb(null, x);
+ else {
+ var moduleError = new Error("Cannot find module '" + x + "' from '" + y + "'");
+ moduleError.code = 'MODULE_NOT_FOUND';
+ cb(moduleError);
+ }
+ });
+
+ function onfile(err, m, pkg) {
+ if (err) cb(err);
+ else if (m) cb(null, m, pkg);
+ else loadAsDirectory(res, function (err, d, pkg) {
+ if (err) cb(err);
+ else if (d) cb(null, d, pkg);
+ else {
+ var moduleError = new Error("Cannot find module '" + x + "' from '" + y + "'");
+ moduleError.code = 'MODULE_NOT_FOUND';
+ cb(moduleError);
+ }
+ });
+ }
+
+ function loadAsFile(x, thePackage, callback) {
+ var loadAsFilePackage = thePackage;
+ var cb = callback;
+ if (typeof loadAsFilePackage === 'function') {
+ cb = loadAsFilePackage;
+ loadAsFilePackage = undefined;
+ }
+
+ var exts = [''].concat(extensions);
+ load(exts, x, loadAsFilePackage);
+
+ function load(exts, x, loadPackage) {
+ if (exts.length === 0) return cb(null, undefined, loadPackage);
+ var file = x + exts[0];
+
+ var pkg = loadPackage;
+ if (pkg) onpkg(null, pkg);
+ else loadpkg(path.dirname(file), onpkg);
+
+ function onpkg(err, pkg_, dir) {
+ pkg = pkg_;
+ if (err) return cb(err);
+ if (dir && pkg && opts.pathFilter) {
+ var rfile = path.relative(dir, file);
+ var rel = rfile.slice(0, rfile.length - exts[0].length);
+ var r = opts.pathFilter(pkg, x, rel);
+ if (r) return load(
+ [''].concat(extensions.slice()),
+ path.resolve(dir, r),
+ pkg
+ );
+ }
+ isFile(file, onex);
+ }
+ function onex(err, ex) {
+ if (err) return cb(err);
+ if (ex) return cb(null, file, pkg);
+ load(exts.slice(1), x, pkg);
+ }
+ }
+ }
+
+ function loadpkg(dir, cb) {
+ if (dir === '' || dir === '/') return cb(null);
+ if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) {
+ return cb(null);
+ }
+ if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb(null);
+
+ var pkgfile = path.join(dir, 'package.json');
+ isFile(pkgfile, function (err, ex) {
+ // on err, ex is false
+ if (!ex) return loadpkg(path.dirname(dir), cb);
+
+ readFile(pkgfile, function (err, body) {
+ if (err) cb(err);
+ try { var pkg = JSON.parse(body); } catch (jsonErr) {}
+
+ if (pkg && opts.packageFilter) {
+ pkg = opts.packageFilter(pkg, pkgfile);
+ }
+ cb(null, pkg, dir);
+ });
+ });
+ }
+
+ function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
+ var cb = callback;
+ var fpkg = loadAsDirectoryPackage;
+ if (typeof fpkg === 'function') {
+ cb = fpkg;
+ fpkg = opts.package;
+ }
+
+ var pkgfile = path.join(x, 'package.json');
+ isFile(pkgfile, function (err, ex) {
+ if (err) return cb(err);
+ if (!ex) return loadAsFile(path.join(x, 'index'), fpkg, cb);
+
+ readFile(pkgfile, function (err, body) {
+ if (err) return cb(err);
+ try {
+ var pkg = JSON.parse(body);
+ } catch (jsonErr) {}
+
+ if (opts.packageFilter) {
+ pkg = opts.packageFilter(pkg, pkgfile);
+ }
+
+ if (pkg.main) {
+ if (pkg.main === '.' || pkg.main === './') {
+ pkg.main = 'index';
+ }
+ loadAsFile(path.resolve(x, pkg.main), pkg, function (err, m, pkg) {
+ if (err) return cb(err);
+ if (m) return cb(null, m, pkg);
+ if (!pkg) return loadAsFile(path.join(x, 'index'), pkg, cb);
+
+ var dir = path.resolve(x, pkg.main);
+ loadAsDirectory(dir, pkg, function (err, n, pkg) {
+ if (err) return cb(err);
+ if (n) return cb(null, n, pkg);
+ loadAsFile(path.join(x, 'index'), pkg, cb);
+ });
+ });
+ return;
+ }
+
+ loadAsFile(path.join(x, '/index'), pkg, cb);
+ });
+ });
+ }
+
+ function processDirs(cb, dirs) {
+ if (dirs.length === 0) return cb(null, undefined);
+ var dir = dirs[0];
+
+ var file = path.join(dir, x);
+ loadAsFile(file, undefined, onfile);
+
+ function onfile(err, m, pkg) {
+ if (err) return cb(err);
+ if (m) return cb(null, m, pkg);
+ loadAsDirectory(path.join(dir, x), undefined, ondir);
+ }
+
+ function ondir(err, n, pkg) {
+ if (err) return cb(err);
+ if (n) return cb(null, n, pkg);
+ processDirs(cb, dirs.slice(1));
+ }
+ }
+ function loadNodeModules(x, start, cb) {
+ processDirs(cb, nodeModulesPaths(start, opts));
+ }
+};
diff --git a/node_modules/tslint/node_modules/resolve/lib/caller.js b/node_modules/tslint/node_modules/resolve/lib/caller.js
new file mode 100644
index 000000000..b14a2804a
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/lib/caller.js
@@ -0,0 +1,8 @@
+module.exports = function () {
+ // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
+ var origPrepareStackTrace = Error.prepareStackTrace;
+ Error.prepareStackTrace = function (_, stack) { return stack; };
+ var stack = (new Error()).stack;
+ Error.prepareStackTrace = origPrepareStackTrace;
+ return stack[2].getFileName();
+};
diff --git a/node_modules/tslint/node_modules/resolve/lib/core.js b/node_modules/tslint/node_modules/resolve/lib/core.js
new file mode 100644
index 000000000..5386d4d8d
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/lib/core.js
@@ -0,0 +1,34 @@
+var current = (process.versions && process.versions.node && process.versions.node.split('.')) || [];
+
+function versionIncluded(specifier) {
+ if (specifier === true) { return true; }
+ var parts = specifier.split(' ');
+ var op = parts[0];
+ var versionParts = parts[1].split('.');
+
+ for (var i = 0; i < 3; ++i) {
+ var cur = Number(current[i] || 0);
+ var ver = Number(versionParts[i] || 0);
+ if (cur === ver) {
+ continue; // eslint-disable-line no-restricted-syntax, no-continue
+ }
+ if (op === '<') {
+ return cur < ver;
+ } else if (op === '>=') {
+ return cur >= ver;
+ } else {
+ return false;
+ }
+ }
+ return false;
+}
+
+var data = require('./core.json');
+
+var core = {};
+for (var mod in data) { // eslint-disable-line no-restricted-syntax
+ if (Object.prototype.hasOwnProperty.call(data, mod)) {
+ core[mod] = versionIncluded(data[mod]);
+ }
+}
+module.exports = core;
diff --git a/node_modules/tslint/node_modules/resolve/lib/core.json b/node_modules/tslint/node_modules/resolve/lib/core.json
new file mode 100644
index 000000000..668301f7c
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/lib/core.json
@@ -0,0 +1,43 @@
+{
+ "assert": true,
+ "buffer_ieee754": "< 0.9.7",
+ "buffer": true,
+ "child_process": true,
+ "cluster": true,
+ "console": true,
+ "constants": true,
+ "crypto": true,
+ "_debugger": "< 8",
+ "dgram": true,
+ "dns": true,
+ "domain": true,
+ "events": true,
+ "freelist": "< 6",
+ "fs": true,
+ "http": true,
+ "http2": ">= 8.8",
+ "https": true,
+ "_http_server": ">= 0.11",
+ "_linklist": "< 8",
+ "module": true,
+ "net": true,
+ "os": true,
+ "path": true,
+ "perf_hooks": ">= 8.5",
+ "process": ">= 1",
+ "punycode": true,
+ "querystring": true,
+ "readline": true,
+ "repl": true,
+ "stream": true,
+ "string_decoder": true,
+ "sys": true,
+ "timers": true,
+ "tls": true,
+ "tty": true,
+ "url": true,
+ "util": true,
+ "v8": ">= 1",
+ "vm": true,
+ "zlib": true
+}
diff --git a/node_modules/tslint/node_modules/resolve/lib/node-modules-paths.js b/node_modules/tslint/node_modules/resolve/lib/node-modules-paths.js
new file mode 100644
index 000000000..a4bde6a96
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/lib/node-modules-paths.js
@@ -0,0 +1,45 @@
+var path = require('path');
+var fs = require('fs');
+var parse = path.parse || require('path-parse');
+
+module.exports = function nodeModulesPaths(start, opts) {
+ var modules = opts && opts.moduleDirectory
+ ? [].concat(opts.moduleDirectory)
+ : ['node_modules'];
+
+ // ensure that `start` is an absolute path at this point,
+ // resolving against the process' current working directory
+ var absoluteStart = path.resolve(start);
+
+ if (opts && opts.preserveSymlinks === false) {
+ try {
+ absoluteStart = fs.realpathSync(absoluteStart);
+ } catch (err) {
+ if (err.code !== 'ENOENT') {
+ throw err;
+ }
+ }
+ }
+
+ var prefix = '/';
+ if (/^([A-Za-z]:)/.test(absoluteStart)) {
+ prefix = '';
+ } else if (/^\\\\/.test(absoluteStart)) {
+ prefix = '\\\\';
+ }
+
+ var paths = [absoluteStart];
+ var parsed = parse(absoluteStart);
+ while (parsed.dir !== paths[paths.length - 1]) {
+ paths.push(parsed.dir);
+ parsed = parse(parsed.dir);
+ }
+
+ var dirs = paths.reduce(function (dirs, aPath) {
+ return dirs.concat(modules.map(function (moduleDir) {
+ return path.join(prefix, aPath, moduleDir);
+ }));
+ }, []);
+
+ return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
+};
diff --git a/node_modules/tslint/node_modules/resolve/lib/sync.js b/node_modules/tslint/node_modules/resolve/lib/sync.js
new file mode 100644
index 000000000..bc9e287a1
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/lib/sync.js
@@ -0,0 +1,93 @@
+var core = require('./core');
+var fs = require('fs');
+var path = require('path');
+var caller = require('./caller.js');
+var nodeModulesPaths = require('./node-modules-paths.js');
+
+module.exports = function (x, options) {
+ if (typeof x !== 'string') {
+ throw new TypeError('Path must be a string.');
+ }
+ var opts = options || {};
+ var isFile = opts.isFile || function (file) {
+ try {
+ var stat = fs.statSync(file);
+ } catch (e) {
+ if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
+ throw e;
+ }
+ return stat.isFile() || stat.isFIFO();
+ };
+ var readFileSync = opts.readFileSync || fs.readFileSync;
+
+ var extensions = opts.extensions || ['.js'];
+ var y = opts.basedir || path.dirname(caller());
+
+ opts.paths = opts.paths || [];
+
+ if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
+ var res = path.resolve(y, x);
+ if (x === '..' || x.slice(-1) === '/') res += '/';
+ var m = loadAsFileSync(res) || loadAsDirectorySync(res);
+ if (m) return m;
+ } else {
+ var n = loadNodeModulesSync(x, y);
+ if (n) return n;
+ }
+
+ if (core[x]) return x;
+
+ var err = new Error("Cannot find module '" + x + "' from '" + y + "'");
+ err.code = 'MODULE_NOT_FOUND';
+ throw err;
+
+ function loadAsFileSync(x) {
+ if (isFile(x)) {
+ return x;
+ }
+
+ for (var i = 0; i < extensions.length; i++) {
+ var file = x + extensions[i];
+ if (isFile(file)) {
+ return file;
+ }
+ }
+ }
+
+ function loadAsDirectorySync(x) {
+ var pkgfile = path.join(x, '/package.json');
+ if (isFile(pkgfile)) {
+ try {
+ var body = readFileSync(pkgfile, 'UTF8');
+ var pkg = JSON.parse(body);
+
+ if (opts.packageFilter) {
+ pkg = opts.packageFilter(pkg, x);
+ }
+
+ if (pkg.main) {
+ if (pkg.main === '.' || pkg.main === './') {
+ pkg.main = 'index';
+ }
+ var m = loadAsFileSync(path.resolve(x, pkg.main));
+ if (m) return m;
+ var n = loadAsDirectorySync(path.resolve(x, pkg.main));
+ if (n) return n;
+ }
+ } catch (e) {}
+ }
+
+ return loadAsFileSync(path.join(x, '/index'));
+ }
+
+ function loadNodeModulesSync(x, start) {
+ var dirs = nodeModulesPaths(start, opts);
+ for (var i = 0; i < dirs.length; i++) {
+ var dir = dirs[i];
+ var m = loadAsFileSync(path.join(dir, '/', x));
+ if (m) return m;
+ var n = loadAsDirectorySync(path.join(dir, '/', x));
+ if (n) return n;
+ }
+ }
+};
diff --git a/node_modules/tslint/node_modules/resolve/package.json b/node_modules/tslint/node_modules/resolve/package.json
new file mode 100644
index 000000000..add5b137e
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "resolve",
+ "description": "resolve like require.resolve() on behalf of files asynchronously and synchronously",
+ "version": "1.5.0",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/browserify/node-resolve.git"
+ },
+ "main": "index.js",
+ "keywords": [
+ "resolve",
+ "require",
+ "node",
+ "module"
+ ],
+ "scripts": {
+ "prepublish": "safe-publish-latest",
+ "lint": "eslint .",
+ "tests-only": "tape test/*.js",
+ "pretest": "npm run lint",
+ "test": "npm run --silent tests-only"
+ },
+ "devDependencies": {
+ "@ljharb/eslint-config": "^12.2.1",
+ "eslint": "^4.9.0",
+ "object-keys": "^1.0.11",
+ "safe-publish-latest": "^1.1.1",
+ "tap": "0.4.13",
+ "tape": "^4.8.0"
+ },
+ "license": "MIT",
+ "author": {
+ "name": "James Halliday",
+ "email": "mail@substack.net",
+ "url": "http://substack.net"
+ },
+ "dependencies": {
+ "path-parse": "^1.0.5"
+ }
+}
diff --git a/node_modules/tslint/node_modules/resolve/readme.markdown b/node_modules/tslint/node_modules/resolve/readme.markdown
new file mode 100644
index 000000000..6000624a4
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/readme.markdown
@@ -0,0 +1,160 @@
+# resolve
+
+implements the [node `require.resolve()`
+algorithm](https://nodejs.org/api/modules.html#modules_all_together)
+such that you can `require.resolve()` on behalf of a file asynchronously and
+synchronously
+
+[![build status](https://secure.travis-ci.org/browserify/node-resolve.png)](http://travis-ci.org/browserify/node-resolve)
+
+# example
+
+asynchronously resolve:
+
+``` js
+var resolve = require('resolve');
+resolve('tap', { basedir: __dirname }, function (err, res) {
+ if (err) console.error(err)
+ else console.log(res)
+});
+```
+
+```
+$ node example/async.js
+/home/substack/projects/node-resolve/node_modules/tap/lib/main.js
+```
+
+synchronously resolve:
+
+``` js
+var resolve = require('resolve');
+var res = resolve.sync('tap', { basedir: __dirname });
+console.log(res);
+```
+
+```
+$ node example/sync.js
+/home/substack/projects/node-resolve/node_modules/tap/lib/main.js
+```
+
+# methods
+
+``` js
+var resolve = require('resolve')
+```
+
+## resolve(id, opts={}, cb)
+
+Asynchronously resolve the module path string `id` into `cb(err, res [, pkg])`, where `pkg` (if defined) is the data from `package.json`.
+
+options are:
+
+* opts.basedir - directory to begin resolving from
+
+* opts.package - `package.json` data applicable to the module being loaded
+
+* opts.extensions - array of file extensions to search in order
+
+* opts.readFile - how to read files asynchronously
+
+* opts.isFile - function to asynchronously test whether a file exists
+
+* opts.packageFilter - transform the parsed package.json contents before looking
+at the "main" field
+
+* opts.pathFilter(pkg, path, relativePath) - transform a path within a package
+ * pkg - package data
+ * path - the path being resolved
+ * relativePath - the path relative from the package.json location
+ * returns - a relative path that will be joined from the package.json location
+
+* opts.paths - require.paths array to use if nothing is found on the normal
+node_modules recursive walk (probably don't use this)
+
+* opts.moduleDirectory - directory (or directories) in which to recursively look for modules. default: `"node_modules"`
+
+* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.
+This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
+**Note:** this property is currently `true` by default but it will be changed to
+`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*.
+
+default `opts` values:
+
+``` javascript
+{
+ paths: [],
+ basedir: __dirname,
+ extensions: [ '.js' ],
+ readFile: fs.readFile,
+ isFile: function (file, cb) {
+ fs.stat(file, function (err, stat) {
+ if (err && err.code === 'ENOENT') cb(null, false)
+ else if (err) cb(err)
+ else cb(null, stat.isFile())
+ });
+ },
+ moduleDirectory: 'node_modules',
+ preserveSymlinks: true
+}
+```
+
+## resolve.sync(id, opts)
+
+Synchronously resolve the module path string `id`, returning the result and
+throwing an error when `id` can't be resolved.
+
+options are:
+
+* opts.basedir - directory to begin resolving from
+
+* opts.extensions - array of file extensions to search in order
+
+* opts.readFile - how to read files synchronously
+
+* opts.isFile - function to synchronously test whether a file exists
+
+* `opts.packageFilter(pkg, pkgfile)` - transform the parsed package.json
+* contents before looking at the "main" field
+
+* opts.paths - require.paths array to use if nothing is found on the normal
+node_modules recursive walk (probably don't use this)
+
+* opts.moduleDirectory - directory (or directories) in which to recursively look for modules. default: `"node_modules"`
+
+* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.
+This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
+**Note:** this property is currently `true` by default but it will be changed to
+`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*.
+
+default `opts` values:
+
+``` javascript
+{
+ paths: [],
+ basedir: __dirname,
+ extensions: [ '.js' ],
+ readFileSync: fs.readFileSync,
+ isFile: function (file) {
+ try { return fs.statSync(file).isFile() }
+ catch (e) { return false }
+ },
+ moduleDirectory: 'node_modules',
+ preserveSymlinks: true
+}
+````
+
+## resolve.isCore(pkg)
+
+Return whether a package is in core.
+
+# install
+
+With [npm](https://npmjs.org) do:
+
+```
+npm install resolve
+```
+
+# license
+
+MIT
diff --git a/node_modules/tslint/node_modules/resolve/test/core.js b/node_modules/tslint/node_modules/resolve/test/core.js
new file mode 100644
index 000000000..978c867cb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/core.js
@@ -0,0 +1,36 @@
+var test = require('tape');
+var keys = require('object-keys');
+var resolve = require('../');
+
+test('core modules', function (t) {
+ t.test('isCore()', function (st) {
+ st.ok(resolve.isCore('fs'));
+ st.ok(resolve.isCore('net'));
+ st.ok(resolve.isCore('http'));
+
+ st.ok(!resolve.isCore('seq'));
+ st.ok(!resolve.isCore('../'));
+ st.end();
+ });
+
+ t.test('core list', function (st) {
+ var cores = keys(resolve.core);
+ st.plan(cores.length);
+
+ for (var i = 0; i < cores.length; ++i) {
+ var mod = cores[i];
+ if (resolve.core[mod]) {
+ st.doesNotThrow(
+ function () { require(mod); }, // eslint-disable-line no-loop-func
+ 'requiring ' + mod + ' does not throw'
+ );
+ } else {
+ st.skip(mod + ' not supported');
+ }
+ }
+
+ st.end();
+ });
+
+ t.end();
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/dotdot.js b/node_modules/tslint/node_modules/resolve/test/dotdot.js
new file mode 100644
index 000000000..30806659b
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/dotdot.js
@@ -0,0 +1,29 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('dotdot', function (t) {
+ t.plan(4);
+ var dir = path.join(__dirname, '/dotdot/abc');
+
+ resolve('..', { basedir: dir }, function (err, res, pkg) {
+ t.ifError(err);
+ t.equal(res, path.join(__dirname, 'dotdot/index.js'));
+ });
+
+ resolve('.', { basedir: dir }, function (err, res, pkg) {
+ t.ifError(err);
+ t.equal(res, path.join(dir, 'index.js'));
+ });
+});
+
+test('dotdot sync', function (t) {
+ t.plan(2);
+ var dir = path.join(__dirname, '/dotdot/abc');
+
+ var a = resolve.sync('..', { basedir: dir });
+ t.equal(a, path.join(__dirname, 'dotdot/index.js'));
+
+ var b = resolve.sync('.', { basedir: dir });
+ t.equal(b, path.join(dir, 'index.js'));
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/dotdot/abc/index.js b/node_modules/tslint/node_modules/resolve/test/dotdot/abc/index.js
new file mode 100644
index 000000000..67f2534eb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/dotdot/abc/index.js
@@ -0,0 +1,2 @@
+var x = require('..');
+console.log(x);
diff --git a/node_modules/tslint/node_modules/resolve/test/dotdot/index.js b/node_modules/tslint/node_modules/resolve/test/dotdot/index.js
new file mode 100644
index 000000000..643f9fcc6
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/dotdot/index.js
@@ -0,0 +1 @@
+module.exports = 'whatever';
diff --git a/node_modules/tslint/node_modules/resolve/test/faulty_basedir.js b/node_modules/tslint/node_modules/resolve/test/faulty_basedir.js
new file mode 100644
index 000000000..e20d937ca
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/faulty_basedir.js
@@ -0,0 +1,13 @@
+var test = require('tape');
+var resolve = require('../');
+
+test('faulty basedir must produce error in windows', { skip: process.platform !== 'win32' }, function (t) {
+ t.plan(1);
+
+ var resolverDir = 'C:\\a\\b\\c\\d';
+
+ resolve('tape/lib/test.js', { basedir: resolverDir }, function (err, res, pkg) {
+ t.equal(true, !!err);
+ });
+
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/filter.js b/node_modules/tslint/node_modules/resolve/test/filter.js
new file mode 100644
index 000000000..51a753f16
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/filter.js
@@ -0,0 +1,19 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('filter', function (t) {
+ t.plan(2);
+ var dir = path.join(__dirname, 'resolver');
+ resolve('./baz', {
+ basedir: dir,
+ packageFilter: function (pkg) {
+ pkg.main = 'doom';
+ return pkg;
+ }
+ }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'baz/doom.js'));
+ t.equal(pkg.main, 'doom');
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/filter_sync.js b/node_modules/tslint/node_modules/resolve/test/filter_sync.js
new file mode 100644
index 000000000..fd4e97c28
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/filter_sync.js
@@ -0,0 +1,16 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('filter', function (t) {
+ var dir = path.join(__dirname, 'resolver');
+ var res = resolve.sync('./baz', {
+ basedir: dir,
+ packageFilter: function (pkg) {
+ pkg.main = 'doom';
+ return pkg;
+ }
+ });
+ t.equal(res, path.join(dir, 'baz/doom.js'));
+ t.end();
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/mock.js b/node_modules/tslint/node_modules/resolve/test/mock.js
new file mode 100644
index 000000000..a88059d45
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/mock.js
@@ -0,0 +1,143 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('mock', function (t) {
+ t.plan(8);
+
+ var files = {};
+ files[path.resolve('/foo/bar/baz.js')] = 'beep';
+
+ function opts(basedir) {
+ return {
+ basedir: path.resolve(basedir),
+ isFile: function (file, cb) {
+ cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
+ },
+ readFile: function (file, cb) {
+ cb(null, files[path.resolve(file)]);
+ }
+ };
+ }
+
+ resolve('./baz', opts('/foo/bar'), function (err, res, pkg) {
+ if (err) return t.fail(err);
+ t.equal(res, path.resolve('/foo/bar/baz.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) {
+ if (err) return t.fail(err);
+ t.equal(res, path.resolve('/foo/bar/baz.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('baz', opts('/foo/bar'), function (err, res) {
+ t.equal(err.message, "Cannot find module 'baz' from '" + path.resolve('/foo/bar') + "'");
+ t.equal(err.code, 'MODULE_NOT_FOUND');
+ });
+
+ resolve('../baz', opts('/foo/bar'), function (err, res) {
+ t.equal(err.message, "Cannot find module '../baz' from '" + path.resolve('/foo/bar') + "'");
+ t.equal(err.code, 'MODULE_NOT_FOUND');
+ });
+});
+
+test('mock from package', function (t) {
+ t.plan(8);
+
+ var files = {};
+ files[path.resolve('/foo/bar/baz.js')] = 'beep';
+
+ function opts(basedir) {
+ return {
+ basedir: path.resolve(basedir),
+ isFile: function (file, cb) {
+ cb(null, Object.prototype.hasOwnProperty.call(files, file));
+ },
+ 'package': { main: 'bar' },
+ readFile: function (file, cb) {
+ cb(null, files[file]);
+ }
+ };
+ }
+
+ resolve('./baz', opts('/foo/bar'), function (err, res, pkg) {
+ if (err) return t.fail(err);
+ t.equal(res, path.resolve('/foo/bar/baz.js'));
+ t.equal(pkg && pkg.main, 'bar');
+ });
+
+ resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) {
+ if (err) return t.fail(err);
+ t.equal(res, path.resolve('/foo/bar/baz.js'));
+ t.equal(pkg && pkg.main, 'bar');
+ });
+
+ resolve('baz', opts('/foo/bar'), function (err, res) {
+ t.equal(err.message, "Cannot find module 'baz' from '" + path.resolve('/foo/bar') + "'");
+ t.equal(err.code, 'MODULE_NOT_FOUND');
+ });
+
+ resolve('../baz', opts('/foo/bar'), function (err, res) {
+ t.equal(err.message, "Cannot find module '../baz' from '" + path.resolve('/foo/bar') + "'");
+ t.equal(err.code, 'MODULE_NOT_FOUND');
+ });
+});
+
+test('mock package', function (t) {
+ t.plan(2);
+
+ var files = {};
+ files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
+ files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
+ main: './baz.js'
+ });
+
+ function opts(basedir) {
+ return {
+ basedir: path.resolve(basedir),
+ isFile: function (file, cb) {
+ cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
+ },
+ readFile: function (file, cb) {
+ cb(null, files[path.resolve(file)]);
+ }
+ };
+ }
+
+ resolve('bar', opts('/foo'), function (err, res, pkg) {
+ if (err) return t.fail(err);
+ t.equal(res, path.resolve('/foo/node_modules/bar/baz.js'));
+ t.equal(pkg && pkg.main, './baz.js');
+ });
+});
+
+test('mock package from package', function (t) {
+ t.plan(2);
+
+ var files = {};
+ files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
+ files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
+ main: './baz.js'
+ });
+
+ function opts(basedir) {
+ return {
+ basedir: path.resolve(basedir),
+ isFile: function (file, cb) {
+ cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
+ },
+ 'package': { main: 'bar' },
+ readFile: function (file, cb) {
+ cb(null, files[path.resolve(file)]);
+ }
+ };
+ }
+
+ resolve('bar', opts('/foo'), function (err, res, pkg) {
+ if (err) return t.fail(err);
+ t.equal(res, path.resolve('/foo/node_modules/bar/baz.js'));
+ t.equal(pkg && pkg.main, './baz.js');
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/mock_sync.js b/node_modules/tslint/node_modules/resolve/test/mock_sync.js
new file mode 100644
index 000000000..43af10289
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/mock_sync.js
@@ -0,0 +1,67 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('mock', function (t) {
+ t.plan(4);
+
+ var files = {};
+ files[path.resolve('/foo/bar/baz.js')] = 'beep';
+
+ function opts(basedir) {
+ return {
+ basedir: path.resolve(basedir),
+ isFile: function (file) {
+ return Object.prototype.hasOwnProperty.call(files, file);
+ },
+ readFileSync: function (file) {
+ return files[file];
+ }
+ };
+ }
+
+ t.equal(
+ resolve.sync('./baz', opts('/foo/bar')),
+ path.resolve('/foo/bar/baz.js')
+ );
+
+ t.equal(
+ resolve.sync('./baz.js', opts('/foo/bar')),
+ path.resolve('/foo/bar/baz.js')
+ );
+
+ t.throws(function () {
+ resolve.sync('baz', opts('/foo/bar'));
+ });
+
+ t.throws(function () {
+ resolve.sync('../baz', opts('/foo/bar'));
+ });
+});
+
+test('mock package', function (t) {
+ t.plan(1);
+
+ var files = {};
+ files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
+ files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
+ main: './baz.js'
+ });
+
+ function opts(basedir) {
+ return {
+ basedir: path.resolve(basedir),
+ isFile: function (file) {
+ return Object.prototype.hasOwnProperty.call(files, file);
+ },
+ readFileSync: function (file) {
+ return files[file];
+ }
+ };
+ }
+
+ t.equal(
+ resolve.sync('bar', opts('/foo')),
+ path.resolve('/foo/node_modules/bar/baz.js')
+ );
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/module_dir.js b/node_modules/tslint/node_modules/resolve/test/module_dir.js
new file mode 100644
index 000000000..b50e5bb17
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/module_dir.js
@@ -0,0 +1,56 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('moduleDirectory strings', function (t) {
+ t.plan(4);
+ var dir = path.join(__dirname, 'module_dir');
+ var xopts = {
+ basedir: dir,
+ moduleDirectory: 'xmodules'
+ };
+ resolve('aaa', xopts, function (err, res, pkg) {
+ t.ifError(err);
+ t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
+ });
+
+ var yopts = {
+ basedir: dir,
+ moduleDirectory: 'ymodules'
+ };
+ resolve('aaa', yopts, function (err, res, pkg) {
+ t.ifError(err);
+ t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
+ });
+});
+
+test('moduleDirectory array', function (t) {
+ t.plan(6);
+ var dir = path.join(__dirname, 'module_dir');
+ var aopts = {
+ basedir: dir,
+ moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
+ };
+ resolve('aaa', aopts, function (err, res, pkg) {
+ t.ifError(err);
+ t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
+ });
+
+ var bopts = {
+ basedir: dir,
+ moduleDirectory: ['zmodules', 'ymodules', 'xmodules']
+ };
+ resolve('aaa', bopts, function (err, res, pkg) {
+ t.ifError(err);
+ t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
+ });
+
+ var copts = {
+ basedir: dir,
+ moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
+ };
+ resolve('bbb', copts, function (err, res, pkg) {
+ t.ifError(err);
+ t.equal(res, path.join(dir, '/zmodules/bbb/main.js'));
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/module_dir/xmodules/aaa/index.js b/node_modules/tslint/node_modules/resolve/test/module_dir/xmodules/aaa/index.js
new file mode 100644
index 000000000..dd7cf7b2d
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/module_dir/xmodules/aaa/index.js
@@ -0,0 +1 @@
+module.exports = function (x) { return x * 100; };
diff --git a/node_modules/tslint/node_modules/resolve/test/module_dir/ymodules/aaa/index.js b/node_modules/tslint/node_modules/resolve/test/module_dir/ymodules/aaa/index.js
new file mode 100644
index 000000000..ef2d4d4bf
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/module_dir/ymodules/aaa/index.js
@@ -0,0 +1 @@
+module.exports = function (x) { return x + 100; };
diff --git a/node_modules/tslint/node_modules/resolve/test/module_dir/zmodules/bbb/main.js b/node_modules/tslint/node_modules/resolve/test/module_dir/zmodules/bbb/main.js
new file mode 100644
index 000000000..e8ba62993
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/module_dir/zmodules/bbb/main.js
@@ -0,0 +1 @@
+module.exports = function (n) { return n * 111; };
diff --git a/node_modules/tslint/node_modules/resolve/test/module_dir/zmodules/bbb/package.json b/node_modules/tslint/node_modules/resolve/test/module_dir/zmodules/bbb/package.json
new file mode 100644
index 000000000..c13b8cf6a
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/module_dir/zmodules/bbb/package.json
@@ -0,0 +1,3 @@
+{
+ "main": "main.js"
+}
diff --git a/node_modules/tslint/node_modules/resolve/test/node-modules-paths.js b/node_modules/tslint/node_modules/resolve/test/node-modules-paths.js
new file mode 100644
index 000000000..a917f063a
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/node-modules-paths.js
@@ -0,0 +1,93 @@
+var test = require('tape');
+var path = require('path');
+var parse = path.parse || require('path-parse');
+var keys = require('object-keys');
+
+var nodeModulesPaths = require('../lib/node-modules-paths');
+
+var verifyDirs = function verifyDirs(t, start, dirs, moduleDirectories, paths) {
+ var moduleDirs = [].concat(moduleDirectories || 'node_modules');
+
+ var foundModuleDirs = {};
+ var uniqueDirs = {};
+ var parsedDirs = {};
+ for (var i = 0; i < dirs.length; ++i) {
+ var parsed = parse(dirs[i]);
+ if (!foundModuleDirs[parsed.base]) { foundModuleDirs[parsed.base] = 0; }
+ foundModuleDirs[parsed.base] += 1;
+ parsedDirs[parsed.dir] = true;
+ uniqueDirs[dirs[i]] = true;
+ }
+ t.equal(keys(parsedDirs).length >= start.split(path.sep).length, true, 'there are >= dirs than "start" has');
+ var foundModuleDirNames = keys(foundModuleDirs);
+ t.deepEqual(foundModuleDirNames, moduleDirs.concat(paths || []), 'all desired module dirs were found');
+ t.equal(keys(uniqueDirs).length, dirs.length, 'all dirs provided were unique');
+
+ var counts = {};
+ for (var j = 0; j < foundModuleDirNames.length; ++j) {
+ counts[foundModuleDirs[j]] = true;
+ }
+ t.equal(keys(counts).length, 1, 'all found module directories had the same count');
+};
+
+test('node-modules-paths', function (t) {
+ t.test('no options', function (t) {
+ var start = path.join(__dirname, 'resolver');
+ var dirs = nodeModulesPaths(start);
+
+ verifyDirs(t, start, dirs);
+
+ t.end();
+ });
+
+ t.test('empty options', function (t) {
+ var start = path.join(__dirname, 'resolver');
+ var dirs = nodeModulesPaths(start, {});
+
+ verifyDirs(t, start, dirs);
+
+ t.end();
+ });
+
+ t.test('with paths option', function (t) {
+ var start = path.join(__dirname, 'resolver');
+ var paths = ['a', 'b'];
+ var dirs = nodeModulesPaths(start, { paths: paths });
+
+ verifyDirs(t, start, dirs, null, paths);
+
+ t.end();
+ });
+
+ t.test('with moduleDirectory option', function (t) {
+ var start = path.join(__dirname, 'resolver');
+ var moduleDirectory = 'not node modules';
+ var dirs = nodeModulesPaths(start, { moduleDirectory: moduleDirectory });
+
+ verifyDirs(t, start, dirs, moduleDirectory);
+
+ t.end();
+ });
+
+ t.test('with 1 moduleDirectory and paths options', function (t) {
+ var start = path.join(__dirname, 'resolver');
+ var paths = ['a', 'b'];
+ var moduleDirectory = 'not node modules';
+ var dirs = nodeModulesPaths(start, { paths: paths, moduleDirectory: moduleDirectory });
+
+ verifyDirs(t, start, dirs, moduleDirectory, paths);
+
+ t.end();
+ });
+
+ t.test('with 1+ moduleDirectory and paths options', function (t) {
+ var start = path.join(__dirname, 'resolver');
+ var paths = ['a', 'b'];
+ var moduleDirectories = ['not node modules', 'other modules'];
+ var dirs = nodeModulesPaths(start, { paths: paths, moduleDirectory: moduleDirectories });
+
+ verifyDirs(t, start, dirs, moduleDirectories, paths);
+
+ t.end();
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/node_path.js b/node_modules/tslint/node_modules/resolve/test/node_path.js
new file mode 100644
index 000000000..38a7d7e7d
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/node_path.js
@@ -0,0 +1,49 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('$NODE_PATH', function (t) {
+ t.plan(4);
+
+ resolve('aaa', {
+ paths: [
+ path.join(__dirname, '/node_path/x'),
+ path.join(__dirname, '/node_path/y')
+ ],
+ basedir: __dirname
+ }, function (err, res) {
+ t.equal(res, path.join(__dirname, '/node_path/x/aaa/index.js'));
+ });
+
+ resolve('bbb', {
+ paths: [
+ path.join(__dirname, '/node_path/x'),
+ path.join(__dirname, '/node_path/y')
+ ],
+ basedir: __dirname
+ }, function (err, res) {
+ t.equal(res, path.join(__dirname, '/node_path/y/bbb/index.js'));
+ });
+
+ resolve('ccc', {
+ paths: [
+ path.join(__dirname, '/node_path/x'),
+ path.join(__dirname, '/node_path/y')
+ ],
+ basedir: __dirname
+ }, function (err, res) {
+ t.equal(res, path.join(__dirname, '/node_path/x/ccc/index.js'));
+ });
+
+ // ensure that relative paths still resolve against the
+ // regular `node_modules` correctly
+ resolve('tap', {
+ paths: [
+ 'node_path'
+ ],
+ basedir: 'node_path/x'
+ }, function (err, res) {
+ var root = require('tap/package.json').main;
+ t.equal(res, path.resolve(__dirname, '..', 'node_modules/tap', root));
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/node_path/x/aaa/index.js b/node_modules/tslint/node_modules/resolve/test/node_path/x/aaa/index.js
new file mode 100644
index 000000000..ad70d0bb0
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/node_path/x/aaa/index.js
@@ -0,0 +1 @@
+module.exports = 'A';
diff --git a/node_modules/tslint/node_modules/resolve/test/node_path/x/ccc/index.js b/node_modules/tslint/node_modules/resolve/test/node_path/x/ccc/index.js
new file mode 100644
index 000000000..a64132e4c
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/node_path/x/ccc/index.js
@@ -0,0 +1 @@
+module.exports = 'C';
diff --git a/node_modules/tslint/node_modules/resolve/test/node_path/y/bbb/index.js b/node_modules/tslint/node_modules/resolve/test/node_path/y/bbb/index.js
new file mode 100644
index 000000000..4d0f32e24
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/node_path/y/bbb/index.js
@@ -0,0 +1 @@
+module.exports = 'B';
diff --git a/node_modules/tslint/node_modules/resolve/test/node_path/y/ccc/index.js b/node_modules/tslint/node_modules/resolve/test/node_path/y/ccc/index.js
new file mode 100644
index 000000000..793315e84
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/node_path/y/ccc/index.js
@@ -0,0 +1 @@
+module.exports = 'CY';
diff --git a/node_modules/tslint/node_modules/resolve/test/nonstring.js b/node_modules/tslint/node_modules/resolve/test/nonstring.js
new file mode 100644
index 000000000..ef63c40f9
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/nonstring.js
@@ -0,0 +1,9 @@
+var test = require('tape');
+var resolve = require('../');
+
+test('nonstring', function (t) {
+ t.plan(1);
+ resolve(555, function (err, res, pkg) {
+ t.ok(err);
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/pathfilter.js b/node_modules/tslint/node_modules/resolve/test/pathfilter.js
new file mode 100644
index 000000000..733045a06
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/pathfilter.js
@@ -0,0 +1,42 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('#62: deep module references and the pathFilter', function (t) {
+ t.plan(9);
+
+ var resolverDir = path.join(__dirname, '/pathfilter/deep_ref');
+ var pathFilter = function (pkg, x, remainder) {
+ t.equal(pkg.version, '1.2.3');
+ t.equal(x, path.join(resolverDir, 'node_modules/deep/ref'));
+ t.equal(remainder, 'ref');
+ return 'alt';
+ };
+
+ resolve('deep/ref', { basedir: resolverDir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+
+ t.equal(pkg.version, '1.2.3');
+ t.equal(res, path.join(resolverDir, 'node_modules/deep/ref.js'));
+ });
+
+ resolve(
+ 'deep/deeper/ref',
+ { basedir: resolverDir },
+ function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.notEqual(pkg, undefined);
+ t.equal(pkg.version, '1.2.3');
+ t.equal(res, path.join(resolverDir, 'node_modules/deep/deeper/ref.js'));
+ }
+ );
+
+ resolve(
+ 'deep/ref',
+ { basedir: resolverDir, pathFilter: pathFilter },
+ function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(resolverDir, 'node_modules/deep/alt.js'));
+ }
+ );
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/pathfilter/deep_ref/main.js b/node_modules/tslint/node_modules/resolve/test/pathfilter/deep_ref/main.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/pathfilter/deep_ref/main.js
diff --git a/node_modules/tslint/node_modules/resolve/test/precedence.js b/node_modules/tslint/node_modules/resolve/test/precedence.js
new file mode 100644
index 000000000..2febb598f
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/precedence.js
@@ -0,0 +1,23 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('precedence', function (t) {
+ t.plan(3);
+ var dir = path.join(__dirname, 'precedence/aaa');
+
+ resolve('./', { basedir: dir }, function (err, res, pkg) {
+ t.ifError(err);
+ t.equal(res, path.join(dir, 'index.js'));
+ t.equal(pkg.name, 'resolve');
+ });
+});
+
+test('./ should not load ${dir}.js', function (t) { // eslint-disable-line no-template-curly-in-string
+ t.plan(1);
+ var dir = path.join(__dirname, 'precedence/bbb');
+
+ resolve('./', { basedir: dir }, function (err, res, pkg) {
+ t.ok(err);
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/precedence/aaa.js b/node_modules/tslint/node_modules/resolve/test/precedence/aaa.js
new file mode 100644
index 000000000..b83a3e7ad
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/precedence/aaa.js
@@ -0,0 +1 @@
+module.exports = 'wtf';
diff --git a/node_modules/tslint/node_modules/resolve/test/precedence/aaa/index.js b/node_modules/tslint/node_modules/resolve/test/precedence/aaa/index.js
new file mode 100644
index 000000000..e0f8f6abf
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/precedence/aaa/index.js
@@ -0,0 +1 @@
+module.exports = 'okok';
diff --git a/node_modules/tslint/node_modules/resolve/test/precedence/aaa/main.js b/node_modules/tslint/node_modules/resolve/test/precedence/aaa/main.js
new file mode 100644
index 000000000..93542a965
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/precedence/aaa/main.js
@@ -0,0 +1 @@
+console.log(require('./'));
diff --git a/node_modules/tslint/node_modules/resolve/test/precedence/bbb.js b/node_modules/tslint/node_modules/resolve/test/precedence/bbb.js
new file mode 100644
index 000000000..2298f47fd
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/precedence/bbb.js
@@ -0,0 +1 @@
+module.exports = '>_<';
diff --git a/node_modules/tslint/node_modules/resolve/test/precedence/bbb/main.js b/node_modules/tslint/node_modules/resolve/test/precedence/bbb/main.js
new file mode 100644
index 000000000..716b81d4b
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/precedence/bbb/main.js
@@ -0,0 +1 @@
+console.log(require('./')); // should throw
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver.js b/node_modules/tslint/node_modules/resolve/test/resolver.js
new file mode 100644
index 000000000..56641dfde
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver.js
@@ -0,0 +1,349 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('async foo', function (t) {
+ t.plan(10);
+ var dir = path.join(__dirname, 'resolver');
+
+ resolve('./foo', { basedir: dir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'foo.js'));
+ t.equal(pkg && pkg.name, 'resolve');
+ });
+
+ resolve('./foo.js', { basedir: dir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'foo.js'));
+ t.equal(pkg && pkg.name, 'resolve');
+ });
+
+ resolve('./foo', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'foo.js'));
+ t.equal(pkg && pkg.main, 'resolver');
+ });
+
+ resolve('./foo.js', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'foo.js'));
+ t.equal(pkg.main, 'resolver');
+ });
+
+ resolve('foo', { basedir: dir }, function (err) {
+ t.equal(err.message, "Cannot find module 'foo' from '" + path.resolve(dir) + "'");
+ t.equal(err.code, 'MODULE_NOT_FOUND');
+ });
+});
+
+test('bar', function (t) {
+ t.plan(6);
+ var dir = path.join(__dirname, 'resolver');
+
+ resolve('foo', { basedir: dir + '/bar' }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('foo', { basedir: dir + '/bar' }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('foo', { basedir: dir + '/bar', 'package': { main: 'bar' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js'));
+ t.equal(pkg, undefined);
+ });
+});
+
+test('baz', function (t) {
+ t.plan(4);
+ var dir = path.join(__dirname, 'resolver');
+
+ resolve('./baz', { basedir: dir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'baz/quux.js'));
+ t.equal(pkg.main, 'quux.js');
+ });
+
+ resolve('./baz', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'baz/quux.js'));
+ t.equal(pkg.main, 'quux.js');
+ });
+});
+
+test('biz', function (t) {
+ t.plan(24);
+ var dir = path.join(__dirname, 'resolver/biz/node_modules');
+
+ resolve('./grux', { basedir: dir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'grux/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('./grux', { basedir: dir, 'package': { main: 'biz' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'grux/index.js'));
+ t.equal(pkg.main, 'biz');
+ });
+
+ resolve('./garply', { basedir: dir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'garply/lib/index.js'));
+ t.equal(pkg.main, './lib');
+ });
+
+ resolve('./garply', { basedir: dir, 'package': { main: 'biz' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'garply/lib/index.js'));
+ t.equal(pkg.main, './lib');
+ });
+
+ resolve('tiv', { basedir: dir + '/grux' }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'tiv/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('tiv', { basedir: dir + '/grux', 'package': { main: 'grux' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'tiv/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('tiv', { basedir: dir + '/garply' }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'tiv/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('tiv', { basedir: dir + '/garply', 'package': { main: './lib' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'tiv/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('grux', { basedir: dir + '/tiv' }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'grux/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('grux', { basedir: dir + '/tiv', 'package': { main: 'tiv' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'grux/index.js'));
+ t.equal(pkg, undefined);
+ });
+
+ resolve('garply', { basedir: dir + '/tiv' }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'garply/lib/index.js'));
+ t.equal(pkg.main, './lib');
+ });
+
+ resolve('garply', { basedir: dir + '/tiv', 'package': { main: 'tiv' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'garply/lib/index.js'));
+ t.equal(pkg.main, './lib');
+ });
+});
+
+test('quux', function (t) {
+ t.plan(2);
+ var dir = path.join(__dirname, 'resolver/quux');
+
+ resolve('./foo', { basedir: dir, 'package': { main: 'quux' } }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'foo/index.js'));
+ t.equal(pkg.main, 'quux');
+ });
+});
+
+test('normalize', function (t) {
+ t.plan(2);
+ var dir = path.join(__dirname, 'resolver/biz/node_modules/grux');
+
+ resolve('../grux', { basedir: dir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'index.js'));
+ t.equal(pkg, undefined);
+ });
+});
+
+test('cup', function (t) {
+ t.plan(4);
+ var dir = path.join(__dirname, 'resolver');
+
+ resolve('./cup', { basedir: dir, extensions: ['.js', '.coffee'] }, function (err, res) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'cup.coffee'));
+ });
+
+ resolve('./cup.coffee', { basedir: dir }, function (err, res) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'cup.coffee'));
+ });
+
+ resolve('./cup', { basedir: dir, extensions: ['.js'] }, function (err, res) {
+ t.equal(err.message, "Cannot find module './cup' from '" + path.resolve(dir) + "'");
+ t.equal(err.code, 'MODULE_NOT_FOUND');
+ });
+});
+
+test('mug', function (t) {
+ t.plan(3);
+ var dir = path.join(__dirname, 'resolver');
+
+ resolve('./mug', { basedir: dir }, function (err, res) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'mug.js'));
+ });
+
+ resolve('./mug', { basedir: dir, extensions: ['.coffee', '.js'] }, function (err, res) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, '/mug.coffee'));
+ });
+
+ resolve('./mug', { basedir: dir, extensions: ['.js', '.coffee'] }, function (err, res) {
+ t.equal(res, path.join(dir, '/mug.js'));
+ });
+});
+
+test('other path', function (t) {
+ t.plan(6);
+ var resolverDir = path.join(__dirname, 'resolver');
+ var dir = path.join(resolverDir, 'bar');
+ var otherDir = path.join(resolverDir, 'other_path');
+
+ resolve('root', { basedir: dir, paths: [otherDir] }, function (err, res) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(resolverDir, 'other_path/root.js'));
+ });
+
+ resolve('lib/other-lib', { basedir: dir, paths: [otherDir] }, function (err, res) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(resolverDir, 'other_path/lib/other-lib.js'));
+ });
+
+ resolve('root', { basedir: dir }, function (err, res) {
+ t.equal(err.message, "Cannot find module 'root' from '" + path.resolve(dir) + "'");
+ t.equal(err.code, 'MODULE_NOT_FOUND');
+ });
+
+ resolve('zzz', { basedir: dir, paths: [otherDir] }, function (err, res) {
+ t.equal(err.message, "Cannot find module 'zzz' from '" + path.resolve(dir) + "'");
+ t.equal(err.code, 'MODULE_NOT_FOUND');
+ });
+});
+
+test('incorrect main', function (t) {
+ t.plan(1);
+
+ var resolverDir = path.join(__dirname, 'resolver');
+ var dir = path.join(resolverDir, 'incorrect_main');
+
+ resolve('./incorrect_main', { basedir: resolverDir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'index.js'));
+ });
+});
+
+test('without basedir', function (t) {
+ t.plan(1);
+
+ var dir = path.join(__dirname, 'resolver/without_basedir');
+ var tester = require(path.join(dir, 'main.js'));
+
+ tester(t, function (err, res, pkg) {
+ if (err) {
+ t.fail(err);
+ } else {
+ t.equal(res, path.join(dir, 'node_modules/mymodule.js'));
+ }
+ });
+});
+
+test('#25: node modules with the same name as node stdlib modules', function (t) {
+ t.plan(1);
+
+ var resolverDir = path.join(__dirname, 'resolver/punycode');
+
+ resolve('punycode', { basedir: resolverDir }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(resolverDir, 'node_modules/punycode/index.js'));
+ });
+});
+
+test('#52 - incorrectly resolves module-paths like "./someFolder/" when there is a file of the same name', function (t) {
+ t.plan(2);
+
+ var dir = path.join(__dirname, 'resolver');
+
+ resolve('./foo', { basedir: path.join(dir, 'same_names') }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'same_names/foo.js'));
+ });
+
+ resolve('./foo/', { basedir: path.join(dir, 'same_names') }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(dir, 'same_names/foo/index.js'));
+ });
+});
+
+test('async: #121 - treating an existing file as a dir when no basedir', function (t) {
+ var testFile = path.basename(__filename);
+
+ t.test('sanity check', function (st) {
+ st.plan(1);
+ resolve('./' + testFile, function (err, res, pkg) {
+ if (err) t.fail(err);
+ st.equal(res, __filename, 'sanity check');
+ });
+ });
+
+ t.test('with a fake directory', function (st) {
+ st.plan(4);
+
+ resolve('./' + testFile + '/blah', function (err, res, pkg) {
+ st.ok(err, 'there is an error');
+ st.notOk(res, 'no result');
+
+ st.equal(err && err.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');
+ st.equal(
+ err && err.message,
+ 'Cannot find module \'./' + testFile + '/blah\' from \'' + __dirname + '\'',
+ 'can not find nonexistent module'
+ );
+ st.end();
+ });
+ });
+
+ t.end();
+});
+
+test('async dot main', function (t) {
+ var start = new Date();
+ t.plan(3);
+ resolve('./resolver/dot_main', function (err, ret) {
+ t.notOk(err);
+ t.equal(ret, path.join(__dirname, 'resolver/dot_main/index.js'));
+ t.ok(new Date() - start < 50, 'resolve.sync timedout');
+ t.end();
+ });
+});
+
+test('async dot slash main', function (t) {
+ var start = new Date();
+ t.plan(3);
+ resolve('./resolver/dot_slash_main', function (err, ret) {
+ t.notOk(err);
+ t.equal(ret, path.join(__dirname, 'resolver/dot_slash_main/index.js'));
+ t.ok(new Date() - start < 50, 'resolve.sync timedout');
+ t.end();
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/baz/doom.js b/node_modules/tslint/node_modules/resolve/test/resolver/baz/doom.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/baz/doom.js
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/baz/package.json b/node_modules/tslint/node_modules/resolve/test/resolver/baz/package.json
new file mode 100644
index 000000000..c41e4dbf7
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/baz/package.json
@@ -0,0 +1,3 @@
+{
+ "main": "quux.js"
+}
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/baz/quux.js b/node_modules/tslint/node_modules/resolve/test/resolver/baz/quux.js
new file mode 100644
index 000000000..bd816eaba
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/baz/quux.js
@@ -0,0 +1 @@
+module.exports = 1;
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/cup.coffee b/node_modules/tslint/node_modules/resolve/test/resolver/cup.coffee
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/cup.coffee
@@ -0,0 +1 @@
+
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/dot_main/index.js b/node_modules/tslint/node_modules/resolve/test/resolver/dot_main/index.js
new file mode 100644
index 000000000..bd816eaba
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/dot_main/index.js
@@ -0,0 +1 @@
+module.exports = 1;
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/dot_main/package.json b/node_modules/tslint/node_modules/resolve/test/resolver/dot_main/package.json
new file mode 100644
index 000000000..d7f4fc807
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/dot_main/package.json
@@ -0,0 +1,3 @@
+{
+ "main": "."
+}
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/dot_slash_main/index.js b/node_modules/tslint/node_modules/resolve/test/resolver/dot_slash_main/index.js
new file mode 100644
index 000000000..bd816eaba
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/dot_slash_main/index.js
@@ -0,0 +1 @@
+module.exports = 1;
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/dot_slash_main/package.json b/node_modules/tslint/node_modules/resolve/test/resolver/dot_slash_main/package.json
new file mode 100644
index 000000000..f51287b9d
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/dot_slash_main/package.json
@@ -0,0 +1,3 @@
+{
+ "main": "./"
+}
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/foo.js b/node_modules/tslint/node_modules/resolve/test/resolver/foo.js
new file mode 100644
index 000000000..bd816eaba
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/foo.js
@@ -0,0 +1 @@
+module.exports = 1;
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/incorrect_main/index.js b/node_modules/tslint/node_modules/resolve/test/resolver/incorrect_main/index.js
new file mode 100644
index 000000000..bc1fb0a6f
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/incorrect_main/index.js
@@ -0,0 +1,2 @@
+// this is the actual main file 'index.js', not 'wrong.js' like the package.json would indicate
+module.exports = 1;
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/incorrect_main/package.json b/node_modules/tslint/node_modules/resolve/test/resolver/incorrect_main/package.json
new file mode 100644
index 000000000..b71880417
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/incorrect_main/package.json
@@ -0,0 +1,3 @@
+{
+ "main": "wrong.js"
+}
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/mug.coffee b/node_modules/tslint/node_modules/resolve/test/resolver/mug.coffee
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/mug.coffee
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/mug.js b/node_modules/tslint/node_modules/resolve/test/resolver/mug.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/mug.js
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/other_path/lib/other-lib.js b/node_modules/tslint/node_modules/resolve/test/resolver/other_path/lib/other-lib.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/other_path/lib/other-lib.js
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/other_path/root.js b/node_modules/tslint/node_modules/resolve/test/resolver/other_path/root.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/other_path/root.js
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/quux/foo/index.js b/node_modules/tslint/node_modules/resolve/test/resolver/quux/foo/index.js
new file mode 100644
index 000000000..bd816eaba
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/quux/foo/index.js
@@ -0,0 +1 @@
+module.exports = 1;
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/same_names/foo.js b/node_modules/tslint/node_modules/resolve/test/resolver/same_names/foo.js
new file mode 100644
index 000000000..888cae37a
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/same_names/foo.js
@@ -0,0 +1 @@
+module.exports = 42;
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/same_names/foo/index.js b/node_modules/tslint/node_modules/resolve/test/resolver/same_names/foo/index.js
new file mode 100644
index 000000000..bd816eaba
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/same_names/foo/index.js
@@ -0,0 +1 @@
+module.exports = 1;
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/symlinked/_/symlink_target/.gitkeep b/node_modules/tslint/node_modules/resolve/test/resolver/symlinked/_/symlink_target/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/symlinked/_/symlink_target/.gitkeep
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver/without_basedir/main.js b/node_modules/tslint/node_modules/resolve/test/resolver/without_basedir/main.js
new file mode 100644
index 000000000..5b31975be
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver/without_basedir/main.js
@@ -0,0 +1,5 @@
+var resolve = require('../../../');
+
+module.exports = function (t, cb) {
+ resolve('mymodule', null, cb);
+};
diff --git a/node_modules/tslint/node_modules/resolve/test/resolver_sync.js b/node_modules/tslint/node_modules/resolve/test/resolver_sync.js
new file mode 100644
index 000000000..8e33dca69
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/resolver_sync.js
@@ -0,0 +1,267 @@
+var path = require('path');
+var test = require('tape');
+var resolve = require('../');
+
+test('foo', function (t) {
+ var dir = path.join(__dirname, 'resolver');
+
+ t.equal(
+ resolve.sync('./foo', { basedir: dir }),
+ path.join(dir, 'foo.js')
+ );
+
+ t.equal(
+ resolve.sync('./foo.js', { basedir: dir }),
+ path.join(dir, 'foo.js')
+ );
+
+ t.throws(function () {
+ resolve.sync('foo', { basedir: dir });
+ });
+
+ t.end();
+});
+
+test('bar', function (t) {
+ var dir = path.join(__dirname, 'resolver');
+
+ t.equal(
+ resolve.sync('foo', { basedir: path.join(dir, 'bar') }),
+ path.join(dir, 'bar/node_modules/foo/index.js')
+ );
+ t.end();
+});
+
+test('baz', function (t) {
+ var dir = path.join(__dirname, 'resolver');
+
+ t.equal(
+ resolve.sync('./baz', { basedir: dir }),
+ path.join(dir, 'baz/quux.js')
+ );
+ t.end();
+});
+
+test('biz', function (t) {
+ var dir = path.join(__dirname, 'resolver/biz/node_modules');
+ t.equal(
+ resolve.sync('./grux', { basedir: dir }),
+ path.join(dir, 'grux/index.js')
+ );
+
+ t.equal(
+ resolve.sync('tiv', { basedir: path.join(dir, 'grux') }),
+ path.join(dir, 'tiv/index.js')
+ );
+
+ t.equal(
+ resolve.sync('grux', { basedir: path.join(dir, 'tiv') }),
+ path.join(dir, 'grux/index.js')
+ );
+ t.end();
+});
+
+test('normalize', function (t) {
+ var dir = path.join(__dirname, 'resolver/biz/node_modules/grux');
+ t.equal(
+ resolve.sync('../grux', { basedir: dir }),
+ path.join(dir, 'index.js')
+ );
+ t.end();
+});
+
+test('cup', function (t) {
+ var dir = path.join(__dirname, 'resolver');
+ t.equal(
+ resolve.sync('./cup', {
+ basedir: dir,
+ extensions: ['.js', '.coffee']
+ }),
+ path.join(dir, 'cup.coffee')
+ );
+
+ t.equal(
+ resolve.sync('./cup.coffee', { basedir: dir }),
+ path.join(dir, 'cup.coffee')
+ );
+
+ t.throws(function () {
+ resolve.sync('./cup', {
+ basedir: dir,
+ extensions: ['.js']
+ });
+ });
+
+ t.end();
+});
+
+test('mug', function (t) {
+ var dir = path.join(__dirname, 'resolver');
+ t.equal(
+ resolve.sync('./mug', { basedir: dir }),
+ path.join(dir, 'mug.js')
+ );
+
+ t.equal(
+ resolve.sync('./mug', {
+ basedir: dir,
+ extensions: ['.coffee', '.js']
+ }),
+ path.join(dir, 'mug.coffee')
+ );
+
+ t.equal(
+ resolve.sync('./mug', {
+ basedir: dir,
+ extensions: ['.js', '.coffee']
+ }),
+ path.join(dir, 'mug.js')
+ );
+
+ t.end();
+});
+
+test('other path', function (t) {
+ var resolverDir = path.join(__dirname, 'resolver');
+ var dir = path.join(resolverDir, 'bar');
+ var otherDir = path.join(resolverDir, 'other_path');
+
+ t.equal(
+ resolve.sync('root', {
+ basedir: dir,
+ paths: [otherDir]
+ }),
+ path.join(resolverDir, 'other_path/root.js')
+ );
+
+ t.equal(
+ resolve.sync('lib/other-lib', {
+ basedir: dir,
+ paths: [otherDir]
+ }),
+ path.join(resolverDir, 'other_path/lib/other-lib.js')
+ );
+
+ t.throws(function () {
+ resolve.sync('root', { basedir: dir });
+ });
+
+ t.throws(function () {
+ resolve.sync('zzz', {
+ basedir: dir,
+ paths: [otherDir]
+ });
+ });
+
+ t.end();
+});
+
+test('incorrect main', function (t) {
+ var resolverDir = path.join(__dirname, 'resolver');
+ var dir = path.join(resolverDir, 'incorrect_main');
+
+ t.equal(
+ resolve.sync('./incorrect_main', { basedir: resolverDir }),
+ path.join(dir, 'index.js')
+ );
+
+ t.end();
+});
+
+test('#25: node modules with the same name as node stdlib modules', function (t) {
+ var resolverDir = path.join(__dirname, 'resolver/punycode');
+
+ t.equal(
+ resolve.sync('punycode', { basedir: resolverDir }),
+ path.join(resolverDir, 'node_modules/punycode/index.js')
+ );
+
+ t.end();
+});
+
+var stubStatSync = function stubStatSync(fn) {
+ var fs = require('fs');
+ var statSync = fs.statSync;
+ try {
+ fs.statSync = function () {
+ throw new EvalError('Unknown Error');
+ };
+ return fn();
+ } finally {
+ fs.statSync = statSync;
+ }
+};
+
+test('#79 - re-throw non ENOENT errors from stat', function (t) {
+ var dir = path.join(__dirname, 'resolver');
+
+ stubStatSync(function () {
+ t.throws(function () {
+ resolve.sync('foo', { basedir: dir });
+ }, /Unknown Error/);
+ });
+
+ t.end();
+});
+
+test('#52 - incorrectly resolves module-paths like "./someFolder/" when there is a file of the same name', function (t) {
+ var dir = path.join(__dirname, 'resolver');
+
+ t.equal(
+ resolve.sync('./foo', { basedir: path.join(dir, 'same_names') }),
+ path.join(dir, 'same_names/foo.js')
+ );
+ t.equal(
+ resolve.sync('./foo/', { basedir: path.join(dir, 'same_names') }),
+ path.join(dir, 'same_names/foo/index.js')
+ );
+ t.end();
+});
+
+test('sync: #121 - treating an existing file as a dir when no basedir', function (t) {
+ var testFile = path.basename(__filename);
+
+ t.test('sanity check', function (st) {
+ st.equal(
+ resolve.sync('./' + testFile),
+ __filename,
+ 'sanity check'
+ );
+ st.end();
+ });
+
+ t.test('with a fake directory', function (st) {
+ function run() { return resolve.sync('./' + testFile + '/blah'); }
+
+ st.throws(run, 'throws an error');
+
+ try {
+ run();
+ } catch (e) {
+ st.equal(e.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');
+ st.equal(
+ e.message,
+ 'Cannot find module \'./' + testFile + '/blah\' from \'' + __dirname + '\'',
+ 'can not find nonexistent module'
+ );
+ }
+
+ st.end();
+ });
+
+ t.end();
+});
+
+test('sync dot main', function (t) {
+ var start = new Date();
+ t.equal(resolve.sync('./resolver/dot_main'), path.join(__dirname, 'resolver/dot_main/index.js'));
+ t.ok(new Date() - start < 50, 'resolve.sync timedout');
+ t.end();
+});
+
+test('sync dot slash main', function (t) {
+ var start = new Date();
+ t.equal(resolve.sync('./resolver/dot_slash_main'), path.join(__dirname, 'resolver/dot_slash_main/index.js'));
+ t.ok(new Date() - start < 50, 'resolve.sync timedout');
+ t.end();
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/subdirs.js b/node_modules/tslint/node_modules/resolve/test/subdirs.js
new file mode 100644
index 000000000..b7b8450a9
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/subdirs.js
@@ -0,0 +1,13 @@
+var test = require('tape');
+var resolve = require('../');
+var path = require('path');
+
+test('subdirs', function (t) {
+ t.plan(2);
+
+ var dir = path.join(__dirname, '/subdirs');
+ resolve('a/b/c/x.json', { basedir: dir }, function (err, res) {
+ t.ifError(err);
+ t.equal(res, path.join(dir, 'node_modules/a/b/c/x.json'));
+ });
+});
diff --git a/node_modules/tslint/node_modules/resolve/test/symlinks.js b/node_modules/tslint/node_modules/resolve/test/symlinks.js
new file mode 100644
index 000000000..544a02371
--- /dev/null
+++ b/node_modules/tslint/node_modules/resolve/test/symlinks.js
@@ -0,0 +1,54 @@
+var path = require('path');
+var fs = require('fs');
+var test = require('tape');
+var resolve = require('../');
+
+var symlinkDir = path.join(__dirname, 'resolver', 'symlinked', 'symlink');
+try {
+ fs.unlinkSync(symlinkDir);
+} catch (err) {}
+try {
+ fs.symlinkSync('./_/symlink_target', symlinkDir, 'dir');
+} catch (err) {
+ // if fails then it is probably on Windows and lets try to create a junction
+ fs.symlinkSync(path.join(__dirname, 'resolver', 'symlinked', '_', 'symlink_target') + '\\', symlinkDir, 'junction');
+}
+
+test('symlink', function (t) {
+ t.plan(1);
+
+ resolve('foo', { basedir: symlinkDir, preserveSymlinks: false }, function (err, res, pkg) {
+ if (err) t.fail(err);
+ t.equal(res, path.join(__dirname, 'resolver', 'symlinked', '_', 'node_modules', 'foo.js'));
+ });
+});
+
+test('sync symlink when preserveSymlinks = true', function (t) {
+ t.plan(4);
+
+ resolve('foo', { basedir: symlinkDir }, function (err, res, pkg) {
+ t.ok(err, 'there is an error');
+ t.notOk(res, 'no result');
+
+ t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');
+ t.equal(
+ err && err.message,
+ 'Cannot find module \'foo\' from \'' + symlinkDir + '\'',
+ 'can not find nonexistent module'
+ );
+ });
+});
+
+test('sync symlink', function (t) {
+ var start = new Date();
+ t.equal(resolve.sync('foo', { basedir: symlinkDir, preserveSymlinks: false }), path.join(__dirname, 'resolver', 'symlinked', '_', 'node_modules', 'foo.js'));
+ t.ok(new Date() - start < 50, 'resolve.sync timedout');
+ t.end();
+});
+
+test('sync symlink when preserveSymlinks = true', function (t) {
+ t.throws(function () {
+ resolve.sync('foo', { basedir: symlinkDir });
+ }, /Cannot find module 'foo'/);
+ t.end();
+});
diff --git a/node_modules/tslint/package.json b/node_modules/tslint/package.json
index 1031df0b2..2b32392eb 100644
--- a/node_modules/tslint/package.json
+++ b/node_modules/tslint/package.json
@@ -1,6 +1,6 @@
{
"name": "tslint",
- "version": "5.7.0",
+ "version": "5.8.0",
"description": "An extensible static analysis linter for the TypeScript language",
"bin": {
"tslint": "./bin/tslint"
@@ -38,7 +38,8 @@
},
"dependencies": {
"babel-code-frame": "^6.22.0",
- "colors": "^1.1.2",
+ "builtin-modules": "^1.1.1",
+ "chalk": "^2.1.0",
"commander": "^2.9.0",
"diff": "^3.2.0",
"glob": "^7.1.1",
@@ -46,7 +47,7 @@
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.7.1",
- "tsutils": "^2.8.1"
+ "tsutils": "^2.12.1"
},
"peerDependencies": {
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev"
@@ -54,7 +55,7 @@
"devDependencies": {
"@types/babel-code-frame": "^6.20.0",
"@types/chai": "^3.5.0",
- "@types/colors": "^1.1.3",
+ "@types/chalk": "^0.4.31",
"@types/commander": "^2.9.0",
"@types/diff": "^3.2.0",
"@types/glob": "^5.0.30",
@@ -63,6 +64,7 @@
"@types/mocha": "^2.2.35",
"@types/node": "^7.0.29",
"@types/resolve": "^0.0.4",
+ "@types/rimraf": "^2.0.2",
"@types/semver": "^5.3.30",
"chai": "^3.5.0",
"github": "^8.2.1",
@@ -72,7 +74,8 @@
"npm-run-all": "^4.0.2",
"nyc": "^10.2.0",
"rimraf": "^2.5.4",
- "tslint": "^5.6.0",
+ "ts-node": "^3.3.0",
+ "tslint": "^5.7.0",
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative",
"typescript": "~2.5.1"
},