Deployed the page to Github Pages.

This commit is contained in:
Batuhan Berk Başoğlu 2024-11-03 21:30:09 -05:00
parent 1d79754e93
commit 2c89899458
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
62797 changed files with 6551425 additions and 15279 deletions

5
node_modules/tslint/.prettierrc generated vendored Normal file
View file

@ -0,0 +1,5 @@
{
"printWidth": 100,
"tabWidth": 4,
"trailingComma": "all"
}

2428
node_modules/tslint/CHANGELOG.md generated vendored Normal file

File diff suppressed because it is too large Load diff

201
node_modules/tslint/LICENSE generated vendored Normal file
View file

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
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.

75
node_modules/tslint/README.md generated vendored Normal file
View file

@ -0,0 +1,75 @@
[![NPM version](https://badge.fury.io/js/tslint.svg)](https://badge.fury.io/js/tslint)
[![Downloads](https://img.shields.io/npm/dm/tslint.svg)](https://npmjs.org/package/tslint)
[![Dependency Status](https://david-dm.org/palantir/tslint.svg)](https://david-dm.org/palantir/tslint)
[![devDependency Status](https://david-dm.org/palantir/tslint/dev-status.svg)](https://david-dm.org/palantir/tslint/?type=dev)
[![peerDependency Status](https://david-dm.org/palantir/tslint/peer-status.svg)](https://david-dm.org/palantir/tslint/?type=peer)
[![Circle CI](https://circleci.com/gh/palantir/tslint.svg?style=svg)](https://circleci.com/gh/palantir/tslint)
# TSLint
:warning: __TSLint is deprecated.__
> See this issue for more details: [Roadmap: TSLint → ESLint](https://github.com/palantir/tslint/issues/4534). If you're interested in helping with the TSLint/ESLint migration, please check out our [OSS Fellowship](https://medium.com/palantir/fellowships-for-open-source-developers-3892e6b75ee1) program.
TSLint is an extensible static analysis tool that checks [TypeScript](https://github.com/Microsoft/TypeScript) code for readability, maintainability, and functionality errors. It is widely supported across modern editors & build systems and can be customized with your own lint rules, configurations, and formatters.
TSLint currently supports:
- an extensive set of core rules
- custom lint rules
- custom formatters (failure reporters)
- inline disabling and enabling of rules with comment flags in source code
- 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](https://www.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=ms-vscode.vscode-typescript-tslint-plugin) (alternative: use [this extension](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) for TS <3.2), [WebStorm](https://www.jetbrains.com/webstorm/help/tslint.html) and [more](https://palantir.github.io/tslint/usage/third-party-tools/)
## Installation & Usage
Please refer to the full installation & usage documentation on the [TSLint website](https://palantir.github.io/tslint/). There, you'll find information about
- [configuration](https://palantir.github.io/tslint/usage/configuration/),
- [core rules](https://palantir.github.io/tslint/rules/),
- [core formatters](https://palantir.github.io/tslint/formatters/), and
- [customization of TSLint](https://palantir.github.io/tslint/develop/custom-rules/).
- [inline disabling and enabling of rules with comment flags](https://palantir.github.io/tslint/usage/rule-flags/)
## TSLint Playground
There is a sandbox environment for TSLint at [palantir.github.io/tslint-playground](https://palantir.github.io/tslint-playground/), which can be used to test rules and see how TSLint works. Issues can be filed against `tslint-playground` [here](https://github.com/palantir/tslint-playground).
## Custom Rules & Plugins
#### Custom rule sets from Palantir
- [tslint-react](https://github.com/palantir/tslint-react) - Lint rules related to React & JSX.
- [tslint-blueprint](https://github.com/palantir/tslint-blueprint) - Lint rules to enforce best practices with [blueprintjs libraries](https://github.com/palantir/blueprint)
#### Custom rule sets from the community
If we don't have all the rules you're looking for, you can either write your own [custom rules](https://palantir.github.io/tslint/develop/custom-rules/) or use rules implementations developed by the community. The repos below are a good source of custom rules:
- [ESLint rules for TSLint](https://github.com/buzinas/tslint-eslint-rules) - Improve your TSLint with the missing ESLint Rules
- [tslint-microsoft-contrib](https://github.com/Microsoft/tslint-microsoft-contrib) - A set of TSLint rules used on some Microsoft projects
- [codelyzer](https://github.com/mgechev/codelyzer) - A set of tslint rules for static code analysis of Angular TypeScript projects
- [vrsource-tslint-rules](https://github.com/vrsource/vrsource-tslint-rules)
- [tslint-immutable](https://github.com/jonaskello/tslint-immutable) - TSLint rules to disable mutation in TypeScript
- [tslint-consistent-codestyle](https://github.com/ajafff/tslint-consistent-codestyle) - TSLint rules to enforce consistent code style in TypeScript
- [tslint-sonarts](https://github.com/SonarSource/SonarTS) - Bug-finding rules based on advanced code models to spot hard to find errors in TypeScript
- [tslint-clean-code](https://github.com/Glavin001/tslint-clean-code) - A set of TSLint rules inspired by the Clean Code handbook
- [rxjs-tslint-rules](https://github.com/cartant/rxjs-tslint-rules) - TSLint rules for RxJS
## Development
Prerequisites:
- `node` v7+
- `yarn` v1.0+
#### Quick Start
```bash
git clone git@github.com:palantir/tslint.git --config core.autocrlf=input --config core.eol=lf
yarn
yarn compile
yarn test
```

3
node_modules/tslint/bin/tslint generated vendored Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env node
require("../lib/tslintCli");

263
node_modules/tslint/lib/configs/all.d.ts generated vendored Normal file
View file

@ -0,0 +1,263 @@
/**
* @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.
*/
export declare const rules: {
"adjacent-overload-signatures": boolean;
"ban-types": {
options: string[][];
};
"ban-ts-ignore": boolean;
"member-access": {
options: string[];
};
"member-ordering": {
options: {
order: string;
alphabetize: boolean;
};
};
"no-any": boolean;
"no-empty-interface": boolean;
"no-for-in": boolean;
"no-import-side-effect": boolean;
"no-inferrable-types": {
options: string[];
};
"no-internal-module": boolean;
"no-magic-numbers": boolean;
"no-namespace": boolean;
"no-non-null-assertion": boolean;
"no-reference": boolean;
"no-restricted-globals": boolean;
"no-this-assignment": boolean;
"no-var-requires": boolean;
"only-arrow-functions": boolean;
"prefer-for-of": boolean;
"prefer-readonly": boolean;
"promise-function-async": boolean;
typedef: {
options: string[];
};
"typedef-whitespace": {
options: {
"call-signature": string;
"index-signature": string;
parameter: string;
"property-declaration": string;
"variable-declaration": string;
}[];
};
"unified-signatures": boolean;
"await-promise": boolean;
"ban-comma-operator": boolean;
curly: boolean;
forin: boolean;
"function-constructor": boolean;
"label-position": boolean;
"no-arg": boolean;
"no-async-without-await": boolean;
"no-bitwise": boolean;
"no-conditional-assignment": boolean;
"no-console": boolean;
"no-construct": boolean;
"no-debugger": boolean;
"no-duplicate-super": boolean;
"no-duplicate-switch-case": boolean;
"no-duplicate-variable": {
options: string[];
};
"no-dynamic-delete": 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-null-undefined-union": boolean;
"no-object-literal-type-assertion": boolean;
"no-promise-as-boolean": 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-tautology-expression": boolean;
"no-unbound-method": boolean;
"no-unnecessary-class": {
options: string[];
};
"no-unsafe-any": boolean;
"no-unsafe-finally": boolean;
"no-unused-expression": boolean;
"no-var-keyword": boolean;
"no-void-expression": boolean;
"prefer-conditional-expression": boolean;
radix: boolean;
"restrict-plus-operands": boolean;
"static-this": boolean;
"strict-boolean-expressions": boolean;
"strict-string-expressions": boolean;
"strict-comparisons": boolean;
"strict-type-predicates": boolean;
"switch-default": boolean;
"triple-equals": boolean;
"unnecessary-constructor": boolean;
"use-default-type-parameter": boolean;
"use-isnan": boolean;
"cyclomatic-complexity": boolean;
eofline: boolean;
indent: {
options: string[];
};
"invalid-void": boolean;
"linebreak-style": {
options: string;
};
"max-classes-per-file": {
options: number;
};
"max-file-line-count": {
options: number;
};
"max-line-length": {
options: {
limit: number;
};
};
"no-default-export": boolean;
"no-default-import": boolean;
"no-duplicate-imports": boolean;
"no-irregular-whitespace": boolean;
"no-mergeable-namespace": boolean;
"no-parameter-reassignment": boolean;
"no-require-imports": boolean;
"no-trailing-whitespace": boolean;
"object-literal-sort-keys": boolean;
"prefer-const": boolean;
"trailing-comma": {
options: {
esSpecCompliant: boolean;
multiline: string;
singleline: string;
};
};
align: {
options: string[];
};
"array-type": {
options: string;
};
"arrow-parens": boolean;
"arrow-return-shorthand": {
options: string;
};
"binary-expression-operand-order": boolean;
"callable-types": boolean;
"class-name": boolean;
"comment-format": {
options: string[];
};
"comment-type": {
options: string[];
};
"completed-docs": boolean;
deprecation: boolean;
encoding: boolean;
"file-name-casing": {
options: string;
};
"import-spacing": boolean;
"increment-decrement": boolean;
"interface-name": boolean;
"interface-over-type-literal": boolean;
"jsdoc-format": {
options: string;
};
"match-default-export-name": boolean;
"new-parens": boolean;
"newline-before-return": boolean;
"newline-per-chained-call": boolean;
"no-angle-bracket-type-assertion": boolean;
"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;
"no-unnecessary-qualifier": boolean;
"no-unnecessary-type-assertion": boolean;
"number-literal-format": boolean;
"object-literal-key-quotes": {
options: string;
};
"object-literal-shorthand": boolean;
"one-line": {
options: string[];
};
"one-variable-per-declaration": boolean;
"ordered-imports": {
options: {
"grouped-imports": boolean;
"import-sources-order": string;
"named-imports-order": string;
"module-source-path": string;
};
};
"prefer-function-over-method": boolean;
"prefer-method-signature": boolean;
"prefer-object-spread": boolean;
"prefer-switch": boolean;
"prefer-template": boolean;
"prefer-while": boolean;
quotemark: {
options: string[];
};
"return-undefined": boolean;
semicolon: {
options: string[];
};
"space-before-function-paren": {
options: {
anonymous: string;
asyncArrow: string;
constructor: string;
method: string;
named: string;
};
};
"space-within-parens": {
options: number;
};
"switch-final-break": boolean;
"type-literal-delimiter": boolean;
"unnecessary-bind": boolean;
"unnecessary-else": boolean;
"variable-name": {
options: string[];
};
whitespace: {
options: string[];
};
};
export declare const RULES_EXCLUDED_FROM_ALL_CONFIG: string[];
export declare const jsRules: {
[key: string]: any;
};

306
node_modules/tslint/lib/configs/all.js generated vendored Normal file
View file

@ -0,0 +1,306 @@
"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 });
exports.jsRules = exports.RULES_EXCLUDED_FROM_ALL_CONFIG = exports.rules = void 0;
var path_1 = require("path");
var ruleLoader_1 = require("../ruleLoader");
// tslint:disable object-literal-sort-keys
// tslint:disable object-literal-key-quotes
exports.rules = {
// TypeScript Specific
"adjacent-overload-signatures": true,
"ban-types": {
options: [
["Object", "Avoid using the `Object` type. Did you mean `object`?"],
[
"Function",
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
],
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
["Number", "Avoid using the `Number` type. Did you mean `number`?"],
["String", "Avoid using the `String` type. Did you mean `string`?"],
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"],
],
},
"ban-ts-ignore": true,
"member-access": {
options: ["check-accessor", "check-constructor", "check-parameter-property"],
},
"member-ordering": {
options: {
order: "statics-first",
alphabetize: true,
},
},
"no-any": true,
"no-empty-interface": true,
"no-for-in": true,
"no-import-side-effect": true,
// Technically this is not the strictest setting, but don't want to conflict with "typedef"
"no-inferrable-types": { options: ["ignore-params"] },
"no-internal-module": true,
"no-magic-numbers": true,
"no-namespace": true,
"no-non-null-assertion": true,
"no-reference": true,
"no-restricted-globals": true,
"no-this-assignment": true,
"no-var-requires": true,
"only-arrow-functions": true,
"prefer-for-of": true,
"prefer-readonly": true,
"promise-function-async": true,
typedef: {
options: [
"call-signature",
"arrow-call-signature",
"parameter",
"arrow-parameter",
"property-declaration",
"variable-declaration",
"member-variable-declaration",
],
},
"typedef-whitespace": {
options: [
{
"call-signature": "nospace",
"index-signature": "nospace",
parameter: "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace",
},
{
"call-signature": "onespace",
"index-signature": "onespace",
parameter: "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace",
},
],
},
"unified-signatures": true,
// Functionality
"await-promise": true,
// "ban": no sensible default
"ban-comma-operator": true,
curly: true,
forin: true,
"function-constructor": true,
// "import-blacklist": no sensible default
"label-position": true,
"no-arg": true,
"no-async-without-await": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-console": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-duplicate-switch-case": true,
"no-duplicate-variable": { options: ["check-parameters"] },
"no-dynamic-delete": true,
"no-empty": true,
"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-null-undefined-union": true,
"no-object-literal-type-assertion": true,
"no-promise-as-boolean": 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-tautology-expression": true,
"no-unbound-method": true,
"no-unnecessary-class": { options: ["allow-empty-class"] },
"no-unsafe-any": true,
"no-unsafe-finally": true,
"no-unused-expression": true,
// "no-unused-variable" - deprecated in #3919
// "no-use-before-declare" - deprecated in #4802,
"no-var-keyword": true,
"no-void-expression": true,
"prefer-conditional-expression": true,
radix: true,
"restrict-plus-operands": true,
"static-this": true,
"strict-boolean-expressions": true,
"strict-string-expressions": true,
"strict-comparisons": true,
"strict-type-predicates": true,
"switch-default": true,
"triple-equals": true,
"unnecessary-constructor": true,
"use-default-type-parameter": true,
"use-isnan": true,
// Maintainability
"cyclomatic-complexity": true,
eofline: true,
indent: { options: ["spaces"] },
"invalid-void": true,
"linebreak-style": { options: "LF" },
"max-classes-per-file": { options: 1 },
"max-file-line-count": { options: 1000 },
"max-line-length": {
options: { limit: 120 },
},
"no-default-export": true,
"no-default-import": true,
"no-duplicate-imports": true,
"no-irregular-whitespace": true,
"no-mergeable-namespace": true,
"no-parameter-reassignment": true,
"no-require-imports": true,
"no-trailing-whitespace": true,
"object-literal-sort-keys": true,
"prefer-const": true,
"trailing-comma": {
options: {
esSpecCompliant: true,
multiline: "always",
singleline: "never",
},
},
// Style
align: {
options: ["parameters", "arguments", "statements", "elements", "members"],
},
"array-type": { options: "array-simple" },
"arrow-parens": true,
"arrow-return-shorthand": { options: "multiline" },
"binary-expression-operand-order": true,
"callable-types": true,
"class-name": true,
"comment-format": { options: ["check-space", "check-uppercase"] },
"comment-type": { options: ["singleline", "multiline", "doc", "directive"] },
"completed-docs": true,
deprecation: true,
encoding: true,
"file-name-casing": { options: "camel-case" },
"import-spacing": true,
"increment-decrement": true,
"interface-name": true,
"interface-over-type-literal": true,
"jsdoc-format": { options: "check-multiline-start" },
"match-default-export-name": true,
"new-parens": true,
"newline-before-return": true,
"newline-per-chained-call": true,
"no-angle-bracket-type-assertion": true,
"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,
"no-unnecessary-qualifier": true,
"no-unnecessary-type-assertion": true,
"number-literal-format": true,
"object-literal-key-quotes": { options: "consistent-as-needed" },
"object-literal-shorthand": true,
"one-line": {
options: [
"check-catch",
"check-else",
"check-finally",
"check-open-brace",
"check-whitespace",
],
},
"one-variable-per-declaration": true,
"ordered-imports": {
options: {
"grouped-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,
"prefer-object-spread": true,
"prefer-switch": true,
"prefer-template": true,
"prefer-while": true,
quotemark: {
options: ["double", "avoid-escape", "avoid-template"],
},
"return-undefined": true,
semicolon: { options: ["always"] },
"space-before-function-paren": {
options: {
anonymous: "never",
asyncArrow: "always",
constructor: "never",
method: "never",
named: "never",
},
},
"space-within-parens": { options: 0 },
"switch-final-break": true,
"type-literal-delimiter": true,
"unnecessary-bind": true,
"unnecessary-else": true,
"variable-name": { options: ["ban-keywords", "check-format", "require-const-for-all-caps"] },
whitespace: {
options: [
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-type",
"check-typecast",
"check-preblock",
"check-type-operator",
"check-rest-spread",
],
},
};
exports.RULES_EXCLUDED_FROM_ALL_CONFIG = [
"ban",
"fileHeader",
"importBlacklist",
"noInvalidThis",
"noSwitchCaseFallThrough",
"typeofCompare",
"noUnusedVariable",
"noUseBeforeDeclare",
];
// Exclude typescript-only rules from jsRules, otherwise it's identical.
exports.jsRules = {};
for (var _i = 0, _a = Object.keys(exports.rules); _i < _a.length; _i++) {
var key = _a[_i];
var Rule = ruleLoader_1.findRule(key, path_1.join(__dirname, "..", "rules"));
if (Rule === undefined) {
throw new Error("Couldn't find rule '" + key + "'.");
}
if (!Rule.metadata.typescriptOnly) {
exports.jsRules[key] = exports.rules[key];
}
}

49
node_modules/tslint/lib/configs/latest.d.ts generated vendored Normal file
View file

@ -0,0 +1,49 @@
/**
* @license
* Copyright 2018 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.
*/
export declare const rules: {
align: {
options: string[];
};
"no-invalid-template-strings": boolean;
"no-sparse-arrays": boolean;
"no-object-literal-type-assertion": boolean;
"prefer-conditional-expression": boolean;
"prefer-object-spread": boolean;
"no-duplicate-variable": {
options: string;
};
"no-this-assignment": boolean;
"no-duplicate-imports": boolean;
"space-within-parens": {
options: number;
};
"no-submodule-imports": boolean;
whitespace: {
options: string[];
};
"ban-comma-operator": boolean;
"jsdoc-format": {
options: string;
};
"no-duplicate-switch-case": boolean;
"no-implicit-dependencies": boolean;
"no-return-await": boolean;
"function-constructor": boolean;
"unnecessary-bind": boolean;
};
declare const xtends = "tslint:recommended";
export { xtends as extends };

68
node_modules/tslint/lib/configs/latest.js generated vendored Normal file
View file

@ -0,0 +1,68 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.extends = exports.rules = void 0;
// tslint:disable object-literal-sort-keys
// tslint:disable:object-literal-key-quotes
exports.rules = {
// added in v5.1
align: {
options: ["parameters", "statements", "members"],
},
"no-invalid-template-strings": true,
"no-sparse-arrays": true,
// added in v5.2
"no-object-literal-type-assertion": true,
// added in v5.3
"prefer-conditional-expression": true,
"prefer-object-spread": true,
// added in v5.4
"no-duplicate-variable": { options: "check-parameters" },
// added in v5.5
"no-this-assignment": true,
// added in v5.6
"no-duplicate-imports": true,
"space-within-parens": { options: 0 },
"no-submodule-imports": true,
// added in v5.7
whitespace: {
options: [
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type",
"check-typecast",
"check-type-operator",
"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,
// added in v5.12
"function-constructor": true,
"unnecessary-bind": true,
};
// tslint:enable object-literal-sort-keys
// work around "extends" being a keyword
var xtends = "tslint:recommended";
exports.extends = xtends;

125
node_modules/tslint/lib/configs/recommended.d.ts generated vendored Normal file
View file

@ -0,0 +1,125 @@
/**
* @license
* Copyright 2018 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.
*/
export declare const rules: {
"adjacent-overload-signatures": boolean;
"array-type": {
options: string[];
};
"ban-types": {
options: string[][];
};
"callable-types": boolean;
"class-name": boolean;
"comment-format": {
options: string[];
};
"cyclomatic-complexity": boolean;
forin: boolean;
"jsdoc-format": boolean;
"label-position": boolean;
"max-classes-per-file": {
options: number;
};
"new-parens": boolean;
"no-angle-bracket-type-assertion": boolean;
"no-any": boolean;
"no-arg": boolean;
"no-bitwise": boolean;
"no-conditional-assignment": boolean;
"no-console": boolean;
"no-construct": boolean;
"no-debugger": boolean;
"no-duplicate-super": boolean;
"no-empty": boolean;
"no-empty-interface": boolean;
"no-eval": boolean;
"no-internal-module": boolean;
"no-invalid-this": boolean;
"no-misused-new": boolean;
"no-namespace": boolean;
"no-parameter-properties": boolean;
"no-reference": boolean;
"no-reference-import": boolean;
"no-shadowed-variable": boolean;
"no-string-literal": boolean;
"no-string-throw": boolean;
"no-switch-case-fall-through": boolean;
"no-trailing-whitespace": boolean;
"no-unnecessary-initializer": boolean;
"no-unsafe-finally": boolean;
"no-unused-expression": boolean;
"no-use-before-declare": boolean;
"no-var-keyword": boolean;
"no-var-requires": boolean;
"object-literal-shorthand": boolean;
"one-variable-per-declaration": {
options: string[];
};
"only-arrow-functions": {
options: string[];
};
"prefer-const": boolean;
"prefer-for-of": boolean;
radix: boolean;
"triple-equals": {
options: string[];
};
typedef: boolean;
"typeof-compare": boolean;
"unified-signatures": boolean;
"use-isnan": boolean;
"variable-name": {
options: string[];
};
};
export declare const jsRules: {
"class-name": boolean;
forin: boolean;
"import-spacing": boolean;
"jsdoc-format": boolean;
"label-position": boolean;
"new-parens": boolean;
"no-arg": boolean;
"no-bitwise": boolean;
"no-conditional-assignment": boolean;
"no-consecutive-blank-lines": boolean;
"no-console": boolean;
"no-construct": boolean;
"no-debugger": boolean;
"no-duplicate-super": boolean;
"no-duplicate-variable": boolean;
"no-empty": boolean;
"no-eval": boolean;
"no-reference": boolean;
"no-shadowed-variable": boolean;
"no-string-literal": boolean;
"no-string-throw": boolean;
"no-switch-case-fall-through": boolean;
"no-unused-expression": boolean;
"no-use-before-declare": boolean;
"one-variable-per-declaration": {
options: string[];
};
radix: boolean;
"triple-equals": {
options: string[];
};
"use-isnan": boolean;
"variable-name": {
options: string[];
};
};

129
node_modules/tslint/lib/configs/recommended.js generated vendored Normal file
View file

@ -0,0 +1,129 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.jsRules = exports.rules = void 0;
exports.rules = {
"adjacent-overload-signatures": true,
"array-type": {
options: ["array"],
},
"ban-types": {
options: [
["Object", "Avoid using the `Object` type. Did you mean `object`?"],
[
"Function",
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
],
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
["Number", "Avoid using the `Number` type. Did you mean `number`?"],
["String", "Avoid using the `String` type. Did you mean `string`?"],
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"],
],
},
"callable-types": true,
"class-name": true,
"comment-format": {
options: ["check-space"],
},
"cyclomatic-complexity": false,
forin: true,
"jsdoc-format": true,
"label-position": true,
"max-classes-per-file": { options: 1 },
"new-parens": true,
"no-angle-bracket-type-assertion": true,
"no-any": false,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-console": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-empty": true,
"no-empty-interface": true,
"no-eval": true,
"no-internal-module": true,
"no-invalid-this": false,
"no-misused-new": true,
"no-namespace": true,
"no-parameter-properties": false,
"no-reference": true,
"no-reference-import": true,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-string-throw": true,
"no-switch-case-fall-through": false,
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unsafe-finally": true,
"no-unused-expression": true,
"no-use-before-declare": false,
"no-var-keyword": true,
"no-var-requires": true,
"object-literal-shorthand": true,
"one-variable-per-declaration": { options: ["ignore-for-loop"] },
"only-arrow-functions": {
options: ["allow-declarations", "allow-named-functions"],
},
"prefer-const": true,
"prefer-for-of": true,
radix: true,
"triple-equals": { options: ["allow-null-check"] },
typedef: false,
"typeof-compare": false,
"unified-signatures": true,
"use-isnan": true,
"variable-name": {
options: ["allow-leading-underscore", "ban-keywords", "check-format", "allow-pascal-case"],
},
};
exports.jsRules = {
"class-name": true,
forin: true,
"import-spacing": true,
"jsdoc-format": true,
"label-position": true,
"new-parens": true,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-consecutive-blank-lines": true,
"no-console": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-reference": true,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-string-throw": true,
"no-switch-case-fall-through": false,
"no-unused-expression": true,
// disable this rule as it is very heavy performance-wise and not that useful
"no-use-before-declare": false,
"one-variable-per-declaration": { options: ["ignore-for-loop"] },
radix: true,
"triple-equals": { options: ["allow-null-check"] },
"use-isnan": true,
"variable-name": {
options: ["allow-leading-underscore", "ban-keywords", "check-format", "allow-pascal-case"],
},
};

140
node_modules/tslint/lib/configuration.d.ts generated vendored Normal file
View file

@ -0,0 +1,140 @@
/**
* @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 { IOptions, RuleSeverity } from "./language/rule/rule";
export interface IConfigurationFile {
/**
* @deprecated property is never set
*
* The severity that is applied to rules in this config file as well as rules
* in any inherited config files which have their severity set to "default".
* Not inherited.
*/
defaultSeverity?: RuleSeverity;
/**
* An array of config files whose rules are inherited by this config file.
*/
extends: string[];
/**
* Rules that are used to lint to JavaScript files.
*/
jsRules: Map<string, Partial<IOptions>>;
/**
* A subset of the CLI options.
*/
linterOptions?: Partial<{
exclude: string[];
format: string;
}>;
/**
* Directories containing custom rules. Resolved using node module semantics.
*/
rulesDirectory: string[];
/**
* Rules that are used to lint TypeScript files.
*/
rules: Map<string, Partial<IOptions>>;
}
export interface IConfigurationLoadResult {
path?: string;
results?: IConfigurationFile;
}
export declare const JSON_CONFIG_FILENAME = "tslint.json";
/** @deprecated use `JSON_CONFIG_FILENAME` or `CONFIG_FILENAMES` instead. */
export declare const CONFIG_FILENAME = "tslint.json";
export declare const CONFIG_FILENAMES: string[];
export declare const DEFAULT_CONFIG: IConfigurationFile;
export declare const EMPTY_CONFIG: IConfigurationFile;
/**
* 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
*/
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.
* @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 or tslint.yml or tslint.yaml file
* 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:
* '/path/to/config' will be treated as an absolute path
* './path/to/config' will be treated as a relative path
* 'path/to/config' will attempt to load a to/config file inside a node module named path
* @param configFilePath The configuration to load
* @param originalFilePath (deprecated) The entry point configuration file
* @returns a configuration object for TSLint loaded from the file at configFilePath
*/
export declare function loadConfigurationFromPath(configFilePath?: string, _originalFilePath?: string): IConfigurationFile;
/** Reads the configuration file from disk and parses it as raw JSON, YAML or JS depending on the extension. */
export declare function readConfigurationFile(filepath: string): RawConfigFile;
export declare function extendConfigurationFile(targetConfig: IConfigurationFile, nextConfigSource: IConfigurationFile): IConfigurationFile;
/**
* returns the absolute path (contrary to what the name implies)
*
* @deprecated use `path.resolve` instead
*/
export declare function getRelativePath(directory?: string | null, relativeTo?: string): string | undefined;
export declare function useAsPath(directory: string): boolean;
/**
* @param directories A path(s) to a directory of custom rules
* @param relativeTo A path that directories provided are relative to.
* For example, if the directories come from a tslint.json file, this path
* should be the path to the tslint.json file.
* @return An array of absolute paths to directories potentially containing rules
*/
export declare function getRulesDirectories(directories?: string | string[], relativeTo?: string): string[];
export interface RawConfigFile {
extends?: string | string[];
linterOptions?: IConfigurationFile["linterOptions"];
rulesDirectory?: string | string[];
defaultSeverity?: string;
rules?: RawRulesConfig;
jsRules?: RawRulesConfig | boolean;
}
export interface RawRulesConfig {
[key: string]: RawRuleConfig;
}
export declare type RawRuleConfig = null | undefined | boolean | any[] | {
severity?: RuleSeverity | "warn" | "none" | "default";
options?: any;
};
/**
* Parses a config file and normalizes legacy config settings.
* If `configFileDir` and `readConfig` are provided, this function will load all base configs and reduce them to the final configuration.
*
* @param configFile The raw object read from the JSON of a config file
* @param configFileDir The directory of the config file
* @param readConfig Will be used to load all base configurations while parsing. The function is called with the resolved path.
*/
export declare function parseConfigFile(configFile: RawConfigFile, configFileDir?: string, readConfig?: (path: string) => RawConfigFile): IConfigurationFile;
/**
* Fills in default values for `IOption` properties and outputs an array of `IOption`
*/
export declare function convertRuleOptions(ruleConfiguration: Map<string, Partial<IOptions>>): IOptions[];
export declare function isFileExcluded(filepath: string, configFile?: IConfigurationFile): boolean;
export declare function stringifyConfiguration(configFile: IConfigurationFile): string;

517
node_modules/tslint/lib/configuration.js generated vendored Normal file
View file

@ -0,0 +1,517 @@
"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 });
exports.stringifyConfiguration = exports.isFileExcluded = exports.convertRuleOptions = exports.parseConfigFile = exports.getRulesDirectories = exports.useAsPath = exports.getRelativePath = exports.extendConfigurationFile = exports.readConfigurationFile = exports.loadConfigurationFromPath = exports.findConfigurationPath = exports.findConfiguration = exports.EMPTY_CONFIG = exports.DEFAULT_CONFIG = exports.CONFIG_FILENAMES = exports.CONFIG_FILENAME = exports.JSON_CONFIG_FILENAME = void 0;
var tslib_1 = require("tslib");
var fs = require("fs");
var yaml = require("js-yaml");
var minimatch_1 = require("minimatch");
var os = require("os");
var path = require("path");
var error_1 = require("./error");
var ruleLoader_1 = require("./ruleLoader");
var utils_1 = require("./utils");
// Note: eslint prefers yaml over json, while tslint prefers json over yaml
// for backward-compatibility.
exports.JSON_CONFIG_FILENAME = "tslint.json";
/** @deprecated use `JSON_CONFIG_FILENAME` or `CONFIG_FILENAMES` instead. */
exports.CONFIG_FILENAME = exports.JSON_CONFIG_FILENAME;
exports.CONFIG_FILENAMES = [exports.JSON_CONFIG_FILENAME, "tslint.yaml", "tslint.yml"];
exports.DEFAULT_CONFIG = {
defaultSeverity: "error",
extends: ["tslint:recommended"],
jsRules: new Map(),
rules: new Map(),
rulesDirectory: [],
};
exports.EMPTY_CONFIG = {
defaultSeverity: "error",
extends: [],
jsRules: new Map(),
rules: new Map(),
rulesDirectory: [],
};
var BUILT_IN_CONFIG = /^tslint:(.*)$/;
function findConfiguration(configFile, inputFilePath) {
var configPath = findConfigurationPath(configFile, inputFilePath);
var loadResult = { path: configPath };
try {
loadResult.results = loadConfigurationFromPath(configPath);
return loadResult;
}
catch (error) {
throw new error_1.FatalError("Failed to load " + configPath + ": " + error.message, error);
}
}
exports.findConfiguration = findConfiguration;
function findConfigurationPath(suppliedConfigFilePath, inputFilePath) {
if (suppliedConfigFilePath != undefined) {
if (!fs.existsSync(suppliedConfigFilePath)) {
throw new error_1.FatalError("Could not find config file at: " + path.resolve(suppliedConfigFilePath));
}
else {
return path.resolve(suppliedConfigFilePath);
}
}
else {
// convert to dir if it's a file or doesn't exist
var useDirName = false;
try {
var stats = fs.statSync(inputFilePath);
if (stats.isFile()) {
useDirName = true;
}
}
catch (e) {
// throws if file doesn't exist
useDirName = true;
}
if (useDirName) {
inputFilePath = path.dirname(inputFilePath);
}
// search for tslint.json from input file location
var configFilePath = findup(exports.CONFIG_FILENAMES, path.resolve(inputFilePath));
if (configFilePath !== undefined) {
return configFilePath;
}
// search for tslint.json in home directory
var homeDir = os.homedir();
for (var _i = 0, CONFIG_FILENAMES_1 = exports.CONFIG_FILENAMES; _i < CONFIG_FILENAMES_1.length; _i++) {
var configFilename = CONFIG_FILENAMES_1[_i];
configFilePath = path.join(homeDir, configFilename);
if (fs.existsSync(configFilePath)) {
return path.resolve(configFilePath);
}
}
// no path could be found
return undefined;
}
}
exports.findConfigurationPath = findConfigurationPath;
/**
* Find a file by names in a directory or any ancestor directory.
* Will try each filename in filenames before recursing to a parent directory.
* This is case-insensitive, so it can find 'TsLiNt.JsOn' when searching for 'tslint.json'.
*/
function findup(filenames, directory) {
while (true) {
var res = findFile(directory);
if (res !== undefined) {
return path.join(directory, res);
}
var parent = path.dirname(directory);
if (parent === directory) {
return undefined;
}
directory = parent;
}
function findFile(cwd) {
var dirFiles = fs.readdirSync(cwd);
var _loop_1 = function (filename) {
var index = dirFiles.indexOf(filename);
if (index > -1) {
return { value: filename };
}
// TODO: remove in v6.0.0
// Try reading in the entire directory and looking for a file with different casing.
var result = dirFiles.find(function (entry) { return entry.toLowerCase() === filename; });
if (result !== undefined) {
error_1.showWarningOnce("Using mixed case " + filename + " is deprecated. Found: " + path.join(cwd, result));
return { value: result };
}
};
for (var _i = 0, filenames_1 = filenames; _i < filenames_1.length; _i++) {
var filename = filenames_1[_i];
var state_1 = _loop_1(filename);
if (typeof state_1 === "object")
return state_1.value;
}
return undefined;
}
}
/**
* Used Node semantics to load a configuration file given configFilePath.
* For example:
* '/path/to/config' will be treated as an absolute path
* './path/to/config' will be treated as a relative path
* 'path/to/config' will attempt to load a to/config file inside a node module named path
* @param configFilePath The configuration to load
* @param originalFilePath (deprecated) The entry point configuration file
* @returns a configuration object for TSLint loaded from the file at configFilePath
*/
function loadConfigurationFromPath(configFilePath, _originalFilePath) {
if (configFilePath == undefined) {
return exports.DEFAULT_CONFIG;
}
else {
var resolvedConfigFilePath = resolveConfigurationPath(configFilePath);
var rawConfigFile = readConfigurationFile(resolvedConfigFilePath);
return parseConfigFile(rawConfigFile, path.dirname(resolvedConfigFilePath), readConfigurationFile);
}
}
exports.loadConfigurationFromPath = loadConfigurationFromPath;
/** Reads the configuration file from disk and parses it as raw JSON, YAML or JS depending on the extension. */
function readConfigurationFile(filepath) {
var resolvedConfigFileExt = path.extname(filepath);
if (/\.(json|ya?ml)/.test(resolvedConfigFileExt)) {
var fileContent = fs.readFileSync(filepath, "utf8").replace(/^\uFEFF/, "");
try {
if (resolvedConfigFileExt === ".json") {
return JSON.parse(utils_1.stripComments(fileContent));
}
else {
return yaml.safeLoad(fileContent);
}
}
catch (e) {
var error = e;
// include the configuration file being parsed in the error since it may differ from the directly referenced config
throw new Error(error.message + " in " + filepath);
}
}
else {
var rawConfigFile = require(filepath);
// tslint:disable-next-line no-dynamic-delete
delete require.cache[filepath];
return rawConfigFile;
}
}
exports.readConfigurationFile = readConfigurationFile;
/**
* Resolve configuration file path or node_module reference
* @param filePath Relative ("./path"), absolute ("/path"), node module ("path"), or built-in ("tslint:path")
*/
function resolveConfigurationPath(filePath, relativeTo) {
var matches = filePath.match(BUILT_IN_CONFIG);
var isBuiltInConfig = matches !== null && matches.length > 0;
if (isBuiltInConfig) {
var configName = matches[1];
try {
return require.resolve("./configs/" + configName);
}
catch (err) {
throw new Error(filePath + " is not a built-in config, try \"tslint:recommended\" instead.");
}
}
var basedir = relativeTo !== undefined ? relativeTo : process.cwd();
try {
var resolvedPackagePath = utils_1.tryResolvePackage(filePath, basedir);
if (resolvedPackagePath === undefined) {
resolvedPackagePath = require.resolve(filePath);
}
return resolvedPackagePath;
}
catch (err) {
throw new Error("Invalid \"extends\" configuration value - could not require \"" + filePath + "\". " +
"Review the Node lookup algorithm (https://nodejs.org/api/modules.html#modules_all_together) " +
"for the approximate method TSLint uses to find the referenced configuration file.");
}
}
function extendConfigurationFile(targetConfig, nextConfigSource) {
function combineProperties(targetProperty, nextProperty) {
var combinedProperty = {};
add(targetProperty);
// next config source overwrites the target config object
add(nextProperty);
return combinedProperty;
function add(property) {
if (property !== undefined) {
for (var _i = 0, _a = Object.keys(property); _i < _a.length; _i++) {
var name = _a[_i];
combinedProperty[name] = property[name];
}
}
}
}
function combineMaps(target, next) {
var combined = new Map();
target.forEach(function (options, ruleName) {
combined.set(ruleName, options);
});
next.forEach(function (options, ruleName) {
var combinedRule = combined.get(ruleName);
if (combinedRule !== undefined) {
combined.set(ruleName, combineProperties(combinedRule, options));
}
else {
combined.set(ruleName, options);
}
});
return combined;
}
var combinedRulesDirs = targetConfig.rulesDirectory.concat(nextConfigSource.rulesDirectory);
var dedupedRulesDirs = Array.from(new Set(combinedRulesDirs));
return {
extends: [],
jsRules: combineMaps(targetConfig.jsRules, nextConfigSource.jsRules),
linterOptions: combineProperties(targetConfig.linterOptions, nextConfigSource.linterOptions),
rules: combineMaps(targetConfig.rules, nextConfigSource.rules),
rulesDirectory: dedupedRulesDirs,
};
}
exports.extendConfigurationFile = extendConfigurationFile;
/**
* returns the absolute path (contrary to what the name implies)
*
* @deprecated use `path.resolve` instead
*/
// tslint:disable-next-line no-null-undefined-union
function getRelativePath(directory, relativeTo) {
if (directory != undefined) {
var basePath = relativeTo !== undefined ? relativeTo : process.cwd();
return path.resolve(basePath, directory);
}
return undefined;
}
exports.getRelativePath = getRelativePath;
// check if directory should be used as path or if it should be resolved like a module
// matches if directory starts with '/', './', '../', 'node_modules/' or equals '.' or '..'
function useAsPath(directory) {
return /^(?:\.?\.?(?:\/|$)|node_modules\/)/.test(directory);
}
exports.useAsPath = useAsPath;
/**
* @param directories A path(s) to a directory of custom rules
* @param relativeTo A path that directories provided are relative to.
* For example, if the directories come from a tslint.json file, this path
* should be the path to the tslint.json file.
* @return An array of absolute paths to directories potentially containing rules
*/
function getRulesDirectories(directories, relativeTo) {
return utils_1.arrayify(directories).map(function (dir) {
if (!useAsPath(dir)) {
var resolvedPackagePath = utils_1.tryResolvePackage(dir, relativeTo);
if (resolvedPackagePath !== undefined) {
return path.dirname(resolvedPackagePath);
}
}
var absolutePath = relativeTo === undefined ? path.resolve(dir) : path.resolve(relativeTo, dir);
if (absolutePath !== undefined) {
if (!fs.existsSync(absolutePath)) {
throw new error_1.FatalError("Could not find custom rule directory: " + dir);
}
}
return absolutePath;
});
}
exports.getRulesDirectories = getRulesDirectories;
/**
* Parses the options of a single rule and upgrades legacy settings such as `true`, `[true, "option"]`
*
* @param ruleConfigValue The raw option setting of a rule
*/
function parseRuleOptions(ruleConfigValue, rawDefaultRuleSeverity) {
var ruleArguments;
var defaultRuleSeverity = "error";
if (rawDefaultRuleSeverity !== undefined) {
switch (rawDefaultRuleSeverity.toLowerCase()) {
case "warn":
case "warning":
defaultRuleSeverity = "warning";
break;
case "off":
case "none":
defaultRuleSeverity = "off";
break;
default:
defaultRuleSeverity = "error";
}
}
var ruleSeverity = defaultRuleSeverity;
if (ruleConfigValue == undefined) {
ruleArguments = [];
ruleSeverity = "off";
}
else if (Array.isArray(ruleConfigValue)) {
if (ruleConfigValue.length > 0) {
// old style: array
ruleArguments = ruleConfigValue.slice(1);
ruleSeverity = ruleConfigValue[0] === true ? defaultRuleSeverity : "off";
}
}
else if (typeof ruleConfigValue === "boolean") {
// old style: boolean
ruleArguments = [];
ruleSeverity = ruleConfigValue ? defaultRuleSeverity : "off";
}
else if (typeof ruleConfigValue === "object") {
if (ruleConfigValue.severity !== undefined) {
switch (ruleConfigValue.severity.toLowerCase()) {
case "default":
ruleSeverity = defaultRuleSeverity;
break;
case "error":
ruleSeverity = "error";
break;
case "warn":
case "warning":
ruleSeverity = "warning";
break;
case "off":
case "none":
ruleSeverity = "off";
break;
default:
console.warn("Invalid severity level: " + ruleConfigValue.severity);
ruleSeverity = defaultRuleSeverity;
}
}
if (ruleConfigValue.options != undefined) {
ruleArguments = utils_1.arrayify(ruleConfigValue.options);
}
}
return {
ruleArguments: ruleArguments,
ruleSeverity: ruleSeverity,
};
}
/**
* Parses a config file and normalizes legacy config settings.
* If `configFileDir` and `readConfig` are provided, this function will load all base configs and reduce them to the final configuration.
*
* @param configFile The raw object read from the JSON of a config file
* @param configFileDir The directory of the config file
* @param readConfig Will be used to load all base configurations while parsing. The function is called with the resolved path.
*/
function parseConfigFile(configFile, configFileDir, readConfig) {
var defaultSeverity = configFile.defaultSeverity;
if (readConfig === undefined || configFileDir === undefined) {
return parse(configFile, configFileDir);
}
return loadExtendsRecursive(configFile, configFileDir)
.map(function (_a) {
var dir = _a.dir, config = _a.config;
return parse(config, dir);
})
.reduce(extendConfigurationFile, exports.EMPTY_CONFIG);
/** Read files in order, depth first, and assign `defaultSeverity` (last config in extends wins). */
function loadExtendsRecursive(raw, dir) {
var configs = [];
for (var _i = 0, _a = utils_1.arrayify(raw.extends); _i < _a.length; _i++) {
var relativePath = _a[_i];
var resolvedPath = resolveConfigurationPath(relativePath, dir);
var extendedRaw = readConfig(resolvedPath);
configs.push.apply(configs, loadExtendsRecursive(extendedRaw, path.dirname(resolvedPath)));
}
if (raw.defaultSeverity !== undefined) {
defaultSeverity = raw.defaultSeverity;
}
configs.push({ dir: dir, config: raw });
return configs;
}
function parse(config, dir) {
var rulesDirectory = getRulesDirectories(config.rulesDirectory, dir);
var rules = parseRules(config.rules);
var jsRules = typeof config.jsRules === "boolean"
? filterValidJsRules(rules, config.jsRules, rulesDirectory)
: parseRules(config.jsRules);
return {
extends: utils_1.arrayify(config.extends),
jsRules: jsRules,
linterOptions: parseLinterOptions(config.linterOptions, dir),
rules: rules,
rulesDirectory: rulesDirectory,
};
}
function parseRules(config) {
var map = new Map();
if (config !== undefined) {
for (var _i = 0, _a = Object.keys(config); _i < _a.length; _i++) {
var ruleName = _a[_i];
map.set(ruleName, parseRuleOptions(config[ruleName], defaultSeverity));
}
}
return map;
}
function filterValidJsRules(rules, copyRulestoJsRules, rulesDirectory) {
if (copyRulestoJsRules === void 0) { copyRulestoJsRules = false; }
var validJsRules = new Map();
if (copyRulestoJsRules) {
rules.forEach(function (ruleOptions, ruleName) {
var Rule = ruleLoader_1.findRule(ruleName, rulesDirectory);
if (Rule !== undefined &&
(Rule.metadata === undefined || !Rule.metadata.typescriptOnly)) {
validJsRules.set(ruleName, ruleOptions);
}
});
}
return validJsRules;
}
function parseLinterOptions(raw, dir) {
if (raw === undefined) {
return {};
}
return tslib_1.__assign(tslib_1.__assign({}, (raw.exclude !== undefined
? {
exclude: utils_1.arrayify(raw.exclude).map(function (pattern) {
return dir === undefined ? path.resolve(pattern) : path.resolve(dir, pattern);
}),
}
: {})), (raw.format !== undefined
? {
format: raw.format,
}
: {}));
}
}
exports.parseConfigFile = parseConfigFile;
/**
* Fills in default values for `IOption` properties and outputs an array of `IOption`
*/
function convertRuleOptions(ruleConfiguration) {
var output = [];
ruleConfiguration.forEach(function (_a, ruleName) {
var ruleArguments = _a.ruleArguments, ruleSeverity = _a.ruleSeverity;
var options = {
disabledIntervals: [],
ruleArguments: ruleArguments != undefined ? ruleArguments : [],
ruleName: ruleName,
ruleSeverity: ruleSeverity != undefined ? ruleSeverity : "error",
};
output.push(options);
});
return output;
}
exports.convertRuleOptions = convertRuleOptions;
function isFileExcluded(filepath, configFile) {
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); });
}
exports.isFileExcluded = isFileExcluded;
function stringifyConfiguration(configFile) {
return JSON.stringify({
extends: configFile.extends,
jsRules: convertRulesMapToObject(configFile.jsRules),
linterOptions: configFile.linterOptions,
rules: convertRulesMapToObject(configFile.rules),
rulesDirectory: configFile.rulesDirectory,
}, undefined, 2);
}
exports.stringifyConfiguration = stringifyConfiguration;
function convertRulesMapToObject(rules) {
return Array.from(rules).reduce(function (result, _a) {
var _b;
var key = _a[0], value = _a[1];
return (tslib_1.__assign(tslib_1.__assign({}, result), (_b = {}, _b[key] = value, _b)));
}, {});
}

27
node_modules/tslint/lib/enableDisableRules.d.ts generated vendored Normal file
View file

@ -0,0 +1,27 @@
/**
* @license
* Copyright 2014 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 { RuleFailure } from "./language/rule/rule";
/**
* regex is: start of string followed by any amount of whitespace
* followed by tslint and colon
* followed by either "enable" or "disable"
* followed optionally by -line or -next-line
* followed by either colon, whitespace or end of string
*/
export declare const ENABLE_DISABLE_REGEX: RegExp;
export declare function removeDisabledFailures(sourceFile: ts.SourceFile, failures: RuleFailure[]): RuleFailure[];

155
node_modules/tslint/lib/enableDisableRules.js generated vendored Normal file
View file

@ -0,0 +1,155 @@
"use strict";
/**
* @license
* Copyright 2014 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 });
exports.removeDisabledFailures = exports.ENABLE_DISABLE_REGEX = void 0;
// tslint:disable object-literal-sort-keys
var utils = require("tsutils");
var ts = require("typescript");
/**
* regex is: start of string followed by any amount of whitespace
* followed by tslint and colon
* followed by either "enable" or "disable"
* followed optionally by -line or -next-line
* followed by either colon, whitespace or end of string
*/
exports.ENABLE_DISABLE_REGEX = /^\s*tslint:(enable|disable)(?:-(line|next-line))?(:|\s|$)/;
function removeDisabledFailures(sourceFile, failures) {
if (failures.length === 0) {
// Usually there won't be failures anyway, so no need to look for "tslint:disable".
return failures;
}
var failingRules = new Set(failures.map(function (f) { return f.getRuleName(); }));
var map = getDisableMap(sourceFile, failingRules);
return failures.filter(function (failure) {
var disabledIntervals = map.get(failure.getRuleName());
return (disabledIntervals === undefined ||
!disabledIntervals.some(function (_a) {
var pos = _a.pos, end = _a.end;
var failPos = failure.getStartPosition().getPosition();
var failEnd = failure.getEndPosition().getPosition();
return failEnd >= pos && (end === -1 || failPos < end);
}));
});
}
exports.removeDisabledFailures = removeDisabledFailures;
/**
* The map will have an array of TextRange for each disable of a rule in a file.
* (It will have no entry if the rule is never disabled, meaning all arrays are non-empty.)
*/
function getDisableMap(sourceFile, failingRules) {
var map = new Map();
utils.forEachComment(sourceFile, function (fullText, comment) {
var commentText = comment.kind === ts.SyntaxKind.SingleLineCommentTrivia
? fullText.substring(comment.pos + 2, comment.end)
: fullText.substring(comment.pos + 2, comment.end - 2);
var parsed = parseComment(commentText);
if (parsed !== undefined) {
var rulesList = parsed.rulesList, isEnabled = parsed.isEnabled, modifier = parsed.modifier;
var switchRange = getSwitchRange(modifier, comment, sourceFile);
if (switchRange !== undefined) {
var rulesToSwitch = rulesList === "all"
? Array.from(failingRules)
: rulesList.filter(function (r) { return failingRules.has(r); });
for (var _i = 0, rulesToSwitch_1 = rulesToSwitch; _i < rulesToSwitch_1.length; _i++) {
var ruleToSwitch = rulesToSwitch_1[_i];
switchRuleState(ruleToSwitch, isEnabled, switchRange.pos, switchRange.end);
}
}
}
});
return map;
function switchRuleState(ruleName, isEnable, start, end) {
var disableRanges = map.get(ruleName);
if (isEnable) {
if (disableRanges !== undefined) {
var lastDisable = disableRanges[disableRanges.length - 1];
if (lastDisable.end === -1) {
lastDisable.end = start;
if (end !== -1) {
// Disable it again after the enable range is over.
disableRanges.push({ pos: end, end: -1 });
}
}
}
}
else {
// disable
if (disableRanges === undefined) {
map.set(ruleName, [{ pos: start, end: end }]);
}
else if (disableRanges[disableRanges.length - 1].end !== -1) {
disableRanges.push({ pos: start, end: end });
}
}
}
}
/** End will be -1 to indicate no end. */
function getSwitchRange(modifier, range, sourceFile) {
var lineStarts = sourceFile.getLineStarts();
switch (modifier) {
case "line":
return {
// start at the beginning of the line where comment starts
pos: getStartOfLinePosition(range.pos),
// end at the beginning of the line following the comment
end: getStartOfLinePosition(range.end, 1),
};
case "next-line":
// start at the beginning of the line following the comment
var pos = getStartOfLinePosition(range.end, 1);
if (pos === -1) {
// no need to switch anything, there is no next line
return undefined;
}
// end at the beginning of the line following the next line
return { pos: pos, end: getStartOfLinePosition(range.end, 2) };
default:
// switch rule for the rest of the file
// start at the current position, but skip end position
return { pos: range.pos, end: -1 };
}
/** Returns -1 for last line. */
function getStartOfLinePosition(position, lineOffset) {
if (lineOffset === void 0) { lineOffset = 0; }
var line = ts.getLineAndCharacterOfPosition(sourceFile, position).line + lineOffset;
return line >= lineStarts.length ? -1 : lineStarts[line];
}
}
function parseComment(commentText) {
var match = exports.ENABLE_DISABLE_REGEX.exec(commentText);
if (match === null) {
return undefined;
}
// remove everything matched by the previous regex to get only the specified rules
// split at whitespaces
// filter empty items coming from whitespaces at start, at end or empty list
var rulesList = splitOnSpaces(commentText.substr(match[0].length));
if (rulesList.length === 0 && match[3] === ":") {
// nothing to do here: an explicit separator was specified but no rules to switch
return undefined;
}
if (rulesList.length === 0 || rulesList.indexOf("all") !== -1) {
// if list is empty we default to all enabled rules
// if `all` is specified we ignore the other rules and take all enabled rules
rulesList = "all";
}
return { rulesList: rulesList, isEnabled: match[1] === "enable", modifier: match[2] };
}
function splitOnSpaces(str) {
return str.split(/\s+/).filter(function (s) { return s !== ""; });
}

39
node_modules/tslint/lib/error.d.ts generated vendored Normal file
View file

@ -0,0 +1,39 @@
/**
* @license
* Copyright 2018 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.
*/
/**
* Generic error typing for EcmaScript errors
* Define `Error` here to avoid using `Error` from @types/node.
* Using the `node` version causes a compilation error when this code is used as an npm library if @types/node is not already imported.
*/
export declare class Error {
name?: string;
message: string;
stack?: string;
constructor(message?: string);
}
/**
* Used to exit the program and display a friendly message without the callstack.
*/
export declare class FatalError extends Error {
message: string;
innerError?: Error | undefined;
static NAME: string;
constructor(message: string, innerError?: Error | undefined);
}
export declare function isError(possibleError: any): possibleError is Error;
export declare function showWarningOnce(message: string): void;
export declare function showRuleCrashWarning(message: string, ruleName: string, fileName: string): void;

54
node_modules/tslint/lib/error.js generated vendored Normal file
View file

@ -0,0 +1,54 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.showRuleCrashWarning = exports.showWarningOnce = exports.isError = exports.FatalError = void 0;
var tslib_1 = require("tslib");
var shownWarnings = new Set();
/**
* Used to exit the program and display a friendly message without the callstack.
*/
var FatalError = /** @class */ (function (_super) {
tslib_1.__extends(FatalError, _super);
function FatalError(message, innerError) {
var _this = _super.call(this, message) || this;
_this.message = message;
_this.innerError = innerError;
_this.name = FatalError.NAME;
// Fix prototype chain for target ES5
Object.setPrototypeOf(_this, FatalError.prototype);
return _this;
}
FatalError.NAME = "FatalError";
return FatalError;
}(Error));
exports.FatalError = FatalError;
function isError(possibleError) {
return possibleError != undefined && possibleError.message !== undefined;
}
exports.isError = isError;
function showWarningOnce(message) {
if (!shownWarnings.has(message)) {
console.warn(message);
shownWarnings.add(message);
}
}
exports.showWarningOnce = showWarningOnce;
function showRuleCrashWarning(message, ruleName, fileName) {
console.warn("The '" + ruleName + "' rule threw an error in '" + fileName + "':\n" + message);
}
exports.showRuleCrashWarning = showRuleCrashWarning;

19
node_modules/tslint/lib/files/reading.d.ts generated vendored Normal file
View file

@ -0,0 +1,19 @@
/**
* @license
* Copyright 2019 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 { Logger } from "../runner";
/** Read a file, but return undefined if it is an MPEG '.ts' file. */
export declare function tryReadFile(filename: string, logger: Logger): Promise<string | undefined>;

50
node_modules/tslint/lib/files/reading.js generated vendored Normal file
View file

@ -0,0 +1,50 @@
"use strict";
/**
* @license
* Copyright 2019 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 });
exports.tryReadFile = void 0;
var tslib_1 = require("tslib");
var fs = require("fs");
var error_1 = require("../error");
/** Read a file, but return undefined if it is an MPEG '.ts' file. */
function tryReadFile(filename, logger) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var buffer, fd;
return tslib_1.__generator(this, function (_a) {
if (!fs.existsSync(filename)) {
throw new error_1.FatalError("Unable to open file: " + filename);
}
buffer = Buffer.allocUnsafe(256);
fd = fs.openSync(filename, "r");
try {
fs.readSync(fd, buffer, 0, 256, 0);
if (buffer.readInt8(0) === 0x47 && buffer.readInt8(188) === 0x47) {
// MPEG transport streams use the '.ts' file extension. They use 0x47 as the frame
// separator, repeating every 188 bytes. It is unlikely to find that pattern in
// TypeScript source, so tslint ignores files with the specific pattern.
logger.error(filename + ": ignoring MPEG transport stream\n");
return [2 /*return*/, undefined];
}
}
finally {
fs.closeSync(fd);
}
return [2 /*return*/, fs.readFileSync(filename, "utf8")];
});
});
}
exports.tryReadFile = tryReadFile;

25
node_modules/tslint/lib/files/resolution.d.ts generated vendored Normal file
View file

@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 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 { Logger, Options } from "../runner";
export declare function filterFiles(files: string[], patterns: string[], include: boolean): string[];
export declare function findTsconfig(project: string): string | undefined;
export declare function resolveGlobs(files: string[], ignore: string[], outputAbsolutePaths: boolean | undefined, logger: Logger): string[];
export declare function resolveFilesAndProgram({ files, project, exclude, outputAbsolutePaths }: Options, logger: Logger): {
files: string[];
program?: ts.Program;
};

101
node_modules/tslint/lib/files/resolution.js generated vendored Normal file
View file

@ -0,0 +1,101 @@
"use strict";
/**
* @license
* Copyright 2019 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 });
exports.resolveFilesAndProgram = exports.resolveGlobs = exports.findTsconfig = exports.filterFiles = void 0;
var fs = require("fs");
var glob = require("glob");
var minimatch_1 = require("minimatch");
var path = require("path");
var error_1 = require("../error");
var linter_1 = require("../linter");
var utils_1 = require("../utils");
function filterFiles(files, patterns, include) {
if (patterns.length === 0) {
return include ? [] : files;
}
var matcher = patterns.map(function (pattern) { return new minimatch_1.Minimatch(pattern, { dot: !include }); }); // `glob` always enables `dot` for ignore patterns
return files.filter(function (file) { return include === matcher.some(function (pattern) { return pattern.match(file); }); });
}
exports.filterFiles = filterFiles;
function findTsconfig(project) {
try {
var stats = fs.statSync(project); // throws if file does not exist
if (!stats.isDirectory()) {
return project;
}
var projectFile = path.join(project, "tsconfig.json");
fs.accessSync(projectFile); // throws if file does not exist
return projectFile;
}
catch (e) {
return undefined;
}
}
exports.findTsconfig = findTsconfig;
function resolveGlobs(files, ignore, outputAbsolutePaths, logger) {
var results = utils_1.flatMap(files, function (file) {
return glob.sync(utils_1.trimSingleQuotes(file), { ignore: ignore, nodir: true });
});
// warn if `files` contains non-existent files, that are not patters and not excluded by any of the exclude patterns
for (var _i = 0, _a = filterFiles(files, ignore, false); _i < _a.length; _i++) {
var file = _a[_i];
if (!glob.hasMagic(file) && !results.some(minimatch_1.filter(file))) {
logger.error("'" + file + "' does not exist. This will be an error in TSLint 6.\n"); // TODO make this an error in v6.0.0
}
}
var cwd = process.cwd();
return results.map(function (file) {
return outputAbsolutePaths ? path.resolve(cwd, file) : path.relative(cwd, file);
});
}
exports.resolveGlobs = resolveGlobs;
function resolveFilesAndProgram(_a, logger) {
var files = _a.files, project = _a.project, exclude = _a.exclude, outputAbsolutePaths = _a.outputAbsolutePaths;
// remove single quotes which break matching on Windows when glob is passed in single quotes
exclude = exclude.map(utils_1.trimSingleQuotes);
if (project === undefined) {
return { files: resolveGlobs(files, exclude, outputAbsolutePaths, logger) };
}
var projectPath = findTsconfig(project);
if (projectPath === undefined) {
throw new error_1.FatalError("Invalid option for project: " + project);
}
exclude = exclude.map(function (pattern) { return path.resolve(pattern); });
var program = linter_1.Linter.createProgram(projectPath);
var filesFound;
if (files.length === 0) {
filesFound = filterFiles(linter_1.Linter.getFileNames(program), exclude, false);
}
else {
files = files.map(function (f) { return path.resolve(f); });
filesFound = filterFiles(program.getSourceFiles().map(function (f) { return f.fileName; }), files, true);
filesFound = filterFiles(filesFound, exclude, false);
// find non-glob files that have no matching file in the project and are not excluded by any exclude pattern
for (var _i = 0, _b = filterFiles(files, exclude, false); _i < _b.length; _i++) {
var file = _b[_i];
if (!glob.hasMagic(file) && !filesFound.some(minimatch_1.filter(file))) {
if (fs.existsSync(file)) {
throw new error_1.FatalError("'" + file + "' is not included in project.");
}
logger.error("'" + file + "' does not exist. This will be an error in TSLint 6.\n"); // TODO make this an error in v6.0.0
}
}
}
return { files: filesFound, program: program };
}
exports.resolveFilesAndProgram = resolveFilesAndProgram;

18
node_modules/tslint/lib/formatterLoader.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
/**
* @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 { FormatterConstructor } from "./index";
export declare function findFormatter(name: string | FormatterConstructor, formattersDirectory?: string): FormatterConstructor | undefined;

86
node_modules/tslint/lib/formatterLoader.js generated vendored Normal file
View file

@ -0,0 +1,86 @@
"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 });
exports.findFormatter = void 0;
var fs = require("fs");
var path = require("path");
var utils_1 = require("./utils");
var CORE_FORMATTERS_DIRECTORY = path.resolve(__dirname, "formatters");
function findFormatter(name, formattersDirectory) {
if (typeof name === "function") {
return name;
}
else if (typeof name === "string") {
name = name.trim();
var camelizedName = utils_1.camelize(name + "Formatter");
// first check for core formatters
var Formatter = loadFormatter(CORE_FORMATTERS_DIRECTORY, camelizedName, true);
if (Formatter !== undefined) {
return Formatter;
}
// then check for rules within the first level of rulesDirectory
if (formattersDirectory !== undefined) {
Formatter = loadFormatter(formattersDirectory, camelizedName);
if (Formatter !== undefined) {
return Formatter;
}
}
// else try to resolve as module
return loadFormatterModule(name);
}
else {
// If an something else is passed as a name (e.g. object)
throw new Error("Name of type " + typeof name + " is not supported.");
}
}
exports.findFormatter = findFormatter;
function loadFormatter(directory, name, isCore) {
var formatterPath = path.resolve(path.join(directory, name));
var fullPath;
if (isCore) {
fullPath = formatterPath + ".js";
if (!fs.existsSync(fullPath)) {
return undefined;
}
}
else {
// Resolve using node's path resolution to allow developers to write custom formatters in TypeScript which can be loaded by TS-Node
try {
fullPath = require.resolve(formatterPath);
}
catch (_a) {
return undefined;
}
}
return require(fullPath).Formatter;
}
function loadFormatterModule(name) {
var src;
try {
// first try to find a module in the dependencies of the currently linted project
src = utils_1.tryResolvePackage(name, process.cwd());
if (src === undefined) {
// if there is no local module, try relative to the installation of TSLint (might be global)
src = require.resolve(name);
}
}
catch (_a) {
return undefined;
}
return require(src).Formatter;
}

18
node_modules/tslint/lib/formatters.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
/**
* @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.
*/
export * from "./language/formatter/abstractFormatter";
export * from "./formatters/index";

21
node_modules/tslint/lib/formatters.js generated vendored Normal file
View file

@ -0,0 +1,21 @@
"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");
tslib_1.__exportStar(require("./language/formatter/abstractFormatter"), exports);
tslib_1.__exportStar(require("./formatters/index"), exports);

View file

@ -0,0 +1,25 @@
/**
* @license
* Copyright 2018 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[], _fixes?: RuleFailure[], fileNames?: string[]): string;
private formatFailure;
private escapeXml;
}

View file

@ -0,0 +1,83 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.Formatter = void 0;
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, _fixes, fileNames) {
var _this = this;
var groupedFailures = {};
for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) {
var failure = failures_1[_i];
var fileName = failure.getFileName();
if (groupedFailures[fileName] !== undefined) {
groupedFailures[fileName].push(failure);
}
else {
groupedFailures[fileName] = [failure];
}
}
if (fileNames === undefined) {
fileNames = Object.keys(groupedFailures);
}
var formattedFiles = fileNames.map(function (fileName) {
var formattedFailures = groupedFailures[fileName] !== undefined
? groupedFailures[fileName].map(function (f) { return _this.formatFailure(f); })
: [];
var joinedFailures = formattedFailures.join(""); // may be empty
return "<file name=\"" + _this.escapeXml(fileName) + "\">" + joinedFailures + "</file>";
});
var joinedFiles = formattedFiles.join("");
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle version=\"4.3\">" + joinedFiles + "</checkstyle>";
};
Formatter.prototype.formatFailure = function (failure) {
var line = failure.getStartPosition().getLineAndCharacter().line + 1;
var column = failure.getStartPosition().getLineAndCharacter().character + 1;
var severity = failure.getRuleSeverity();
var message = this.escapeXml(failure.getFailure());
// checkstyle parser wants "source" to have structure like <anything>dot<category>dot<type>
var source = "failure.tslint." + this.escapeXml(failure.getRuleName());
return "<error line=\"" + line + "\" column=\"" + column + "\" severity=\"" + severity + "\" message=\"" + message + "\" source=\"" + source + "\" />";
};
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: "checkstyle",
description: "Formats errors as though they were Checkstyle output.",
descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Imitates the XMLLogger from Checkstyle 4.3. All failures have the 'warning' severity. Files without errors are still included."], ["\n Imitates the XMLLogger from Checkstyle 4.3. All failures have the 'warning' severity. Files without errors are still included."]))),
sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <checkstyle version=\"4.3\">\n <file name=\"myFile.ts\">\n <error line=\"1\" column=\"14\" severity=\"warning\" message=\"Missing semicolon\" source=\"failure.tslint.semicolon\" />\n </file>\n </checkstyle>"], ["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <checkstyle version=\"4.3\">\n <file name=\"myFile.ts\">\n <error line=\"1\" column=\"14\" severity=\"warning\" message=\"Missing semicolon\" source=\"failure.tslint.semicolon\" />\n </file>\n </checkstyle>"]))),
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
var templateObject_1, templateObject_2;

View file

@ -0,0 +1,23 @@
/**
* @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 { 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;
}

View file

@ -0,0 +1,84 @@
"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 });
exports.Formatter = void 0;
var tslib_1 = require("tslib");
var code_frame_1 = require("@babel/code-frame");
var chalk_1 = require("chalk");
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) {
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++) {
var failure = failures_1[_i];
var fileName = failure.getFileName();
// Output the name of each file once
if (currentFile !== fileName) {
outputLines.push("");
outputLines.push(fileName);
currentFile = fileName;
}
var failureString = failure.getFailure();
failureString =
failure.getRuleSeverity() === "warning"
? chalk_1.default.yellow(failureString)
: chalk_1.default.red(failureString);
// Rule
var ruleName = failure.getRuleName();
ruleName = chalk_1.default.gray("(" + ruleName + ")");
// Frame
var _a = failure.getStartPosition().getLineAndCharacter(), column = _a.character, line = _a.line;
var frame = code_frame_1.codeFrameColumns(failure.getRawLines(), { start: { line: line + 1, column: column } }, // babel-code-frame is 1 index
{
forceColor: chalk_1.default.enabled,
highlightCode: true,
});
// Ouput
outputLines.push(failureString + " " + ruleName);
outputLines.push(frame);
outputLines.push("");
}
// Removes initial blank line
if (outputLines[0] === "") {
outputLines.shift();
}
return outputLines.join("\n") + "\n";
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "codeFrame",
description: "Framed formatter which creates a frame of error code.",
descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Prints syntax highlighted code in a frame with a pointer to where\n exactly lint error is happening."], ["\n Prints syntax highlighted code in a frame with a pointer to where\n exactly lint error is happening."]))),
sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n src/components/Payment.tsx\n Parentheses are required around the parameters of an arrow function definition (arrow-parens)\n 21 | public componentDidMount() {\n 22 | this.input.focus();\n > 23 | loadStripe().then(Stripe => Stripe.pay());\n | ^\n 24 | }\n 25 |\n 26 | public render() {"], ["\n src/components/Payment.tsx\n Parentheses are required around the parameters of an arrow function definition (arrow-parens)\n 21 | public componentDidMount() {\n 22 | this.input.focus();\n > 23 | loadStripe().then(Stripe => Stripe.pay());\n | ^\n 24 | }\n 25 |\n 26 | public render() {"]))),
consumer: "human",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
var templateObject_1, templateObject_2;

View file

@ -0,0 +1,23 @@
/**
* @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 { 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;
}

View file

@ -0,0 +1,53 @@
"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 });
exports.Formatter = void 0;
var tslib_1 = require("tslib");
var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
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) {
if (failures.length === 0) {
return "";
}
var files = [];
var currentFile;
for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) {
var failure = failures_1[_i];
var fileName = failure.getFileName();
if (fileName !== currentFile) {
files.push(fileName);
currentFile = fileName;
}
}
return files.join("\n") + "\n";
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "filesList",
description: "Lists files containing lint errors.",
sample: "directory/myFile.ts",
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;

25
node_modules/tslint/lib/formatters/index.d.ts generated vendored Normal file
View file

@ -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.
*/
export { Formatter as JsonFormatter } from "./jsonFormatter";
export { Formatter as PmdFormatter } from "./pmdFormatter";
export { Formatter as ProseFormatter } from "./proseFormatter";
export { Formatter as VerboseFormatter } from "./verboseFormatter";
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";

37
node_modules/tslint/lib/formatters/index.js generated vendored Normal file
View file

@ -0,0 +1,37 @@
"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 });
exports.JUnitFormatter = exports.TapFormatter = exports.CodeFrameFormatter = exports.FileslistFormatter = exports.StylishFormatter = exports.VerboseFormatter = exports.ProseFormatter = exports.PmdFormatter = exports.JsonFormatter = void 0;
var jsonFormatter_1 = require("./jsonFormatter");
Object.defineProperty(exports, "JsonFormatter", { enumerable: true, get: function () { return jsonFormatter_1.Formatter; } });
var pmdFormatter_1 = require("./pmdFormatter");
Object.defineProperty(exports, "PmdFormatter", { enumerable: true, get: function () { return pmdFormatter_1.Formatter; } });
var proseFormatter_1 = require("./proseFormatter");
Object.defineProperty(exports, "ProseFormatter", { enumerable: true, get: function () { return proseFormatter_1.Formatter; } });
var verboseFormatter_1 = require("./verboseFormatter");
Object.defineProperty(exports, "VerboseFormatter", { enumerable: true, get: function () { return verboseFormatter_1.Formatter; } });
var stylishFormatter_1 = require("./stylishFormatter");
Object.defineProperty(exports, "StylishFormatter", { enumerable: true, get: function () { return stylishFormatter_1.Formatter; } });
var fileslistFormatter_1 = require("./fileslistFormatter");
Object.defineProperty(exports, "FileslistFormatter", { enumerable: true, get: function () { return fileslistFormatter_1.Formatter; } });
var codeFrameFormatter_1 = require("./codeFrameFormatter");
Object.defineProperty(exports, "CodeFrameFormatter", { enumerable: true, get: function () { return codeFrameFormatter_1.Formatter; } });
var tapFormatter_1 = require("./tapFormatter");
Object.defineProperty(exports, "TapFormatter", { enumerable: true, get: function () { return tapFormatter_1.Formatter; } });
var junitFormatter_1 = require("./junitFormatter");
Object.defineProperty(exports, "JUnitFormatter", { enumerable: true, get: function () { return junitFormatter_1.Formatter; } });

23
node_modules/tslint/lib/formatters/jsonFormatter.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* @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 { 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;
}

43
node_modules/tslint/lib/formatters/jsonFormatter.js generated vendored Normal file
View file

@ -0,0 +1,43 @@
"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 });
exports.Formatter = void 0;
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 failuresJSON = failures.map(function (failure) { return failure.toJson(); });
return JSON.stringify(failuresJSON);
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "json",
description: "Formats errors as simple JSON.",
sample: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n [\n {\n \"endPosition\": {\n \"character\": 13,\n \"line\": 0,\n \"position\": 13\n },\n \"failure\": \"Missing semicolon\",\n \"fix\": {\n \"innerStart\": 13,\n \"innerLength\": 0,\n \"innerText\": \";\"\n },\n \"name\": \"myFile.ts\",\n \"ruleName\": \"semicolon\",\n \"startPosition\": {\n \"character\": 13,\n \"line\": 0,\n \"position\": 13\n }\n }\n ]"], ["\n [\n {\n \"endPosition\": {\n \"character\": 13,\n \"line\": 0,\n \"position\": 13\n },\n \"failure\": \"Missing semicolon\",\n \"fix\": {\n \"innerStart\": 13,\n \"innerLength\": 0,\n \"innerText\": \";\"\n },\n \"name\": \"myFile.ts\",\n \"ruleName\": \"semicolon\",\n \"startPosition\": {\n \"character\": 13,\n \"line\": 0,\n \"position\": 13\n }\n }\n ]"]))),
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
var templateObject_1;

24
node_modules/tslint/lib/formatters/junitFormatter.d.ts generated vendored Normal file
View file

@ -0,0 +1,24 @@
/**
* @license
* Copyright 2018 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[], _fixes?: RuleFailure[], fileNames?: string[]): string;
private escapeXml;
}

94
node_modules/tslint/lib/formatters/junitFormatter.js generated vendored Normal file
View file

@ -0,0 +1,94 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.Formatter = void 0;
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, _fixes, fileNames) {
var output = '<?xml version="1.0" encoding="utf-8"?><testsuites package="tslint">';
var failureFileNames = new Set(tslib_1.__spreadArrays(failures.map(function (f) { return f.getFileName(); })));
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=\"" + rule + "\" ";
output += "classname=\"" + this.escapeXml(failure.getFileName()) + "\">";
output += "<failure type=\"" + severity + "\">" + message + " ";
output += "Line " + (lineAndCharacter.line + 1) + ", ";
output += "Column " + (lineAndCharacter.character + 1);
output += "</failure>";
output += "</testcase>";
}
if (previousFilename !== null) {
output += "</testsuite>";
}
}
if (fileNames !== undefined && fileNames.length !== 0) {
// Filter out files which have had a failure associated with them.
var filteredFileNames = fileNames.filter(function (fileName) { return !failureFileNames.has(fileName); });
for (var _a = 0, filteredFileNames_1 = filteredFileNames; _a < filteredFileNames_1.length; _a++) {
var fileName = filteredFileNames_1[_a];
output += "<testsuite name=\"" + this.escapeXml(fileName) + "\" errors=\"0\">";
output += "<testcase name=\"" + this.escapeXml(fileName) + "\" />";
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 though they were JUnit output.",
descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Imitates the JUnit XML Output"], ["\n Imitates the JUnit XML Output"]))),
sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <testsuites package=\"tslint\">\n <testsuite name=\"myFile.ts\">\n <testcase name=\"semicolon\" classname=\"myFile.ts\">\n <failure type=\"warning\">Missing semicolon Line 1, Column 14</failure>\n </testcase>\n </testsuite>\n </testsuites>\n "], ["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <testsuites package=\"tslint\">\n <testsuite name=\"myFile.ts\">\n <testcase name=\"semicolon\" classname=\"myFile.ts\">\n <failure type=\"warning\">Missing semicolon Line 1, Column 14</failure>\n </testcase>\n </testsuite>\n </testsuites>\n "]))),
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
var templateObject_1, templateObject_2;

View file

@ -0,0 +1,23 @@
/**
* @license
* Copyright 2018 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;
}

53
node_modules/tslint/lib/formatters/msbuildFormatter.js generated vendored Normal file
View file

@ -0,0 +1,53 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.Formatter = void 0;
var tslib_1 = require("tslib");
var path = require("path");
var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
var utils_1 = 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 outputLines = failures.map(function (failure) {
var fileName = path.normalize(failure.getFileName());
var failureString = failure.getFailure();
var camelizedRule = utils_1.camelize(failure.getRuleName());
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var positionTuple = "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character +
1) + ")";
var severity = failure.getRuleSeverity();
return "" + fileName + positionTuple + ": " + severity + " " + camelizedRule + ": " + failureString;
});
return outputLines.join("\n") + "\n";
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "msbuild",
description: "Formats errors for consumption by msbuild.",
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;

23
node_modules/tslint/lib/formatters/pmdFormatter.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* @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 { 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;
}

62
node_modules/tslint/lib/formatters/pmdFormatter.js generated vendored Normal file
View file

@ -0,0 +1,62 @@
"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 });
exports.Formatter = void 0;
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 = '<pmd version="tslint">';
for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) {
var failure = failures_1[_i];
var failureString = failure
.getFailure()
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/'/g, "&#39;")
.replace(/"/g, "&quot;");
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var priority = failure.getRuleSeverity() === "warning" ? 4 : 3;
output += "<file name=\"" + failure.getFileName();
output += "\"><violation begincolumn=\"" + (lineAndCharacter.character + 1);
output += "\" beginline=\"" + (lineAndCharacter.line + 1);
output += "\" priority=\"" + priority + "\"";
output += " rule=\"" + failureString + "\"></violation></file>";
}
output += "</pmd>";
return output;
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "pmd",
description: "Formats errors as though they were PMD output.",
descriptionDetails: "Imitates the XML output from PMD. All errors have a priority of 1.",
sample: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n <pmd version=\"tslint\">\n <file name=\"myFile.ts\">\n <violation begincolumn=\"14\" beginline=\"1\" priority=\"3\" rule=\"Missing semicolon\"></violation>\n </file>\n </pmd>"], ["\n <pmd version=\"tslint\">\n <file name=\"myFile.ts\">\n <violation begincolumn=\"14\" beginline=\"1\" priority=\"3\" rule=\"Missing semicolon\"></violation>\n </file>\n </pmd>"]))),
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
var templateObject_1;

23
node_modules/tslint/lib/formatters/proseFormatter.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* @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 { 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[], fixes?: RuleFailure[]): string;
}

66
node_modules/tslint/lib/formatters/proseFormatter.js generated vendored Normal file
View file

@ -0,0 +1,66 @@
"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 });
exports.Formatter = void 0;
var tslib_1 = require("tslib");
var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
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, fixes) {
if (failures.length === 0 && (fixes === undefined || fixes.length === 0)) {
return "\n";
}
failures = this.sortFailures(failures);
var fixLines = [];
if (fixes !== undefined) {
var perFileFixes = new Map();
for (var _i = 0, fixes_1 = fixes; _i < fixes_1.length; _i++) {
var fix = fixes_1[_i];
var prevFixes = perFileFixes.get(fix.getFileName());
perFileFixes.set(fix.getFileName(), (prevFixes !== undefined ? prevFixes : 0) + 1);
}
perFileFixes.forEach(function (fixCount, fixedFile) {
fixLines.push("Fixed " + fixCount + " error(s) in " + fixedFile);
});
fixLines.push(""); // add a blank line between fixes and failures
}
var errorLines = failures.map(function (failure) {
var fileName = failure.getFileName();
var failureString = failure.getFailure();
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var positionTuple = lineAndCharacter.line + 1 + ":" + (lineAndCharacter.character + 1);
return failure
.getRuleSeverity()
.toUpperCase() + ": " + fileName + ":" + positionTuple + " - " + failureString;
});
return fixLines.concat(errorLines).join("\n") + "\n";
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "prose",
description: "The default formatter which outputs simple human-readable messages.",
sample: "ERROR: myFile.ts:1:14 - Missing semicolon",
consumer: "human",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;

View file

@ -0,0 +1,27 @@
/**
* @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 { 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 mapToMessages;
private pad;
private getPositionMaxSize;
private getRuleMaxSize;
}

115
node_modules/tslint/lib/formatters/stylishFormatter.js generated vendored Normal file
View file

@ -0,0 +1,115 @@
"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 });
exports.Formatter = void 0;
var tslib_1 = require("tslib");
var chalk_1 = require("chalk");
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) {
failures = this.sortFailures(failures);
var outputLines = this.mapToMessages(failures);
// Removes initial blank line
if (outputLines[0] === "") {
outputLines.shift();
}
return outputLines.join("\n") + "\n";
};
Formatter.prototype.mapToMessages = function (failures) {
if (failures.length === 0) {
return [];
}
var outputLines = [];
var positionMaxSize = this.getPositionMaxSize(failures);
var ruleMaxSize = this.getRuleMaxSize(failures);
var currentFile;
for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) {
var failure = failures_1[_i];
var fileName = failure.getFileName();
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var positionTuple = lineAndCharacter.line + 1 + ":" + (lineAndCharacter.character + 1);
// Output the name of each file once
if (currentFile !== fileName) {
outputLines.push("");
outputLines.push("" + fileName + chalk_1.default.hidden(":" + positionTuple));
currentFile = fileName;
}
var failureString = failure.getFailure();
failureString = chalk_1.default.yellow(failureString);
// Rule
var ruleName = failure.getRuleName();
ruleName = this.pad(ruleName, ruleMaxSize);
ruleName = chalk_1.default.grey(ruleName);
// Lines
positionTuple = this.pad(positionTuple, positionMaxSize);
positionTuple =
failure.getRuleSeverity() === "warning"
? chalk_1.default.blue(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple)
: chalk_1.default.red(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple);
// Output
var output = positionTuple + " " + ruleName + " " + failureString;
outputLines.push(output);
}
return outputLines;
};
Formatter.prototype.pad = function (str, len) {
var padder = Array(len + 1).join(" ");
return (str + padder).substring(0, padder.length);
};
Formatter.prototype.getPositionMaxSize = function (failures) {
var positionMaxSize = 0;
for (var _i = 0, failures_2 = failures; _i < failures_2.length; _i++) {
var failure = failures_2[_i];
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var positionSize = (lineAndCharacter.line + 1 + ":" + (lineAndCharacter.character + 1))
.length;
if (positionSize > positionMaxSize) {
positionMaxSize = positionSize;
}
}
return positionMaxSize;
};
Formatter.prototype.getRuleMaxSize = function (failures) {
var ruleMaxSize = 0;
for (var _i = 0, failures_3 = failures; _i < failures_3.length; _i++) {
var failure = failures_3[_i];
var ruleSize = failure.getRuleName().length;
if (ruleSize > ruleMaxSize) {
ruleMaxSize = ruleSize;
}
}
return ruleMaxSize;
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "stylish",
description: "Human-readable formatter which creates stylish messages.",
descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n The output matches what is produced by ESLint's stylish formatter.\n Its readability is enhanced through spacing and colouring."], ["\n The output matches what is produced by ESLint's stylish formatter.\n Its readability is enhanced through spacing and colouring."]))),
sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n myFile.ts\n Error: 1:14 semicolon Missing semicolon"], ["\n myFile.ts\n Error: 1:14 semicolon Missing semicolon"]))),
consumer: "human",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
var templateObject_1, templateObject_2;

24
node_modules/tslint/lib/formatters/tapFormatter.d.ts generated vendored Normal file
View file

@ -0,0 +1,24 @@
/**
* @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 { 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 mapToMessages;
}

60
node_modules/tslint/lib/formatters/tapFormatter.js generated vendored Normal file
View file

@ -0,0 +1,60 @@
"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 });
exports.Formatter = void 0;
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 = ["TAP version 13"];
output =
failures.length === 0
? output.concat(["1..0 # SKIP No failures"])
: output.concat(["1.." + failures.length]).concat(this.mapToMessages(failures));
return output.join("\n") + "\n";
};
Formatter.prototype.mapToMessages = function (failures) {
return failures.map(function (failure, i) {
var fileName = failure.getFileName();
var failureString = failure.getFailure();
var ruleName = failure.getRuleName();
var failureMessage = failure.getFailure();
var failureSeverity = failure.getRuleSeverity();
var failureRaw = failure.getRawLines();
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
return Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n not ok ", " - ", "\n ---\n message : ", "\n severity: ", "\n data:\n ruleName: ", "\n fileName: ", "\n line: ", "\n character: ", "\n failureString: ", "\n rawLines: ", "\n ..."], ["\n not ok ", " - ", "\n ---\n message : ", "\n severity: ", "\n data:\n ruleName: ", "\n fileName: ", "\n line: ", "\n character: ", "\n failureString: ", "\n rawLines: ", "\n ..."])), String(i + 1), failureMessage, failureMessage, failureSeverity, ruleName, fileName, String(lineAndCharacter.line), String(lineAndCharacter.character), failureString, failureRaw);
});
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "tap",
description: "Formats output as TAP stream.",
descriptionDetails: "Provides error messages output in TAP13 format which can be consumed by any TAP formatter.",
sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n TAP version 13\n 1..1\n not ok 1 - Some error\n ---\n message: Variable has any type\n severity: error\n data:\n ruleName: no-any\n fileName: test-file.ts\n line: 10\n character: 10\n failureString: Some error\n rawLines: Some raw output\n ..."], ["\n TAP version 13\n 1..1\n not ok 1 - Some error\n ---\n message: Variable has any type\n severity: error\n data:\n ruleName: no-any\n fileName: test-file.ts\n line: 10\n character: 10\n failureString: Some error\n rawLines: Some raw output\n ..."]))),
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
var templateObject_1, templateObject_2;

View file

@ -0,0 +1,24 @@
/**
* @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 { 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 mapToMessages;
}

55
node_modules/tslint/lib/formatters/verboseFormatter.js generated vendored Normal file
View file

@ -0,0 +1,55 @@
"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 });
exports.Formatter = void 0;
var tslib_1 = require("tslib");
var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
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) {
failures = this.sortFailures(failures);
return this.mapToMessages(failures).join("\n") + "\n";
};
Formatter.prototype.mapToMessages = function (failures) {
return failures.map(function (failure) {
var fileName = failure.getFileName();
var failureString = failure.getFailure();
var ruleName = failure.getRuleName();
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var positionTuple = "[" + (lineAndCharacter.line + 1) + ", " + (lineAndCharacter.character +
1) + "]";
return failure
.getRuleSeverity()
.toUpperCase() + ": (" + ruleName + ") " + fileName + positionTuple + ": " + failureString;
});
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "verbose",
description: "The human-readable formatter which includes the rule name in messages.",
descriptionDetails: "Basic formatter which outputs simple human-readable messages",
sample: "ERROR: (semicolon) myFile.ts[1, 14]: Missing semicolon",
consumer: "human",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;

23
node_modules/tslint/lib/formatters/vsoFormatter.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* @license
* Copyright 2018 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;
}

54
node_modules/tslint/lib/formatters/vsoFormatter.js generated vendored Normal file
View file

@ -0,0 +1,54 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.Formatter = void 0;
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 outputLines = failures.map(function (failure) {
var fileName = failure.getFileName();
var failureString = failure.getFailure();
var failureSeverity = failure.getRuleSeverity();
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var line = lineAndCharacter.line + 1;
var character = lineAndCharacter.character + 1;
var code = failure.getRuleName();
var properties = "sourcepath=" + fileName + ";linenumber=" + line + ";columnnumber=" + character + ";code=" + code + ";";
return "##vso[task.logissue type=" + failureSeverity + ";" + properties + "]" + failureString;
});
return outputLines.join("\n") + "\n";
};
/* tslint:disable:object-literal-sort-keys */
Formatter.metadata = {
formatterName: "vso",
description: "Formats output as VSO/TFS logging commands.",
descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Integrates with Azure DevOps (previously known as Visual Studio Online, Team Foundation Server,\n or Visual Studio Team Services) by outputting errors as 'warning' logging commands."], ["\n Integrates with Azure DevOps (previously known as Visual Studio Online, Team Foundation Server,\n or Visual Studio Team Services) by outputting errors as 'warning' logging commands."]))),
sample: "##vso[task.logissue type=warning;sourcepath=myFile.ts;linenumber=1;columnnumber=14;code=semicolon;]Missing semicolon",
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
var templateObject_1;

47
node_modules/tslint/lib/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,47 @@
/**
* @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 Configuration from "./configuration";
import * as Formatters from "./formatters";
import { FormatterConstructor } from "./language/formatter/formatter";
import { RuleFailure } from "./language/rule/rule";
import * as Rules from "./rules";
import * as Test from "./test";
import * as Utils from "./utils";
export { Configuration, Formatters, Rules, Test, Utils };
export * from "./linter";
export * from "./language/rule/rule";
export * from "./enableDisableRules";
export * from "./formatterLoader";
export * from "./ruleLoader";
export * from "./language/utils";
export * from "./language/walker";
export * from "./language/formatter/formatter";
export interface LintResult {
errorCount: number;
warningCount: number;
failures: RuleFailure[];
fixes?: RuleFailure[];
format: string | FormatterConstructor;
output: string;
}
export interface ILinterOptions {
fix: boolean;
formatter?: string | FormatterConstructor;
formattersDirectory?: string;
quiet?: boolean;
rulesDirectory?: string | string[];
}

38
node_modules/tslint/lib/index.js generated vendored Normal file
View file

@ -0,0 +1,38 @@
"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 });
exports.Utils = exports.Test = exports.Rules = exports.Formatters = exports.Configuration = void 0;
var tslib_1 = require("tslib");
var Configuration = require("./configuration");
exports.Configuration = Configuration;
var Formatters = require("./formatters");
exports.Formatters = Formatters;
var Rules = require("./rules");
exports.Rules = Rules;
var Test = require("./test");
exports.Test = Test;
var Utils = require("./utils");
exports.Utils = Utils;
tslib_1.__exportStar(require("./linter"), exports);
tslib_1.__exportStar(require("./language/rule/rule"), exports);
tslib_1.__exportStar(require("./enableDisableRules"), exports);
tslib_1.__exportStar(require("./formatterLoader"), exports);
tslib_1.__exportStar(require("./ruleLoader"), exports);
tslib_1.__exportStar(require("./language/utils"), exports);
tslib_1.__exportStar(require("./language/walker"), exports);
tslib_1.__exportStar(require("./language/formatter/formatter"), exports);

View file

@ -0,0 +1,23 @@
/**
* @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 { RuleFailure } from "../rule/rule";
import { IFormatter, IFormatterMetadata } from "./formatter";
export declare abstract class AbstractFormatter implements IFormatter {
static metadata: IFormatterMetadata;
abstract format(failures: RuleFailure[], fixes?: RuleFailure[], fileNames?: string[]): string;
protected sortFailures(failures: RuleFailure[]): RuleFailure[];
}

View file

@ -0,0 +1,29 @@
"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 });
exports.AbstractFormatter = void 0;
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;

View file

@ -0,0 +1,52 @@
/**
* @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 { RuleFailure } from "../rule/rule";
export interface IFormatterMetadata {
/**
* The name of the formatter.
*/
formatterName: string;
/**
* A short, one line description of what the formatter does.
*/
description: string;
/**
* More elaborate details about the formatter.
*/
descriptionDetails?: string;
/**
* Sample output from the formatter.
*/
sample: string;
/**
* Sample output from the formatter.
*/
consumer: ConsumerType;
}
export declare type ConsumerType = "human" | "machine";
export interface FormatterConstructor {
new (): IFormatter;
}
export interface IFormatter {
/**
* Formats linter results
* @param failures Linter failures that were not fixed
* @param fixes Fixed linter failures. Available when the `--fix` argument is used on the command line
* @param fileNames All of the file paths that were linted
*/
format(failures: RuleFailure[], fixes?: RuleFailure[], fileNames?: string[]): string;
}

View file

@ -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 });

View file

@ -0,0 +1,43 @@
/**
* @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 { IWalker, WalkContext } from "../walker";
import { IOptions, IRule, IRuleMetadata, RuleFailure, RuleSeverity } from "./rule";
export declare type NoInfer<T> = T & {
[K in keyof T]: T[K];
};
export declare abstract class AbstractRule implements IRule {
private readonly options;
static metadata: IRuleMetadata;
ruleName: string;
protected readonly ruleArguments: any[];
protected readonly ruleSeverity: RuleSeverity;
constructor(options: IOptions);
getOptions(): IOptions;
abstract apply(sourceFile: ts.SourceFile): RuleFailure[];
applyWithWalker(walker: IWalker): RuleFailure[];
isEnabled(): boolean;
protected applyWithFunction(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext) => void): RuleFailure[];
protected applyWithFunction<T>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T>) => void, options: NoInfer<T>): RuleFailure[];
protected applyWithFunction<T, U>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T>, programOrChecker: U) => void, options: NoInfer<T>, checker: NoInfer<U>): RuleFailure[];
/**
* @deprecated
* Failures will be filtered based on `tslint:disable` comments by tslint.
* This method now does nothing.
*/
protected filterFailures(failures: RuleFailure[]): RuleFailure[];
}

53
node_modules/tslint/lib/language/rule/abstractRule.js generated vendored Normal file
View file

@ -0,0 +1,53 @@
"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 });
exports.AbstractRule = void 0;
var walker_1 = require("../walker");
var AbstractRule = /** @class */ (function () {
function AbstractRule(options) {
this.options = options;
this.ruleName = options.ruleName;
this.ruleArguments = options.ruleArguments;
this.ruleSeverity = options.ruleSeverity;
}
AbstractRule.prototype.getOptions = function () {
return this.options;
};
AbstractRule.prototype.applyWithWalker = function (walker) {
walker.walk(walker.getSourceFile());
return walker.getFailures();
};
AbstractRule.prototype.isEnabled = function () {
return this.ruleSeverity !== "off";
};
AbstractRule.prototype.applyWithFunction = function (sourceFile, walkFn, options, programOrChecker) {
var ctx = new walker_1.WalkContext(sourceFile, this.ruleName, options);
walkFn(ctx, programOrChecker);
return ctx.failures;
};
/**
* @deprecated
* Failures will be filtered based on `tslint:disable` comments by tslint.
* This method now does nothing.
*/
AbstractRule.prototype.filterFailures = function (failures) {
return failures;
};
return AbstractRule;
}());
exports.AbstractRule = AbstractRule;

View file

@ -0,0 +1,22 @@
/**
* @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 { AbstractRule } from "./abstractRule";
import { ITypedRule, RuleFailure } from "./rule";
export declare abstract class OptionallyTypedRule extends AbstractRule implements ITypedRule {
abstract applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[];
}

View file

@ -0,0 +1,29 @@
"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 });
exports.OptionallyTypedRule = void 0;
var tslib_1 = require("tslib");
var abstractRule_1 = require("./abstractRule");
var OptionallyTypedRule = /** @class */ (function (_super) {
tslib_1.__extends(OptionallyTypedRule, _super);
function OptionallyTypedRule() {
return _super !== null && _super.apply(this, arguments) || this;
}
return OptionallyTypedRule;
}(abstractRule_1.AbstractRule));
exports.OptionallyTypedRule = OptionallyTypedRule;

191
node_modules/tslint/lib/language/rule/rule.d.ts generated vendored Normal file
View file

@ -0,0 +1,191 @@
/**
* @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 { IWalker } from "../walker";
export interface RuleConstructor {
metadata: IRuleMetadata;
new (options: IOptions): IRule;
}
export interface IRuleMetadata {
/**
* The kebab-case name of the rule.
*/
ruleName: string;
/**
* The type of the rule - its overall purpose
*/
type: RuleType;
/**
* A rule deprecation message, if applicable.
*/
deprecationMessage?: string;
/**
* A short, one line description of what the rule does.
*/
description: string;
/**
* More elaborate details about the rule.
*/
descriptionDetails?: string;
/**
* Whether or not the rule will provide fix suggestions.
*/
hasFix?: boolean;
/**
* An explanation of the available options for the rule.
*/
optionsDescription: string;
/**
* Schema of the options the rule accepts.
* The first boolean for whether the rule is enabled or not is already implied.
* This field describes the options after that boolean.
* If null, this rule has no options and is not configurable.
*/
options: any;
/**
* Examples of what a standard config for the rule might look like.
* Using a string[] here is deprecated. Write the options as a JSON object instead.
*/
optionExamples?: Array<true | any[]> | string[] | Array<{
options: any;
}>;
/**
* An explanation of why the rule is useful.
*/
rationale?: string;
/**
* Whether or not the rule requires type info to run.
*/
requiresTypeInfo?: boolean;
/**
* Whether or not the rule use for TypeScript only. If `false`, this rule may be used with .js files.
*/
typescriptOnly: boolean;
/**
* Examples demonstrating what the lint rule will pass and fail
*/
codeExamples?: ICodeExample[];
}
export declare type RuleType = "functionality" | "maintainability" | "style" | "typescript" | "formatting";
export declare type RuleSeverity = "warning" | "error" | "off";
export interface ICodeExample {
config: string;
description: string;
pass: string;
fail?: string;
}
export interface IOptions {
ruleArguments: any[];
ruleSeverity: RuleSeverity;
ruleName: string;
/**
* @deprecated
* Tslint now handles disables itself.
* This will be empty.
*/
disabledIntervals: IDisabledInterval[];
}
/**
* @deprecated
* These are now handled internally.
*/
export interface IDisabledInterval {
startPosition: number;
endPosition: number;
}
export interface IRule {
getOptions(): IOptions;
isEnabled(): boolean;
apply(sourceFile: ts.SourceFile): RuleFailure[];
applyWithWalker(walker: IWalker): RuleFailure[];
}
export interface ITypedRule extends IRule {
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[];
}
export interface IRuleFailureJson {
endPosition: IRuleFailurePositionJson;
failure: string;
fix?: FixJson;
name: string;
ruleSeverity: string;
ruleName: string;
startPosition: IRuleFailurePositionJson;
}
export interface IRuleFailurePositionJson {
character: number;
line: number;
position: number;
}
export declare function isTypedRule(rule: IRule): rule is ITypedRule;
export interface ReplacementJson {
innerStart: number;
innerLength: number;
innerText: string;
}
export declare class Replacement {
readonly start: number;
readonly length: number;
readonly text: string;
static applyFixes(content: string, fixes: Fix[]): string;
static applyAll(content: string, replacements: Replacement[]): string;
static replaceNode(node: ts.Node, text: string, sourceFile?: ts.SourceFile): Replacement;
static replaceFromTo(start: number, end: number, text: string): Replacement;
static deleteText(start: number, length: number): Replacement;
static deleteFromTo(start: number, end: number): Replacement;
static appendText(start: number, text: string): Replacement;
constructor(start: number, length: number, text: string);
get end(): number;
apply(content: string): string;
toJson(): ReplacementJson;
}
export declare class RuleFailurePosition {
private readonly position;
private readonly lineAndCharacter;
constructor(position: number, lineAndCharacter: ts.LineAndCharacter);
getPosition(): number;
getLineAndCharacter(): ts.LineAndCharacter;
toJson(): IRuleFailurePositionJson;
equals(ruleFailurePosition: RuleFailurePosition): boolean;
}
export declare type Fix = Replacement | Replacement[];
export declare type FixJson = ReplacementJson | ReplacementJson[];
export declare class RuleFailure {
private readonly sourceFile;
private readonly failure;
private readonly ruleName;
private readonly fix?;
static compare(a: RuleFailure, b: RuleFailure): number;
private readonly fileName;
private readonly startPosition;
private readonly endPosition;
private readonly rawLines;
private ruleSeverity;
constructor(sourceFile: ts.SourceFile, start: number, end: number, failure: string, ruleName: string, fix?: Replacement | Replacement[] | undefined);
getFileName(): string;
getRuleName(): string;
getStartPosition(): RuleFailurePosition;
getEndPosition(): RuleFailurePosition;
getFailure(): string;
hasFix(): boolean;
getFix(): Replacement | Replacement[] | undefined;
getRawLines(): string;
getRuleSeverity(): RuleSeverity;
setRuleSeverity(value: RuleSeverity): void;
toJson(): IRuleFailureJson;
equals(ruleFailure: RuleFailure): boolean;
private createFailurePosition;
}

181
node_modules/tslint/lib/language/rule/rule.js generated vendored Normal file
View file

@ -0,0 +1,181 @@
"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 });
exports.RuleFailure = exports.RuleFailurePosition = exports.Replacement = exports.isTypedRule = void 0;
var utils_1 = require("../../utils");
function isTypedRule(rule) {
return "applyWithProgram" in rule;
}
exports.isTypedRule = isTypedRule;
var Replacement = /** @class */ (function () {
function Replacement(start, length, text) {
this.start = start;
this.length = length;
this.text = text;
}
Replacement.applyFixes = function (content, fixes) {
return Replacement.applyAll(content, utils_1.flatMap(fixes, utils_1.arrayify));
};
Replacement.applyAll = function (content, replacements) {
// sort in reverse so that diffs are properly applied
replacements.sort(function (a, b) { return (b.end !== a.end ? b.end - a.end : b.start - a.start); });
return replacements.reduce(function (text, r) { return r.apply(text); }, content);
};
Replacement.replaceNode = function (node, text, sourceFile) {
return Replacement.replaceFromTo(node.getStart(sourceFile), node.getEnd(), text);
};
Replacement.replaceFromTo = function (start, end, text) {
return new Replacement(start, end - start, text);
};
Replacement.deleteText = function (start, length) {
return new Replacement(start, length, "");
};
Replacement.deleteFromTo = function (start, end) {
return new Replacement(start, end - start, "");
};
Replacement.appendText = function (start, text) {
return new Replacement(start, 0, text);
};
Object.defineProperty(Replacement.prototype, "end", {
get: function () {
return this.start + this.length;
},
enumerable: false,
configurable: true
});
Replacement.prototype.apply = function (content) {
return (content.substring(0, this.start) +
this.text +
content.substring(this.start + this.length));
};
Replacement.prototype.toJson = function () {
// tslint:disable object-literal-sort-keys
return {
innerStart: this.start,
innerLength: this.length,
innerText: this.text,
};
// tslint:enable object-literal-sort-keys
};
return Replacement;
}());
exports.Replacement = Replacement;
var RuleFailurePosition = /** @class */ (function () {
function RuleFailurePosition(position, lineAndCharacter) {
this.position = position;
this.lineAndCharacter = lineAndCharacter;
}
RuleFailurePosition.prototype.getPosition = function () {
return this.position;
};
RuleFailurePosition.prototype.getLineAndCharacter = function () {
return this.lineAndCharacter;
};
RuleFailurePosition.prototype.toJson = function () {
return {
character: this.lineAndCharacter.character,
line: this.lineAndCharacter.line,
position: this.position,
};
};
RuleFailurePosition.prototype.equals = function (ruleFailurePosition) {
var ll = this.lineAndCharacter;
var rr = ruleFailurePosition.lineAndCharacter;
return (this.position === ruleFailurePosition.position &&
ll.line === rr.line &&
ll.character === rr.character);
};
return RuleFailurePosition;
}());
exports.RuleFailurePosition = RuleFailurePosition;
var RuleFailure = /** @class */ (function () {
function RuleFailure(sourceFile, start, end, failure, ruleName, fix) {
this.sourceFile = sourceFile;
this.failure = failure;
this.ruleName = ruleName;
this.fix = fix;
this.fileName = sourceFile.fileName;
this.startPosition = this.createFailurePosition(start);
this.endPosition = this.createFailurePosition(end);
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;
};
RuleFailure.prototype.getRuleName = function () {
return this.ruleName;
};
RuleFailure.prototype.getStartPosition = function () {
return this.startPosition;
};
RuleFailure.prototype.getEndPosition = function () {
return this.endPosition;
};
RuleFailure.prototype.getFailure = function () {
return this.failure;
};
RuleFailure.prototype.hasFix = function () {
return this.fix !== undefined;
};
RuleFailure.prototype.getFix = function () {
return this.fix;
};
RuleFailure.prototype.getRawLines = function () {
return this.rawLines;
};
RuleFailure.prototype.getRuleSeverity = function () {
return this.ruleSeverity;
};
RuleFailure.prototype.setRuleSeverity = function (value) {
this.ruleSeverity = value;
};
RuleFailure.prototype.toJson = function () {
return {
endPosition: this.endPosition.toJson(),
failure: this.failure,
fix: this.fix === undefined
? undefined
: Array.isArray(this.fix)
? this.fix.map(function (r) { return r.toJson(); })
: this.fix.toJson(),
name: this.fileName,
ruleName: this.ruleName,
ruleSeverity: this.ruleSeverity,
startPosition: this.startPosition.toJson(),
};
};
RuleFailure.prototype.equals = function (ruleFailure) {
return (this.failure === ruleFailure.getFailure() &&
this.fileName === ruleFailure.getFileName() &&
this.startPosition.equals(ruleFailure.getStartPosition()) &&
this.endPosition.equals(ruleFailure.getEndPosition()));
};
RuleFailure.prototype.createFailurePosition = function (position) {
var lineAndCharacter = this.sourceFile.getLineAndCharacterOfPosition(position);
return new RuleFailurePosition(position, lineAndCharacter);
};
return RuleFailure;
}());
exports.RuleFailure = RuleFailure;

23
node_modules/tslint/lib/language/rule/typedRule.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* @license
* Copyright 2018 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 { AbstractRule } from "./abstractRule";
import { ITypedRule, RuleFailure } from "./rule";
export declare abstract class TypedRule extends AbstractRule implements ITypedRule {
apply(): RuleFailure[];
abstract applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[];
}

35
node_modules/tslint/lib/language/rule/typedRule.js generated vendored Normal file
View file

@ -0,0 +1,35 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.TypedRule = void 0;
var tslib_1 = require("tslib");
var error_1 = require("../../error");
var abstractRule_1 = require("./abstractRule");
var TypedRule = /** @class */ (function (_super) {
tslib_1.__extends(TypedRule, _super);
function TypedRule() {
return _super !== null && _super.apply(this, arguments) || this;
}
TypedRule.prototype.apply = function () {
// if no program is given to the linter, show an error
error_1.showWarningOnce("Warning: The '" + this.ruleName + "' rule requires type information.");
return [];
};
return TypedRule;
}(abstractRule_1.AbstractRule));
exports.TypedRule = TypedRule;

18
node_modules/tslint/lib/language/typeUtils.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
/**
* @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";
export declare const typeIsOrHasBaseType: (type: ts.Type, parentType: ts.Type) => boolean;

36
node_modules/tslint/lib/language/typeUtils.js generated vendored Normal file
View file

@ -0,0 +1,36 @@
"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 });
exports.typeIsOrHasBaseType = void 0;
exports.typeIsOrHasBaseType = function (type, parentType) {
if (type.symbol === undefined || parentType.symbol === undefined) {
return false;
}
var typeAndBaseTypes = [type];
var ancestorTypes = type.getBaseTypes();
if (ancestorTypes !== undefined) {
typeAndBaseTypes.push.apply(typeAndBaseTypes, ancestorTypes);
}
for (var _i = 0, typeAndBaseTypes_1 = typeAndBaseTypes; _i < typeAndBaseTypes_1.length; _i++) {
var baseType = typeAndBaseTypes_1[_i];
if (baseType.symbol !== undefined && baseType.symbol.name === parentType.symbol.name) {
return true;
}
}
return false;
};

157
node_modules/tslint/lib/language/utils.d.ts generated vendored Normal file
View file

@ -0,0 +1,157 @@
/**
* @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 { IDisabledInterval, RuleFailure } from "./rule/rule";
export declare function getSourceFile(fileName: string, source: string): ts.SourceFile;
/** @deprecated See IDisabledInterval. */
export declare function doesIntersect(failure: RuleFailure, disabledIntervals: IDisabledInterval[]): boolean;
/**
* @returns true if any modifier kinds passed along exist in the given modifiers array
*
* @deprecated use `hasModifier` from `tsutils`
*/
export declare function hasModifier(modifiers: ts.ModifiersArray | undefined, ...modifierKinds: ts.SyntaxKind[]): boolean;
/**
* Determines if the appropriate bit in the parent (VariableDeclarationList) is set,
* which indicates this is a "let" or "const".
*
* @deprecated use `isBlockScopedVariableDeclarationList` from `tsutils`
*/
export declare function isBlockScopedVariable(node: ts.VariableDeclaration | ts.VariableStatement): boolean;
/** @deprecated use `isBlockScopedVariableDeclarationList` and `getDeclarationOfBindingElement` from `tsutils` */
export declare function isBlockScopedBindingElement(node: ts.BindingElement): boolean;
/** @deprecated use `getDeclarationOfBindingElement` from `tsutils` */
export declare function getBindingElementVariableDeclaration(node: ts.BindingElement): ts.VariableDeclaration | null;
/**
* Finds a child of a given node with a given kind.
* Note: This uses `node.getChildren()`, which does extra parsing work to include tokens.
*
* @deprecated use `getChildOfKind` from `tsutils`
*/
export declare function childOfKind(node: ts.Node, kind: ts.SyntaxKind): ts.Node | undefined;
/**
* @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself.
*
* @deprecated no longer used, use a `while` loop instead
*/
export declare function someAncestor(node: ts.Node, predicate: (n: ts.Node) => boolean): boolean;
export declare function ancestorWhere<T extends ts.Node = ts.Node>(node: ts.Node, predicate: ((n: ts.Node) => n is T) | ((n: ts.Node) => boolean)): T | undefined;
/** @deprecated use `isBinaryExpression(node) && isAssignmentKind(node.operatorToken.kind)` with functions from `tsutils` */
export declare function isAssignment(node: ts.Node): boolean;
/**
* Bitwise check for node flags.
*
* @deprecated use `isNodeFlagSet` from `tsutils`
*/
export declare function isNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean;
/**
* Bitwise check for combined node flags.
*
* @deprecated no longer used
*/
export declare function isCombinedNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean;
/**
* Bitwise check for combined modifier flags.
*
* @deprecated no longer used
*/
export declare function isCombinedModifierFlagSet(node: ts.Declaration, flagToCheck: ts.ModifierFlags): boolean;
/**
* Bitwise check for type flags.
*
* @deprecated use `isTypeFlagSet` from `tsutils`
*/
export declare function isTypeFlagSet(type: ts.Type, flagToCheck: ts.TypeFlags): boolean;
/**
* Bitwise check for symbol flags.
*
* @deprecated use `isSymbolFlagSet` from `tsutils`
*/
export declare function isSymbolFlagSet(symbol: ts.Symbol, flagToCheck: ts.SymbolFlags): boolean;
/**
* Bitwise check for object flags.
* Does not work with TypeScript 2.0.x
*
* @deprecated use `isObjectFlagSet` from `tsutils`
*/
export declare function isObjectFlagSet(objectType: ts.ObjectType, flagToCheck: ts.ObjectFlags): boolean;
/**
* @returns true if decl is a nested module declaration, i.e. represents a segment of a dotted module path.
*
* @deprecated use `decl.parent!.kind === ts.SyntaxKind.ModuleDeclaration`
*/
export declare function isNestedModuleDeclaration(decl: ts.ModuleDeclaration): boolean;
export declare function unwrapParentheses(node: ts.Expression): ts.Expression;
/** @deprecated use `isFunctionScopeBoundary` from `tsutils` */
export declare function isScopeBoundary(node: ts.Node): boolean;
/** @deprecated use `isBlockScopeBoundary` from `tsutils` */
export declare function isBlockScopeBoundary(node: ts.Node): boolean;
/** @deprecated use `isIterationStatement` from `tsutils` or `typescript` */
export declare function isLoop(node: ts.Node): node is ts.IterationStatement;
/**
* @returns Whether node is a numeric expression.
*/
export declare function isNumeric(node: ts.Expression): boolean;
export interface TokenPosition {
/** The start of the token including all trivia before it */
fullStart: number;
/** The start of the token */
tokenStart: number;
/** The end of the token */
end: number;
}
export declare type ForEachTokenCallback = (fullText: string, kind: ts.SyntaxKind, pos: TokenPosition, parent: ts.Node) => void;
export declare type ForEachCommentCallback = (fullText: string, kind: ts.SyntaxKind, pos: TokenPosition) => void;
export declare type FilterCallback = (node: ts.Node) => boolean;
/**
* Iterate over all tokens of `node`
*
* @description JsDoc comments are treated like regular comments and only visited if `skipTrivia` === false.
*
* @param node The node whose tokens should be visited
* @param skipTrivia If set to false all trivia preceeding `node` or any of its children is included
* @param cb Is called for every token of `node`. It gets the full text of the SourceFile and the position of the token within that text.
* @param filter If provided, will be called for every Node and Token found. If it returns false `cb` will not be called for this subtree.
*
* @deprecated use `forEachToken` or `forEachTokenWithTrivia` from `tsutils`
*/
export declare function forEachToken(node: ts.Node, skipTrivia: boolean, cb: ForEachTokenCallback, filter?: FilterCallback): void;
/**
* Iterate over all comments owned by `node` or its children
*
* @deprecated use `forEachComment` from `tsutils`
*/
export declare function forEachComment(node: ts.Node, cb: ForEachCommentCallback): void;
/**
* Checks if there are any comments between `position` and the next non-trivia token
*
* @param text The text to scan
* @param position The position inside `text` where to start scanning. Make sure that this is a valid start position.
* This value is typically obtained from `node.getFullStart()` or `node.getEnd()`
*/
export declare function hasCommentAfterPosition(text: string, position: number): boolean;
export interface EqualsKind {
isPositive: boolean;
isStrict: boolean;
}
export declare function getEqualsKind(node: ts.BinaryOperatorToken): EqualsKind | undefined;
export declare function isStrictNullChecksEnabled(options: ts.CompilerOptions): boolean;
export declare function isNegativeNumberLiteral(node: ts.Node): node is ts.PrefixUnaryExpression & {
operand: ts.NumericLiteral;
};
/** Wrapper for compatibility with typescript@<2.3.1 */
export declare function isWhiteSpace(ch: number): boolean;

479
node_modules/tslint/lib/language/utils.js generated vendored Normal file
View file

@ -0,0 +1,479 @@
"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 });
exports.isWhiteSpace = exports.isNegativeNumberLiteral = exports.isStrictNullChecksEnabled = exports.getEqualsKind = exports.hasCommentAfterPosition = exports.forEachComment = exports.forEachToken = exports.isNumeric = exports.isLoop = exports.isBlockScopeBoundary = exports.isScopeBoundary = exports.unwrapParentheses = exports.isNestedModuleDeclaration = exports.isObjectFlagSet = exports.isSymbolFlagSet = exports.isTypeFlagSet = exports.isCombinedModifierFlagSet = exports.isCombinedNodeFlagSet = exports.isNodeFlagSet = exports.isAssignment = exports.ancestorWhere = exports.someAncestor = exports.childOfKind = exports.getBindingElementVariableDeclaration = exports.isBlockScopedBindingElement = exports.isBlockScopedVariable = exports.hasModifier = exports.doesIntersect = exports.getSourceFile = void 0;
var path = require("path");
var tsutils_1 = require("tsutils");
var ts = require("typescript");
function getSourceFile(fileName, source) {
var normalizedName = path.normalize(fileName).replace(/\\/g, "/");
return ts.createSourceFile(normalizedName, source, ts.ScriptTarget.ES5,
/*setParentNodes*/ true);
}
exports.getSourceFile = getSourceFile;
/** @deprecated See IDisabledInterval. */
function doesIntersect(failure,
// tslint:disable-next-line:deprecation
disabledIntervals) {
return disabledIntervals.some(function (interval) {
var maxStart = Math.max(interval.startPosition, failure.getStartPosition().getPosition());
var minEnd = Math.min(interval.endPosition, failure.getEndPosition().getPosition());
return maxStart <= minEnd;
});
}
exports.doesIntersect = doesIntersect;
/**
* @returns true if any modifier kinds passed along exist in the given modifiers array
*
* @deprecated use `hasModifier` from `tsutils`
*/
function hasModifier(modifiers) {
var modifierKinds = [];
for (var _i = 1; _i < arguments.length; _i++) {
modifierKinds[_i - 1] = arguments[_i];
}
if (modifiers === undefined || modifierKinds.length === 0) {
return false;
}
return modifiers.some(function (m) { return modifierKinds.some(function (k) { return m.kind === k; }); });
}
exports.hasModifier = hasModifier;
/**
* Determines if the appropriate bit in the parent (VariableDeclarationList) is set,
* which indicates this is a "let" or "const".
*
* @deprecated use `isBlockScopedVariableDeclarationList` from `tsutils`
*/
function isBlockScopedVariable(node) {
if (node.kind === ts.SyntaxKind.VariableDeclaration) {
var parent = node.parent;
return (parent.kind === ts.SyntaxKind.CatchClause ||
tsutils_1.isBlockScopedVariableDeclarationList(parent));
}
else {
return tsutils_1.isBlockScopedVariableDeclarationList(node.declarationList);
}
}
exports.isBlockScopedVariable = isBlockScopedVariable;
/** @deprecated use `isBlockScopedVariableDeclarationList` and `getDeclarationOfBindingElement` from `tsutils` */
function isBlockScopedBindingElement(node) {
var variableDeclaration = getBindingElementVariableDeclaration(node); // tslint:disable-line:deprecation
// if no variable declaration, it must be a function param, which is block scoped
return variableDeclaration === null || isBlockScopedVariable(variableDeclaration); // tslint:disable-line:deprecation
}
exports.isBlockScopedBindingElement = isBlockScopedBindingElement;
/** @deprecated use `getDeclarationOfBindingElement` from `tsutils` */
function getBindingElementVariableDeclaration(node) {
var currentParent = node.parent;
while (currentParent.kind !== ts.SyntaxKind.VariableDeclaration) {
if (currentParent.parent === undefined) {
return null; // function parameter, no variable declaration
}
else {
currentParent = currentParent.parent;
}
}
return currentParent;
}
exports.getBindingElementVariableDeclaration = getBindingElementVariableDeclaration;
/**
* Finds a child of a given node with a given kind.
* Note: This uses `node.getChildren()`, which does extra parsing work to include tokens.
*
* @deprecated use `getChildOfKind` from `tsutils`
*/
function childOfKind(node, kind) {
return node.getChildren().find(function (child) { return child.kind === kind; });
}
exports.childOfKind = childOfKind;
/**
* @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself.
*
* @deprecated no longer used, use a `while` loop instead
*/
function someAncestor(node, predicate) {
return predicate(node) || (node.parent !== undefined && someAncestor(node.parent, predicate)); // tslint:disable-line:deprecation
}
exports.someAncestor = someAncestor;
function ancestorWhere(node, predicate) {
var cur = node;
do {
if (predicate(cur)) {
return cur;
}
cur = cur.parent;
} while (cur !== undefined);
return undefined;
}
exports.ancestorWhere = ancestorWhere;
/** @deprecated use `isBinaryExpression(node) && isAssignmentKind(node.operatorToken.kind)` with functions from `tsutils` */
function isAssignment(node) {
if (node.kind === ts.SyntaxKind.BinaryExpression) {
var binaryExpression = node;
return (binaryExpression.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
binaryExpression.operatorToken.kind <= ts.SyntaxKind.LastAssignment);
}
else {
return false;
}
}
exports.isAssignment = isAssignment;
/**
* Bitwise check for node flags.
*
* @deprecated use `isNodeFlagSet` from `tsutils`
*/
function isNodeFlagSet(node, flagToCheck) {
// tslint:disable-next-line:no-bitwise
return (node.flags & flagToCheck) !== 0;
}
exports.isNodeFlagSet = isNodeFlagSet;
/**
* Bitwise check for combined node flags.
*
* @deprecated no longer used
*/
function isCombinedNodeFlagSet(node, flagToCheck) {
// tslint:disable-next-line:no-bitwise
return (ts.getCombinedNodeFlags(node) & flagToCheck) !== 0;
}
exports.isCombinedNodeFlagSet = isCombinedNodeFlagSet;
/**
* Bitwise check for combined modifier flags.
*
* @deprecated no longer used
*/
function isCombinedModifierFlagSet(node, flagToCheck) {
// tslint:disable-next-line:no-bitwise
return (ts.getCombinedModifierFlags(node) & flagToCheck) !== 0;
}
exports.isCombinedModifierFlagSet = isCombinedModifierFlagSet;
/**
* Bitwise check for type flags.
*
* @deprecated use `isTypeFlagSet` from `tsutils`
*/
function isTypeFlagSet(type, flagToCheck) {
// tslint:disable-next-line:no-bitwise
return (type.flags & flagToCheck) !== 0;
}
exports.isTypeFlagSet = isTypeFlagSet;
/**
* Bitwise check for symbol flags.
*
* @deprecated use `isSymbolFlagSet` from `tsutils`
*/
function isSymbolFlagSet(symbol, flagToCheck) {
// tslint:disable-next-line:no-bitwise
return (symbol.flags & flagToCheck) !== 0;
}
exports.isSymbolFlagSet = isSymbolFlagSet;
/**
* Bitwise check for object flags.
* Does not work with TypeScript 2.0.x
*
* @deprecated use `isObjectFlagSet` from `tsutils`
*/
function isObjectFlagSet(objectType, flagToCheck) {
// tslint:disable-next-line:no-bitwise
return (objectType.objectFlags & flagToCheck) !== 0;
}
exports.isObjectFlagSet = isObjectFlagSet;
/**
* @returns true if decl is a nested module declaration, i.e. represents a segment of a dotted module path.
*
* @deprecated use `decl.parent!.kind === ts.SyntaxKind.ModuleDeclaration`
*/
function isNestedModuleDeclaration(decl) {
// in a declaration expression like 'module a.b.c' - 'a' is the top level module declaration node and 'b' and 'c'
// are nested therefore we can depend that a node's position will only match with its name's position for nested
// nodes
return decl.name.pos === decl.pos;
}
exports.isNestedModuleDeclaration = isNestedModuleDeclaration;
function unwrapParentheses(node) {
while (node.kind === ts.SyntaxKind.ParenthesizedExpression) {
node = node.expression;
}
return node;
}
exports.unwrapParentheses = unwrapParentheses;
/** @deprecated use `isFunctionScopeBoundary` from `tsutils` */
function isScopeBoundary(node) {
return (node.kind === ts.SyntaxKind.FunctionDeclaration ||
node.kind === ts.SyntaxKind.FunctionExpression ||
node.kind === ts.SyntaxKind.PropertyAssignment ||
node.kind === ts.SyntaxKind.ShorthandPropertyAssignment ||
node.kind === ts.SyntaxKind.MethodDeclaration ||
node.kind === ts.SyntaxKind.Constructor ||
node.kind === ts.SyntaxKind.ModuleDeclaration ||
node.kind === ts.SyntaxKind.ArrowFunction ||
node.kind === ts.SyntaxKind.ParenthesizedExpression ||
node.kind === ts.SyntaxKind.ClassDeclaration ||
node.kind === ts.SyntaxKind.ClassExpression ||
node.kind === ts.SyntaxKind.InterfaceDeclaration ||
node.kind === ts.SyntaxKind.GetAccessor ||
node.kind === ts.SyntaxKind.SetAccessor ||
(node.kind === ts.SyntaxKind.SourceFile && ts.isExternalModule(node)));
}
exports.isScopeBoundary = isScopeBoundary;
/** @deprecated use `isBlockScopeBoundary` from `tsutils` */
function isBlockScopeBoundary(node) {
return (isScopeBoundary(node) || // tslint:disable-line:deprecation
node.kind === ts.SyntaxKind.Block ||
isLoop(node) || // tslint:disable-line:deprecation
node.kind === ts.SyntaxKind.WithStatement ||
node.kind === ts.SyntaxKind.SwitchStatement ||
(node.parent !== undefined &&
(node.parent.kind === ts.SyntaxKind.TryStatement ||
node.parent.kind === ts.SyntaxKind.IfStatement)));
}
exports.isBlockScopeBoundary = isBlockScopeBoundary;
/** @deprecated use `isIterationStatement` from `tsutils` or `typescript` */
function isLoop(node) {
return (node.kind === ts.SyntaxKind.DoStatement ||
node.kind === ts.SyntaxKind.WhileStatement ||
node.kind === ts.SyntaxKind.ForStatement ||
node.kind === ts.SyntaxKind.ForInStatement ||
node.kind === ts.SyntaxKind.ForOfStatement);
}
exports.isLoop = isLoop;
/**
* @returns Whether node is a numeric expression.
*/
function isNumeric(node) {
while (tsutils_1.isPrefixUnaryExpression(node) &&
(node.operator === ts.SyntaxKind.PlusToken || node.operator === ts.SyntaxKind.MinusToken)) {
node = node.operand;
}
return (node.kind === ts.SyntaxKind.NumericLiteral ||
(tsutils_1.isIdentifier(node) && (node.text === "NaN" || node.text === "Infinity")));
}
exports.isNumeric = isNumeric;
/**
* Iterate over all tokens of `node`
*
* @description JsDoc comments are treated like regular comments and only visited if `skipTrivia` === false.
*
* @param node The node whose tokens should be visited
* @param skipTrivia If set to false all trivia preceeding `node` or any of its children is included
* @param cb Is called for every token of `node`. It gets the full text of the SourceFile and the position of the token within that text.
* @param filter If provided, will be called for every Node and Token found. If it returns false `cb` will not be called for this subtree.
*
* @deprecated use `forEachToken` or `forEachTokenWithTrivia` from `tsutils`
*/
function forEachToken(node, skipTrivia, cb, filter) {
// this function will most likely be called with SourceFile anyways, so there is no need for an additional parameter
var sourceFile = node.getSourceFile();
var fullText = sourceFile.text;
var iterateFn = filter === undefined ? iterateChildren : iterateWithFilter;
var handleTrivia = skipTrivia ? undefined : createTriviaHandler(sourceFile, cb);
iterateFn(node);
// this function is used to save the if condition for the common case where no filter is provided
function iterateWithFilter(child) {
if (filter(child)) {
return iterateChildren(child);
}
}
function iterateChildren(child) {
if (child.kind < ts.SyntaxKind.FirstNode ||
// for backwards compatibility to typescript 2.0.10
// JsxText was no Token, but a Node in that version
child.kind === ts.SyntaxKind.JsxText) {
// we found a token, tokens have no children, stop recursing here
return callback(child);
}
/* Exclude everything contained in JsDoc, it will be handled with the other trivia anyway.
* When we would handle JsDoc tokens like regular ones, we would scan some trivia multiple times.
* Even worse, we would scan for trivia inside the JsDoc comment, which yields unexpected results.*/
if (child.kind !== ts.SyntaxKind.JSDocComment) {
// recurse into Node's children to find tokens
return child.getChildren(sourceFile).forEach(iterateFn);
}
}
function callback(token) {
var tokenStart = token.getStart(sourceFile);
if (!skipTrivia && tokenStart !== token.pos) {
// we only have to handle trivia before each token, because there is nothing after EndOfFileToken
handleTrivia(token.pos, tokenStart, token);
}
return cb(fullText, token.kind, { tokenStart: tokenStart, fullStart: token.pos, end: token.end }, token.parent);
}
}
exports.forEachToken = forEachToken;
function createTriviaHandler(sourceFile, cb) {
var fullText = sourceFile.text;
var scanner = ts.createScanner(sourceFile.languageVersion, false, sourceFile.languageVariant, fullText);
/**
* Scan the specified range to get all trivia tokens.
* This includes trailing trivia of the last token and the leading trivia of the current token
*/
function handleTrivia(start, end, token) {
var parent = token.parent;
// prevent false positives by not scanning inside JsxText
if (!canHaveLeadingTrivia(token.kind, parent)) {
return;
}
scanner.setTextPos(start);
var position;
// we only get here if start !== end, so we can scan at least one time
do {
var kind = scanner.scan();
position = scanner.getTextPos();
cb(fullText, kind, { tokenStart: scanner.getTokenPos(), end: position, fullStart: start }, parent);
} while (position < end);
}
return handleTrivia;
}
/**
* Iterate over all comments owned by `node` or its children
*
* @deprecated use `forEachComment` from `tsutils`
*/
function forEachComment(node, cb) {
/* Visit all tokens and skip trivia.
Comment ranges between tokens are parsed without the need of a scanner.
forEachToken also does intentionally not pay attention to the correct comment ownership of nodes as it always
scans all trivia before each token, which could include trailing comments of the previous token.
Comment onwership is done right in this function*/
// tslint:disable-next-line:deprecation
return forEachToken(node, true, function (fullText, tokenKind, pos, parent) {
// don't search for comments inside JsxText
if (canHaveLeadingTrivia(tokenKind, parent)) {
// Comments before the first token (pos.fullStart === 0) are all considered leading comments, so no need for special treatment
var comments = ts.getLeadingCommentRanges(fullText, pos.fullStart);
if (comments !== undefined) {
for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
var comment = comments_1[_i];
cb(fullText, comment.kind, {
end: comment.end,
fullStart: pos.fullStart,
tokenStart: comment.pos,
});
}
}
}
if (canHaveTrailingTrivia(tokenKind, parent)) {
var comments = ts.getTrailingCommentRanges(fullText, pos.end);
if (comments !== undefined) {
for (var _a = 0, comments_2 = comments; _a < comments_2.length; _a++) {
var comment = comments_2[_a];
cb(fullText, comment.kind, {
end: comment.end,
fullStart: pos.fullStart,
tokenStart: comment.pos,
});
}
}
}
});
}
exports.forEachComment = forEachComment;
/** Exclude leading positions that would lead to scanning for trivia inside JsxText */
function canHaveLeadingTrivia(tokenKind, parent) {
switch (tokenKind) {
case ts.SyntaxKind.JsxText:
return false; // there is no trivia before JsxText
case ts.SyntaxKind.OpenBraceToken:
// before a JsxExpression inside a JsxElement's body can only be other JsxChild, but no trivia
return (parent.kind !== ts.SyntaxKind.JsxExpression ||
parent.parent.kind !== ts.SyntaxKind.JsxElement);
case ts.SyntaxKind.LessThanToken:
switch (parent.kind) {
case ts.SyntaxKind.JsxClosingElement:
return false; // would be inside the element body
case ts.SyntaxKind.JsxOpeningElement:
case ts.SyntaxKind.JsxSelfClosingElement:
// there can only be leading trivia if we are at the end of the top level element
return parent.parent.parent.kind !== ts.SyntaxKind.JsxElement;
default:
return true;
}
default:
return true;
}
}
/** Exclude trailing positions that would lead to scanning for trivia inside JsxText */
function canHaveTrailingTrivia(tokenKind, parent) {
switch (tokenKind) {
case ts.SyntaxKind.JsxText:
// there is no trivia after JsxText
return false;
case ts.SyntaxKind.CloseBraceToken:
// after a JsxExpression inside a JsxElement's body can only be other JsxChild, but no trivia
return (parent.kind !== ts.SyntaxKind.JsxExpression ||
parent.parent.kind !== ts.SyntaxKind.JsxElement);
case ts.SyntaxKind.GreaterThanToken:
switch (parent.kind) {
case ts.SyntaxKind.JsxOpeningElement:
return false; // would be inside the element
case ts.SyntaxKind.JsxClosingElement:
case ts.SyntaxKind.JsxSelfClosingElement:
// there can only be trailing trivia if we are at the end of the top level element
return parent.parent.parent.kind !== ts.SyntaxKind.JsxElement;
default:
return true;
}
default:
return true;
}
}
/**
* Checks if there are any comments between `position` and the next non-trivia token
*
* @param text The text to scan
* @param position The position inside `text` where to start scanning. Make sure that this is a valid start position.
* This value is typically obtained from `node.getFullStart()` or `node.getEnd()`
*/
function hasCommentAfterPosition(text, position) {
return (ts.getTrailingCommentRanges(text, position) !== undefined ||
ts.getLeadingCommentRanges(text, position) !== undefined);
}
exports.hasCommentAfterPosition = hasCommentAfterPosition;
function getEqualsKind(node) {
switch (node.kind) {
case ts.SyntaxKind.EqualsEqualsToken:
return { isPositive: true, isStrict: false };
case ts.SyntaxKind.EqualsEqualsEqualsToken:
return { isPositive: true, isStrict: true };
case ts.SyntaxKind.ExclamationEqualsToken:
return { isPositive: false, isStrict: false };
case ts.SyntaxKind.ExclamationEqualsEqualsToken:
return { isPositive: false, isStrict: true };
default:
return undefined;
}
}
exports.getEqualsKind = getEqualsKind;
function isStrictNullChecksEnabled(options) {
return (options.strictNullChecks === true ||
(options.strict === true && options.strictNullChecks !== false));
}
exports.isStrictNullChecksEnabled = isStrictNullChecksEnabled;
function isNegativeNumberLiteral(node) {
return (tsutils_1.isPrefixUnaryExpression(node) &&
node.operator === ts.SyntaxKind.MinusToken &&
node.operand.kind === ts.SyntaxKind.NumericLiteral);
}
exports.isNegativeNumberLiteral = isNegativeNumberLiteral;
/** Wrapper for compatibility with typescript@<2.3.1 */
function isWhiteSpace(ch) {
// tslint:disable-next-line
return (ts.isWhiteSpaceLike || ts.isWhiteSpace)(ch);
}
exports.isWhiteSpace = isWhiteSpace;

View file

@ -0,0 +1,38 @@
/**
* @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 { IOptions } from "../rule/rule";
import { ScopeAwareRuleWalker } from "./scopeAwareRuleWalker";
/**
* @deprecated See comment on ScopeAwareRuleWalker.
*
* An AST walker that is aware of block scopes in addition to regular scopes. Block scopes
* are a superset of regular scopes (new block scopes are created more frequently in a program).
*/
export declare abstract class BlockScopeAwareRuleWalker<T, U> extends ScopeAwareRuleWalker<T> {
private readonly blockScopeStack;
constructor(sourceFile: ts.SourceFile, options: IOptions);
abstract createBlockScope(node: ts.Node): U;
getAllBlockScopes(): U[];
getCurrentBlockScope(): U;
getCurrentBlockDepth(): number;
onBlockScopeStart(): void;
onBlockScopeEnd(): void;
findBlockScope(predicate: (scope: U) => boolean): U | undefined;
protected visitNode(node: ts.Node): void;
private isBlockScopeBoundary;
}

View file

@ -0,0 +1,85 @@
"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 });
exports.BlockScopeAwareRuleWalker = void 0;
var tslib_1 = require("tslib");
var ts = require("typescript");
var utils_1 = require("../utils");
var scopeAwareRuleWalker_1 = require("./scopeAwareRuleWalker");
// tslint:disable:deprecation (extends deprecated class and uses deprecated utils - doesn't matter because it's deprecated, too)
/**
* @deprecated See comment on ScopeAwareRuleWalker.
*
* An AST walker that is aware of block scopes in addition to regular scopes. Block scopes
* are a superset of regular scopes (new block scopes are created more frequently in a program).
*/
var BlockScopeAwareRuleWalker = /** @class */ (function (_super) {
tslib_1.__extends(BlockScopeAwareRuleWalker, _super);
function BlockScopeAwareRuleWalker(sourceFile, options) {
var _this = _super.call(this, sourceFile, options) || this;
// initialize with global scope if file is not a module
_this.blockScopeStack = ts.isExternalModule(sourceFile)
? []
: [_this.createBlockScope(sourceFile)];
return _this;
}
// get all block scopes available at this depth
BlockScopeAwareRuleWalker.prototype.getAllBlockScopes = function () {
return this.blockScopeStack;
};
BlockScopeAwareRuleWalker.prototype.getCurrentBlockScope = function () {
return this.blockScopeStack[this.blockScopeStack.length - 1];
};
BlockScopeAwareRuleWalker.prototype.getCurrentBlockDepth = function () {
return this.blockScopeStack.length;
};
// callback notifier when a block scope begins
BlockScopeAwareRuleWalker.prototype.onBlockScopeStart = function () {
return;
};
// callback notifier when a block scope ends
BlockScopeAwareRuleWalker.prototype.onBlockScopeEnd = function () {
return;
};
BlockScopeAwareRuleWalker.prototype.findBlockScope = function (predicate) {
// look through block scopes from local -> global
for (var i = this.blockScopeStack.length - 1; i >= 0; i--) {
if (predicate(this.blockScopeStack[i])) {
return this.blockScopeStack[i];
}
}
return undefined;
};
BlockScopeAwareRuleWalker.prototype.visitNode = function (node) {
var isNewBlockScope = this.isBlockScopeBoundary(node);
if (isNewBlockScope) {
this.blockScopeStack.push(this.createBlockScope(node));
this.onBlockScopeStart();
}
_super.prototype.visitNode.call(this, node);
if (isNewBlockScope) {
this.onBlockScopeEnd();
this.blockScopeStack.pop();
}
};
BlockScopeAwareRuleWalker.prototype.isBlockScopeBoundary = function (node) {
return utils_1.isBlockScopeBoundary(node);
};
return BlockScopeAwareRuleWalker;
}(scopeAwareRuleWalker_1.ScopeAwareRuleWalker));
exports.BlockScopeAwareRuleWalker = BlockScopeAwareRuleWalker;

23
node_modules/tslint/lib/language/walker/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* @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.
*/
export * from "./blockScopeAwareRuleWalker";
export * from "./programAwareRuleWalker";
export * from "./ruleWalker";
export * from "./scopeAwareRuleWalker";
export * from "./syntaxWalker";
export * from "./walkContext";
export * from "./walker";

26
node_modules/tslint/lib/language/walker/index.js generated vendored Normal file
View file

@ -0,0 +1,26 @@
"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");
tslib_1.__exportStar(require("./blockScopeAwareRuleWalker"), exports);
tslib_1.__exportStar(require("./programAwareRuleWalker"), exports);
tslib_1.__exportStar(require("./ruleWalker"), exports);
tslib_1.__exportStar(require("./scopeAwareRuleWalker"), exports);
tslib_1.__exportStar(require("./syntaxWalker"), exports);
tslib_1.__exportStar(require("./walkContext"), exports);
tslib_1.__exportStar(require("./walker"), exports);

View file

@ -0,0 +1,32 @@
/**
* @license
* Copyright 2018 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 { IOptions } from "../rule/rule";
import { RuleWalker } from "./ruleWalker";
/**
* @deprecated
* RuleWalker-based rules are slow,
* so it's generally preferable to use applyWithFunction instead of applyWithWalker.
* @see https://github.com/palantir/tslint/issues/2522
*/
export declare class ProgramAwareRuleWalker extends RuleWalker {
private readonly program;
private readonly typeChecker;
constructor(sourceFile: ts.SourceFile, options: IOptions, program: ts.Program);
getProgram(): ts.Program;
getTypeChecker(): ts.TypeChecker;
}

View file

@ -0,0 +1,45 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.ProgramAwareRuleWalker = void 0;
var tslib_1 = require("tslib");
var ruleWalker_1 = require("./ruleWalker");
/**
* @deprecated
* RuleWalker-based rules are slow,
* so it's generally preferable to use applyWithFunction instead of applyWithWalker.
* @see https://github.com/palantir/tslint/issues/2522
*/
// tslint:disable-next-line deprecation
var ProgramAwareRuleWalker = /** @class */ (function (_super) {
tslib_1.__extends(ProgramAwareRuleWalker, _super);
function ProgramAwareRuleWalker(sourceFile, options, program) {
var _this = _super.call(this, sourceFile, options) || this;
_this.program = program;
_this.typeChecker = program.getTypeChecker();
return _this;
}
ProgramAwareRuleWalker.prototype.getProgram = function () {
return this.program;
};
ProgramAwareRuleWalker.prototype.getTypeChecker = function () {
return this.typeChecker;
};
return ProgramAwareRuleWalker;
}(ruleWalker_1.RuleWalker));
exports.ProgramAwareRuleWalker = ProgramAwareRuleWalker;

View file

@ -0,0 +1,55 @@
/**
* @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 { Fix, IOptions, Replacement, RuleFailure } from "../rule/rule";
import { SyntaxWalker } from "./syntaxWalker";
import { IWalker } from "./walker";
/**
* @deprecated
* RuleWalker-based rules are slow,
* so it's generally preferable to use applyWithFunction instead of applyWithWalker.
* @see https://github.com/palantir/tslint/issues/2522
*/
export declare class RuleWalker extends SyntaxWalker implements IWalker {
private readonly sourceFile;
private readonly limit;
private readonly options?;
private readonly failures;
private readonly ruleName;
constructor(sourceFile: ts.SourceFile, options: IOptions);
getSourceFile(): ts.SourceFile;
getLineAndCharacterOfPosition(position: number): ts.LineAndCharacter;
getFailures(): RuleFailure[];
getLimit(): number;
getOptions(): any;
hasOption(option: string): boolean;
/** @deprecated Prefer `addFailureAt` and its variants. */
createFailure(start: number, width: number, failure: string, fix?: Fix): RuleFailure;
/** @deprecated Prefer `addFailureAt` and its variants. */
addFailure(failure: RuleFailure): void;
/** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
addFailureAt(start: number, width: number, failure: string, fix?: Fix): void;
/** Like `addFailureAt` but uses start and end instead of start and width. */
addFailureFromStartToEnd(start: number, end: number, failure: string, fix?: Fix): void;
/** Add a failure using a node's span. */
addFailureAtNode(node: ts.Node, failure: string, fix?: Fix): void;
createReplacement(start: number, length: number, text: string): Replacement;
appendText(start: number, text: string): Replacement;
deleteText(start: number, length: number): Replacement;
deleteFromTo(start: number, end: number): Replacement;
getRuleName(): string;
}

103
node_modules/tslint/lib/language/walker/ruleWalker.js generated vendored Normal file
View file

@ -0,0 +1,103 @@
"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 });
exports.RuleWalker = void 0;
var tslib_1 = require("tslib");
var rule_1 = require("../rule/rule");
var syntaxWalker_1 = require("./syntaxWalker");
/**
* @deprecated
* RuleWalker-based rules are slow,
* so it's generally preferable to use applyWithFunction instead of applyWithWalker.
* @see https://github.com/palantir/tslint/issues/2522
*/
var RuleWalker = /** @class */ (function (_super) {
tslib_1.__extends(RuleWalker, _super);
function RuleWalker(sourceFile, options) {
var _this = _super.call(this) || this;
_this.sourceFile = sourceFile;
_this.failures = [];
_this.options = options.ruleArguments;
_this.limit = _this.sourceFile.getFullWidth();
_this.ruleName = options.ruleName;
return _this;
}
RuleWalker.prototype.getSourceFile = function () {
return this.sourceFile;
};
RuleWalker.prototype.getLineAndCharacterOfPosition = function (position) {
return this.sourceFile.getLineAndCharacterOfPosition(position);
};
RuleWalker.prototype.getFailures = function () {
return this.failures;
};
RuleWalker.prototype.getLimit = function () {
return this.limit;
};
RuleWalker.prototype.getOptions = function () {
return this.options;
};
RuleWalker.prototype.hasOption = function (option) {
if (this.options !== undefined) {
return this.options.indexOf(option) !== -1;
}
else {
return false;
}
};
/** @deprecated Prefer `addFailureAt` and its variants. */
RuleWalker.prototype.createFailure = function (start, width, failure, fix) {
var from = start > this.limit ? this.limit : start;
var to = start + width > this.limit ? this.limit : start + width;
return new rule_1.RuleFailure(this.sourceFile, from, to, failure, this.ruleName, fix);
};
/** @deprecated Prefer `addFailureAt` and its variants. */
RuleWalker.prototype.addFailure = function (failure) {
this.failures.push(failure);
};
/** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
RuleWalker.prototype.addFailureAt = function (start, width, failure, fix) {
// tslint:disable-next-line deprecation
this.addFailure(this.createFailure(start, width, failure, fix));
};
/** Like `addFailureAt` but uses start and end instead of start and width. */
RuleWalker.prototype.addFailureFromStartToEnd = function (start, end, failure, fix) {
this.addFailureAt(start, end - start, failure, fix);
};
/** Add a failure using a node's span. */
RuleWalker.prototype.addFailureAtNode = function (node, failure, fix) {
this.addFailureAt(node.getStart(this.sourceFile), node.getWidth(this.sourceFile), failure, fix);
};
RuleWalker.prototype.createReplacement = function (start, length, text) {
return new rule_1.Replacement(start, length, text);
};
RuleWalker.prototype.appendText = function (start, text) {
return this.createReplacement(start, 0, text);
};
RuleWalker.prototype.deleteText = function (start, length) {
return this.createReplacement(start, length, "");
};
RuleWalker.prototype.deleteFromTo = function (start, end) {
return this.createReplacement(start, end - start, "");
};
RuleWalker.prototype.getRuleName = function () {
return this.ruleName;
};
return RuleWalker;
}(syntaxWalker_1.SyntaxWalker));
exports.RuleWalker = RuleWalker;

View file

@ -0,0 +1,65 @@
/**
* @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 { IOptions } from "../rule/rule";
import { RuleWalker } from "./ruleWalker";
/**
* @deprecated Prefer to manually maintain any contextual information.
*
* For example, imagine a `no-break` rule that warns on `break` in `for` but not in `switch`:
*
* function walk(ctx: Lint.WalkContext): void {
* let isInFor = false;
* ts.forEachChild(ctx.sourceFile, function cb(node: ts.Node): void {
* switch (node.kind) {
* case ts.SyntaxKind.Break:
* if (isInFor) {
* ctx.addFailureAtNode(node, "!");
* }
* break;
* case ts.SyntaxKind.ForStatement: {
* const old = isInFor;
* isInFor = true;
* ts.forEachChild(node, cb);
* isInFor = old;
* break;
* }
* case ts.SyntaxKind.SwitchStatement: {
* const old = isInFor;
* isInFor = false;
* ts.forEachChild(node, cb);
* isInFor = old;
* break;
* }
* default:
* ts.forEachChild(node, cb);
* }
* });
* }
*/
export declare abstract class ScopeAwareRuleWalker<T> extends RuleWalker {
private readonly scopeStack;
constructor(sourceFile: ts.SourceFile, options: IOptions);
abstract createScope(node: ts.Node): T;
getCurrentScope(): T;
getAllScopes(): T[];
getCurrentDepth(): number;
onScopeStart(): void;
onScopeEnd(): void;
protected visitNode(node: ts.Node): void;
protected isScopeBoundary(node: ts.Node): boolean;
}

View file

@ -0,0 +1,102 @@
"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 });
exports.ScopeAwareRuleWalker = void 0;
var tslib_1 = require("tslib");
var ts = require("typescript");
var utils_1 = require("../utils");
var ruleWalker_1 = require("./ruleWalker");
/**
* @deprecated Prefer to manually maintain any contextual information.
*
* For example, imagine a `no-break` rule that warns on `break` in `for` but not in `switch`:
*
* function walk(ctx: Lint.WalkContext): void {
* let isInFor = false;
* ts.forEachChild(ctx.sourceFile, function cb(node: ts.Node): void {
* switch (node.kind) {
* case ts.SyntaxKind.Break:
* if (isInFor) {
* ctx.addFailureAtNode(node, "!");
* }
* break;
* case ts.SyntaxKind.ForStatement: {
* const old = isInFor;
* isInFor = true;
* ts.forEachChild(node, cb);
* isInFor = old;
* break;
* }
* case ts.SyntaxKind.SwitchStatement: {
* const old = isInFor;
* isInFor = false;
* ts.forEachChild(node, cb);
* isInFor = old;
* break;
* }
* default:
* ts.forEachChild(node, cb);
* }
* });
* }
*/
// tslint:disable-next-line deprecation
var ScopeAwareRuleWalker = /** @class */ (function (_super) {
tslib_1.__extends(ScopeAwareRuleWalker, _super);
function ScopeAwareRuleWalker(sourceFile, options) {
var _this = _super.call(this, sourceFile, options) || this;
// initialize with global scope if file is not a module
_this.scopeStack = ts.isExternalModule(sourceFile) ? [] : [_this.createScope(sourceFile)];
return _this;
}
ScopeAwareRuleWalker.prototype.getCurrentScope = function () {
return this.scopeStack[this.scopeStack.length - 1];
};
// get all scopes available at this depth
ScopeAwareRuleWalker.prototype.getAllScopes = function () {
return this.scopeStack;
};
ScopeAwareRuleWalker.prototype.getCurrentDepth = function () {
return this.scopeStack.length;
};
// callback notifier when a scope begins
ScopeAwareRuleWalker.prototype.onScopeStart = function () {
return;
};
// callback notifier when a scope ends
ScopeAwareRuleWalker.prototype.onScopeEnd = function () {
return;
};
ScopeAwareRuleWalker.prototype.visitNode = function (node) {
var isNewScope = this.isScopeBoundary(node);
if (isNewScope) {
this.scopeStack.push(this.createScope(node));
this.onScopeStart();
}
_super.prototype.visitNode.call(this, node);
if (isNewScope) {
this.onScopeEnd();
this.scopeStack.pop();
}
};
ScopeAwareRuleWalker.prototype.isScopeBoundary = function (node) {
return utils_1.isScopeBoundary(node); // tslint:disable-line:deprecation
};
return ScopeAwareRuleWalker;
}(ruleWalker_1.RuleWalker));
exports.ScopeAwareRuleWalker = ScopeAwareRuleWalker;

View file

@ -0,0 +1,105 @@
/**
* @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";
export declare class SyntaxWalker {
walk(node: ts.Node): void;
protected visitAnyKeyword(node: ts.Node): void;
protected visitArrayLiteralExpression(node: ts.ArrayLiteralExpression): void;
protected visitArrayType(node: ts.ArrayTypeNode): void;
protected visitArrowFunction(node: ts.ArrowFunction): void;
protected visitBinaryExpression(node: ts.BinaryExpression): void;
protected visitBindingElement(node: ts.BindingElement): void;
protected visitBindingPattern(node: ts.BindingPattern): void;
protected visitBlock(node: ts.Block): void;
protected visitBreakStatement(node: ts.BreakOrContinueStatement): void;
protected visitCallExpression(node: ts.CallExpression): void;
protected visitCallSignature(node: ts.SignatureDeclaration): void;
protected visitCaseClause(node: ts.CaseClause): void;
protected visitClassDeclaration(node: ts.ClassDeclaration): void;
protected visitClassExpression(node: ts.ClassExpression): void;
protected visitCatchClause(node: ts.CatchClause): void;
protected visitConditionalExpression(node: ts.ConditionalExpression): void;
protected visitConstructSignature(node: ts.ConstructSignatureDeclaration): void;
protected visitConstructorDeclaration(node: ts.ConstructorDeclaration): void;
protected visitConstructorType(node: ts.FunctionOrConstructorTypeNode): void;
protected visitContinueStatement(node: ts.BreakOrContinueStatement): void;
protected visitDebuggerStatement(node: ts.Statement): void;
protected visitDefaultClause(node: ts.DefaultClause): void;
protected visitDoStatement(node: ts.DoStatement): void;
protected visitElementAccessExpression(node: ts.ElementAccessExpression): void;
protected visitEndOfFileToken(node: ts.Node): void;
protected visitEnumDeclaration(node: ts.EnumDeclaration): void;
protected visitEnumMember(node: ts.EnumMember): void;
protected visitExportAssignment(node: ts.ExportAssignment): void;
protected visitExpressionStatement(node: ts.ExpressionStatement): void;
protected visitForStatement(node: ts.ForStatement): void;
protected visitForInStatement(node: ts.ForInStatement): void;
protected visitForOfStatement(node: ts.ForOfStatement): void;
protected visitFunctionDeclaration(node: ts.FunctionDeclaration): void;
protected visitFunctionExpression(node: ts.FunctionExpression): void;
protected visitFunctionType(node: ts.FunctionOrConstructorTypeNode): void;
protected visitGetAccessor(node: ts.AccessorDeclaration): void;
protected visitIdentifier(node: ts.Identifier): void;
protected visitIfStatement(node: ts.IfStatement): void;
protected visitImportDeclaration(node: ts.ImportDeclaration): void;
protected visitImportEqualsDeclaration(node: ts.ImportEqualsDeclaration): void;
protected visitIndexSignatureDeclaration(node: ts.IndexSignatureDeclaration): void;
protected visitInterfaceDeclaration(node: ts.InterfaceDeclaration): void;
protected visitJsxAttribute(node: ts.JsxAttribute): void;
protected visitJsxElement(node: ts.JsxElement): void;
protected visitJsxExpression(node: ts.JsxExpression): void;
protected visitJsxSelfClosingElement(node: ts.JsxSelfClosingElement): void;
protected visitJsxSpreadAttribute(node: ts.JsxSpreadAttribute): void;
protected visitLabeledStatement(node: ts.LabeledStatement): void;
protected visitMethodDeclaration(node: ts.MethodDeclaration): void;
protected visitMethodSignature(node: ts.SignatureDeclaration): void;
protected visitModuleDeclaration(node: ts.ModuleDeclaration): void;
protected visitNamedImports(node: ts.NamedImports): void;
protected visitNamespaceImport(node: ts.NamespaceImport): void;
protected visitNewExpression(node: ts.NewExpression): void;
protected visitNonNullExpression(node: ts.NonNullExpression): void;
protected visitNumericLiteral(node: ts.NumericLiteral): void;
protected visitObjectLiteralExpression(node: ts.ObjectLiteralExpression): void;
protected visitParameterDeclaration(node: ts.ParameterDeclaration): void;
protected visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression): void;
protected visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression): void;
protected visitPropertyAccessExpression(node: ts.PropertyAccessExpression): void;
protected visitPropertyAssignment(node: ts.PropertyAssignment): void;
protected visitPropertyDeclaration(node: ts.PropertyDeclaration): void;
protected visitPropertySignature(node: ts.Node): void;
protected visitRegularExpressionLiteral(node: ts.Node): void;
protected visitReturnStatement(node: ts.ReturnStatement): void;
protected visitSetAccessor(node: ts.AccessorDeclaration): void;
protected visitSourceFile(node: ts.SourceFile): void;
protected visitStringLiteral(node: ts.StringLiteral): void;
protected visitSwitchStatement(node: ts.SwitchStatement): void;
protected visitTemplateExpression(node: ts.TemplateExpression): void;
protected visitThrowStatement(node: ts.ThrowStatement): void;
protected visitTryStatement(node: ts.TryStatement): void;
protected visitTupleType(node: ts.TupleTypeNode): void;
protected visitTypeAliasDeclaration(node: ts.TypeAliasDeclaration): void;
protected visitTypeAssertionExpression(node: ts.TypeAssertion): void;
protected visitTypeLiteral(node: ts.TypeLiteralNode): void;
protected visitTypeReference(node: ts.TypeReferenceNode): void;
protected visitVariableDeclaration(node: ts.VariableDeclaration): void;
protected visitVariableDeclarationList(node: ts.VariableDeclarationList): void;
protected visitVariableStatement(node: ts.VariableStatement): void;
protected visitWhileStatement(node: ts.WhileStatement): void;
protected visitWithStatement(node: ts.WithStatement): void;
protected visitNode(node: ts.Node): void;
protected walkChildren(node: ts.Node): void;
}

540
node_modules/tslint/lib/language/walker/syntaxWalker.js generated vendored Normal file
View file

@ -0,0 +1,540 @@
"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 });
exports.SyntaxWalker = void 0;
var ts = require("typescript");
var SyntaxWalker = /** @class */ (function () {
function SyntaxWalker() {
}
SyntaxWalker.prototype.walk = function (node) {
this.visitNode(node);
};
SyntaxWalker.prototype.visitAnyKeyword = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitArrayType = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitArrowFunction = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBinaryExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBindingElement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBindingPattern = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBlock = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBreakStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitCallExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitCallSignature = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitCaseClause = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitClassDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitClassExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitCatchClause = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitConditionalExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitConstructSignature = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitConstructorDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitConstructorType = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitContinueStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitDebuggerStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitDefaultClause = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitDoStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitElementAccessExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitEndOfFileToken = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitEnumDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitEnumMember = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitExportAssignment = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitExpressionStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitForStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitForInStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitForOfStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitFunctionDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitFunctionExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitFunctionType = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitGetAccessor = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitIdentifier = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitIfStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitImportDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitImportEqualsDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitIndexSignatureDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxAttribute = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxElement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxSelfClosingElement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxSpreadAttribute = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitLabeledStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitMethodDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitMethodSignature = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitModuleDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNamedImports = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNamespaceImport = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNewExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNonNullExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNumericLiteral = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitParameterDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPropertyAccessExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPropertyAssignment = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPropertyDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPropertySignature = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitRegularExpressionLiteral = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitReturnStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitSetAccessor = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitSourceFile = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitStringLiteral = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitSwitchStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTemplateExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitThrowStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTryStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTupleType = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTypeAliasDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTypeAssertionExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTypeLiteral = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTypeReference = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitVariableDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitVariableDeclarationList = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitVariableStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitWhileStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitWithStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNode = function (node) {
switch (node.kind) {
case ts.SyntaxKind.AnyKeyword:
this.visitAnyKeyword(node);
break;
case ts.SyntaxKind.ArrayBindingPattern:
this.visitBindingPattern(node);
break;
case ts.SyntaxKind.ArrayLiteralExpression:
this.visitArrayLiteralExpression(node);
break;
case ts.SyntaxKind.ArrayType:
this.visitArrayType(node);
break;
case ts.SyntaxKind.ArrowFunction:
this.visitArrowFunction(node);
break;
case ts.SyntaxKind.BinaryExpression:
this.visitBinaryExpression(node);
break;
case ts.SyntaxKind.BindingElement:
this.visitBindingElement(node);
break;
case ts.SyntaxKind.Block:
this.visitBlock(node);
break;
case ts.SyntaxKind.BreakStatement:
this.visitBreakStatement(node);
break;
case ts.SyntaxKind.CallExpression:
this.visitCallExpression(node);
break;
case ts.SyntaxKind.CallSignature:
this.visitCallSignature(node);
break;
case ts.SyntaxKind.CaseClause:
this.visitCaseClause(node);
break;
case ts.SyntaxKind.ClassDeclaration:
this.visitClassDeclaration(node);
break;
case ts.SyntaxKind.ClassExpression:
this.visitClassExpression(node);
break;
case ts.SyntaxKind.CatchClause:
this.visitCatchClause(node);
break;
case ts.SyntaxKind.ConditionalExpression:
this.visitConditionalExpression(node);
break;
case ts.SyntaxKind.ConstructSignature:
this.visitConstructSignature(node);
break;
case ts.SyntaxKind.Constructor:
this.visitConstructorDeclaration(node);
break;
case ts.SyntaxKind.ConstructorType:
this.visitConstructorType(node);
break;
case ts.SyntaxKind.ContinueStatement:
this.visitContinueStatement(node);
break;
case ts.SyntaxKind.DebuggerStatement:
this.visitDebuggerStatement(node);
break;
case ts.SyntaxKind.DefaultClause:
this.visitDefaultClause(node);
break;
case ts.SyntaxKind.DoStatement:
this.visitDoStatement(node);
break;
case ts.SyntaxKind.ElementAccessExpression:
this.visitElementAccessExpression(node);
break;
case ts.SyntaxKind.EndOfFileToken:
this.visitEndOfFileToken(node);
break;
case ts.SyntaxKind.EnumDeclaration:
this.visitEnumDeclaration(node);
break;
case ts.SyntaxKind.EnumMember:
this.visitEnumMember(node);
break;
case ts.SyntaxKind.ExportAssignment:
this.visitExportAssignment(node);
break;
case ts.SyntaxKind.ExpressionStatement:
this.visitExpressionStatement(node);
break;
case ts.SyntaxKind.ForStatement:
this.visitForStatement(node);
break;
case ts.SyntaxKind.ForInStatement:
this.visitForInStatement(node);
break;
case ts.SyntaxKind.ForOfStatement:
this.visitForOfStatement(node);
break;
case ts.SyntaxKind.FunctionDeclaration:
this.visitFunctionDeclaration(node);
break;
case ts.SyntaxKind.FunctionExpression:
this.visitFunctionExpression(node);
break;
case ts.SyntaxKind.FunctionType:
this.visitFunctionType(node);
break;
case ts.SyntaxKind.GetAccessor:
this.visitGetAccessor(node);
break;
case ts.SyntaxKind.Identifier:
this.visitIdentifier(node);
break;
case ts.SyntaxKind.IfStatement:
this.visitIfStatement(node);
break;
case ts.SyntaxKind.ImportDeclaration:
this.visitImportDeclaration(node);
break;
case ts.SyntaxKind.ImportEqualsDeclaration:
this.visitImportEqualsDeclaration(node);
break;
case ts.SyntaxKind.IndexSignature:
this.visitIndexSignatureDeclaration(node);
break;
case ts.SyntaxKind.InterfaceDeclaration:
this.visitInterfaceDeclaration(node);
break;
case ts.SyntaxKind.JsxAttribute:
this.visitJsxAttribute(node);
break;
case ts.SyntaxKind.JsxElement:
this.visitJsxElement(node);
break;
case ts.SyntaxKind.JsxExpression:
this.visitJsxExpression(node);
break;
case ts.SyntaxKind.JsxSelfClosingElement:
this.visitJsxSelfClosingElement(node);
break;
case ts.SyntaxKind.JsxSpreadAttribute:
this.visitJsxSpreadAttribute(node);
break;
case ts.SyntaxKind.LabeledStatement:
this.visitLabeledStatement(node);
break;
case ts.SyntaxKind.MethodDeclaration:
this.visitMethodDeclaration(node);
break;
case ts.SyntaxKind.MethodSignature:
this.visitMethodSignature(node);
break;
case ts.SyntaxKind.ModuleDeclaration:
this.visitModuleDeclaration(node);
break;
case ts.SyntaxKind.NamedImports:
this.visitNamedImports(node);
break;
case ts.SyntaxKind.NamespaceImport:
this.visitNamespaceImport(node);
break;
case ts.SyntaxKind.NewExpression:
this.visitNewExpression(node);
break;
case ts.SyntaxKind.NonNullExpression:
this.visitNonNullExpression(node);
break;
case ts.SyntaxKind.NumericLiteral:
this.visitNumericLiteral(node);
break;
case ts.SyntaxKind.ObjectBindingPattern:
this.visitBindingPattern(node);
break;
case ts.SyntaxKind.ObjectLiteralExpression:
this.visitObjectLiteralExpression(node);
break;
case ts.SyntaxKind.Parameter:
this.visitParameterDeclaration(node);
break;
case ts.SyntaxKind.PostfixUnaryExpression:
this.visitPostfixUnaryExpression(node);
break;
case ts.SyntaxKind.PrefixUnaryExpression:
this.visitPrefixUnaryExpression(node);
break;
case ts.SyntaxKind.PropertyAccessExpression:
this.visitPropertyAccessExpression(node);
break;
case ts.SyntaxKind.PropertyAssignment:
this.visitPropertyAssignment(node);
break;
case ts.SyntaxKind.PropertyDeclaration:
this.visitPropertyDeclaration(node);
break;
case ts.SyntaxKind.PropertySignature:
this.visitPropertySignature(node);
break;
case ts.SyntaxKind.RegularExpressionLiteral:
this.visitRegularExpressionLiteral(node);
break;
case ts.SyntaxKind.ReturnStatement:
this.visitReturnStatement(node);
break;
case ts.SyntaxKind.SetAccessor:
this.visitSetAccessor(node);
break;
case ts.SyntaxKind.SourceFile:
this.visitSourceFile(node);
break;
case ts.SyntaxKind.StringLiteral:
this.visitStringLiteral(node);
break;
case ts.SyntaxKind.SwitchStatement:
this.visitSwitchStatement(node);
break;
case ts.SyntaxKind.TemplateExpression:
this.visitTemplateExpression(node);
break;
case ts.SyntaxKind.ThrowStatement:
this.visitThrowStatement(node);
break;
case ts.SyntaxKind.TryStatement:
this.visitTryStatement(node);
break;
case ts.SyntaxKind.TupleType:
this.visitTupleType(node);
break;
case ts.SyntaxKind.TypeAliasDeclaration:
this.visitTypeAliasDeclaration(node);
break;
case ts.SyntaxKind.TypeAssertionExpression:
this.visitTypeAssertionExpression(node);
break;
case ts.SyntaxKind.TypeLiteral:
this.visitTypeLiteral(node);
break;
case ts.SyntaxKind.TypeReference:
this.visitTypeReference(node);
break;
case ts.SyntaxKind.VariableDeclaration:
this.visitVariableDeclaration(node);
break;
case ts.SyntaxKind.VariableDeclarationList:
this.visitVariableDeclarationList(node);
break;
case ts.SyntaxKind.VariableStatement:
this.visitVariableStatement(node);
break;
case ts.SyntaxKind.WhileStatement:
this.visitWhileStatement(node);
break;
case ts.SyntaxKind.WithStatement:
this.visitWithStatement(node);
break;
default:
this.walkChildren(node);
}
};
SyntaxWalker.prototype.walkChildren = function (node) {
var _this = this;
ts.forEachChild(node, function (child) { return _this.visitNode(child); });
};
return SyntaxWalker;
}());
exports.SyntaxWalker = SyntaxWalker;

View file

@ -0,0 +1,30 @@
/**
* @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 { Fix, RuleFailure } from "../rule/rule";
export declare class WalkContext<T = undefined> {
readonly sourceFile: ts.SourceFile;
readonly ruleName: string;
readonly options: T;
readonly failures: RuleFailure[];
constructor(sourceFile: ts.SourceFile, ruleName: string, options: T);
/** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
addFailureAt(start: number, width: number, failure: string, fix?: Fix): void;
addFailure(start: number, end: number, failure: string, fix?: Fix): void;
/** Add a failure using a node's span. */
addFailureAtNode(node: ts.Node, failure: string, fix?: Fix): void;
}

42
node_modules/tslint/lib/language/walker/walkContext.js generated vendored Normal file
View file

@ -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 });
exports.WalkContext = void 0;
var rule_1 = require("../rule/rule");
var WalkContext = /** @class */ (function () {
function WalkContext(sourceFile, ruleName, options) {
this.sourceFile = sourceFile;
this.ruleName = ruleName;
this.options = options;
this.failures = [];
}
/** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
WalkContext.prototype.addFailureAt = function (start, width, failure, fix) {
this.addFailure(start, start + width, failure, fix);
};
WalkContext.prototype.addFailure = function (start, end, failure, fix) {
var fileLength = this.sourceFile.end;
this.failures.push(new rule_1.RuleFailure(this.sourceFile, Math.min(start, fileLength), Math.min(end, fileLength), failure, this.ruleName, fix));
};
/** Add a failure using a node's span. */
WalkContext.prototype.addFailureAtNode = function (node, failure, fix) {
this.addFailure(node.getStart(this.sourceFile), node.getEnd(), failure, fix);
};
return WalkContext;
}());
exports.WalkContext = WalkContext;

29
node_modules/tslint/lib/language/walker/walker.d.ts generated vendored Normal file
View file

@ -0,0 +1,29 @@
/**
* @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 { RuleFailure } from "../rule/rule";
import { WalkContext } from "./walkContext";
export interface IWalker {
getSourceFile(): ts.SourceFile;
walk(sourceFile: ts.SourceFile): void;
getFailures(): RuleFailure[];
}
export declare abstract class AbstractWalker<T = undefined> extends WalkContext<T> implements IWalker {
abstract walk(sourceFile: ts.SourceFile): void;
getSourceFile(): ts.SourceFile;
getFailures(): RuleFailure[];
}

35
node_modules/tslint/lib/language/walker/walker.js generated vendored Normal file
View file

@ -0,0 +1,35 @@
"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 });
exports.AbstractWalker = void 0;
var tslib_1 = require("tslib");
var walkContext_1 = require("./walkContext");
var AbstractWalker = /** @class */ (function (_super) {
tslib_1.__extends(AbstractWalker, _super);
function AbstractWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
AbstractWalker.prototype.getSourceFile = function () {
return this.sourceFile;
};
AbstractWalker.prototype.getFailures = function () {
return this.failures;
};
return AbstractWalker;
}(walkContext_1.WalkContext));
exports.AbstractWalker = AbstractWalker;

55
node_modules/tslint/lib/linter.d.ts generated vendored Normal file
View file

@ -0,0 +1,55 @@
/**
* @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 { findConfiguration, findConfigurationPath, getRulesDirectories, IConfigurationFile, loadConfigurationFromPath } from "./configuration";
import { ILinterOptions, LintResult } from "./index";
import { RuleFailure } from "./language/rule/rule";
/**
* Linter that can lint multiple files in consecutive runs.
*/
export declare class Linter {
private readonly options;
private program?;
static VERSION: string;
static findConfiguration: typeof findConfiguration;
static findConfigurationPath: typeof findConfigurationPath;
static getRulesDirectories: typeof getRulesDirectories;
static loadConfigurationFromPath: typeof loadConfigurationFromPath;
/**
* Creates a TypeScript program object from a tsconfig.json file path and optional project directory.
*/
static createProgram(configFile: string, projectDirectory?: string): ts.Program;
/**
* Returns a list of source file names from a TypeScript program. This includes all referenced
* files and excludes declaration (".d.ts") files, as well as JSON files, to avoid problems with
* `resolveJsonModule`.
*/
static getFileNames(program: ts.Program): string[];
private failures;
private fixes;
private readonly fileNames;
constructor(options: ILinterOptions, program?: ts.Program | undefined);
lint(fileName: string, source: string, configuration?: IConfigurationFile): void;
getResult(): LintResult;
private getAllFailures;
private applyAllFixes;
protected applyFixes(sourceFilePath: string, source: string, fixableFailures: RuleFailure[]): string;
private updateProgram;
private applyRule;
private getEnabledRules;
private getSourceFile;
}

273
node_modules/tslint/lib/linter.js generated vendored Normal file
View file

@ -0,0 +1,273 @@
"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 });
exports.Linter = void 0;
var tslib_1 = require("tslib");
var fs = require("fs");
var path = require("path");
var ts = require("typescript");
var configuration_1 = require("./configuration");
var enableDisableRules_1 = require("./enableDisableRules");
var error_1 = require("./error");
var formatterLoader_1 = require("./formatterLoader");
var rule_1 = require("./language/rule/rule");
var utils = require("./language/utils");
var ruleLoader_1 = require("./ruleLoader");
var utils_1 = require("./utils");
/**
* Linter that can lint multiple files in consecutive runs.
*/
var Linter = /** @class */ (function () {
function Linter(options, program) {
this.options = options;
this.program = program;
this.failures = [];
this.fixes = [];
this.fileNames = [];
if (typeof options !== "object") {
throw new Error("Unknown Linter options type: " + typeof options);
}
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() ? ");
}
}
/**
* Creates a TypeScript program object from a tsconfig.json file path and optional project directory.
*/
Linter.createProgram = function (configFile, projectDirectory) {
if (projectDirectory === void 0) { projectDirectory = path.dirname(configFile); }
var config = ts.readConfigFile(configFile, ts.sys.readFile);
if (config.error !== undefined) {
throw new error_1.FatalError(ts.formatDiagnostics([config.error], {
getCanonicalFileName: function (f) { return f; },
getCurrentDirectory: process.cwd,
getNewLine: function () { return "\n"; },
}));
}
var parseConfigHost = {
fileExists: fs.existsSync,
readDirectory: ts.sys.readDirectory,
readFile: function (file) { return fs.readFileSync(file, "utf8"); },
useCaseSensitiveFileNames: true,
};
var parsed = ts.parseJsonConfigFileContent(config.config, parseConfigHost, path.resolve(projectDirectory), { noEmit: true });
if (parsed.errors !== undefined) {
// ignore warnings and 'TS18003: No inputs were found in config file ...'
var errors = parsed.errors.filter(function (d) { return d.category === ts.DiagnosticCategory.Error && d.code !== 18003; });
if (errors.length !== 0) {
throw new error_1.FatalError(ts.formatDiagnostics(errors, {
getCanonicalFileName: function (f) { return f; },
getCurrentDirectory: process.cwd,
getNewLine: function () { return "\n"; },
}));
}
}
var host = ts.createCompilerHost(parsed.options, true);
var program = ts.createProgram(parsed.fileNames, parsed.options, host);
return program;
};
/**
* Returns a list of source file names from a TypeScript program. This includes all referenced
* files and excludes declaration (".d.ts") files, as well as JSON files, to avoid problems with
* `resolveJsonModule`.
*/
Linter.getFileNames = function (program) {
return utils_1.mapDefined(program.getSourceFiles(), function (file) {
return file.fileName.endsWith(".d.ts") ||
file.fileName.endsWith(".json") ||
program.isSourceFileFromExternalLibrary(file)
? undefined
: file.fileName;
});
};
Linter.prototype.lint = function (fileName, source, configuration) {
if (configuration === void 0) { configuration = configuration_1.DEFAULT_CONFIG; }
if (configuration_1.isFileExcluded(fileName, configuration)) {
return;
}
this.fileNames.push(fileName);
var sourceFile = this.getSourceFile(fileName, source);
var isJs = /\.jsx?$/i.test(fileName);
var enabledRules = this.getEnabledRules(configuration, isJs);
if (enabledRules.length === 0) {
error_1.showWarningOnce("Tried to lint " + fileName + " but found no valid, enabled rules for this file type and file path in the resolved configuration.");
}
var fileFailures = this.getAllFailures(sourceFile, enabledRules);
if (fileFailures.length === 0) {
// Usual case: no errors.
return;
}
if (this.options.fix && fileFailures.some(function (f) { return f.hasFix(); })) {
fileFailures = this.applyAllFixes(enabledRules, fileFailures, sourceFile, fileName);
}
// add rule severity to failures
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());
if (severity === undefined) {
throw new Error("Severity for rule '" + failure.getRuleName() + "' not found");
}
failure.setRuleSeverity(severity);
}
this.failures = this.failures.concat(fileFailures);
};
Linter.prototype.getResult = function () {
var errors = this.failures.filter(function (failure) { return failure.getRuleSeverity() === "error"; });
var failures = this.options.quiet ? errors : this.failures;
var formatterName = this.options.formatter !== undefined ? this.options.formatter : "stylish";
var Formatter = formatterLoader_1.findFormatter(formatterName, this.options.formattersDirectory);
if (Formatter === undefined) {
throw new Error("formatter '" + String(formatterName) + "' not found");
}
var formatter = new Formatter();
var output = formatter.format(failures, this.fixes, this.fileNames);
var errorCount = errors.length;
return {
errorCount: errorCount,
failures: failures,
fixes: this.fixes,
format: formatterName,
output: output,
warningCount: failures.length - errorCount,
};
};
Linter.prototype.getAllFailures = function (sourceFile, enabledRules) {
var _this = this;
var failures = utils_1.flatMap(enabledRules, function (rule) { return _this.applyRule(rule, sourceFile); });
return enableDisableRules_1.removeDisabledFailures(sourceFile, failures);
};
Linter.prototype.applyAllFixes = function (enabledRules, fileFailures, sourceFile, sourceFileName) {
// When fixing, we need to be careful as a fix in one rule may affect other rules.
// So fix each rule separately.
var source = sourceFile.text;
var _loop_1 = function (rule) {
var hasFixes = fileFailures.some(function (f) { return f.hasFix() && f.getRuleName() === rule.getOptions().ruleName; });
if (hasFixes) {
// Get new failures in case the file changed.
var updatedFailures = enableDisableRules_1.removeDisabledFailures(sourceFile, this_1.applyRule(rule, sourceFile));
var fixableFailures = updatedFailures.filter(function (f) { return f.hasFix(); });
this_1.fixes = this_1.fixes.concat(fixableFailures);
source = this_1.applyFixes(sourceFileName, source, fixableFailures);
sourceFile = this_1.getSourceFile(sourceFileName, source);
}
};
var this_1 = this;
for (var _i = 0, enabledRules_1 = enabledRules; _i < enabledRules_1.length; _i++) {
var rule = enabledRules_1[_i];
_loop_1(rule);
}
// If there were fixes, get the *new* list of failures.
return this.getAllFailures(sourceFile, enabledRules);
};
// Only "protected" because a test directly accesses it.
// tslint:disable-next-line member-ordering
Linter.prototype.applyFixes = function (sourceFilePath, source, fixableFailures) {
var _this = this;
var fixesByFile = createMultiMap(fixableFailures, function (f) { return [f.getFileName(), f.getFix()]; });
fixesByFile.forEach(function (fileFixes, filePath) {
var fileNewSource;
if (path.resolve(filePath) === path.resolve(sourceFilePath)) {
source = rule_1.Replacement.applyFixes(source, fileFixes);
fileNewSource = source;
}
else {
var oldSource = fs.readFileSync(filePath, "utf-8");
fileNewSource = rule_1.Replacement.applyFixes(oldSource, fileFixes);
}
fs.writeFileSync(path.resolve(filePath), fileNewSource);
_this.updateProgram(filePath);
});
return source;
};
Linter.prototype.updateProgram = function (sourceFilePath) {
if (this.program !== undefined &&
this.program.getSourceFile(sourceFilePath) !== undefined) {
var options = this.program.getCompilerOptions();
this.program = ts.createProgram(this.program.getRootFileNames(), options, ts.createCompilerHost(options, true), this.program);
}
};
Linter.prototype.applyRule = function (rule, sourceFile) {
try {
if (this.program !== undefined && rule_1.isTypedRule(rule)) {
return rule.applyWithProgram(sourceFile, this.program);
}
else {
return rule.apply(sourceFile);
}
}
catch (error) {
if (error_1.isError(error) && error.stack !== undefined) {
error_1.showRuleCrashWarning(error.stack, rule.getOptions().ruleName, sourceFile.fileName);
}
else {
error_1.showRuleCrashWarning(String(error), rule.getOptions().ruleName, sourceFile.fileName);
}
return [];
}
};
Linter.prototype.getEnabledRules = function (configuration, isJs) {
if (configuration === void 0) { configuration = configuration_1.DEFAULT_CONFIG; }
var ruleOptionsList = configuration_1.convertRuleOptions(isJs ? configuration.jsRules : configuration.rules);
var rulesDirectories = utils_1.arrayify(this.options.rulesDirectory).concat(utils_1.arrayify(configuration.rulesDirectory));
return ruleLoader_1.loadRules(ruleOptionsList, rulesDirectories, isJs);
};
Linter.prototype.getSourceFile = function (fileName, source) {
if (this.program !== undefined) {
var sourceFile = this.program.getSourceFile(fileName);
if (sourceFile === undefined) {
var INVALID_SOURCE_ERROR = utils_1.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Invalid source file: ", ". Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.\n "], ["\n Invalid source file: ", ". Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.\n "])), fileName);
throw new error_1.FatalError(INVALID_SOURCE_ERROR);
}
return sourceFile;
}
else {
return utils.getSourceFile(fileName, source);
}
};
Linter.VERSION = "6.1.3";
Linter.findConfiguration = configuration_1.findConfiguration;
Linter.findConfigurationPath = configuration_1.findConfigurationPath;
Linter.getRulesDirectories = configuration_1.getRulesDirectories;
Linter.loadConfigurationFromPath = configuration_1.loadConfigurationFromPath;
return Linter;
}());
exports.Linter = Linter;
function createMultiMap(inputs, getPair) {
var map = new Map();
for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
var input = inputs_1[_i];
var pair = getPair(input);
if (pair !== undefined) {
var k = pair[0], v = pair[1];
var vs = map.get(k);
if (vs !== undefined) {
vs.push(v);
}
else {
map.set(k, [v]);
}
}
}
return map;
}
var templateObject_1;

20
node_modules/tslint/lib/ruleLoader.d.ts generated vendored Normal file
View file

@ -0,0 +1,20 @@
/**
* @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 { IOptions, IRule, RuleConstructor } from "./language/rule/rule";
export declare function loadRules(ruleOptionsList: IOptions[], rulesDirectories?: string | string[], isJs?: boolean): IRule[];
/** @internal private API */
export declare function findRule(name: string, rulesDirectories?: string | string[]): RuleConstructor | undefined;

121
node_modules/tslint/lib/ruleLoader.js generated vendored Normal file
View file

@ -0,0 +1,121 @@
"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 });
exports.findRule = exports.loadRules = void 0;
var tslib_1 = require("tslib");
var fs = require("fs");
var path = require("path");
var error_1 = require("./error");
var utils_1 = require("./utils");
var CORE_RULES_DIRECTORY = path.resolve(__dirname, "rules");
var cachedRules = new Map();
function loadRules(ruleOptionsList, rulesDirectories, isJs) {
if (isJs === void 0) { isJs = false; }
var rules = [];
var notFoundRules = [];
var notAllowedInJsRules = [];
for (var _i = 0, ruleOptionsList_1 = ruleOptionsList; _i < ruleOptionsList_1.length; _i++) {
var ruleOptions = ruleOptionsList_1[_i];
if (ruleOptions.ruleSeverity === "off") {
// Perf: don't bother finding the rule if it's disabled.
continue;
}
var ruleName = ruleOptions.ruleName;
var Rule = findRule(ruleName, rulesDirectories);
if (Rule === undefined) {
notFoundRules.push(ruleName);
}
else if (isJs && Rule.metadata !== undefined && Rule.metadata.typescriptOnly) {
notAllowedInJsRules.push(ruleName);
}
else {
var rule = new Rule(ruleOptions);
if (rule.isEnabled()) {
rules.push(rule);
}
if (Rule.metadata !== undefined && Boolean(Rule.metadata.deprecationMessage)) {
error_1.showWarningOnce(Rule.metadata.ruleName + " is deprecated. " + Rule.metadata.deprecationMessage);
}
}
}
if (notFoundRules.length > 0) {
var warning = utils_1.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Could not find implementations for the following rules specified in the configuration:\n ", "\n Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.\n If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.\n "], ["\n Could not find implementations for the following rules specified in the configuration:\n ", "\n Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.\n If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.\n "])), notFoundRules.join("\n "));
error_1.showWarningOnce(warning);
}
if (notAllowedInJsRules.length > 0) {
var warning = utils_1.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Following rules specified in configuration couldn't be applied to .js or .jsx files:\n ", "\n Make sure to exclude them from \"jsRules\" section of your tslint.json.\n "], ["\n Following rules specified in configuration couldn't be applied to .js or .jsx files:\n ", "\n Make sure to exclude them from \"jsRules\" section of your tslint.json.\n "])), notAllowedInJsRules.join("\n "));
error_1.showWarningOnce(warning);
}
return rules;
}
exports.loadRules = loadRules;
/** @internal private API */
function findRule(name, rulesDirectories) {
var camelizedName = transformName(name);
// first check for core rules
var Rule = loadCachedRule(CORE_RULES_DIRECTORY, camelizedName);
return Rule !== undefined
? Rule
: // then check for rules within the first level of rulesDirectory
utils_1.find(utils_1.arrayify(rulesDirectories), function (dir) { return loadCachedRule(dir, camelizedName, true); });
}
exports.findRule = findRule;
function transformName(name) {
// camelize strips out leading and trailing underscores and dashes, so make sure they aren't passed to camelize
// the regex matches the groups (leading underscores and dashes)(other characters)(trailing underscores and dashes)
var nameMatch = name.match(/^([-_]*)(.*?)([-_]*)$/);
if (nameMatch === null) {
return name + "Rule";
}
return "" + nameMatch[1] + utils_1.camelize(nameMatch[2]) + nameMatch[3] + "Rule";
}
/**
* @param directory - An absolute path to a directory of rules
* @param ruleName - A name of a rule in filename format. ex) "someLintRule"
*/
function loadRule(directory, ruleName) {
var ruleFullPath;
try {
// Resolve using node's path resolution to allow developers to write custom rules in TypeScript which can be loaded by TS-Node
ruleFullPath = require.resolve(path.join(directory, ruleName));
}
catch (_a) {
return "not-found";
}
return require(ruleFullPath).Rule;
}
function loadCachedRule(directory, ruleName, isCustomPath) {
// use cached value if available
var fullPath = path.join(directory, ruleName);
var cachedRule = cachedRules.get(fullPath);
if (cachedRule !== undefined) {
return cachedRule === "not-found" ? undefined : cachedRule;
}
// treat directory as a relative path (which needs to be resolved) if it's a custom rule directory
var absolutePath = directory;
if (isCustomPath) {
absolutePath = path.resolve(directory);
if (!fs.existsSync(absolutePath)) {
throw new error_1.FatalError("Could not find custom rule directory: " + absolutePath);
}
}
var Rule = loadRule(absolutePath, ruleName);
cachedRules.set(fullPath, Rule);
return Rule === "not-found" ? undefined : Rule;
}
var templateObject_1, templateObject_2;

19
node_modules/tslint/lib/rules.d.ts generated vendored Normal file
View file

@ -0,0 +1,19 @@
/**
* @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.
*/
export * from "./language/rule/abstractRule";
export * from "./language/rule/typedRule";
export * from "./language/rule/optionallyTypedRule";

22
node_modules/tslint/lib/rules.js generated vendored Normal file
View file

@ -0,0 +1,22 @@
"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");
tslib_1.__exportStar(require("./language/rule/abstractRule"), exports);
tslib_1.__exportStar(require("./language/rule/typedRule"), exports);
tslib_1.__exportStar(require("./language/rule/optionallyTypedRule"), exports);

View file

@ -0,0 +1,24 @@
/**
* @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 * as Lint from "../index";
export declare class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata;
static FAILURE_STRING(name: string): string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
}
export declare function getOverloadKey(node: ts.SignatureDeclaration): string | undefined;

View file

@ -0,0 +1,167 @@
"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.
*/
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOverloadKey = exports.Rule = void 0;
var tslib_1 = require("tslib");
var utils = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
var OPTION_IGNORE_ACCESSORS = "ignore-accessors";
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 = function (name) {
return "All '" + name + "' signatures should be adjacent";
};
Rule.prototype.apply = function (sourceFile) {
// tslint:disable-next-line: no-object-literal-type-assertion
var rawOptions = tslib_1.__assign({}, this.ruleArguments[0]);
return this.applyWithFunction(sourceFile, walk, {
ignoreAccessors: !!rawOptions[OPTION_IGNORE_ACCESSORS],
});
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "adjacent-overload-signatures",
description: "Enforces function overloads to be consecutive.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then getters and setters are not considered to be overloads\n of function with the same signature."], ["\n If \\`", "\\` is specified, then getters and setters are not considered to be overloads\n of function with the same signature."])), OPTION_IGNORE_ACCESSORS),
options: {
type: "object",
properties: (_a = {},
_a[OPTION_IGNORE_ACCESSORS] = {
type: "boolean",
},
_a),
additionalProperties: false,
},
optionExamples: [true, [true, { OPTION_IGNORE_ACCESSORS: true }]],
rationale: "Improves readability and organization by grouping naturally related items together.",
type: "typescript",
typescriptOnly: true,
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
var sourceFile = ctx.sourceFile;
visitStatements(sourceFile.statements);
return ts.forEachChild(sourceFile, function cb(node) {
switch (node.kind) {
case ts.SyntaxKind.ModuleBlock:
visitStatements(node.statements);
break;
case ts.SyntaxKind.InterfaceDeclaration:
case ts.SyntaxKind.ClassDeclaration:
case ts.SyntaxKind.TypeLiteral: {
var members = node.members;
addFailures(getMisplacedOverloads(members, function (member) {
return utils.isSignatureDeclaration(member)
? getOverloadKey(member)
: undefined;
}, ctx.options.ignoreAccessors));
}
}
return ts.forEachChild(node, cb);
});
function visitStatements(statements) {
addFailures(getMisplacedOverloads(statements, function (statement) {
return utils.isFunctionDeclaration(statement) && statement.name !== undefined
? statement.name.text
: undefined;
}, ctx.options.ignoreAccessors));
}
function addFailures(misplacedOverloads) {
for (var _i = 0, misplacedOverloads_1 = misplacedOverloads; _i < misplacedOverloads_1.length; _i++) {
var node = misplacedOverloads_1[_i];
ctx.addFailureAtNode(node, Rule.FAILURE_STRING(printOverload(node)));
}
}
}
/** 'getOverloadName' may return undefined for nodes that cannot be overloads, e.g. a `const` declaration. */
function getMisplacedOverloads(overloads, getKey, ignoreAccessors) {
var result = [];
var lastKey;
var seen = new Set();
for (var _i = 0, overloads_1 = overloads; _i < overloads_1.length; _i++) {
var node = overloads_1[_i];
if (node.kind === ts.SyntaxKind.SemicolonClassElement ||
(ignoreAccessors && isAccessor(node))) {
continue;
}
var key = getKey(node);
if (key !== undefined) {
if (seen.has(key) && lastKey !== key) {
result.push(node);
}
seen.add(key);
lastKey = key;
}
else {
lastKey = undefined;
}
}
return result;
}
function isAccessor(member) {
return member.kind === ts.SyntaxKind.GetAccessor || member.kind === ts.SyntaxKind.SetAccessor;
}
function printOverload(node) {
var info = getOverloadInfo(node);
return typeof info === "string" ? info : info === undefined ? "<unknown>" : info.name;
}
function getOverloadKey(node) {
var info = getOverloadInfo(node);
if (info === undefined) {
return undefined;
}
var _a = typeof info === "string" ? [false, info] : [info.computed, info.name], computed = _a[0], name = _a[1];
var isStatic = utils.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword);
return (computed ? "0" : "1") + (isStatic ? "0" : "1") + name;
}
exports.getOverloadKey = getOverloadKey;
function getOverloadInfo(node) {
switch (node.kind) {
case ts.SyntaxKind.ConstructSignature:
case ts.SyntaxKind.Constructor:
return "constructor";
case ts.SyntaxKind.CallSignature:
return "()";
default: {
var name = node.name;
if (name === undefined) {
return undefined;
}
switch (name.kind) {
case ts.SyntaxKind.Identifier:
return name.text;
case ts.SyntaxKind.ComputedPropertyName:
var expression = name.expression;
return utils.isLiteralExpression(expression)
? expression.text
: { name: expression.getText(), computed: true };
default:
return utils.isLiteralExpression(name) ? name.text : undefined;
}
}
}
}
var templateObject_1;

23
node_modules/tslint/lib/rules/alignRule.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* @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 * as Lint from "../index";
export declare class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata;
static FAILURE_STRING_SUFFIX: string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
}

196
node_modules/tslint/lib/rules/alignRule.js generated vendored Normal file
View file

@ -0,0 +1,196 @@
"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 });
exports.Rule = void 0;
var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
var OPTION_STATEMENTS = "statements";
var OPTION_MEMBERS = "members";
var OPTION_ELEMENTS = "elements";
var OPTION_PARAMETERS = "parameters";
var OPTION_ARGUMENTS = "arguments";
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 AlignWalker(sourceFile, this.ruleName, {
arguments: this.ruleArguments.indexOf(OPTION_ARGUMENTS) !== -1,
elements: this.ruleArguments.indexOf(OPTION_ELEMENTS) !== -1,
members: this.ruleArguments.indexOf(OPTION_MEMBERS) !== -1,
parameters: this.ruleArguments.indexOf(OPTION_PARAMETERS) !== -1,
statements: this.ruleArguments.indexOf(OPTION_STATEMENTS) !== -1,
}));
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "align",
description: "Enforces vertical alignment.",
hasFix: true,
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Helps maintain a readable, consistent style in your codebase.\n\n Consistent alignment for code statements helps keep code readable and clear.\n Statements misaligned from the standard can be harder to read and understand."], ["\n Helps maintain a readable, consistent style in your codebase.\n\n Consistent alignment for code statements helps keep code readable and clear.\n Statements misaligned from the standard can be harder to read and understand."]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Five arguments may be optionally provided:\n\n * `\"", "\"` checks alignment of function parameters.\n * `\"", "\"` checks alignment of function call arguments.\n * `\"", "\"` checks alignment of statements.\n * `\"", "\"` checks alignment of members of classes, interfaces, type literal, object literals and\n object destructuring.\n * `\"", "\"` checks alignment of elements of array literals, array destructuring and tuple types."], ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\` checks alignment of function parameters.\n * \\`\"", "\"\\` checks alignment of function call arguments.\n * \\`\"", "\"\\` checks alignment of statements.\n * \\`\"", "\"\\` checks alignment of members of classes, interfaces, type literal, object literals and\n object destructuring.\n * \\`\"", "\"\\` checks alignment of elements of array literals, array destructuring and tuple types."])), OPTION_PARAMETERS, OPTION_ARGUMENTS, OPTION_STATEMENTS, OPTION_MEMBERS, OPTION_ELEMENTS),
options: {
type: "array",
items: {
type: "string",
enum: [
OPTION_ARGUMENTS,
OPTION_ELEMENTS,
OPTION_MEMBERS,
OPTION_PARAMETERS,
OPTION_STATEMENTS,
],
},
minLength: 1,
maxLength: 5,
},
optionExamples: [[true, "parameters", "statements"]],
type: "formatting",
typescriptOnly: false,
};
/* tslint:enable:object-literal-sort-keys */
Rule.FAILURE_STRING_SUFFIX = " are not aligned";
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var AlignWalker = /** @class */ (function (_super) {
tslib_1.__extends(AlignWalker, _super);
function AlignWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
AlignWalker.prototype.walk = function (sourceFile) {
var _this = this;
var cb = function (node) {
if (_this.options.statements && tsutils_1.isBlockLike(node)) {
_this.checkAlignment(node.statements.filter(function (s) { return s.kind !== ts.SyntaxKind.EmptyStatement; }), OPTION_STATEMENTS);
}
else {
switch (node.kind) {
case ts.SyntaxKind.NewExpression:
if (node.arguments === undefined) {
break;
}
// falls through
case ts.SyntaxKind.CallExpression:
if (_this.options.arguments) {
_this.checkAlignment(node.arguments, OPTION_ARGUMENTS);
}
break;
case ts.SyntaxKind.FunctionDeclaration:
case ts.SyntaxKind.FunctionExpression:
case ts.SyntaxKind.Constructor:
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.ArrowFunction:
case ts.SyntaxKind.CallSignature:
case ts.SyntaxKind.ConstructSignature:
case ts.SyntaxKind.MethodSignature:
case ts.SyntaxKind.FunctionType:
case ts.SyntaxKind.ConstructorType:
if (_this.options.parameters) {
_this.checkAlignment(node.parameters, OPTION_PARAMETERS);
}
break;
case ts.SyntaxKind.ArrayLiteralExpression:
case ts.SyntaxKind.ArrayBindingPattern:
if (_this.options.elements) {
_this.checkAlignment(node.elements, OPTION_ELEMENTS);
}
break;
case ts.SyntaxKind.TupleType:
if (_this.options.elements) {
_this.checkAlignment(
// In TS 4 TupleTypeNode.elementTypes has been updated to elements
// tslint:disable-next-line
node.elementTypes || node.elements, OPTION_ELEMENTS);
}
break;
case ts.SyntaxKind.ObjectLiteralExpression:
if (_this.options.members) {
_this.checkAlignment(node.properties, OPTION_MEMBERS);
}
break;
case ts.SyntaxKind.ObjectBindingPattern:
if (_this.options.members) {
_this.checkAlignment(node.elements, OPTION_MEMBERS);
}
break;
case ts.SyntaxKind.ClassDeclaration:
case ts.SyntaxKind.ClassExpression:
if (_this.options.members) {
_this.checkAlignment(node.members.filter(function (m) { return m.kind !== ts.SyntaxKind.SemicolonClassElement; }), OPTION_MEMBERS);
}
break;
case ts.SyntaxKind.InterfaceDeclaration:
case ts.SyntaxKind.TypeLiteral:
if (_this.options.members) {
_this.checkAlignment(node.members, OPTION_MEMBERS);
}
}
}
return ts.forEachChild(node, cb);
};
return cb(sourceFile);
};
AlignWalker.prototype.checkAlignment = function (nodes, kind) {
if (nodes.length <= 1) {
return;
}
var sourceFile = this.sourceFile;
var pos = getLineAndCharacterWithoutBom(sourceFile, this.getStart(nodes[0]));
var alignToColumn = pos.character;
var line = pos.line;
// skip first node in list
for (var i = 1; i < nodes.length; ++i) {
var node = nodes[i];
var start = this.getStart(node);
pos = ts.getLineAndCharacterOfPosition(sourceFile, start);
if (line !== pos.line && pos.character !== alignToColumn) {
var diff = alignToColumn - pos.character;
var fix = void 0;
if (diff >= 0) {
fix = Lint.Replacement.appendText(start, " ".repeat(diff));
}
else if (node.pos <= start + diff &&
/^\s+$/.test(sourceFile.text.substring(start + diff, start))) {
// only delete text if there is only whitespace
fix = Lint.Replacement.deleteText(start + diff, -diff);
}
this.addFailure(start, Math.max(node.end, start), kind + Rule.FAILURE_STRING_SUFFIX, fix);
}
line = pos.line;
}
};
AlignWalker.prototype.getStart = function (node) {
return node.kind !== ts.SyntaxKind.OmittedExpression
? node.getStart(this.sourceFile)
: // find the comma token following the OmmitedExpression
tsutils_1.getNextToken(node, this.sourceFile).getStart(this.sourceFile);
};
return AlignWalker;
}(Lint.AbstractWalker));
function getLineAndCharacterWithoutBom(sourceFile, pos) {
var result = ts.getLineAndCharacterOfPosition(sourceFile, pos);
if (result.line === 0 && sourceFile.text[0] === "\uFEFF") {
result.character -= 1;
}
return result;
}
var templateObject_1, templateObject_2;

26
node_modules/tslint/lib/rules/arrayTypeRule.d.ts generated vendored Normal file
View file

@ -0,0 +1,26 @@
/**
* @license
* Copyright 2018 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_STRING_ARRAY: string;
static FAILURE_STRING_GENERIC: string;
static FAILURE_STRING_ARRAY_SIMPLE: string;
static FAILURE_STRING_GENERIC_SIMPLE: string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
}

163
node_modules/tslint/lib/rules/arrayTypeRule.js generated vendored Normal file
View file

@ -0,0 +1,163 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.Rule = void 0;
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("../index");
var OPTION_ARRAY = "array";
var OPTION_GENERIC = "generic";
var OPTION_ARRAY_SIMPLE = "array-simple";
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, this.ruleArguments[0]);
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "array-type",
description: "Requires using either 'T[]' or 'Array<T>' for arrays.",
hasFix: true,
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n One of the following arguments must be provided:\n\n * `\"", "\"` enforces use of `T[]` for all types T.\n * `\"", "\"` enforces use of `Array<T>` for all types T.\n * `\"", "\"` enforces use of `T[]` if `T` is a simple type (primitive or type reference)."], ["\n One of the following arguments must be provided:\n\n * \\`\"", "\"\\` enforces use of \\`T[]\\` for all types T.\n * \\`\"", "\"\\` enforces use of \\`Array<T>\\` for all types T.\n * \\`\"", "\"\\` enforces use of \\`T[]\\` if \\`T\\` is a simple type (primitive or type reference)."])), OPTION_ARRAY, OPTION_GENERIC, OPTION_ARRAY_SIMPLE),
options: {
type: "string",
enum: [OPTION_ARRAY, OPTION_GENERIC, OPTION_ARRAY_SIMPLE],
},
optionExamples: [[true, OPTION_ARRAY], [true, OPTION_GENERIC], [true, OPTION_ARRAY_SIMPLE]],
type: "style",
typescriptOnly: true,
};
/* tslint:enable:object-literal-sort-keys */
Rule.FAILURE_STRING_ARRAY = "Array type using 'Array<T>' is forbidden. Use 'T[]' instead.";
Rule.FAILURE_STRING_GENERIC = "Array type using 'T[]' is forbidden. Use 'Array<T>' instead.";
Rule.FAILURE_STRING_ARRAY_SIMPLE = "Array type using 'Array<T>' is forbidden for simple types. Use 'T[]' instead.";
Rule.FAILURE_STRING_GENERIC_SIMPLE = "Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead.";
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
var sourceFile = ctx.sourceFile, option = ctx.options;
return ts.forEachChild(sourceFile, function cb(node) {
switch (node.kind) {
case ts.SyntaxKind.ArrayType:
checkArrayType(node);
break;
case ts.SyntaxKind.TypeReference:
checkTypeReference(node);
}
return ts.forEachChild(node, cb);
});
function checkArrayType(node) {
var elementType = node.elementType, parent = node.parent;
if (option === "array" || (option === "array-simple" && isSimpleType(elementType))) {
return;
}
var failureString = option === "generic" ? Rule.FAILURE_STRING_GENERIC : Rule.FAILURE_STRING_GENERIC_SIMPLE;
var parens = elementType.kind === ts.SyntaxKind.ParenthesizedType ? 1 : 0;
// Add a space if the type is preceded by 'as' and the node has no leading whitespace
var space = parens === 0 &&
parent.kind === ts.SyntaxKind.AsExpression &&
node.getStart() === node.getFullStart();
var fix = [
new Lint.Replacement(elementType.getStart(), parens, (space ? " " : "") + "Array<"),
// Delete the square brackets and replace with an angle bracket
Lint.Replacement.replaceFromTo(elementType.getEnd() - parens, node.getEnd(), ">"),
];
ctx.addFailureAtNode(node, failureString, fix);
}
function checkTypeReference(node) {
var typeName = node.typeName, typeArguments = node.typeArguments;
if (option === "generic" || !isArrayIdentifier(typeName)) {
return;
}
var failureString = option === "array" ? Rule.FAILURE_STRING_ARRAY : Rule.FAILURE_STRING_ARRAY_SIMPLE;
if (typeArguments === undefined || typeArguments.length === 0) {
// Create an 'any' array
ctx.addFailureAtNode(node, failureString, Lint.Replacement.replaceFromTo(node.getStart(), node.getEnd(), "any[]"));
return;
}
if (typeArguments.length !== 1 ||
(option === "array-simple" && !isSimpleType(typeArguments[0]))) {
return;
}
var type = typeArguments[0];
var parens = typeNeedsParentheses(type);
ctx.addFailureAtNode(node, failureString, [
// Delete 'Array<'
Lint.Replacement.replaceFromTo(node.getStart(), type.getStart(), parens ? "(" : ""),
// Delete '>' and replace with '[]
Lint.Replacement.replaceFromTo(type.getEnd(), node.getEnd(), parens ? ")[]" : "[]"),
]);
}
}
function typeNeedsParentheses(type) {
switch (type.kind) {
case ts.SyntaxKind.UnionType:
case ts.SyntaxKind.FunctionType:
case ts.SyntaxKind.IntersectionType:
case ts.SyntaxKind.TypeOperator:
return true;
default:
return false;
}
}
function isArrayIdentifier(name) {
return name.kind === ts.SyntaxKind.Identifier && name.text === "Array";
}
function isSimpleType(nodeType) {
switch (nodeType.kind) {
case ts.SyntaxKind.AnyKeyword:
case ts.SyntaxKind.ArrayType:
case ts.SyntaxKind.BooleanKeyword:
case ts.SyntaxKind.NullKeyword:
case ts.SyntaxKind.ObjectKeyword:
case ts.SyntaxKind.UndefinedKeyword:
case ts.SyntaxKind.NumberKeyword:
case ts.SyntaxKind.StringKeyword:
case ts.SyntaxKind.SymbolKeyword:
case ts.SyntaxKind.VoidKeyword:
case ts.SyntaxKind.NeverKeyword:
case ts.SyntaxKind.ThisType:
case ts.SyntaxKind.UnknownKeyword:
return true;
case ts.SyntaxKind.ParenthesizedType:
return isSimpleType(nodeType.type);
case ts.SyntaxKind.TypeReference:
// TypeReferences must be non-generic or be another Array with a simple type
var _a = nodeType, typeName = _a.typeName, typeArguments = _a.typeArguments;
if (typeArguments === undefined) {
return true;
}
switch (typeArguments.length) {
case 0:
return true;
case 1:
return (typeName.kind === ts.SyntaxKind.Identifier &&
typeName.text === "Array" &&
isSimpleType(typeArguments[0]));
default:
return false;
}
default:
return false;
}
}
var templateObject_1;

24
node_modules/tslint/lib/rules/arrowParensRule.d.ts generated vendored Normal file
View file

@ -0,0 +1,24 @@
/**
* @license
* Copyright 2018 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_STRING_MISSING: string;
static FAILURE_STRING_EXISTS: string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
}

98
node_modules/tslint/lib/rules/arrowParensRule.js generated vendored Normal file
View file

@ -0,0 +1,98 @@
"use strict";
/**
* @license
* Copyright 2018 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 });
exports.Rule = void 0;
var tslib_1 = require("tslib");
var tsutils_1 = require("tsutils");
var ts = require("typescript");
var Lint = require("../index");
var BAN_SINGLE_ARG_PARENS = "ban-single-arg-parens";
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, {
banSingleArgParens: this.ruleArguments.indexOf(BAN_SINGLE_ARG_PARENS) !== -1,
});
};
/* tslint:disable:object-literal-sort-keys */
Rule.metadata = {
ruleName: "arrow-parens",
description: "Requires parentheses around the parameters of arrow function definitions.",
hasFix: true,
rationale: "Maintains stylistic consistency with other arrow function definitions.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then arrow functions with one parameter\n must not have parentheses if removing them is allowed by TypeScript."], ["\n If \\`", "\\` is specified, then arrow functions with one parameter\n must not have parentheses if removing them is allowed by TypeScript."])), BAN_SINGLE_ARG_PARENS),
options: {
type: "string",
enum: [BAN_SINGLE_ARG_PARENS],
},
optionExamples: [true, [true, BAN_SINGLE_ARG_PARENS]],
type: "formatting",
typescriptOnly: false,
};
/* tslint:enable:object-literal-sort-keys */
Rule.FAILURE_STRING_MISSING = "Parentheses are required around the parameters of an arrow function definition";
Rule.FAILURE_STRING_EXISTS = "Parentheses are prohibited around the parameter in this single parameter arrow function";
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
function cb(node) {
if (tsutils_1.isArrowFunction(node) && parensAreOptional(node)) {
var openParen = tsutils_1.getChildOfKind(node, ts.SyntaxKind.OpenParenToken);
if (openParen === undefined) {
if (!ctx.options.banSingleArgParens) {
var parameter = node.parameters[0];
var start = parameter.getStart(ctx.sourceFile);
var end = parameter.end;
ctx.addFailure(start, end, Rule.FAILURE_STRING_MISSING, [
Lint.Replacement.appendText(start, "("),
Lint.Replacement.appendText(end, ")"),
]);
}
}
else if (ctx.options.banSingleArgParens) {
var closeParen = tsutils_1.getChildOfKind(node, ts.SyntaxKind.CloseParenToken);
var charBeforeOpenParen = ctx.sourceFile.text.substring(openParen.pos - 1, openParen.pos);
var replaceValue = charBeforeOpenParen.match(/[a-z]/i) !== null ? " " : "";
ctx.addFailureAtNode(node.parameters[0], Rule.FAILURE_STRING_EXISTS, [
Lint.Replacement.replaceFromTo(openParen.pos, node.parameters[0].getStart(ctx.sourceFile), replaceValue),
Lint.Replacement.deleteFromTo(node.parameters[0].end, closeParen.end),
]);
}
}
return ts.forEachChild(node, cb);
}
return ts.forEachChild(ctx.sourceFile, cb);
}
function parensAreOptional(node) {
return (node.parameters.length === 1 &&
node.typeParameters === undefined &&
node.type === undefined &&
isSimpleParameter(node.parameters[0]));
}
function isSimpleParameter(parameter) {
return (parameter.name.kind === ts.SyntaxKind.Identifier &&
parameter.dotDotDotToken === undefined &&
parameter.initializer === undefined &&
parameter.questionToken === undefined &&
parameter.type === undefined);
}
var templateObject_1;

View file

@ -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 FAILURE_STRING(isObjectLiteral: boolean): string;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
}

Some files were not shown because too many files have changed in this diff Show more