Update TSLint configuration to detect bad indentation.

This commit is contained in:
Chris Gavin
2020-06-23 14:19:51 +01:00
parent a1d945f14f
commit 211ad30f72
136 changed files with 15588 additions and 3 deletions

19
node_modules/doctrine/LICENSE.BSD generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

202
node_modules/doctrine/LICENSE.closure-compiler generated vendored Normal file
View File

@@ -0,0 +1,202 @@
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.

19
node_modules/doctrine/LICENSE.esprima generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

174
node_modules/doctrine/README.md generated vendored Normal file
View File

@@ -0,0 +1,174 @@
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Downloads][downloads-image]][downloads-url]
[![Join the chat at https://gitter.im/eslint/doctrine](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/doctrine?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Doctrine
Doctrine is a [JSDoc](http://usejsdoc.org) parser that parses documentation comments from JavaScript (you need to pass in the comment, not a whole JavaScript file).
## Installation
You can install Doctrine using [npm](https://npmjs.com):
```
$ npm install doctrine --save-dev
```
Doctrine can also be used in web browsers using [Browserify](http://browserify.org).
## Usage
Require doctrine inside of your JavaScript:
```js
var doctrine = require("doctrine");
```
### parse()
The primary method is `parse()`, which accepts two arguments: the JSDoc comment to parse and an optional options object. The available options are:
* `unwrap` - set to `true` to delete the leading `/**`, any `*` that begins a line, and the trailing `*/` from the source text. Default: `false`.
* `tags` - an array of tags to return. When specified, Doctrine returns only tags in this array. For example, if `tags` is `["param"]`, then only `@param` tags will be returned. Default: `null`.
* `recoverable` - set to `true` to keep parsing even when syntax errors occur. Default: `false`.
* `sloppy` - set to `true` to allow optional parameters to be specified in brackets (`@param {string} [foo]`). Default: `false`.
* `lineNumberes` - set to `true` to add `lineNumber` to each node, specifying the line on which the node is found in the source. Default: `false`.
Here's a simple example:
```js
var ast = doctrine.parse(
[
"/**",
" * This function comment is parsed by doctrine",
" * @param {{ok:String}} userName",
"*/"
].join('\n'), { unwrap: true });
```
This example returns the following AST:
{
"description": "This function comment is parsed by doctrine",
"tags": [
{
"title": "param",
"description": null,
"type": {
"type": "RecordType",
"fields": [
{
"type": "FieldType",
"key": "ok",
"value": {
"type": "NameExpression",
"name": "String"
}
}
]
},
"name": "userName"
}
]
}
See the [demo page](http://eslint.org/doctrine/demo/) more detail.
## Team
These folks keep the project moving and are resources for help:
* Nicholas C. Zakas ([@nzakas](https://github.com/nzakas)) - project lead
* Yusuke Suzuki ([@constellation](https://github.com/constellation)) - reviewer
## Contributing
Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/doctrine/issues).
## Frequently Asked Questions
### Can I pass a whole JavaScript file to Doctrine?
No. Doctrine can only parse JSDoc comments, so you'll need to pass just the JSDoc comment to Doctrine in order to work.
### License
#### doctrine
Copyright (C) 2012 [Yusuke Suzuki](http://github.com/Constellation)
(twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#### esprima
some of functions is derived from esprima
Copyright (C) 2012, 2011 [Ariya Hidayat](http://ariya.ofilabs.com/about)
(twitter: [@ariyahidayat](http://twitter.com/ariyahidayat)) and other contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#### closure-compiler
some of extensions is derived from closure-compiler
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
### Where to ask for help?
Join our [Chatroom](https://gitter.im/eslint/doctrine)
[npm-image]: https://img.shields.io/npm/v/doctrine.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/doctrine
[travis-image]: https://img.shields.io/travis/eslint/doctrine/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/eslint/doctrine
[coveralls-image]: https://img.shields.io/coveralls/eslint/doctrine/master.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/eslint/doctrine?branch=master
[downloads-image]: http://img.shields.io/npm/dm/doctrine.svg?style=flat-square
[downloads-url]: https://www.npmjs.com/package/doctrine

833
node_modules/doctrine/lib/doctrine.js generated vendored Normal file
View File

@@ -0,0 +1,833 @@
/*
Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2014 Dan Tao <daniel.tao@gmail.com>
Copyright (C) 2013 Andrew Eisenberg <andrew@eisenberg.as>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function () {
'use strict';
var typed,
utility,
isArray,
jsdoc,
esutils,
hasOwnProperty;
esutils = require('esutils');
isArray = require('isarray');
typed = require('./typed');
utility = require('./utility');
function sliceSource(source, index, last) {
return source.slice(index, last);
}
hasOwnProperty = (function () {
var func = Object.prototype.hasOwnProperty;
return function hasOwnProperty(obj, name) {
return func.call(obj, name);
};
}());
function shallowCopy(obj) {
var ret = {}, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
ret[key] = obj[key];
}
}
return ret;
}
function isASCIIAlphanumeric(ch) {
return (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) ||
(ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) ||
(ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */);
}
function isParamTitle(title) {
return title === 'param' || title === 'argument' || title === 'arg';
}
function isReturnTitle(title) {
return title === 'return' || title === 'returns';
}
function isProperty(title) {
return title === 'property' || title === 'prop';
}
function isNameParameterRequired(title) {
return isParamTitle(title) || isProperty(title) ||
title === 'alias' || title === 'this' || title === 'mixes' || title === 'requires';
}
function isAllowedName(title) {
return isNameParameterRequired(title) || title === 'const' || title === 'constant';
}
function isAllowedNested(title) {
return isProperty(title) || isParamTitle(title);
}
function isTypeParameterRequired(title) {
return isParamTitle(title) || isReturnTitle(title) ||
title === 'define' || title === 'enum' ||
title === 'implements' || title === 'this' ||
title === 'type' || title === 'typedef' || isProperty(title);
}
// Consider deprecation instead using 'isTypeParameterRequired' and 'Rules' declaration to pick when a type is optional/required
// This would require changes to 'parseType'
function isAllowedType(title) {
return isTypeParameterRequired(title) || title === 'throws' || title === 'const' || title === 'constant' ||
title === 'namespace' || title === 'member' || title === 'var' || title === 'module' ||
title === 'constructor' || title === 'class' || title === 'extends' || title === 'augments' ||
title === 'public' || title === 'private' || title === 'protected';
}
function trim(str) {
return str.replace(/^\s+/, '').replace(/\s+$/, '');
}
function unwrapComment(doc) {
// JSDoc comment is following form
// /**
// * .......
// */
// remove /**, */ and *
var BEFORE_STAR = 0,
STAR = 1,
AFTER_STAR = 2,
index,
len,
mode,
result,
ch;
doc = doc.replace(/^\/\*\*?/, '').replace(/\*\/$/, '');
index = 0;
len = doc.length;
mode = BEFORE_STAR;
result = '';
while (index < len) {
ch = doc.charCodeAt(index);
switch (mode) {
case BEFORE_STAR:
if (esutils.code.isLineTerminator(ch)) {
result += String.fromCharCode(ch);
} else if (ch === 0x2A /* '*' */) {
mode = STAR;
} else if (!esutils.code.isWhiteSpace(ch)) {
result += String.fromCharCode(ch);
mode = AFTER_STAR;
}
break;
case STAR:
if (!esutils.code.isWhiteSpace(ch)) {
result += String.fromCharCode(ch);
}
mode = esutils.code.isLineTerminator(ch) ? BEFORE_STAR : AFTER_STAR;
break;
case AFTER_STAR:
result += String.fromCharCode(ch);
if (esutils.code.isLineTerminator(ch)) {
mode = BEFORE_STAR;
}
break;
}
index += 1;
}
return result.replace(/\s+$/, '');
}
// JSDoc Tag Parser
(function (exports) {
var Rules,
index,
lineNumber,
length,
source,
recoverable,
sloppy,
strict;
function advance() {
var ch = source.charCodeAt(index);
index += 1;
if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D /* '\r' */ && source.charCodeAt(index) === 0x0A /* '\n' */)) {
lineNumber += 1;
}
return String.fromCharCode(ch);
}
function scanTitle() {
var title = '';
// waste '@'
advance();
while (index < length && isASCIIAlphanumeric(source.charCodeAt(index))) {
title += advance();
}
return title;
}
function seekContent() {
var ch, waiting, last = index;
waiting = false;
while (last < length) {
ch = source.charCodeAt(last);
if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D /* '\r' */ && source.charCodeAt(last + 1) === 0x0A /* '\n' */)) {
waiting = true;
} else if (waiting) {
if (ch === 0x40 /* '@' */) {
break;
}
if (!esutils.code.isWhiteSpace(ch)) {
waiting = false;
}
}
last += 1;
}
return last;
}
// type expression may have nest brace, such as,
// { { ok: string } }
//
// therefore, scanning type expression with balancing braces.
function parseType(title, last) {
var ch, brace, type, direct = false;
// search '{'
while (index < last) {
ch = source.charCodeAt(index);
if (esutils.code.isWhiteSpace(ch)) {
advance();
} else if (ch === 0x7B /* '{' */) {
advance();
break;
} else {
// this is direct pattern
direct = true;
break;
}
}
if (direct) {
return null;
}
// type expression { is found
brace = 1;
type = '';
while (index < last) {
ch = source.charCodeAt(index);
if (esutils.code.isLineTerminator(ch)) {
advance();
} else {
if (ch === 0x7D /* '}' */) {
brace -= 1;
if (brace === 0) {
advance();
break;
}
} else if (ch === 0x7B /* '{' */) {
brace += 1;
}
type += advance();
}
}
if (brace !== 0) {
// braces is not balanced
return utility.throwError('Braces are not balanced');
}
if (isParamTitle(title)) {
return typed.parseParamType(type);
}
return typed.parseType(type);
}
function scanIdentifier(last) {
var identifier;
if (!esutils.code.isIdentifierStart(source.charCodeAt(index))) {
return null;
}
identifier = advance();
while (index < last && esutils.code.isIdentifierPart(source.charCodeAt(index))) {
identifier += advance();
}
return identifier;
}
function skipWhiteSpace(last) {
while (index < last && (esutils.code.isWhiteSpace(source.charCodeAt(index)) || esutils.code.isLineTerminator(source.charCodeAt(index)))) {
advance();
}
}
function parseName(last, allowBrackets, allowNestedParams) {
var name = '', useBrackets;
skipWhiteSpace(last);
if (index >= last) {
return null;
}
if (allowBrackets && source.charCodeAt(index) === 0x5B /* '[' */) {
useBrackets = true;
name = advance();
}
if (!esutils.code.isIdentifierStart(source.charCodeAt(index))) {
return null;
}
name += scanIdentifier(last);
if (allowNestedParams) {
if (source.charCodeAt(index) === 0x3A /* ':' */ && (
name === 'module' ||
name === 'external' ||
name === 'event')) {
name += advance();
name += scanIdentifier(last);
}
if(source.charCodeAt(index) === 0x5B /* '[' */ && source.charCodeAt(index + 1) === 0x5D /* ']' */){
name += advance();
name += advance();
}
while (source.charCodeAt(index) === 0x2E /* '.' */ ||
source.charCodeAt(index) === 0x23 /* '#' */ ||
source.charCodeAt(index) === 0x7E /* '~' */) {
name += advance();
name += scanIdentifier(last);
}
}
if (useBrackets) {
// do we have a default value for this?
if (source.charCodeAt(index) === 0x3D /* '=' */) {
// consume the '='' symbol
name += advance();
var bracketDepth = 1;
// scan in the default value
while (index < last) {
if (source.charCodeAt(index) === 0x5B /* '[' */) {
bracketDepth++;
} else if (source.charCodeAt(index) === 0x5D /* ']' */ &&
--bracketDepth === 0) {
break;
}
name += advance();
}
}
if (index >= last || source.charCodeAt(index) !== 0x5D /* ']' */) {
// we never found a closing ']'
return null;
}
// collect the last ']'
name += advance();
}
return name;
}
function skipToTag() {
while (index < length && source.charCodeAt(index) !== 0x40 /* '@' */) {
advance();
}
if (index >= length) {
return false;
}
utility.assert(source.charCodeAt(index) === 0x40 /* '@' */);
return true;
}
function TagParser(options, title) {
this._options = options;
this._title = title;
this._tag = {
title: title,
description: null
};
if (this._options.lineNumbers) {
this._tag.lineNumber = lineNumber;
}
this._last = 0;
// space to save special information for title parsers.
this._extra = { };
}
// addError(err, ...)
TagParser.prototype.addError = function addError(errorText) {
var args = Array.prototype.slice.call(arguments, 1),
msg = errorText.replace(
/%(\d)/g,
function (whole, index) {
utility.assert(index < args.length, 'Message reference must be in range');
return args[index];
}
);
if (!this._tag.errors) {
this._tag.errors = [];
}
if (strict) {
utility.throwError(msg);
}
this._tag.errors.push(msg);
return recoverable;
};
TagParser.prototype.parseType = function () {
// type required titles
if (isTypeParameterRequired(this._title)) {
try {
this._tag.type = parseType(this._title, this._last);
if (!this._tag.type) {
if (!isParamTitle(this._title) && !isReturnTitle(this._title)) {
if (!this.addError('Missing or invalid tag type')) {
return false;
}
}
}
} catch (error) {
this._tag.type = null;
if (!this.addError(error.message)) {
return false;
}
}
} else if (isAllowedType(this._title)) {
// optional types
try {
this._tag.type = parseType(this._title, this._last);
} catch (e) {
//For optional types, lets drop the thrown error when we hit the end of the file
}
}
return true;
};
TagParser.prototype._parseNamePath = function (optional) {
var name;
name = parseName(this._last, sloppy && isParamTitle(this._title), true);
if (!name) {
if (!optional) {
if (!this.addError('Missing or invalid tag name')) {
return false;
}
}
}
this._tag.name = name;
return true;
};
TagParser.prototype.parseNamePath = function () {
return this._parseNamePath(false);
};
TagParser.prototype.parseNamePathOptional = function () {
return this._parseNamePath(true);
};
TagParser.prototype.parseName = function () {
var assign, name;
// param, property requires name
if (isAllowedName(this._title)) {
this._tag.name = parseName(this._last, sloppy && isParamTitle(this._title), isAllowedNested(this._title));
if (!this._tag.name) {
if (!isNameParameterRequired(this._title)) {
return true;
}
// it's possible the name has already been parsed but interpreted as a type
// it's also possible this is a sloppy declaration, in which case it will be
// fixed at the end
if (isParamTitle(this._title) && this._tag.type && this._tag.type.name) {
this._extra.name = this._tag.type;
this._tag.name = this._tag.type.name;
this._tag.type = null;
} else {
if (!this.addError('Missing or invalid tag name')) {
return false;
}
}
} else {
name = this._tag.name;
if (name.charAt(0) === '[' && name.charAt(name.length - 1) === ']') {
// extract the default value if there is one
// example: @param {string} [somebody=John Doe] description
assign = name.substring(1, name.length - 1).split('=');
if (assign[1]) {
this._tag['default'] = assign[1];
}
this._tag.name = assign[0];
// convert to an optional type
if (this._tag.type && this._tag.type.type !== 'OptionalType') {
this._tag.type = {
type: 'OptionalType',
expression: this._tag.type
};
}
}
}
}
return true;
};
TagParser.prototype.parseDescription = function parseDescription() {
var description = trim(sliceSource(source, index, this._last));
if (description) {
if ((/^-\s+/).test(description)) {
description = description.substring(2);
}
this._tag.description = description;
}
return true;
};
TagParser.prototype.parseKind = function parseKind() {
var kind, kinds;
kinds = {
'class': true,
'constant': true,
'event': true,
'external': true,
'file': true,
'function': true,
'member': true,
'mixin': true,
'module': true,
'namespace': true,
'typedef': true
};
kind = trim(sliceSource(source, index, this._last));
this._tag.kind = kind;
if (!hasOwnProperty(kinds, kind)) {
if (!this.addError('Invalid kind name \'%0\'', kind)) {
return false;
}
}
return true;
};
TagParser.prototype.parseAccess = function parseAccess() {
var access;
access = trim(sliceSource(source, index, this._last));
this._tag.access = access;
if (access !== 'private' && access !== 'protected' && access !== 'public') {
if (!this.addError('Invalid access name \'%0\'', access)) {
return false;
}
}
return true;
};
TagParser.prototype.parseVariation = function parseVariation() {
var variation, text;
text = trim(sliceSource(source, index, this._last));
variation = parseFloat(text, 10);
this._tag.variation = variation;
if (isNaN(variation)) {
if (!this.addError('Invalid variation \'%0\'', text)) {
return false;
}
}
return true;
};
TagParser.prototype.ensureEnd = function () {
var shouldBeEmpty = trim(sliceSource(source, index, this._last));
if (shouldBeEmpty) {
if (!this.addError('Unknown content \'%0\'', shouldBeEmpty)) {
return false;
}
}
return true;
};
TagParser.prototype.epilogue = function epilogue() {
var description;
description = this._tag.description;
// un-fix potentially sloppy declaration
if (isParamTitle(this._title) && !this._tag.type && description && description.charAt(0) === '[') {
this._tag.type = this._extra.name;
if (!this._tag.name) {
this._tag.name = undefined;
}
if (!sloppy) {
if (!this.addError('Missing or invalid tag name')) {
return false;
}
}
}
return true;
};
Rules = {
// http://usejsdoc.org/tags-access.html
'access': ['parseAccess'],
// http://usejsdoc.org/tags-alias.html
'alias': ['parseNamePath', 'ensureEnd'],
// http://usejsdoc.org/tags-augments.html
'augments': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
// http://usejsdoc.org/tags-constructor.html
'constructor': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
// Synonym: http://usejsdoc.org/tags-constructor.html
'class': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
// Synonym: http://usejsdoc.org/tags-extends.html
'extends': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
// http://usejsdoc.org/tags-deprecated.html
'deprecated': ['parseDescription'],
// http://usejsdoc.org/tags-global.html
'global': ['ensureEnd'],
// http://usejsdoc.org/tags-inner.html
'inner': ['ensureEnd'],
// http://usejsdoc.org/tags-instance.html
'instance': ['ensureEnd'],
// http://usejsdoc.org/tags-kind.html
'kind': ['parseKind'],
// http://usejsdoc.org/tags-mixes.html
'mixes': ['parseNamePath', 'ensureEnd'],
// http://usejsdoc.org/tags-mixin.html
'mixin': ['parseNamePathOptional', 'ensureEnd'],
// http://usejsdoc.org/tags-member.html
'member': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
// http://usejsdoc.org/tags-method.html
'method': ['parseNamePathOptional', 'ensureEnd'],
// http://usejsdoc.org/tags-module.html
'module': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
// Synonym: http://usejsdoc.org/tags-method.html
'func': ['parseNamePathOptional', 'ensureEnd'],
// Synonym: http://usejsdoc.org/tags-method.html
'function': ['parseNamePathOptional', 'ensureEnd'],
// Synonym: http://usejsdoc.org/tags-member.html
'var': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
// http://usejsdoc.org/tags-name.html
'name': ['parseNamePath', 'ensureEnd'],
// http://usejsdoc.org/tags-namespace.html
'namespace': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
// http://usejsdoc.org/tags-private.html
'private': ['parseType', 'parseDescription'],
// http://usejsdoc.org/tags-protected.html
'protected': ['parseType', 'parseDescription'],
// http://usejsdoc.org/tags-public.html
'public': ['parseType', 'parseDescription'],
// http://usejsdoc.org/tags-readonly.html
'readonly': ['ensureEnd'],
// http://usejsdoc.org/tags-requires.html
'requires': ['parseNamePath', 'ensureEnd'],
// http://usejsdoc.org/tags-since.html
'since': ['parseDescription'],
// http://usejsdoc.org/tags-static.html
'static': ['ensureEnd'],
// http://usejsdoc.org/tags-summary.html
'summary': ['parseDescription'],
// http://usejsdoc.org/tags-this.html
'this': ['parseNamePath', 'ensureEnd'],
// http://usejsdoc.org/tags-todo.html
'todo': ['parseDescription'],
// http://usejsdoc.org/tags-typedef.html
'typedef': ['parseType', 'parseNamePathOptional'],
// http://usejsdoc.org/tags-variation.html
'variation': ['parseVariation'],
// http://usejsdoc.org/tags-version.html
'version': ['parseDescription']
};
TagParser.prototype.parse = function parse() {
var i, iz, sequences, method;
// empty title
if (!this._title) {
if (!this.addError('Missing or invalid title')) {
return null;
}
}
// Seek to content last index.
this._last = seekContent(this._title);
if (hasOwnProperty(Rules, this._title)) {
sequences = Rules[this._title];
} else {
// default sequences
sequences = ['parseType', 'parseName', 'parseDescription', 'epilogue'];
}
for (i = 0, iz = sequences.length; i < iz; ++i) {
method = sequences[i];
if (!this[method]()) {
return null;
}
}
return this._tag;
};
function parseTag(options) {
var title, parser, tag;
// skip to tag
if (!skipToTag()) {
return null;
}
// scan title
title = scanTitle();
// construct tag parser
parser = new TagParser(options, title);
tag = parser.parse();
// Seek global index to end of this tag.
while (index < parser._last) {
advance();
}
return tag;
}
//
// Parse JSDoc
//
function scanJSDocDescription(preserveWhitespace) {
var description = '', ch, atAllowed;
atAllowed = true;
while (index < length) {
ch = source.charCodeAt(index);
if (atAllowed && ch === 0x40 /* '@' */) {
break;
}
if (esutils.code.isLineTerminator(ch)) {
atAllowed = true;
} else if (atAllowed && !esutils.code.isWhiteSpace(ch)) {
atAllowed = false;
}
description += advance();
}
return preserveWhitespace ? description : trim(description);
}
function parse(comment, options) {
var tags = [], tag, description, interestingTags, i, iz;
if (options === undefined) {
options = {};
}
if (typeof options.unwrap === 'boolean' && options.unwrap) {
source = unwrapComment(comment);
} else {
source = comment;
}
// array of relevant tags
if (options.tags) {
if (isArray(options.tags)) {
interestingTags = { };
for (i = 0, iz = options.tags.length; i < iz; i++) {
if (typeof options.tags[i] === 'string') {
interestingTags[options.tags[i]] = true;
} else {
utility.throwError('Invalid "tags" parameter: ' + options.tags);
}
}
} else {
utility.throwError('Invalid "tags" parameter: ' + options.tags);
}
}
length = source.length;
index = 0;
lineNumber = 0;
recoverable = options.recoverable;
sloppy = options.sloppy;
strict = options.strict;
description = scanJSDocDescription(options.preserveWhitespace);
while (true) {
tag = parseTag(options);
if (!tag) {
break;
}
if (!interestingTags || interestingTags.hasOwnProperty(tag.title)) {
tags.push(tag);
}
}
return {
description: description,
tags: tags
};
}
exports.parse = parse;
}(jsdoc = {}));
exports.version = utility.VERSION;
exports.parse = jsdoc.parse;
exports.parseType = typed.parseType;
exports.parseParamType = typed.parseParamType;
exports.unwrapComment = unwrapComment;
exports.Syntax = shallowCopy(typed.Syntax);
exports.Error = utility.DoctrineError;
exports.type = {
Syntax: exports.Syntax,
parseType: typed.parseType,
parseParamType: typed.parseParamType,
stringify: typed.stringify
};
}());
/* vim: set sw=4 ts=4 et tw=80 : */

1261
node_modules/doctrine/lib/typed.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

54
node_modules/doctrine/lib/utility.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
/*
Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function () {
'use strict';
var VERSION;
VERSION = require('../package.json').version;
exports.VERSION = VERSION;
function DoctrineError(message) {
this.name = 'DoctrineError';
this.message = message;
}
DoctrineError.prototype = (function () {
var Middle = function () { };
Middle.prototype = Error.prototype;
return new Middle();
}());
DoctrineError.prototype.constructor = DoctrineError;
exports.DoctrineError = DoctrineError;
function throwError(message) {
throw new DoctrineError(message);
}
exports.throwError = throwError;
exports.assert = require('assert');
}());
/* vim: set sw=4 ts=4 et tw=80 : */

19
node_modules/doctrine/node_modules/esutils/LICENSE.BSD generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

169
node_modules/doctrine/node_modules/esutils/README.md generated vendored Normal file
View File

@@ -0,0 +1,169 @@
### esutils [![Build Status](https://secure.travis-ci.org/Constellation/esutils.svg)](http://travis-ci.org/Constellation/esutils)
esutils ([esutils](http://github.com/Constellation/esutils)) is
utility box for ECMAScript language tools.
### API
### ast
#### ast.isExpression(node)
Returns true if `node` is an Expression as defined in ECMA262 edition 5.1 section
[11](https://es5.github.io/#x11).
#### ast.isStatement(node)
Returns true if `node` is a Statement as defined in ECMA262 edition 5.1 section
[12](https://es5.github.io/#x12).
#### ast.isIterationStatement(node)
Returns true if `node` is an IterationStatement as defined in ECMA262 edition
5.1 section [12.6](https://es5.github.io/#x12.6).
#### ast.isSourceElement(node)
Returns true if `node` is a SourceElement as defined in ECMA262 edition 5.1
section [14](https://es5.github.io/#x14).
#### ast.trailingStatement(node)
Returns `Statement?` if `node` has trailing `Statement`.
```js
if (cond)
consequent;
```
When taking this `IfStatement`, returns `consequent;` statement.
#### ast.isProblematicIfStatement(node)
Returns true if `node` is a problematic IfStatement. If `node` is a problematic `IfStatement`, `node` cannot be represented as an one on one JavaScript code.
```js
{
type: 'IfStatement',
consequent: {
type: 'WithStatement',
body: {
type: 'IfStatement',
consequent: {type: 'EmptyStatement'}
}
},
alternate: {type: 'EmptyStatement'}
}
```
The above node cannot be represented as a JavaScript code, since the top level `else` alternate belongs to an inner `IfStatement`.
### code
#### code.isDecimalDigit(code)
Return true if provided code is decimal digit.
#### code.isHexDigit(code)
Return true if provided code is hexadecimal digit.
#### code.isOctalDigit(code)
Return true if provided code is octal digit.
#### code.isWhiteSpace(code)
Return true if provided code is white space. White space characters are formally defined in ECMA262.
#### code.isLineTerminator(code)
Return true if provided code is line terminator. Line terminator characters are formally defined in ECMA262.
#### code.isIdentifierStart(code)
Return true if provided code can be the first character of ECMA262 Identifier. They are formally defined in ECMA262.
#### code.isIdentifierPart(code)
Return true if provided code can be the trailing character of ECMA262 Identifier. They are formally defined in ECMA262.
### keyword
#### keyword.isKeywordES5(id, strict)
Returns `true` if provided identifier string is a Keyword or Future Reserved Word
in ECMA262 edition 5.1. They are formally defined in ECMA262 sections
[7.6.1.1](http://es5.github.io/#x7.6.1.1) and [7.6.1.2](http://es5.github.io/#x7.6.1.2),
respectively. If the `strict` flag is truthy, this function additionally checks whether
`id` is a Keyword or Future Reserved Word under strict mode.
#### keyword.isKeywordES6(id, strict)
Returns `true` if provided identifier string is a Keyword or Future Reserved Word
in ECMA262 edition 6. They are formally defined in ECMA262 sections
[11.6.2.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-keywords) and
[11.6.2.2](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-future-reserved-words),
respectively. If the `strict` flag is truthy, this function additionally checks whether
`id` is a Keyword or Future Reserved Word under strict mode.
#### keyword.isReservedWordES5(id, strict)
Returns `true` if provided identifier string is a Reserved Word in ECMA262 edition 5.1.
They are formally defined in ECMA262 section [7.6.1](http://es5.github.io/#x7.6.1).
If the `strict` flag is truthy, this function additionally checks whether `id`
is a Reserved Word under strict mode.
#### keyword.isReservedWordES6(id, strict)
Returns `true` if provided identifier string is a Reserved Word in ECMA262 edition 6.
They are formally defined in ECMA262 section [11.6.2](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-reserved-words).
If the `strict` flag is truthy, this function additionally checks whether `id`
is a Reserved Word under strict mode.
#### keyword.isRestrictedWord(id)
Returns `true` if provided identifier string is one of `eval` or `arguments`.
They are restricted in strict mode code throughout ECMA262 edition 5.1 and
in ECMA262 edition 6 section [12.1.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers-static-semantics-early-errors).
#### keyword.isIdentifierName(id)
Return true if provided identifier string is an IdentifierName as specified in
ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6).
#### keyword.isIdentifierES5(id, strict)
Return true if provided identifier string is an Identifier as specified in
ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6). If the `strict`
flag is truthy, this function additionally checks whether `id` is an Identifier
under strict mode.
#### keyword.isIdentifierES6(id, strict)
Return true if provided identifier string is an Identifier as specified in
ECMA262 edition 6 section [12.1](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-identifiers).
If the `strict` flag is truthy, this function additionally checks whether `id`
is an Identifier under strict mode.
### License
Copyright (C) 2013 [Yusuke Suzuki](http://github.com/Constellation)
(twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

144
node_modules/doctrine/node_modules/esutils/lib/ast.js generated vendored Normal file
View File

@@ -0,0 +1,144 @@
/*
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function () {
'use strict';
function isExpression(node) {
if (node == null) { return false; }
switch (node.type) {
case 'ArrayExpression':
case 'AssignmentExpression':
case 'BinaryExpression':
case 'CallExpression':
case 'ConditionalExpression':
case 'FunctionExpression':
case 'Identifier':
case 'Literal':
case 'LogicalExpression':
case 'MemberExpression':
case 'NewExpression':
case 'ObjectExpression':
case 'SequenceExpression':
case 'ThisExpression':
case 'UnaryExpression':
case 'UpdateExpression':
return true;
}
return false;
}
function isIterationStatement(node) {
if (node == null) { return false; }
switch (node.type) {
case 'DoWhileStatement':
case 'ForInStatement':
case 'ForStatement':
case 'WhileStatement':
return true;
}
return false;
}
function isStatement(node) {
if (node == null) { return false; }
switch (node.type) {
case 'BlockStatement':
case 'BreakStatement':
case 'ContinueStatement':
case 'DebuggerStatement':
case 'DoWhileStatement':
case 'EmptyStatement':
case 'ExpressionStatement':
case 'ForInStatement':
case 'ForStatement':
case 'IfStatement':
case 'LabeledStatement':
case 'ReturnStatement':
case 'SwitchStatement':
case 'ThrowStatement':
case 'TryStatement':
case 'VariableDeclaration':
case 'WhileStatement':
case 'WithStatement':
return true;
}
return false;
}
function isSourceElement(node) {
return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
}
function trailingStatement(node) {
switch (node.type) {
case 'IfStatement':
if (node.alternate != null) {
return node.alternate;
}
return node.consequent;
case 'LabeledStatement':
case 'ForStatement':
case 'ForInStatement':
case 'WhileStatement':
case 'WithStatement':
return node.body;
}
return null;
}
function isProblematicIfStatement(node) {
var current;
if (node.type !== 'IfStatement') {
return false;
}
if (node.alternate == null) {
return false;
}
current = node.consequent;
do {
if (current.type === 'IfStatement') {
if (current.alternate == null) {
return true;
}
}
current = trailingStatement(current);
} while (current);
return false;
}
module.exports = {
isExpression: isExpression,
isStatement: isStatement,
isIterationStatement: isIterationStatement,
isSourceElement: isSourceElement,
isProblematicIfStatement: isProblematicIfStatement,
trailingStatement: trailingStatement
};
}());
/* vim: set sw=4 ts=4 et tw=80 : */

101
node_modules/doctrine/node_modules/esutils/lib/code.js generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,137 @@
/*
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function () {
'use strict';
var code = require('./code');
function isStrictModeReservedWordES6(id) {
switch (id) {
case 'implements':
case 'interface':
case 'package':
case 'private':
case 'protected':
case 'public':
case 'static':
case 'let':
return true;
default:
return false;
}
}
function isKeywordES5(id, strict) {
// yield should not be treated as keyword under non-strict mode.
if (!strict && id === 'yield') {
return false;
}
return isKeywordES6(id, strict);
}
function isKeywordES6(id, strict) {
if (strict && isStrictModeReservedWordES6(id)) {
return true;
}
switch (id.length) {
case 2:
return (id === 'if') || (id === 'in') || (id === 'do');
case 3:
return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try');
case 4:
return (id === 'this') || (id === 'else') || (id === 'case') ||
(id === 'void') || (id === 'with') || (id === 'enum');
case 5:
return (id === 'while') || (id === 'break') || (id === 'catch') ||
(id === 'throw') || (id === 'const') || (id === 'yield') ||
(id === 'class') || (id === 'super');
case 6:
return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
(id === 'switch') || (id === 'export') || (id === 'import');
case 7:
return (id === 'default') || (id === 'finally') || (id === 'extends');
case 8:
return (id === 'function') || (id === 'continue') || (id === 'debugger');
case 10:
return (id === 'instanceof');
default:
return false;
}
}
function isReservedWordES5(id, strict) {
return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
}
function isReservedWordES6(id, strict) {
return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
}
function isRestrictedWord(id) {
return id === 'eval' || id === 'arguments';
}
function isIdentifierName(id) {
var i, iz, ch;
if (id.length === 0) {
return false;
}
ch = id.charCodeAt(0);
if (!code.isIdentifierStart(ch) || ch === 92) { // \ (backslash)
return false;
}
for (i = 1, iz = id.length; i < iz; ++i) {
ch = id.charCodeAt(i);
if (!code.isIdentifierPart(ch) || ch === 92) { // \ (backslash)
return false;
}
}
return true;
}
function isIdentifierES5(id, strict) {
return isIdentifierName(id) && !isReservedWordES5(id, strict);
}
function isIdentifierES6(id, strict) {
return isIdentifierName(id) && !isReservedWordES6(id, strict);
}
module.exports = {
isKeywordES5: isKeywordES5,
isKeywordES6: isKeywordES6,
isReservedWordES5: isReservedWordES5,
isReservedWordES6: isReservedWordES6,
isRestrictedWord: isRestrictedWord,
isIdentifierName: isIdentifierName,
isIdentifierES5: isIdentifierES5,
isIdentifierES6: isIdentifierES6
};
}());
/* vim: set sw=4 ts=4 et tw=80 : */

View File

@@ -0,0 +1,33 @@
/*
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function () {
'use strict';
exports.ast = require('./ast');
exports.code = require('./code');
exports.keyword = require('./keyword');
}());
/* vim: set sw=4 ts=4 et tw=80 : */

View File

@@ -0,0 +1,49 @@
{
"name": "esutils",
"description": "utility box for ECMAScript language tools",
"homepage": "https://github.com/Constellation/esutils",
"main": "lib/utils.js",
"version": "1.1.6",
"engines": {
"node": ">=0.10.0"
},
"directories": {
"lib": "./lib"
},
"files": [
"LICENSE.BSD",
"README.md",
"lib"
],
"maintainers": [
{
"name": "Yusuke Suzuki",
"email": "utatane.tea@gmail.com",
"web": "http://github.com/Constellation"
}
],
"repository": {
"type": "git",
"url": "http://github.com/Constellation/esutils.git"
},
"devDependencies": {
"mocha": "~1.12.0",
"chai": "~1.7.2",
"jshint": "2.1.5",
"coffee-script": "~1.6.3",
"unicode-6.3.0": "~0.1.1",
"regenerate": "~0.5.4"
},
"licenses": [
{
"type": "BSD",
"url": "http://github.com/Constellation/esutils/raw/master/LICENSE.BSD"
}
],
"scripts": {
"test": "npm run-script lint && npm run-script unit-test",
"lint": "jshint lib/*.js",
"unit-test": "mocha --compilers coffee:coffee-script -R spec",
"generate-regex": "node tools/generate-identifier-regex.js"
}
}

69
node_modules/doctrine/package.json generated vendored Normal file
View File

@@ -0,0 +1,69 @@
{
"name": "doctrine",
"description": "JSDoc parser",
"homepage": "https://github.com/eslint/doctrine",
"main": "lib/doctrine.js",
"version": "0.7.2",
"engines": {
"node": ">=0.10.0"
},
"directories": {
"lib": "./lib"
},
"files": [
"lib",
"LICENSE.BSD",
"LICENSE.closure-compiler",
"LICENSE.esprima",
"README.md"
],
"maintainers": [
{
"name": "Yusuke Suzuki",
"email": "utatane.tea@gmail.com",
"web": "http://github.com/Constellation"
}
],
"repository": {
"type": "git",
"url": "http://github.com/eslint/doctrine.git"
},
"devDependencies": {
"coveralls": "^2.11.2",
"dateformat": "^1.0.11",
"eslint": "^1.9.0",
"gulp": "^3.8.10",
"gulp-bump": "^0.1.13",
"gulp-eslint": "^0.5.0",
"gulp-filter": "^2.0.2",
"gulp-git": "^1.0.0",
"gulp-istanbul": "^0.6.0",
"gulp-jshint": "^1.9.0",
"gulp-mocha": "^2.0.0",
"gulp-tag-version": "^1.2.1",
"jshint-stylish": "^1.0.0",
"linefix": "^0.1.1",
"mocha": "^2.3.3",
"npm-license": "^0.3.1",
"semver": "^5.0.3",
"shelljs": "^0.5.3",
"shelljs-nodecli": "^0.1.1",
"should": "^5.0.1"
},
"licenses": [
{
"type": "BSD",
"url": "http://github.com/eslint/doctrine/raw/master/LICENSE.BSD"
}
],
"scripts": {
"test": "gulp",
"unit-test": "gulp test",
"lint": "gulp lint",
"coveralls": "cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"
},
"dependencies": {
"esutils": "^1.1.6",
"isarray": "0.0.1"
}
}

54
node_modules/isarray/README.md generated vendored Normal file
View File

@@ -0,0 +1,54 @@
# isarray
`Array#isArray` for older browsers.
## Usage
```js
var isArray = require('isarray');
console.log(isArray([])); // => true
console.log(isArray({})); // => false
```
## Installation
With [npm](http://npmjs.org) do
```bash
$ npm install isarray
```
Then bundle for the browser with
[browserify](https://github.com/substack/browserify).
With [component](http://component.io) do
```bash
$ component install juliangruber/isarray
```
## License
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

209
node_modules/isarray/build/build.js generated vendored Normal file
View File

@@ -0,0 +1,209 @@
/**
* Require the given path.
*
* @param {String} path
* @return {Object} exports
* @api public
*/
function require(path, parent, orig) {
var resolved = require.resolve(path);
// lookup failed
if (null == resolved) {
orig = orig || path;
parent = parent || 'root';
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
err.path = orig;
err.parent = parent;
err.require = true;
throw err;
}
var module = require.modules[resolved];
// perform real require()
// by invoking the module's
// registered function
if (!module.exports) {
module.exports = {};
module.client = module.component = true;
module.call(this, module.exports, require.relative(resolved), module);
}
return module.exports;
}
/**
* Registered modules.
*/
require.modules = {};
/**
* Registered aliases.
*/
require.aliases = {};
/**
* Resolve `path`.
*
* Lookup:
*
* - PATH/index.js
* - PATH.js
* - PATH
*
* @param {String} path
* @return {String} path or null
* @api private
*/
require.resolve = function(path) {
if (path.charAt(0) === '/') path = path.slice(1);
var index = path + '/index.js';
var paths = [
path,
path + '.js',
path + '.json',
path + '/index.js',
path + '/index.json'
];
for (var i = 0; i < paths.length; i++) {
var path = paths[i];
if (require.modules.hasOwnProperty(path)) return path;
}
if (require.aliases.hasOwnProperty(index)) {
return require.aliases[index];
}
};
/**
* Normalize `path` relative to the current path.
*
* @param {String} curr
* @param {String} path
* @return {String}
* @api private
*/
require.normalize = function(curr, path) {
var segs = [];
if ('.' != path.charAt(0)) return path;
curr = curr.split('/');
path = path.split('/');
for (var i = 0; i < path.length; ++i) {
if ('..' == path[i]) {
curr.pop();
} else if ('.' != path[i] && '' != path[i]) {
segs.push(path[i]);
}
}
return curr.concat(segs).join('/');
};
/**
* Register module at `path` with callback `definition`.
*
* @param {String} path
* @param {Function} definition
* @api private
*/
require.register = function(path, definition) {
require.modules[path] = definition;
};
/**
* Alias a module definition.
*
* @param {String} from
* @param {String} to
* @api private
*/
require.alias = function(from, to) {
if (!require.modules.hasOwnProperty(from)) {
throw new Error('Failed to alias "' + from + '", it does not exist');
}
require.aliases[to] = from;
};
/**
* Return a require function relative to the `parent` path.
*
* @param {String} parent
* @return {Function}
* @api private
*/
require.relative = function(parent) {
var p = require.normalize(parent, '..');
/**
* lastIndexOf helper.
*/
function lastIndexOf(arr, obj) {
var i = arr.length;
while (i--) {
if (arr[i] === obj) return i;
}
return -1;
}
/**
* The relative require() itself.
*/
function localRequire(path) {
var resolved = localRequire.resolve(path);
return require(resolved, parent, path);
}
/**
* Resolve relative to the parent.
*/
localRequire.resolve = function(path) {
var c = path.charAt(0);
if ('/' == c) return path.slice(1);
if ('.' == c) return require.normalize(p, path);
// resolve deps by returning
// the dep in the nearest "deps"
// directory
var segs = parent.split('/');
var i = lastIndexOf(segs, 'deps') + 1;
if (!i) i = 0;
path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
return path;
};
/**
* Check if module is defined at `path`.
*/
localRequire.exists = function(path) {
return require.modules.hasOwnProperty(localRequire.resolve(path));
};
return localRequire;
};
require.register("isarray/index.js", function(exports, require, module){
module.exports = Array.isArray || function (arr) {
return Object.prototype.toString.call(arr) == '[object Array]';
};
});
require.alias("isarray/index.js", "isarray/index.js");

19
node_modules/isarray/component.json generated vendored Normal file
View File

@@ -0,0 +1,19 @@
{
"name" : "isarray",
"description" : "Array#isArray for older browsers",
"version" : "0.0.1",
"repository" : "juliangruber/isarray",
"homepage": "https://github.com/juliangruber/isarray",
"main" : "index.js",
"scripts" : [
"index.js"
],
"dependencies" : {},
"keywords": ["browser","isarray","array"],
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
"url": "http://juliangruber.com"
},
"license": "MIT"
}

3
node_modules/isarray/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
module.exports = Array.isArray || function (arr) {
return Object.prototype.toString.call(arr) == '[object Array]';
};

29
node_modules/isarray/package.json generated vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "isarray",
"description": "Array#isArray for older browsers",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/isarray.git"
},
"homepage": "https://github.com/juliangruber/isarray",
"main": "index.js",
"scripts": {
"test": "tap test/*.js"
},
"dependencies": {},
"devDependencies": {
"tap": "*"
},
"keywords": [
"browser",
"isarray",
"array"
],
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
"url": "http://juliangruber.com"
},
"license": "MIT"
}

398
node_modules/tslint-eslint-rules/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,398 @@
# Change Log
## [Unreleased]
## [v5.4.0] - August 14, 2018
*Rules*
- `ter-padded-blocks`
*Updates*
- `object-curly-spacing`: supports `arraysInObjects/objectsInObjects` options.
- Support for typescript 3.0
## [v5.3.1] - May 15, 2018
#### Features
- `valid-jsdoc` recognizes `@inheritDoc` tag
#### Bug fixes
- `sort-imports` rule reads imports correctly (Issue #319)
- `space-in-parens` bugfix when using default options (Issue #305)
- `no-multi-spaces` bugfix in string literals.
NOTE: The Github tag v5.3.0 was deleted since it the NPM package
missed a bugfix due to not syncing the branches locally.
## [v5.2.0] - May 08, 2018
### Rules
- `ter-no-proto`
- `ter-no-script-url`
- `ter-no-self-compare`
### Fixes
- `ter-newline-after-var` - issue 302
## [v5.1.0] - Feb 24, 2018
### Rules
- `ter-padded-blocks`
### Fixes
- `ter-indent`: failed when missing `VariableDeclarator` options ([bfff0e6])
- `ter-newline-after-var`: incorrectly fixing code and within try catch block ([d930c6c])
[bfff0e6]: https://github.com/buzinas/tslint-eslint-rules/commit/bfff0e60263ff4fa38280739566e99c523d9fd4d
[d930c6c]: https://github.com/buzinas/tslint-eslint-rules/commit/d930c6c76de65f9f94d95624a65f5cfd537fe571
## [v5.0.0] - Feb 14, 2018
### Upgraded to TSLint 5.9 and Typescript 2.6
- NOTE: Another release will come soon that uses 2.7
#### Rules Added
- `ter-no-tabs`
See the differences in [v5.0.0] for more information on the changes.
## [v4.1.1] - May 26, 2017
#### Fixes
- valid-jsdoc reported missing return with abstract methods ([3bd2dafb])
[3bd2dafb]: https://github.com/buzinas/tslint-eslint-rules/commit/3bd2dafb22174d2912f1a9b73ca917abe52107fc
## [v4.1.0] - May 21, 2017
#### Fixes
- valid-jsdoc reported at wrong location ([82a3ca75])
#### Rules Added
- [ter-func-call-spacing](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terFuncCallSpacingRule.md)
#### Name Change
The following rule names have been renamed since they are no longer accessible with TSLint 5.0.
- `no-irregular-whitespace` changed to `ter-no-irregular-whitespace`
- `no-sparse-arrays` changed to `ter-no-sparse-arrays`
#### Removed
- `use-isnan`: This rule is now provided by TSLint.
[82a3ca75]: https://github.com/buzinas/tslint-eslint-rules/commit/82a3ca75678240976d868498407b3763ff57419c
## [v4.0.0] - April 4, 2017
### Upgraded to [TSLint 5.0](https://github.com/palantir/tslint/releases/tag/5.0.0)
## [v3.5.1] - 2017/03/17 23:00 GMT-0600
#### Fixes
- sort-imports bug in simple type imports ([3d57149])
[3d57149]: https://github.com/buzinas/tslint-eslint-rules/commit/3d571494aa5642f19f856fc361d5723a1b792e4a
## [v3.5.0] - 2017/03/16 15:20 GMT-0600
#### Fixes
- valid-jsdoc crashed with missing return type ([de16445])
#### Features
- valid-jsdoc added option to omitt return and parameters type ([b81e671])
#### Rules Added
- [sort-imports](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/sortImportsRule.md)
#### Fixers Added
- ter-indent ([b76ee05])
#### Other Changes
`tslint` peer dependency updated to 4.5.0
[de16445]: https://github.com/buzinas/tslint-eslint-rules/commit/de164458164116b1743d0cdc57fcfbcd6a4109c4
[b76ee05]: https://github.com/buzinas/tslint-eslint-rules/commit/b76ee05033a273bdf61b6ee7465290ad8c4a73f1
[b81e671]: https://github.com/buzinas/tslint-eslint-rules/commit/b81e67141abf76f976ab399a0f16f50e971891b8
## [v3.4.0] - 2017/02/16 15:40 GMT-0600
#### Fixes
- array-bracket-spacing handles comments ([9c551d7])
#### Rules Added
- [space-in-parens](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/spaceInParensRule.md)
#### Fixers Added
- object-curly-spacing ([ec81eb4])
- array-bracket-spacing ([3c689ff])
- space-in-parens ([cd50170])
#### Other Changes
`tslint` is no longer a `dependency`. Instead it is a `peerDependency` and `devDependency`.
[ec81eb4]: https://github.com/buzinas/tslint-eslint-rules/commit/ec81eb457aa1758dbc35fd4ea01519fc934e1259
[3c689ff]: https://github.com/buzinas/tslint-eslint-rules/commit/3c689ffa23b36870e9fae8bb04ccdbe51cbf04c7
[cd50170]: https://github.com/buzinas/tslint-eslint-rules/commit/cd50170f658c62062dff3fa60d501cebccd98d9e
[9c551d7]: https://github.com/buzinas/tslint-eslint-rules/commit/9c551d7eaaa55289cc326e16e804d702c36cc3a1
## [v3.3.0] - 2017/02/04 04:45 GMT-0600
#### Changes
- Build errors fixed ([d163eb5])
- TSLint extends support ([18902f1])
[d163eb5]: https://github.com/buzinas/tslint-eslint-rules/commit/d163eb5aa438cce25da2624cf43c478544e7889b
[18902f1]: https://github.com/buzinas/tslint-eslint-rules/commit/18902f10939aeb4dedbcb7334be42d462846457c
## [v3.2.3] - 2016/12/24 22:52 GMT-0600
#### Fixes
- handle-callback-err ([0a9a882])
[0a9a882]: https://github.com/buzinas/tslint-eslint-rules/commit/0a9a88284f199ec292bcea0534b4323f10a5bc50
## [v3.2.2] - 2016/12/24 12:10 GMT-0600
#### Fixes
- ter-indent
- JSDocs no longer break variable declarations [cb01358]
- Interfaces are also checked for indentation [5be6774]
- handle-callback-err: [Issue 153](https://github.com/buzinas/tslint-eslint-rules/issues/153)
- Added `allowProperties` option to make the rule more strict.
Note that the npm release `v3.2.1` only contains this hotfix [cb01358].
[5be6774]: https://github.com/buzinas/tslint-eslint-rules/commit/5be67747d4a74e216be14fc332e3871546609cdd
[cb01358]: https://github.com/buzinas/tslint-eslint-rules/commit/cb013580a74a2eb6781a6a0701a7bfafc0818c75
## [v3.2.0] - 2016/12/14 00:50 GMT-0600
#### Rules Added
- [ter-arrow-body-style](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terArrowBodyStyleRule.md)
- [ter-arrow-parens](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terArrowParensRule.md)
- [ter-arrow-spacing](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terArrowSpacingRule.md)
#### Fixes
- handle-callback-err: [Issue 146](https://github.com/buzinas/tslint-eslint-rules/issues/146)
#### Changes
- Added contributing file detailing how to use the current gulp tasks
- Added links to the rule and test source in each of the rule documentation
## [v3.1.0] - 2016/11/29 23:20 GTM-0600
#### Rules Added
- ter-prefer-arrow-callback
#### Fixes
- ter-indent:
- issues with try/catch statements
- issues with return statements
- issues with method declarations
- A `CallExpression` option has been added.
## [v3.0.0] - 2016/11/21 12:36 GTM-0600
### Upgraded to [TSLint 4.0](https://palantir.github.io/tslint/2016/11/17/new-for-4.0.html)
- Several rules are no longer applicable
- no-duplicate-key
- no-unreachable
- no-unused-variable
- use-strict
#### Developer Tools
- Added RuleTester to help writing tests, see [max-len-rule](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/test/rules/terMaxLenRuleTests.ts) and [no-multi-spaces](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/test/rules/noMultiSpacesRuleTests.ts) for usage examples.
## [v2.2.1] - 2016/11/17 21:50 GMT-0600
#### Fixes
- ter-max-len ([539b3c2](https://github.com/buzinas/tslint-eslint-rules/commit/539b3c210d1fd157d27a9fb61e123c28249e7690))
## [v2.2.0] - 2016/11/17 02:30 GMT-0600
#### Rules Added
- ter-indent ([b0334d4](https://github.com/buzinas/tslint-eslint-rules/commit/b0334d4fbf7286e07521cbffc5fa90f96e536224))
- ter-max-len ([5938feb](https://github.com/buzinas/tslint-eslint-rules/commit/5938feb4c290de54e80ddd4bfdd3259441124279))
#### Fixes
- no-constant-condition ([b0456a4](https://github.com/buzinas/tslint-eslint-rules/commit/b0456a45b25dd7df488880a61027cf485329fe91))
#### Changes
- Rule documentation can be generated from its metadata ([d6ea71e](https://github.com/buzinas/tslint-eslint-rules/commit/d6ea71ee398c26e55d9bc86f01bbe2beca08b350))
## [v2.1.0] - 2016/10/03 19:29 +00:00
#### Fixes
- handle-callback-err ([caf6ec6](https://github.com/buzinas/tslint-eslint-rules/commit/caf6ec62be772297c18a9dd56d280d9b2dac076a))
#### Changes
- Added support for node 4 ([4785e36](https://github.com/buzinas/tslint-eslint-rules/commit/4785e3637166072d10fec61c9bf8a3350aa05733))
- Added support for node 0.10 ([adc290c](https://github.com/buzinas/tslint-eslint-rules/commit/adc290c02f1299251637ce5d448a3c152b58dc56))
- Using `es5` as the TypeScript target ([83ad6e3](https://github.com/buzinas/tslint-eslint-rules/commit/83ad6e3c89eb88a55707502c1251255771805e4a))
## [v2.0.0] - 2016/10/01 06:12 +00:00
### Upgraded to [TypeScript 2.0](https://www.typescriptlang.org/docs/release-notes/typescript-2.0.html)
- Using `es6` as the TypeScript target.
- Dropped support for node 4
## [v1.6.1] - 2016/10/01 05:41 +00:00
#### Fixes
- no-ex-assign ([31afa69](https://github.com/buzinas/tslint-eslint-rules/commit/31afa69d1718bda1b6d7b9f16c77ef1eb157bb37))
## [v1.6.0] - 2016/09/27 05:56 +00:00
#### Rules Added
- no-multi-spaces ([7972712](https://github.com/buzinas/tslint-eslint-rules/commit/79727121b64c383bc3c66f8bf2d5feaab3f2ad02))
#### Fixes
- no-constant-condition ([3f8dcc5](https://github.com/buzinas/tslint-eslint-rules/commit/3f8dcc5a2f5804243c86a47ba6dbfb4a2241d771))
- no-ex-assign ([93de74b](https://github.com/buzinas/tslint-eslint-rules/commit/93de74b4d33bb4d6c32c047ac995dd57eb92648d))
- no-extra-boolean-cast ([8a98530](https://github.com/buzinas/tslint-eslint-rules/commit/8a985309a3c2c645fdd143ae893b026710fa8c01))
#### Changes
- README rules documentation replaced for a table ([1c86880](https://github.com/buzinas/tslint-eslint-rules/commit/1c868803f270ec664a1199dc6df2844bae097ea8))
- Added markdown files for each of the existing rules ([9617910](https://github.com/buzinas/tslint-eslint-rules/commit/961791020bb7947c1c4e942b5f7875165a693b2a))
## [v1.5.0] - 2016/09/05 15:10 +00:00
#### Rules Added
- object-curly-spacing ([28c5727](https://github.com/buzinas/tslint-eslint-rules/commit/28c57275aeb62d83e5df7d6f75dfd9c52b05d2bc))
#### Changes
- Updated Contribution section in README to mention new gulp options
## [v1.4.0] - 2016/09/05 13:47 +00:00
#### Fixes
- block-spacing ([3ad19dd](https://github.com/buzinas/tslint-eslint-rules/commit/3ad19dd4f6aab0cf744880998db3066f2ad99a11))
- brace-style ([874440f](https://github.com/buzinas/tslint-eslint-rules/commit/874440f99f2a37a3acf42939bdcd0212ec0dd148))
- handle-callback-err ([c6b2b40](https://github.com/buzinas/tslint-eslint-rules/commit/c6b2b4088023381895f94abf53037c89c75bdace))
- no-inner-declarations ([debb0f7](https://github.com/buzinas/tslint-eslint-rules/commit/debb0f7d3fb4939242f5f0207d9ab31a30c6087a))
- valid-js-doc ([951a64c](https://github.com/buzinas/tslint-eslint-rules/commit/951a64cbb0c11070ab0fa26c2672cc0bed08e0e3))
## [v1.3.0] - 2016/04/28 22:05 +00:00
#### Rules Added
- handle-callback-err ([8f6f4c3](https://github.com/buzinas/tslint-eslint-rules/commit/8f6f4c3bf147647ed66de5bf5baf37e96e7886f7))
- brace-style ([34b97dc](https://github.com/buzinas/tslint-eslint-rules/commit/34b97dc92f6fa9ff0d5115b8493322e0c90811ab))
- block-spacing ([d0de347](https://github.com/buzinas/tslint-eslint-rules/commit/d0de34796ac0953113f52eee32c74101efb2fb12))
#### Fixes
- no-inner-declarations ([49f410c](https://github.com/buzinas/tslint-eslint-rules/commit/49f410caefe92a34c81aba425712758a4ac723af))
## [v1.2.0] - 2016/04/04 17:28 +00:00
#### Rules Added
- array-bracket-spacing ([2ed91e2](https://github.com/buzinas/tslint-eslint-rules/commit/2ed91e2d6c3691ada63ae855bdfb73d4315174de))
#### Changes
- Updated README to fit current ESLint rules ([aa5c342](https://github.com/buzinas/tslint-eslint-rules/commit/aa5c342))
#### Fixes
- no-unexpected-multiline issue ([bdca78a](https://github.com/buzinas/tslint-eslint-rules/commit/bdca78ae91cca963e9b93c3bdcb18e661378f55a))
- no-constant-condition issue ([4904bec](https://github.com/buzinas/tslint-eslint-rules/commit/4904bec6846d96275901d2570a314f4441f937fe))
## [v1.1.1] - 2016/03/21 18:29 +00:00
#### Added
- index.js ([cd376d0](https://github.com/buzinas/tslint-eslint-rules/commit/cd376d0877aaec62acc7a4dd4d17e66d0807c3a4))
## [v1.1.0] - 2016/03/18 17:05 +00:00
#### Changes
- Updated npm dependencies
#### Fixes
- no-ex-assign: updated failure string and added test for false positive ([9da7ba8](https://github.com/buzinas/tslint-eslint-rules/commit/9da7ba8a45d172c5f5c04733da210a2b0a59d272))
## [v1.0.0] - 2015/12/14 17:14 +00:00
### First stable version
- Improved documentation
- Updated dependencies
## [v0.3.0] - 2015/11/19 14:47 +00:00
#### Rules Added
- valid-jsdoc ([3deb2a3](https://github.com/buzinas/tslint-eslint-rules/commit/3deb2a35789142ca58741c134b158d7ff66b4a20))
## [v0.2.7] - 2015/11/17 14:00 +00:00
#### Rules Added
- no-irregular-whitespace ([15056f0](https://github.com/buzinas/tslint-eslint-rules/commit/15056f0722bee86c4fad44156622af4473261c47))
## [v0.2.6] - 2015/11/17 12:07 +00:00
#### Rules Added
- no-regex-spaces ([c92f89e](https://github.com/buzinas/tslint-eslint-rules/commit/c92f89e31a10eb97660fd2310ec6718fcab3b3b4))
- no-empty-character ([1eb3425](https://github.com/buzinas/tslint-eslint-rules/commit/1eb34253bc16ceb05c061fa5de0dd5d2d8f9054b))
- no-control-regex ([17c66cf](https://github.com/buzinas/tslint-eslint-rules/commit/17c66cf8bf0590d1a138326ef54c0c10a8cbd71d))
## [v0.2.5] - 2015/11/17 11:11 +00:00
#### Rules Added
- no-inner-declarations ([97a0e63](https://github.com/buzinas/tslint-eslint-rules/commit/97a0e637e919d741df56f9872057b9d902f4d4f2))
## [v0.2.4] - 2015/11/17 01:01 +00:00
#### Rules Added
- no-invalid-regexp ([7c2f010](https://github.com/buzinas/tslint-eslint-rules/commit/7c2f0104696f85b03ead14f771406c4845cec819))
#### Changes
- Improved README with commit conventions ([63b0536](https://github.com/buzinas/tslint-eslint-rules/commit/63b053653c2234b531ee233185fdb07d3bd04545))
## [v0.2.3] - 2015/11/14 15:02 +00:00
#### Rules Added
- no-constant-condition ([d5b7f38](https://github.com/buzinas/tslint-eslint-rules/commit/d5b7f38a82abb86bd7503b20dc47b06b07c59211))
- no-duplicate-case ([ac1bb70](https://github.com/buzinas/tslint-eslint-rules/commit/ac1bb700f4f04639cdef40996b2c0c6d42231a23))
- no-sparse-arrays ([55f8481](https://github.com/buzinas/tslint-eslint-rules/commit/55f84818d7c2d031699fbd1f98ee97e33a755cb7))
- no-extra-semi ([4b886d3](https://github.com/buzinas/tslint-eslint-rules/commit/4b886d340890f5aaf035cee18b8993de67a234ee))
- no-extra-boolean-cast ([a5882da](https://github.com/buzinas/tslint-eslint-rules/commit/a5882daf7221aa7c0b6032ed67830f2762704c86))
- no-ex-assign ([9292423](https://github.com/buzinas/tslint-eslint-rules/commit/9292423a033abb75ddcd5ade48f5026861273e05))
- no-unexpected-multiline ([2ad0d8b](https://github.com/buzinas/tslint-eslint-rules/commit/2ad0d8b0c464d23ed4d2a0735368341df0def496))
- valid-typeof ([c2f242e](https://github.com/buzinas/tslint-eslint-rules/commit/c2f242ead01b7467a239398964d7f7543f395200))
- use-isnan ([b07e3d7](https://github.com/buzinas/tslint-eslint-rules/commit/b07e3d757b6c15058e5110a39229fd617440064d))
#### Enhancements
- Added tslint as a dependency ([0fb030a](https://github.com/buzinas/tslint-eslint-rules/commit/0fb030a98fc47af7cb51843336c5c27e9c661ec5))
- Added Travis CI integration ([2a4f9a2](https://github.com/buzinas/tslint-eslint-rules/commit/2a4f9a2c8c1cc024be51775d9be20444f947edb5))
- Added and made lots of improvements in README.md
[Unreleased]: https://github.com/buzinas/tslint-eslint-rules/compare/v5.4.0...HEAD
[v5.4.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v5.3.1...v5.4.0
[v5.3.1]: https://github.com/buzinas/tslint-eslint-rules/compare/v5.2.0...v5.3.1
[v5.2.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v5.1.0...v5.2.0
[v5.1.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v5.0.0...v5.1.0
[v5.0.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v4.1.1...v5.0.0
[v4.1.1]: https://github.com/buzinas/tslint-eslint-rules/compare/v4.1.0...v4.1.1
[v4.1.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v4.0.0...v4.1.0
[v4.0.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.5.1...v4.0.0
[v3.5.1]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.5.0...v3.5.1
[v3.5.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.4.0...v3.5.0
[v3.4.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.3.0...v3.4.0
[v3.3.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.2.3...v3.3.0
[v3.2.3]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.2.2...v3.2.3
[v3.2.2]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.2.0...v3.2.2
[v3.2.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.1.0...v3.2.0
[v3.1.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v3.0.0...v3.1.0
[v3.0.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v2.2.1...v3.0.0
[v2.2.1]: https://github.com/buzinas/tslint-eslint-rules/compare/v2.2.0...v2.2.1
[v2.2.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v2.1.0...v2.2.0
[v2.1.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v2.0.0...v2.1.0
[v2.0.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.6.1...v2.0.0
[v1.6.1]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.6.0...v1.6.1
[v1.6.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.5.0...v1.6.0
[v1.5.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.4.0...v1.5.0
[v1.4.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.3.0...v1.4.0
[v1.3.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.2.0...v1.3.0
[v1.2.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.1.1...v1.2.0
[v1.1.1]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.1.0...v1.1.1
[v1.1.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v1.0.0...v1.1.0
[v1.0.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v0.3.0...v1.0.0
[v0.3.0]: https://github.com/buzinas/tslint-eslint-rules/compare/v0.2.7...v0.3.0
[v0.2.7]: https://github.com/buzinas/tslint-eslint-rules/compare/v0.2.6...v0.2.7
[v0.2.6]: https://github.com/buzinas/tslint-eslint-rules/compare/v0.2.5...v0.2.6
[v0.2.5]: https://github.com/buzinas/tslint-eslint-rules/compare/v0.2.4...v0.2.5
[v0.2.4]: https://github.com/buzinas/tslint-eslint-rules/compare/v0.2.3...v0.2.4
[v0.2.3]: https://github.com/buzinas/tslint-eslint-rules/compare/2601ba448c8e8d639539dc461d8b2dc43bb908fa...v0.2.3

22
node_modules/tslint-eslint-rules/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
Copyright (c) 2015 Vitor Buzinaro, Victor Schiavi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

345
node_modules/tslint-eslint-rules/README.md generated vendored Normal file
View File

@@ -0,0 +1,345 @@
[![Build Status](https://travis-ci.org/buzinas/tslint-eslint-rules.svg)](https://travis-ci.org/buzinas/tslint-eslint-rules)
[![Downloads per Month](https://img.shields.io/npm/dm/tslint-eslint-rules.svg)](https://www.npmjs.com/package/tslint-eslint-rules)
[![NPM Version](https://img.shields.io/npm/v/tslint-eslint-rules.svg)](https://www.npmjs.com/package/tslint-eslint-rules)
[![ZenHub](https://img.shields.io/badge/supercharged%20by-ZenHub.io-3F4D9C.svg)](https://zenhub.io/)
[![Shields.io](https://img.shields.io/badge/badges%20by-shields.io-ff69b4.svg)](https://shields.io/)
[![License](https://img.shields.io/npm/l/tslint-eslint-rules.svg)](LICENSE)
# ESLint rules for TSLint
## Improve your TSLint with the missing ESLint Rules
You want to code in TypeScript but miss all the rules available in ESLint?
Now you can combine both worlds by using this TSLint plugin!
## Usage
### Install from NPM to your Dev Dependencies
```console
npm install --save-dev tslint-eslint-rules
```
### Or install from Yarn to your Dev Dependencies
```console
yarn add tslint-eslint-rules --dev
```
### Configure TSLint to use `tslint-eslint-rules`:
In your `tslint.json` file, extend this package, e.g:
```json
{
"extends": [
"tslint-eslint-rules"
],
"rules": {
"no-constant-condition": true
}
}
```
You can also extend other tslint config packages to combine this plugin with other community custom rules.
### Configure your rules
In your `tslint.json` file, insert the rules as described below.
## Rules (copied from the [ESLint website](http://eslint.org/docs/rules/))
The following tables shows all the existing ESLint rules and the similar rules available in TSLint.
Please refer to the following icons as they provide the status of the rule.
| Icon | Description |
| :--- | :-- |
| :no_entry_sign: | The rule is not applicable to Typescript. |
| :ballot_box_with_check: | The rule is provided natively by [TSLint](http://palantir.github.io/tslint/rules/). |
| :white_check_mark: | The rule is available via tslint-eslint-rules. |
| :x: | The rule is currently unavailable. |
<!-- WARNING!
Do **not** edit this table directly. It is automatically generated.
-->
<!-- Start:AutoTable:: Modify `src/readme/rules.ts` and run `gulp readme` to update block -->
### Possible Errors
The following rules point out areas where you might have made mistakes.
| :grey_question: | ESLint | TSLint | Description |
| :--- | :---: | :---: | :--- |
|:ballot_box_with_check:|[comma-dangle](http://eslint.org/docs/rules/comma-dangle)|[trailing-comma](http://palantir.github.io/tslint/rules/trailing-comma)|disallow or enforce trailing commas (recommended)|
|:ballot_box_with_check:|[no-cond-assign](http://eslint.org/docs/rules/no-cond-assign)|[no-conditional-assignment](http://palantir.github.io/tslint/rules/no-conditional-assignment)|disallow assignment in conditional expressions (recommended)|
|:ballot_box_with_check:|[no-console](http:/eslint.org/docs/rules/no-console)|[no-console](http://palantir.github.io/tslint/rules/no-console)|disallow use of `console` in the node environment (recommended)|
|:white_check_mark:|[no-constant-condition](http://eslint.org/docs/rules/no-constant-condition)|[no-constant-condition](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noConstantConditionRule.md)|disallow use of constant expressions in conditions (recommended)|
|:white_check_mark:|[no-control-regex](http://eslint.org/docs/rules/no-control-regex)|[no-control-regex](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noControlRegexRule.md)|disallow control characters in regular expressions (recommended)|
|:ballot_box_with_check:|[no-debugger](http://eslint.org/docs/rules/no-debugger)|[no-debugger](http://palantir.github.io/tslint/rules/no-debugger)|disallow use of `debugger` (recommended)|
|:no_entry_sign:|[no-dupe-args](http://eslint.org/docs/rules/no-dupe-args)|Not applicable|disallow duplicate arguments in functions (recommended)|
|:no_entry_sign:|[no-dupe-keys](http://eslint.org/docs/rules/no-dupe-keys)|Not applicable|disallow duplicate keys when creating object literals (recommended)|
|:white_check_mark:|[no-duplicate-case](http://eslint.org/docs/rules/no-duplicate-case)|[no-duplicate-case](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noDuplicateCaseRule.md)|disallow a duplicate case label. (recommended)|
|:ballot_box_with_check:|[no-empty](http://eslint.org/docs/rules/no-empty)|[no-empty](http://palantir.github.io/tslint/rules/no-empty)|disallow empty statements (recommended)|
|:white_check_mark:|[no-empty-character-class](http://eslint.org/docs/rules/no-empty-character-class)|[no-empty-character-class](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noEmptyCharacterClassRule.md)|disallow the use of empty character classes in regular expressions (recommended)|
|:white_check_mark:|[no-ex-assign](http://eslint.org/docs/rules/no-ex-assign)|[no-ex-assign](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noExAssignRule.md)|disallow assigning to the exception in a `catch` block (recommended)|
|:white_check_mark:|[no-extra-boolean-cast](http://eslint.org/docs/rules/no-extra-boolean-cast)|[no-extra-boolean-cast](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noExtraBooleanCastRule.md)|disallow double-negation boolean casts in a boolean context (recommended)|
|:x:|[no-extra-parens](http://eslint.org/docs/rules/no-extra-parens)|no-extra-parens|disallow unnecessary parentheses|
|:white_check_mark:|[no-extra-semi](http://eslint.org/docs/rules/no-extra-semi)|[no-extra-semi](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noExtraSemiRule.md)|disallow unnecessary semicolons (recommended)|
|:no_entry_sign:|[no-func-assign](http://eslint.org/docs/rules/no-func-assign)|Not applicable|disallow overwriting functions written as function declarations (recommended)|
|:white_check_mark:|[no-inner-declarations](http://eslint.org/docs/rules/no-inner-declarations)|[no-inner-declarations](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noInnerDeclarationsRule.md)|disallow function or variable declarations in nested blocks (recommended)|
|:white_check_mark:|[no-invalid-regexp](http://eslint.org/docs/rules/no-invalid-regexp)|[no-invalid-regexp](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noInvalidRegexpRule.md)|disallow invalid regular expression strings in the `RegExp` constructor (recommended)|
|:white_check_mark:|[no-irregular-whitespace](http://eslint.org/docs/rules/no-irregular-whitespace)|[ter-no-irregular-whitespace](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terNoIrregularWhitespaceRule.md)|disallow irregular whitespace (recommended)|
|:no_entry_sign:|[no-negated-in-lhs](http://eslint.org/docs/rules/no-negated-in-lhs)|Not applicable|disallow negation of the left operand of an `in` expression (recommended)|
|:no_entry_sign:|[no-obj-calls](http://eslint.org/docs/rules/no-obj-calls)|Not applicable|disallow the use of object properties of the global object (`Math` and `JSON`) as functions (recommended)|
|:white_check_mark:|[no-regex-spaces](http://eslint.org/docs/rules/no-regex-spaces)|[no-regex-spaces](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noRegexSpacesRule.md)|disallow multiple spaces in a regular expression literal (recommended)|
|:white_check_mark:|[no-sparse-arrays](http://eslint.org/docs/rules/no-sparse-arrays)|[ter-no-sparse-arrays](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terNoSparseArraysRule.md)|disallow sparse arrays (recommended)|
|:white_check_mark:|[no-unexpected-multiline](http://eslint.org/docs/rules/no-unexpected-multiline)|[no-unexpected-multiline](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noUnexpectedMultilineRule.md)|Avoid code that looks like two expressions but is actually one|
|:no_entry_sign:|[no-unreachable](http://eslint.org/docs/rules/no-unreachable)|Not applicable|disallow unreachable statements after a return, throw, continue, or break statement (recommended)|
|:ballot_box_with_check:|[no-unsafe-finally](http://eslint.org/docs/rules/no-unsafe-finally)|[no-unsafe-finally](https://palantir.github.io/tslint/rules/no-unsafe-finally)|disallow control flow statements in finally blocks (recommended)|
|:ballot_box_with_check:|[use-isnan](http://eslint.org/docs/rules/use-isnan)|[use-isnan](https://palantir.github.io/tslint/rules/use-isnan)|disallow comparisons with the value `NaN` (recommended)|
|:white_check_mark:|[valid-jsdoc](http://eslint.org/docs/rules/valid-jsdoc)|[valid-jsdoc](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/validJsdocRule.md)|enforce valid JSDoc comments|
|:white_check_mark:|[valid-typeof](http://eslint.org/docs/rules/valid-typeof)|[valid-typeof](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/validTypeofRule.md)|Ensure that the results of typeof are compared against a valid string (recommended)|
### Best Practices
These are rules designed to prevent you from making mistakes. They either
prescribe a better way of doing something or help you avoid footguns.
| :grey_question: | ESLint | TSLint | Description |
| :--- | :---: | :---: | :--- |
|:x:|[accessor-pairs](http://eslint.org/docs/rules/accessor-pairs)|accessor-pairs|Enforces getter/setter pairs in objects|
|:x:|[array-callback-return](http://eslint.org/docs/rules/array-callback-return)|array-callback-return|Enforce return statements in callbacks of arrays methods|
|:x:|[block-scoped-var](http://eslint.org/docs/rules/block-scoped-var)|accessor-pairs|treat `var` statements as if they were block scoped|
|:ballot_box_with_check:|[complexity](http://eslint.org/docs/rules/complexity)|[cyclomatic-complexity](https://palantir.github.io/tslint/rules/cyclomatic-complexity)|specify the maximum cyclomatic complexity allowed in a program|
|:x:|[consistent-return](http://eslint.org/docs/rules/consistent-return)|consistent-return|require `return` statements to either always or never specify values|
|:ballot_box_with_check:|[curly](http://eslint.org/docs/rules/curly)|[curly](http://palantir.github.io/tslint/rules/curly)|specify curly brace conventions for all control statements|
|:ballot_box_with_check:|[default-case](http://eslint.org/docs/rules/default-case)|[switch-default](http://palantir.github.io/tslint/rules/switch-default)|require `default` case in `switch` statements|
|:x:|[dot-location](http://eslint.org/docs/rules/dot-location)|dot-location|enforces consistent newlines before or after dots|
|:x:|[dot-notation](http://eslint.org/docs/rules/dot-notation)|dot-notation|encourages use of dot notation whenever possible|
|:ballot_box_with_check:|[eqeqeq](http://eslint.org/docs/rules/eqeqeq)|[triple-equals](http://palantir.github.io/tslint/rules/triple-equals)|require the use of `===` and `!==`|
|:ballot_box_with_check:|[guard-for-in](http://eslint.org/docs/rules/guard-for-in)|[forin](http://palantir.github.io/tslint/rules/forin)|make sure `for-in` loops have an `if` statement|
|:ballot_box_with_check:|[no-alert](http://eslint.org/docs/rules/no-alert)|[ban](https://palantir.github.io/tslint/rules/ban)|disallow the use of `alert`, `confirm`, and `prompt`<br>can be achieved using the `"ban": [true, ["alert"]]` tslint rule|
|:ballot_box_with_check:|[no-caller](http://eslint.org/docs/rules/no-caller)|[no-arg](http://palantir.github.io/tslint/rules/no-arg)|disallow use of `arguments.caller` or `arguments.callee`|
|:x:|[no-case-declarations](http://eslint.org/docs/rules/no-case-declarations)|no-case-declarations|disallow lexical declarations in case clauses|
|:x:|[no-div-regex](http://eslint.org/docs/rules/no-div-regex)|no-div-regex|disallow division operators explicitly at beginning of regular expression|
|:x:|[no-else-return](http://eslint.org/docs/rules/no-else-return)|no-else-return|disallow `else` after a `return` in an `if`|
|:ballot_box_with_check:|[no-empty-function](http://eslint.org/docs/rules/no-empty-function)|[no-empty](http://palantir.github.io/tslint/rules/no-empty)|disallow use of empty functions|
|:x:|[no-empty-pattern](http://eslint.org/docs/rules/no-empty-pattern)|no-empty-pattern|disallow use of empty destructuring patterns|
|:x:|[no-eq-null](http://eslint.org/docs/rules/no-eq-null)|no-eq-null|disallow comparisons to null without a type-checking operator|
|:ballot_box_with_check:|[no-eval](http://eslint.org/docs/rules/no-eval)|[no-eval](http://palantir.github.io/tslint/rules/no-eval)|disallow use of `eval()`|
|:x:|[no-extend-native](http://eslint.org/docs/rules/no-extend-native)|no-extend-native|disallow adding to native types|
|:x:|[no-extra-bind](http://eslint.org/docs/rules/no-extra-bind)|no-extra-bind|disallow unnecessary function binding|
|:x:|[no-extra-label](http://eslint.org/docs/rules/no-extra-label)|no-extra-label|disallow unnecessary labels|
|:ballot_box_with_check:|[no-fallthrough](http://eslint.org/docs/rules/no-fallthrough)|[no-switch-case-fall-through](http://palantir.github.io/tslint/rules/no-switch-case-fall-through)|disallow fallthrough of `case` statements (recommended)|
|:x:|[no-floating-decimal](http://eslint.org/docs/rules/no-floating-decimal)|no-floating-decimal|disallow the use of leading or trailing decimal points in numeric literals|
|:x:|[no-implicit-coercion](http://eslint.org/docs/rules/no-implicit-coercion)|no-implicit-coercion|disallow the type conversions with shorter notations|
|:x:|[no-implicit-globals](http://eslint.org/docs/rules/no-implicit-globals)|no-implicit-globals|disallow var and named functions in global scope|
|:x:|[no-implied-eval](http://eslint.org/docs/rules/no-implied-eval)|no-implied-eval|disallow use of `eval()`-like methods|
|:ballot_box_with_check:|[no-invalid-this](http://eslint.org/docs/rules/no-invalid-this)|[no-invalid-this](https://palantir.github.io/tslint/rules/no-invalid-this)|disallow `this` keywords outside of classes or class-like objects|
|:x:|[no-iterator](http://eslint.org/docs/rules/no-iterator)|no-iterator|disallow Usage of `__iterator__` property|
|:ballot_box_with_check:|[no-labels](http://eslint.org/docs/rules/no-labels)|[label-position](https://palantir.github.io/tslint/rules/label-position)|disallow use of labeled statements|
|:x:|[no-lone-blocks](http://eslint.org/docs/rules/no-lone-blocks)|no-lone-blocks|disallow unnecessary nested blocks|
|:x:|[no-loop-func](http://eslint.org/docs/rules/no-loop-func)|no-loop-func|disallow creation of functions within loops|
|:ballot_box_with_check:|[no-magic-numbers](http://eslint.org/docs/rules/no-magic-numbers)|[no-magic-numbers](https://palantir.github.io/tslint/rules/no-magic-numbers)|disallow the use of magic numbers|
|:white_check_mark:|[no-multi-spaces](http://eslint.org/docs/rules/no-multi-spaces)|[no-multi-spaces](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/noMultiSpacesRule.md)|disallow use of multiple spaces|
|:x:|[no-multi-str](http://eslint.org/docs/rules/no-multi-str)|no-multi-str|disallow use of multiline strings|
|:no_entry_sign:|[no-native-reassign](http://eslint.org/docs/rules/no-native-reassign)|Not applicable|disallow reassignments of native objects|
|:ballot_box_with_check:|[no-new](http://eslint.org/docs/rules/no-new)|[no-unused-expression](https://palantir.github.io/tslint/rules/no-unused-expression)|disallow use of the `new` operator when not part of an assignment or comparison|
|:x:|[no-new-func](http://eslint.org/docs/rules/no-new-func)|no-new-func|disallow use of new operator for `Function` object|
|:ballot_box_with_check:|[no-new-wrappers](http://eslint.org/docs/rules/no-new-wrappers)|[no-construct](https://palantir.github.io/tslint/rules/no-construct)|disallows creating new instances of `String`,`Number`, and `Boolean`|
|:no_entry_sign:|[no-octal](http://eslint.org/docs/rules/no-octal)|Not applicable|disallow use of octal literals (recommended)|
|:x:|[no-octal-escape](http://eslint.org/docs/rules/no-octal-escape)|no-octal-escape|disallow use of octal escape sequences in string literals, such as `var foo = "Copyright \251";`|
|:x:|[no-param-reassign](http://eslint.org/docs/rules/no-param-reassign)|no-param-reassign|disallow reassignment of function parameters|
|:white_check_mark:|[no-proto](http://eslint.org/docs/rules/no-proto)|[ter-no-proto](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terNoProtoRule.md)|disallow the use of `__proto__` property|
|:ballot_box_with_check:|[no-redeclare](http://eslint.org/docs/rules/no-redeclare)|[no-duplicate-variable](http://palantir.github.io/tslint/rules/no-duplicate-variable)|disallow declaring the same variable more than once (http://eslint.org/docs/rules/recommended)|
|:x:|[no-return-assign](http://eslint.org/docs/rules/no-return-assign)|no-return-assign|disallow use of assignment in `return` statement|
|:white_check_mark:|[no-script-url](http://eslint.org/docs/rules/no-script-url)|[ter-no-script-url](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terNoScriptUrlRule.md)|disallow use of `javascript:` urls.|
|:x:|[no-self-assign](http://eslint.org/docs/rules/no-self-assign)|no-self-assign|disallow assignments where both sides are exactly the same|
|:white_check_mark:|[no-self-compare](http://eslint.org/docs/rules/no-self-compare)|[ter-no-self-compare](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terNoSelfCompareRule.md)|disallow comparisons where both sides are exactly the same|
|:x:|[no-sequences](http://eslint.org/docs/rules/no-sequences)|no-sequences|disallow use of the comma operator|
|:ballot_box_with_check:|[no-throw-literal](http://eslint.org/docs/rules/no-throw-literal)|[no-string-throw](https://palantir.github.io/tslint/rules/no-string-throw)|restrict what can be thrown as an exception|
|:x:|[no-unmodified-loop-condition](http://eslint.org/docs/rules/no-unmodified-loop-condition)|no-unmodified-loop-condition|disallow unmodified conditions of loops|
|:ballot_box_with_check:|[no-unused-expressions](http://eslint.org/docs/rules/no-unused-expressions)|[no-unused-expression](http://palantir.github.io/tslint/rules/no-unused-expression)|disallow Usage of expressions in statement position|
|:x:|[no-unused-labels](http://eslint.org/docs/rules/no-unused-labels)|no-unused-labels|disallow unused labels|
|:x:|[no-useless-call](http://eslint.org/docs/rules/no-useless-call)|no-useless-call|disallow unnecessary `.call()` and `.apply()`|
|:x:|[no-useless-concat](http://eslint.org/docs/rules/no-useless-concat)|no-useless-concat|disallow unnecessary concatenation of literals or template literals|
|:x:|[no-useless-escape](http://eslint.org/docs/rules/no-useless-escape)|no-useless-escape|disallow unnecessary usage of escape character|
|:x:|[no-void](http://eslint.org/docs/rules/no-void)|no-void|disallow use of the `void` operator|
|:x:|[no-warning-comments](http://eslint.org/docs/rules/no-warning-comments)|no-warning-comments|disallow Usage of configurable warning terms in comments e.g. `TODO` or `FIXME`|
|:x:|[no-with](http://eslint.org/docs/rules/no-with)|no-with|disallow use of the `with` statement|
|:ballot_box_with_check:|[radix](http://eslint.org/docs/rules/radix)|[radix](http://palantir.github.io/tslint/rules/radix)|require use of the second argument for `parseInt()`|
|:x:|[vars-on-top](http://eslint.org/docs/rules/vars-on-top)|vars-on-top|require declaration of all vars at the top of their containing scope|
|:x:|[wrap-iife](http://eslint.org/docs/rules/wrap-iife)|wrap-iife|require immediate function invocation to be wrapped in parentheses|
|:x:|[yoda](http://eslint.org/docs/rules/yoda)|yoda|require or disallow Yoda conditions|
### Strict Mode
These rules relate to using strict mode.
| :grey_question: | ESLint | TSLint | Description |
| :--- | :---: | :---: | :--- |
|:no_entry_sign:|[strict](http://eslint.org/docs/rules/strict)|Not applicable|require effective use of strict mode directives|
### Variables
These rules have to do with variable declarations.
| :grey_question: | ESLint | TSLint | Description |
| :--- | :---: | :---: | :--- |
|:x:|[init-declarations](http://eslint.org/docs/rules/init-declarations)|init-declarations|enforce or disallow variable initializations at definition|
|:x:|[no-catch-shadow](http://eslint.org/docs/rules/no-catch-shadow)|no-catch-shadow|disallow the catch clause parameter name being the same as a variable in the outer scope|
|:no_entry_sign:|[no-delete-var](http://eslint.org/docs/rules/no-delete-var)|Not applicable|disallow deletion of variables (recommended)|
|:x:|[no-label-var](http://eslint.org/docs/rules/no-label-var)|no-label-var|disallow labels that share a name with a variable|
|:ballot_box_with_check:|[no-shadow](http://eslint.org/docs/rules/no-shadow)|[no-shadowed-variable](http://palantir.github.io/tslint/rules/no-shadowed-variable)|disallow declaration of variables already declared in the outer scope|
|:x:|[no-shadow-restricted-names](http://eslint.org/docs/rules/no-shadow-restricted-names)|no-shadow-restricted-names|disallow shadowing of names such as `arguments`|
|:no_entry_sign:|[no-undef](http://eslint.org/docs/rules/no-undef)|Not applicable|disallow use of undeclared variables unless mentioned in a `/*global */` block (recommended)|
|:x:|[no-undef-init](http://eslint.org/docs/rules/no-undef-init)|no-undef-init|disallow use of undefined when initializing variables|
|:x:|[no-undefined](http://eslint.org/docs/rules/no-undefined)|no-undefined|disallow use of `undefined` variable|
|:ballot_box_with_check:|[no-unused-vars](http://eslint.org/docs/rules/no-unused-vars)|[no-unused-variable](https://palantir.github.io/tslint/rules/no-unused-variable/)|disallow unused variables (recommended).|
|:ballot_box_with_check:|[no-use-before-define](http://eslint.org/docs/rules/no-use-before-define)|[no-use-before-declare](http://palantir.github.io/tslint/rules/no-use-before-declare)|disallow use of variables before they are defined|
### Node.js and CommonJS
These rules are specific to JavaScript running on Node.js or using CommonJS in the browser.
| :grey_question: | ESLint | TSLint | Description |
| :--- | :---: | :---: | :--- |
|:x:|[callback-return](http://eslint.org/docs/rules/callback-return)|callback-return|enforce `return` after a callback|
|:x:|[global-require](http://eslint.org/docs/rules/global-require)|global-require|enforce `require()` on top-level module scope|
|:white_check_mark:|[handle-callback-err](http://eslint.org/docs/rules/handle-callback-err)|[handle-callback-err](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/handleCallbackErrRule.md)|enforce error handling in callbacks|
|:x:|[no-mixed-requires](http://eslint.org/docs/rules/no-mixed-requires)|no-mixed-requires|disallow mixing regular variable and require declarations|
|:x:|[no-new-require](http://eslint.org/docs/rules/no-new-require)|no-new-require|disallow use of `new` operator with the `require` function|
|:x:|[no-path-concat](http://eslint.org/docs/rules/no-path-concat)|no-path-concat|disallow string concatenation with `__dirname` and `__filename`|
|:x:|[no-process-env](http://eslint.org/docs/rules/no-process-env)|no-process-env|disallow use of `process.env`|
|:x:|[no-process-exit](http://eslint.org/docs/rules/no-process-exit)|no-process-exit|disallow `process.exit()`|
|:x:|[no-restricted-modules](http://eslint.org/docs/rules/no-restricted-modules)|no-restricted-modules|restrict Usage of specified node modules|
|:x:|[no-sync](http://eslint.org/docs/rules/no-sync)|no-sync|disallow use of synchronous methods|
### Stylistic Issues
These rules are purely matters of style and are quite subjective.
| :grey_question: | ESLint | TSLint | Description |
| :--- | :---: | :---: | :--- |
|:white_check_mark:|[array-bracket-spacing](http://eslint.org/docs/rules/array-bracket-spacing)|[array-bracket-spacing](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/arrayBracketSpacingRule.md)|enforce consistent spacing inside array brackets|
|:white_check_mark:|[block-spacing](http://eslint.org/docs/rules/block-spacing)|[block-spacing](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/blockSpacingRule.md)|disallow or enforce spaces inside of single line blocks|
|:white_check_mark:|[brace-style](http://eslint.org/docs/rules/brace-style)|[brace-style](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/braceStyleRule.md)|enforce one true brace style|
|:ballot_box_with_check:|[camelcase](http://eslint.org/docs/rules/camelcase)|[variable-name](http://palantir.github.io/tslint/rules/variable-name)|require camel case names|
|:x:|[comma-spacing](http://eslint.org/docs/rules/comma-spacing)|comma-spacing|enforce spacing before and after comma|
|:x:|[comma-style](http://eslint.org/docs/rules/comma-style)|comma-style|enforce one true comma style|
|:white_check_mark:|[computed-property-spacing](http://eslint.org/docs/rules/computed-property-spacing)|[ter-computed-property-spacing](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terComputedPropertySpacingRule.md)|require or disallow padding inside computed properties|
|:x:|[consistent-this](http://eslint.org/docs/rules/consistent-this)|consistent-this|enforce consistent naming when capturing the current execution context|
|:ballot_box_with_check:|[eol-last](http://eslint.org/docs/rules/eol-last)|[eofline](https://palantir.github.io/tslint/rules/eofline)|enforce newline at the end of file, with no multiple empty lines|
|:white_check_mark:|[func-call-spacing](http://eslint.org/docs/rules/func-call-spacing)|[ter-func-call-spacing](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terFuncCallSpacingRule.md)|require or disallow spacing between function identifiers and their invocations|
|:x:|[func-names](http://eslint.org/docs/rules/func-names)|func-names|require function expressions to have a name|
|:x:|[func-style](http://eslint.org/docs/rules/func-style)|func-style|enforce use of function declarations or expressions|
|:x:|[id-blacklist](http://eslint.org/docs/rules/id-blacklist)|id-blacklist|disallow certain identifiers to prevent them being used|
|:x:|[id-length](http://eslint.org/docs/rules/id-length)|id-length|this option enforces minimum and maximum identifier lengths (variable names, property names etc.)|
|:x:|[id-match](http://eslint.org/docs/rules/id-match)|id-match|require identifiers to match the provided regular expression|
|:white_check_mark:|[indent](http://eslint.org/docs/rules/indent)|[ter-indent](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terIndentRule.md)|enforce consistent indentation|
|:x:|[jsx-quotes](http://eslint.org/docs/rules/jsx-quotes)|jsx-quotes|specify whether double or single quotes should be used in JSX attributes|
|:x:|[key-spacing](http://eslint.org/docs/rules/key-spacing)|key-spacing|enforce spacing between keys and values in object literal properties<br>Tslint's [whitespace](https://palantir.github.io/tslint/rules/whitespace/) can partially be used|
|:x:|[keyword-spacing](http://eslint.org/docs/rules/keyword-spacing)|keyword-spacing|enforce spacing before and after keywords<br>Tslint's [whitespace](https://palantir.github.io/tslint/rules/whitespace/) can partially be used|
|:ballot_box_with_check:|[linebreak-style](http://eslint.org/docs/rules/linebreak-style)|[linebreak-style](https://palantir.github.io/tslint/rules/linebreak-style)|disallow mixed 'LF' and 'CRLF' as linebreaks|
|:x:|[lines-around-comment](http://eslint.org/docs/rules/lines-around-comment)|lines-around-comment|enforce empty lines around comments|
|:x:|[max-depth](http://eslint.org/docs/rules/max-depth)|max-depth|specify the maximum depth that blocks can be nested|
|:white_check_mark:|[max-len](http://eslint.org/docs/rules/max-len)|[ter-max-len](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terMaxLenRule.md)|enforce a maximum line length|
|:ballot_box_with_check:|[max-lines](http://eslint.org/docs/rules/max-lines)|[max-file-line-count](http://palantir.github.io/tslint/rules/max-file-line-count)|enforce a maximum number of lines per file|
|:x:|[max-nested-callbacks](http://eslint.org/docs/rules/max-nested-callbacks)|max-nested-callbacks|specify the maximum depth callbacks can be nested|
|:x:|[max-params](http://eslint.org/docs/rules/max-params)|max-params|specify the number of parameters that can be used in the function declaration|
|:x:|[max-statements](http://eslint.org/docs/rulesmax-statements)|max-statements|specify the maximum number of statement allowed in a function|
|:x:|[max-statements-per-line](http://eslint.org/docs/max-statements-per-line)|max-statements-per-line|specify the maximum number of statements allowed per line|
|:no_entry_sign:|[new-cap](http://eslint.org/docs/rules/new-cap)|Not applicable|require a capital letter for constructors|
|:ballot_box_with_check:|[new-parens](http://eslint.org/docs/rules/new-parens)|[new-parens](https://palantir.github.io/tslint/rules/new-parens)|disallow the omission of parentheses when invoking a constructor with no arguments|
|:white_check_mark:|[newline-after-var](http://eslint.org/docs/rules/newline-after-var)|[ter-newline-after-var](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terNewlineAfterVarRule.md)|require or disallow an empty newline after variable declarations|
|:x:|[newline-before-return](http://eslint.org/docs/rules/newline-before-return)|newline-before-return|require newline before return statement|
|:x:|[newline-per-chained-call](http://eslint.org/docs/rules/newline-per-chained-call)|newline-per-chained-call|enforce newline after each call when chaining the calls|
|:x:|[no-array-constructor](http://eslint.org/docs/rules/no-array-constructor)|no-array-constructor|disallow use of the `Array` constructor|
|:ballot_box_with_check:|[no-bitwise](http://eslint.org/docs/rules/no-bitwise)|[no-bitwise](https://palantir.github.io/tslint/rules/no-bitwise)|disallows bitwise operators|
|:x:|[no-continue](http://eslint.org/docs/rules/no-continue)|no-continue|disallow use of the `continue` statement|
|:x:|[no-inline-comments](http://eslint.org/docs/rules/no-inline-comments)|no-inline-comments|disallow comments inline after code|
|:x:|[no-lonely-if](http://eslint.org/docs/rules/no-lonely-if)|no-lonely-if|disallow `if` as the only statement in an `else` block|
|:white_check_mark:|[no-mixed-spaces-and-tabs](http://eslint.org/docs/rules/no-mixed-spaces-and-tabs)|[ter-no-mixed-spaces-and-tabs](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terNoMixedSpacesAndTabsRule.md)|disallow mixed spaces and tabs for indentation (recommended)|
|:ballot_box_with_check:|[no-multiple-empty-lines](http://eslint.org/docs/rules/no-multiple-empty-lines)|[no-consecutive-blank-lines](http://palantir.github.io/tslint/rules/no-consecutive-blank-lines)|disallow multiple empty lines|
|:x:|[no-negated-condition](http://eslint.org/docs/rules/no-negated-condition)|no-negated-condition|disallow negated conditions|
|:x:|[no-nested-ternary](http://eslint.org/docs/rules/no-nested-ternary)|no-nested-ternary|disallow nested ternary expressions|
|:x:|[no-new-object](http://eslint.org/docs/rules/no-new-object)|no-new-object|disallow the use of the `Object` constructor|
|:x:|[no-restricted-syntax](http://eslint.org/docs/rules/no-restricted-syntax)|no-restricted-syntax|disallow use of certain syntax in code|
|:x:|[no-spaced-func](http://eslint.org/docs/rules/no-spaced-func)|no-spaced-func|disallow space between function identifier and application|
|:x:|[no-ternary](http://eslint.org/docs/rules/no-ternary)|no-ternary|disallow the use of ternary operators|
|:ballot_box_with_check:|[no-trailing-spaces](http://eslint.org/docs/rules/no-trailing-spaces)|[no-trailing-whitespace](http://palantir.github.io/tslint/rules/no-trailing-whitespace)|disallow trailing whitespace at the end of lines|
|:x:|[no-underscore-dangle](http://eslint.org/docs/rules/no-underscore-dangle)|no-underscore-dangle|disallow dangling underscores in identifiers|
|:x:|[no-unneeded-ternary](http://eslint.org/docs/rules/no-unneeded-ternary)|no-unneeded-ternary|disallow the use of ternary operators when a simpler alternative exists|
|:x:|[no-whitespace-before-property](http://eslint.org/docs/rules/no-whitespace-before-property)|no-whitespace-before-property|disallow whitespace before properties|
|:white_check_mark:|[object-curly-spacing](http://eslint.org/docs/rules/object-curly-spacing)|[object-curly-spacing](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/objectCurlySpacingRule.md)|require or disallow padding inside curly braces|
|:ballot_box_with_check:|[one-var](http://eslint.org/docs/rules/one-var)|[one-variable-per-declaration](http://palantir.github.io/tslint/rules/one-variable-per-declaration/)|require or disallow one variable declaration per function|
|:x:|[one-var-declaration-per-line](http://eslint.org/docs/rules/one-var-declaration-per-line)|one-var-declaration-per-line|require or disallow a newline around variable declarations|
|:x:|[operator-assignment](http://eslint.org/docs/rules/operator-assignment)|operator-assignment|require assignment operator shorthand where possible or prohibit it entirely|
|:x:|[operator-linebreak](http://eslint.org/docs/rules/operator-linebreak)|operator-linebreak|enforce operators to be placed before or after line breaks|
|:white_check_mark:|[padded-blocks](http://eslint.org/docs/rules/padded-blocks)|ter-padded-blocks|enforce padding within blocks|
|:ballot_box_with_check:|[quote-props](http://eslint.org/docs/rules/quote-props)|[object-literal-key-quotes](https://palantir.github.io/tslint/rules/object-literal-key-quotes)|require quotes around object literal property names|
|:ballot_box_with_check:|[quotes](http://eslint.org/docs/rules/quotes)|[quotemark](http://palantir.github.io/tslint/rules/quotemark/)|specify whether backticks, double or single quotes should be used|
|:x:|[require-jsdoc](http://eslint.org/docs/rules/require-jsdoc)|require-jsdoc|Require JSDoc comment|
|:ballot_box_with_check:|[semi](http://eslint.org/docs/rules/semi)|[semicolon](http://palantir.github.io/tslint/rules/semicolon)|require or disallow use of semicolons instead of ASI|
|:x:|[semi-spacing](http://eslint.org/docs/rules/semi-spacing)|semi-spacing|enforce spacing before and after semicolons|
|:white_check_mark:|[sort-imports](http://eslint.org/docs/rules/sort-imports)|[sort-imports](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/sortImportsRule.md)|enforce sorting import declarations within module|
|:x:|[sort-vars](http://eslint.org/docs/rules/sort-vars)|sort-vars|sort variables within the same declaration block|
|:x:|[space-before-blocks](http://eslint.org/docs/rules/space-before-blocks)|space-before-blocks|require or disallow a space before blocks|
|:x:|[space-before-function-paren](http://eslint.org/docs/rules/space-before-function-paren)|space-before-function-paren|require or disallow a space before function opening parenthesis|
|:white_check_mark:|[space-in-parens](http://eslint.org/docs/rules/space-in-parens)|[space-in-parens](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/spaceInParensRule.md)|require or disallow spaces inside parentheses|
|:x:|[space-infix-ops](http://eslint.org/docs/rules/space-infix-ops)|space-infix-ops|require spaces around operators<br>Tslint's [whitespace](https://palantir.github.io/tslint/rules/whitespace/) can partially be used|
|:x:|[space-unary-ops](http://eslint.org/docs/rules/space-unary-ops)|space-unary-ops|require or disallow spaces before/after unary operators|
|:ballot_box_with_check:|[spaced-comment](http://eslint.org/docs/rules/spaced-comment)|[comment-format](https://palantir.github.io/tslint/rules/comment-format)|require or disallow a space immediately following the `//` or `/*` in a comment|
|:x:|[wrap-regex](http://eslint.org/docs/rules/wrap-regex)|wrap-regex|require regex literals to be wrapped in parentheses|
|:white_check_mark:|[no-tabs](https://eslint.org/docs/rules/no-tabs)|[ter-no-tabs](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terNoTabsRule.md)|disallow all tabs|
### ECMAScript 6
These rules are only relevant to ES6 environments.
| :grey_question: | ESLint | TSLint | Description |
| :--- | :---: | :---: | :--- |
|:white_check_mark:|[arrow-body-style](http://eslint.org/docs/rules/arrow-body-style)|[ter-arrow-body-style](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terArrowBodyStyleRule.md)|require braces in arrow function body|
|:white_check_mark:|[arrow-parens](http://eslint.org/docs/rules/arrow-parens)|[ter-arrow-parens](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terArrowParensRule.md)|require parens in arrow function arguments|
|:white_check_mark:|[arrow-spacing](http://eslint.org/docs/rules/arrow-spacing)|[ter-arrow-spacing](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terArrowSpacingRule.md)|require space before/after arrow function's arrow|
|:no_entry_sign:|[constructor-super](http://eslint.org/docs/rules/constructor-super)|Not applicable|verify calls of `super()` in constructors|
|:x:|[generator-star-spacing](http://eslint.org/docs/rules/generator-star-spacing)|generator-star-spacing|enforce spacing around the `*` in generator functions|
|:x:|[no-class-assign](http://eslint.org/docs/rules/no-class-assign)|no-class-assign|disallow modifying variables of class declarations|
|:x:|[no-confusing-arrow](http://eslint.org/docs/rules/no-confusing-arrow)|no-confusing-arrow|disallow arrow functions where they could be confused with comparisons|
|:no_entry_sign:|[no-const-assign](http://eslint.org/docs/rules/no-const-assign)|Not applicable|disallow modifying variables that are declared using `const`|
|:no_entry_sign:|[no-dupe-class-members](http://eslint.org/docs/rules/no-dupe-class-members)|Not applicable|disallow duplicate name in class members|
|:x:|[no-duplicate-imports](http://eslint.org/docs/rules/no-duplicate-imports)|no-duplicate-imports|disallow duplicate module imports|
|:x:|[no-new-symbol](http://eslint.org/docs/rules/no-new-symbol)|no-new-symbol|disallow use of the `new` operator with the `Symbol` object|
|:x:|[no-restricted-imports](http://eslint.org/docs/rules/no-restricted-imports)|no-restricted-imports|restrict usage of specified modules when loaded by `import` declaration|
|:no_entry_sign:|[no-this-before-super](http://eslint.org/docs/rules/no-this-before-super)|Not applicable|disallow use of `this`/`super` before calling `super()` in constructors.|
|:x:|[no-useless-constructor](http://eslint.org/docs/rules/no-useless-constructor)|no-useless-constructor|disallow unnecessary constructor|
|:ballot_box_with_check:|[no-var](http://eslint.org/docs/rules/no-var)|[no-var-keyword](http://palantir.github.io/tslint/rules/no-var-keyword)|require `let` or `const` instead of `var`|
|:ballot_box_with_check:|[object-shorthand](http://eslint.org/docs/rules/object-shorthand)|[object-literal-shorthand](https://palantir.github.io/tslint/rules/object-literal-shorthand)|require method and property shorthand syntax for object literals|
|:white_check_mark:|[prefer-arrow-callback](http://eslint.org/docs/rules/prefer-arrow-callback)|[ter-prefer-arrow-callback](https://github.com/buzinas/tslint-eslint-rules/blob/master/src/docs/rules/terPreferArrowCallbackRule.md)|require arrow functions as callbacks|
|:ballot_box_with_check:|[prefer-const](http://eslint.org/docs/rules/prefer-const)|[prefer-const](https://palantir.github.io/tslint/rules/prefer-const)|suggest using `const` declaration for variables that are never modified after declared|
|:x:|[prefer-destructuring](http://eslint.org/docs/rules/prefer-destructuring)|prefer-destructuring|require using destructuring when assigning to variables from arrays and objects|
|:x:|[prefer-reflect](http://eslint.org/docs/rules/prefer-reflect)|prefer-reflect|suggest using Reflect methods where applicable|
|:x:|[prefer-rest-params](http://eslint.org/docs/rules/prefer-rest-params)|prefer-rest-params|suggest using the rest parameters instead of `arguments`|
|:x:|[prefer-spread](http://eslint.org/docs/rules/prefer-spread)|prefer-spread|suggest using the spread operator instead of `.apply()`.|
|:x:|[prefer-template](http://eslint.org/docs/rules/prefer-template)|prefer-template|suggest using template literals instead of strings concatenation|
|:x:|[require-yield](http://eslint.org/docs/rules/require-yield)|require-yield|disallow generator functions that do not have `yield`|
|:x:|[template-curly-spacing](http://eslint.org/docs/rules/template-curly-spacing)|template-curly-spacing|enforce spacing around embedded expressions of template strings|
|:x:|[yield-star-spacing](http://eslint.org/docs/rules/yield-star-spacing)|yield-star-spacing|enforce spacing around the `*` in `yield*` expressions|
<!-- End:AutoTable -->
## Contributing
Bugs, rules requests, doubts etc., open a Github [Issue]. If you want to create one of the missing
rules or fix/improve some existing rule please check out the [contribution guide].
## LICENSE
MIT
[Issue]: https://github.com/buzinas/tslint-eslint-rules/issues/new
[contribution guide]: https://github.com/buzinas/tslint-eslint-rules/blob/master/CONTRIBUTING.md

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var OPTION_ALWAYS = 'always';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new BlockSpacingWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = {
always: 'Requires a space',
never: 'Unexpected space(s)'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var BlockSpacingWalker = (function (_super) {
tslib_1.__extends(BlockSpacingWalker, _super);
function BlockSpacingWalker(sourceFile, options) {
var _this = _super.call(this, sourceFile, options) || this;
_this.always = _this.hasOption(OPTION_ALWAYS) || (_this.getOptions() && _this.getOptions().length === 0);
return _this;
}
BlockSpacingWalker.prototype.visitNode = function (node) {
if (node.kind === ts.SyntaxKind.Block || node.kind === ts.SyntaxKind.CaseBlock) {
this.checkSpacingInsideBraces(node);
}
_super.prototype.visitNode.call(this, node);
};
BlockSpacingWalker.prototype.checkSpacingInsideBraces = function (node) {
var blockChildren = node.getChildren();
var syntaxList = blockChildren[1];
var openBraceLocation = this.getStartPosition(blockChildren[0]);
var closeBraceLocation = this.getStartPosition(blockChildren[blockChildren.length - 1]);
if (syntaxList && syntaxList.getChildCount() > 0 && openBraceLocation.line === closeBraceLocation.line) {
if (this.isSpaceBetween(blockChildren[0], blockChildren[1]) !== this.always
|| this.isSpaceBetween(blockChildren[blockChildren.length - 2], blockChildren[blockChildren.length - 1]) !== this.always) {
var failureString = this.always ? Rule.FAILURE_STRING.always : Rule.FAILURE_STRING.never;
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), failureString));
}
}
};
BlockSpacingWalker.prototype.isSpaceBetween = function (node, nextNode) {
return nextNode.getStart() - node.getEnd() > 0;
};
BlockSpacingWalker.prototype.getStartPosition = function (node) {
return node.getSourceFile().getLineAndCharacterOfPosition(node.getStart());
};
return BlockSpacingWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1b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SCxJQUFJLGFBQWEsR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsY0FBYyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxLQUFLLENBQUM7Z0JBQ3pGLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLFFBQVEsRUFBRSxFQUFFLGFBQWEsQ0FBQyxDQUFDLENBQUM7YUFDdEY7U0FDRjtJQUNILENBQUM7SUFFTywyQ0FBYyxHQUF0QixVQUF1QixJQUFhLEVBQUUsUUFBaUI7UUFDckQsT0FBTyxRQUFRLENBQUMsUUFBUSxFQUFFLEdBQUcsSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLENBQUMsQ0FBQztJQUNqRCxDQUFDO0lBRU8sNkNBQWdCLEdBQXhCLFVBQXlCLElBQWE7UUFDcEMsT0FBTyxJQUFJLENBQUMsYUFBYSxFQUFFLENBQUMsNkJBQTZCLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUM7SUFDN0UsQ0FBQztJQUNILHlCQUFDO0FBQUQsQ0F2Q0EsQUF1Q0MsQ0F2Q2dDLElBQUksQ0FBQyxVQUFVLEdBdUMvQyIsImZpbGUiOiJydWxlcy9ibG9ja1NwYWNpbmdSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,116 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var token_1 = require("../support/token");
var RULE_NAME = 'no-constant-condition';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoConstantConditionWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = 'unexpected constant condition';
Rule.metadata = {
ruleName: RULE_NAME,
description: 'disallow use of constant expressions in conditions (recommended)',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n A constant expression (for example, a literal) as a test condition might be a typo or\n development trigger for a specific behavior. For example, the following code looks as if it is\n not ready for production.\n "], ["\n A constant expression (for example, a literal) as a test condition might be a typo or\n development trigger for a specific behavior. For example, the following code looks as if it is\n not ready for production.\n "]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n - `\"checkLoops\"` Setting this option to `false` allows constant expressions in loops (default: `true`).\n "], ["\n - \\`\"checkLoops\"\\` Setting this option to \\`false\\` allows constant expressions in loops (default: \\`true\\`).\n "]))),
options: {
type: 'object',
properties: {
checkLoops: {
type: 'boolean'
}
},
additionalProperties: false
},
optionExamples: [
Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n \"", "\": true\n "], ["\n \"", "\": true\n "])), RULE_NAME),
Lint.Utils.dedent(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["\n \"", "\": [true, { \"checkLoops\": false }]\n "], ["\n \"", "\": [true, { \"checkLoops\": false }]\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'functionality'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoConstantConditionWalker = (function (_super) {
tslib_1.__extends(NoConstantConditionWalker, _super);
function NoConstantConditionWalker(sourceFile, options) {
var _this = _super.call(this, sourceFile, options) || this;
_this.checkLoops = true;
var opts = _this.getOptions();
if (opts.length && opts[0].checkLoops === false) {
_this.checkLoops = false;
}
return _this;
}
NoConstantConditionWalker.prototype.visitIfStatement = function (node) {
this.validateCondition(node.expression);
_super.prototype.visitIfStatement.call(this, node);
};
NoConstantConditionWalker.prototype.visitWhileStatement = function (node) {
if (this.checkLoops) {
this.validateCondition(node.expression);
}
_super.prototype.visitWhileStatement.call(this, node);
};
NoConstantConditionWalker.prototype.visitDoStatement = function (node) {
if (this.checkLoops) {
this.validateCondition(node.expression);
}
_super.prototype.visitDoStatement.call(this, node);
};
NoConstantConditionWalker.prototype.visitForStatement = function (node) {
if (this.checkLoops && node.condition) {
this.validateCondition(node.condition);
}
_super.prototype.visitForStatement.call(this, node);
};
NoConstantConditionWalker.prototype.visitConditionalExpression = function (node) {
this.validateCondition(node.condition);
_super.prototype.visitConditionalExpression.call(this, node);
};
NoConstantConditionWalker.prototype.validateCondition = function (expression) {
if (this.isConstant(expression)) {
this.addFailure(this.createFailure(expression.getStart(), expression.getWidth(), Rule.FAILURE_STRING));
}
this.walkChildren(expression);
};
NoConstantConditionWalker.prototype.isConstant = function (node) {
switch (node.kind) {
case ts.SyntaxKind.StringLiteral:
case ts.SyntaxKind.NumericLiteral:
case ts.SyntaxKind.TrueKeyword:
case ts.SyntaxKind.FalseKeyword:
case ts.SyntaxKind.ArrowFunction:
case ts.SyntaxKind.FunctionExpression:
case ts.SyntaxKind.ObjectLiteralExpression:
case ts.SyntaxKind.ArrayLiteralExpression:
return true;
case ts.SyntaxKind.PostfixUnaryExpression:
return this.isConstant(node.operand);
case ts.SyntaxKind.BinaryExpression:
if (token_1.isAssignmentToken(node.operatorToken)) {
return this.isConstant(node.right);
}
return this.isConstant(node.left) && this.isConstant(node.right);
case ts.SyntaxKind.ConditionalExpression:
return this.isConstant(node.condition);
case ts.SyntaxKind.PrefixUnaryExpression:
return this.isConstant(node.operand);
case ts.SyntaxKind.ParenthesizedExpression:
return this.isConstant(node.expression);
}
return false;
};
return NoConstantConditionWalker;
}(Lint.RuleWalker));
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZX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MsU0FBUyxDQUFDLENBQUM7WUFDdkUsS0FBSyxFQUFFLENBQUMsVUFBVSxDQUFDLHFCQUFxQjtnQkFDdEMsT0FBTyxJQUFJLENBQUMsVUFBVSxDQUFFLElBQWlDLENBQUMsT0FBTyxDQUFDLENBQUM7WUFDckUsS0FBSyxFQUFFLENBQUMsVUFBVSxDQUFDLHVCQUF1QjtnQkFDeEMsT0FBTyxJQUFJLENBQUMsVUFBVSxDQUFFLElBQW1DLENBQUMsVUFBVSxDQUFDLENBQUM7U0FDM0U7UUFFRCxPQUFPLEtBQUssQ0FBQztJQUNmLENBQUM7SUFDSCxnQ0FBQztBQUFELENBeEZBLEFBd0ZDLENBeEZ1QyxJQUFJLENBQUMsVUFBVSxHQXdGdEQiLCJmaWxlIjoicnVsZXMvbm9Db25zdGFudENvbmRpdGlvblJ1bGUuanMiLCJzb3VyY2VSb290IjoiL1VzZXJzL2ptbG9wZXovdHNsaW50LWVzbGludC1ydWxlcy9zcmMifQ==

View File

@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoControlRegexWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = 'unexpected control character in regular expression';
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoControlRegexWalker = (function (_super) {
tslib_1.__extends(NoControlRegexWalker, _super);
function NoControlRegexWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoControlRegexWalker.prototype.visitRegularExpressionLiteral = function (node) {
this.validateControlRegex(node);
_super.prototype.visitRegularExpressionLiteral.call(this, node);
};
NoControlRegexWalker.prototype.visitNewExpression = function (node) {
if (node.expression.getText() === 'RegExp') {
this.visitRegularExpressionFunction(node);
}
_super.prototype.visitNewExpression.call(this, node);
};
NoControlRegexWalker.prototype.visitCallExpression = function (node) {
if (node.expression.getText() === 'RegExp') {
this.visitRegularExpressionFunction(node);
}
_super.prototype.visitCallExpression.call(this, node);
};
NoControlRegexWalker.prototype.visitRegularExpressionFunction = function (node) {
if (node.arguments && node.arguments.length > 0 && node.arguments[0].kind === ts.SyntaxKind.StringLiteral) {
this.validateControlRegex(node.arguments[0]);
}
};
NoControlRegexWalker.prototype.validateControlRegex = function (node) {
if (/[\x00-\x1f]/.test(node.text)) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
};
return NoControlRegexWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vQ29udHJvbFJlZ2V4UnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwrQkFBaUM7QUFDakMsNkJBQStCO0FBRS9CO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUFPQSxDQUFDO0lBSlEsb0JBQUssR0FBWixVQUFhLFVBQXlCO1FBQ3BDLElBQU0sTUFBTSxHQUFHLElBQUksb0JBQW9CLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQyxDQUFDO1FBQ3ZFLE9BQU8sSUFBSSxDQUFDLGVBQWUsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUN0QyxDQUFDO0lBTGEsbUJBQWMsR0FBRyxvREFBb0QsQ0FBQztJQU10RixXQUFDO0NBUEQsQUFPQyxDQVB5QixJQUFJLENBQUMsS0FBSyxDQUFDLFlBQVksR0FPaEQ7QUFQWSxvQkFBSTtBQVNqQjtJQUFtQyxnREFBZTtJQUFsRDs7SUErQkEsQ0FBQztJQTlCVyw0REFBNkIsR0FBdkMsVUFBd0MsSUFBMEI7UUFDaEUsSUFBSSxDQUFDLG9CQUFvQixDQUFDLEl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DLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLFFBQVEsRUFBRSxFQUFFLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDO1NBQzVGO0lBQ0gsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0EvQkEsQUErQkMsQ0EvQmtDLElBQUksQ0FBQyxVQUFVLEdBK0JqRCIsImZpbGUiOiJydWxlcy9ub0NvbnRyb2xSZWdleFJ1bGUuanMiLCJzb3VyY2VSb290IjoiL1VzZXJzL2ptbG9wZXovdHNsaW50LWVzbGludC1ydWxlcy9zcmMifQ==

View File

@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoDuplicateCaseWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = 'duplicate case label';
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoDuplicateCaseWalker = (function (_super) {
tslib_1.__extends(NoDuplicateCaseWalker, _super);
function NoDuplicateCaseWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoDuplicateCaseWalker.prototype.visitSwitchStatement = function (node) {
this.validateNoDupeCase(node);
_super.prototype.visitSwitchStatement.call(this, node);
};
NoDuplicateCaseWalker.prototype.validateNoDupeCase = function (node) {
var _this = this;
var cases = Object.create(null);
node.caseBlock.clauses.forEach(function (clause) {
if (clause.kind === ts.SyntaxKind.CaseClause) {
var key = clause.getText();
if (cases[key]) {
_this.addFailure(_this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
else {
cases[key] = clause;
}
}
});
};
return NoDuplicateCa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LENBQUMsVUFBVSxDQUFDLFVBQVUsRUFBRTtnQkFDNUMsSUFBTSxHQUFHLEdBQUcsTUFBTSxDQUFDLE9BQU8sRUFBRSxDQUFDO2dCQUM3QixJQUFJLEtBQUssQ0FBQyxHQUFHLENBQUMsRUFBRTtvQkFDZCxLQUFJLENBQUMsVUFBVSxDQUFDLEtBQUksQ0FBQyxhQUFhLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRSxFQUFFLElBQUksQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztpQkFDNUY7cUJBQ0k7b0JBQ0gsS0FBSyxDQUFDLEdBQUcsQ0FBQyxHQUFHLE1BQXVCLENBQUM7aUJBQ3RDO2FBQ0Y7UUFDSCxDQUFDLENBQUMsQ0FBQztJQUNMLENBQUM7SUFDSCw0QkFBQztBQUFELENBckJBLEFBcUJDLENBckJtQyxJQUFJLENBQUMsVUFBVSxHQXFCbEQiLCJmaWxlIjoicnVsZXMvbm9EdXBsaWNhdGVDYXNlUnVsZS5qcyIsInNvdXJjZVJvb3QiOiIvVXNlcnMvam1sb3Blei90c2xpbnQtZXNsaW50LXJ1bGVzL3NyYyJ9

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoEmptyCharacterClassWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = "don't use empty classes in regular expressions";
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoEmptyCharacterClassWalker = (function (_super) {
tslib_1.__extends(NoEmptyCharacterClassWalker, _super);
function NoEmptyCharacterClassWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoEmptyCharacterClassWalker.prototype.visitRegularExpressionLiteral = function (node) {
this.validateEmptyCharacterClass(node);
_super.prototype.visitRegularExpressionLiteral.call(this, node);
};
NoEmptyCharacterClassWalker.prototype.validateEmptyCharacterClass = function (node) {
if (!(/^\/([^\\[]|\\.|\[([^\\\]]|\\.)+\])*\/[gim]*$/.test(node.text))) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
};
return NoEmptyCharacterClassWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vRW1wdHlDaGFyYWN0ZXJDbGFzc1J1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsNkJBQStCO0FBRS9CO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUFPQSxDQUFDO0lBSlEsb0JBQUssR0FBWixVQUFhLFVBQXlCO1FBQ3BDLElBQU0sTUFBTSxHQUFHLElBQUksMkJBQTJCLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQyxDQUFDO1FBQzlFLE9BQU8sSUFBSSxDQUFDLGVBQWUsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUN0QyxDQUFDO0lBTGEsbUJBQWMsR0FBRyxnREFBZ0QsQ0FBQztJQU1sRixXQUFDO0NBUEQsQUFPQyxDQVB5QixJQUFJLENBQUMsS0FBSyxDQUFDLFlBQVksR0FPaEQ7QUFQWSxvQkFBSTtBQVNqQjtJQUEwQyx1REFBZTtJQUF6RDs7SUFXQSxDQUFDO0lBVlcsbUVBQTZCLEdBQXZDLFVBQXdDLElBQTBCO1FBQ2hFLElBQUksQ0FBQywyQkFBMkIsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUN2QyxpQkFBTSw2QkFBNkIsWUFBQyxJQUFJLENBQUMsQ0FBQztJQUM1QyxDQUFDO0lBRU8saUVBQTJCLEdBQW5DLFVBQW9DLElBQTBCO1FBQzVELElBQUksQ0FBQyxDQUFDLDhDQUE4QyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRTtZQUNyRSxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRSxFQUFFLElBQUksQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztTQUM1RjtJQUNILENBQUM7SUFDSCxrQ0FBQztBQUFELENBWEEsQUFXQyxDQVh5QyxJQUFJLENBQUMsVUFBVSxHQVd4RCIsImZpbGUiOiJydWxlcy9ub0VtcHR5Q2hhcmFjdGVyQ2xhc3NSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

View File

@@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var token_1 = require("../support/token");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoExAssignWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = 'do not assign to the exception parameter';
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoExAssignWalker = (function (_super) {
tslib_1.__extends(NoExAssignWalker, _super);
function NoExAssignWalker() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.isInCatchClause = false;
return _this;
}
NoExAssignWalker.prototype.visitCatchClause = function (node) {
this.variableNode = node.variableDeclaration;
this.isInCatchClause = true;
_super.prototype.visitCatchClause.call(this, node);
this.isInCatchClause = false;
delete this.variableNode;
};
NoExAssignWalker.prototype.visitBinaryExpression = function (node) {
var _this = this;
if (this.isInCatchClause) {
if (!token_1.isAssignmentToken(node.operatorToken)) {
return;
}
if (this.variableNode &&
this.variableNode.name.getText() === node.left.getText() &&
node.left.kind === ts.SyntaxKind.Identifier) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
else if (node.left.kind === ts.SyntaxKind.ArrayLiteralExpression) {
var els = node.left.elements;
if (els.some(function (el) { return !!_this.variableNode && el.getText() === _this.variableNode.getText(); })) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
}
}
_super.prototype.visitBinaryExpression.call(this, node);
};
return NoExAssignWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vRXhBc3NpZ25SdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLCtCQUFpQztBQUNqQyw2QkFBK0I7QUFDL0IsMENBQXFEO0FBRXJEO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUFPQSxDQUFDO0lBSlEsb0JBQUssR0FBWixVQUFhLFVBQXlCO1FBQ3BDLElBQU0sTUFBTSxHQUFHLElBQUksZ0JBQWdCLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQyxDQUFDO1FBQ25FLE9BQU8sSUFBSSxDQUFDLGVBQWUsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUN0QyxDQUFDO0lBTGEsbUJBQWMsR0FBRywwQ0FBMEMsQ0FBQztJQU01RSxXQUFDO0NBUEQsQUFPQyxDQVB5QixJQUFJLENBQUMsS0FBSyxDQUFDLFlBQVksR0FPaEQ7QUFQWSxvQkFBSTtBQVNqQjtJQUErQiw0Q0FBZTtJQUE5QztRQUFBLHFFQWlDQztRQWhDUyxxQkFBZSxHQUFHLEtBQUssQ0FBQzs7SUFnQ2xDLENBQUM7SUE3QlcsMkNBQWdCLE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0FBQztnQkFDOUQsSUFBSSxHQUFHLENBQUMsSUFBSSxDQUFDLFVBQUEsRUFBRSxJQUFJLE9BQUEsQ0FBQyxDQUFDLEtBQUksQ0FBQyxZQUFZLElBQUksRUFBRSxDQUFDLE9BQU8sRUFBRSxLQUFLLEtBQUksQ0FBQyxZQUFZLENBQUMsT0FBTyxFQUFFLEVBQW5FLENBQW1FLENBQUMsRUFBRTtvQkFDdkYsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDLENBQUM7aUJBQzVGO2FBQ0Y7U0FDRjtRQUNELGlCQUFNLHFCQUFxQixZQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3BDLENBQUM7SUFDSCx1QkFBQztBQUFELENBakNBLEFBaUNDLENBakM4QixJQUFJLENBQUMsVUFBVSxHQWlDN0MiLCJmaWxlIjoicnVsZXMvbm9FeEFzc2lnblJ1bGUuanMiLCJzb3VyY2VSb290IjoiL1VzZXJzL2ptbG9wZXovdHNsaW50LWVzbGludC1ydWxlcy9zcmMifQ==

View File

@@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoExtraBooleanCastWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = {
if: 'redundant double negation in an if statement condition',
do: 'redundant double negation in a do while loop condition',
while: 'redundant double negation in a while loop condition',
ternaryif: 'redundant double negation in a ternary condition',
for: 'redundant double negation in a for loop condition',
unaryCast: 'redundant multiple negation',
objectCast: 'redundant double negation in call to Boolean()',
newCast: 'redundant double negation in Boolean constructor call'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoExtraBooleanCastWalker = (function (_super) {
tslib_1.__extends(NoExtraBooleanCastWalker, _super);
function NoExtraBooleanCastWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoExtraBooleanCastWalker.prototype.visitPrefixUnaryExpression = function (node) {
this.validateNoExtraBoolean(node);
_super.prototype.visitPrefixUnaryExpression.call(this, node);
};
NoExtraBooleanCastWalker.prototype.validateNoExtraBoolean = function (node) {
if (!node.parent || !node.parent.parent) {
return;
}
var parent = node.parent;
var grandparent = parent.parent;
if (node.operator !== ts.SyntaxKind.ExclamationToken ||
parent.kind !== ts.SyntaxKind.PrefixUnaryExpression ||
parent.operator !== ts.SyntaxKind.ExclamationToken ||
!grandparent) {
return;
}
if (grandparent.kind === ts.SyntaxKind.BinaryExpression) {
grandparent = grandparent.parent;
}
if (!grandparent) {
return;
}
if (grandparent.kind === ts.SyntaxKind.IfStatement) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.if));
}
else if (grandparent.kind === ts.SyntaxKind.DoStatement) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.do));
}
else if (grandparent.kind === ts.SyntaxKind.WhileStatement) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.while));
}
else if (grandparent.kind === ts.SyntaxKind.ConditionalExpression && parent === grandparent.condition) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.ternaryif));
}
else if (grandparent.kind === ts.SyntaxKind.ForStatement && parent === grandparent.condition) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.for));
}
else if (grandparent.kind === ts.SyntaxKind.PrefixUnaryExpression && grandparent.operator === ts.SyntaxKind.ExclamationToken) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.unaryCast));
}
else if (grandparent.kind === ts.SyntaxKind.CallExpression && /^Boolean/.test(grandparent.getText())) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.objectCast));
}
else if (grandparent.kind === ts.SyntaxKind.NewExpression && /^new Boolean/.test(grandparent.getText())) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.newCast));
}
};
return NoExtraBooleanCastWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vRXh0cmFCb29sZWFuQ2FzdFJ1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsK0JBQWlDO0FBQ2pDLDZCQUErQjtBQUUvQjtJQUEwQixnQ0FBdUI7SUFBakQ7O0lBZ0JBLENBQUM7SUFKUSxvQkFBSyxHQUFaLFVBQWEsVUFBeUI7UUFDcEMsSUFBTSxNQUFNLEdBQUcsSUFBSSx3QkFBd0IsQ0FBQyxVQUFVLEVBQUUsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDLENBQUM7UUFDM0UsT0FBTyxJQUFJLENBQUMsZUFBZSxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3RDLENBQUM7SUFkYSxtQkFBYyxHQUFHO1FBQzdCLEVBQUUsRUFBRSx3REFBd0Q7UUFDNUQsRUFBRSxFQUFFLHdEQUF3RDtRQUM1RCxLQUFLLEVBQUUscURBQXFEO1FBQzVELFNBQVMsRUFBRSxrREFBa0Q7UUFDN0QsR0FBRyxFQUFFLG1EQUFtRDtRQUN4RCxTQUFTLEVBQUUsNkJBQTZCO1FBQ3hDLFVBQVUsRUFBRSxnREFBZ0Q7UUFDNUQsT0FBTyxFQUFFLHVEQUF1RDtLQUNqRSxDQUFDO0lBTUosV0FBQztDQWhCRCxBQWdCQyxDQWhCeUIsSUFBSSxDQUFDLEtBQUssQ0FBQyxZQUFZL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BQUMsYUFBYSxJQUFJLGNBQWMsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE9BQU8sRUFBRSxDQUFDLEVBQUU7WUFDekcsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO1NBQ3BHO0lBQ0gsQ0FBQztJQUNILCtCQUFDO0FBQUQsQ0FwREEsQUFvREMsQ0FwRHNDLElBQUksQ0FBQyxVQUFVLEdBb0RyRCIsImZpbGUiOiJydWxlcy9ub0V4dHJhQm9vbGVhbkNhc3RSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

View File

@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoExtraSemiWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = 'unnecessary semicolon';
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoExtraSemiWalker = (function (_super) {
tslib_1.__extends(NoExtraSemiWalker, _super);
function NoExtraSemiWalker() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.ALLOWED_PARENT_TYPES = [
ts.SyntaxKind.ForStatement,
ts.SyntaxKind.ForInStatement,
ts.SyntaxKind.ForOfStatement,
ts.SyntaxKind.WhileStatement,
ts.SyntaxKind.DoStatement
];
return _this;
}
NoExtraSemiWalker.prototype.visitNode = function (node) {
if (node.kind === ts.SyntaxKind.EmptyStatement) {
this.visitEmptyStatement(node);
}
_super.prototype.visitNode.call(this, node);
};
NoExtraSemiWalker.prototype.visitClassDeclaration = function (node) {
this.checkClass(node);
_super.prototype.visitClassDeclaration.call(this, node);
};
NoExtraSemiWalker.prototype.visitEmptyStatement = function (node) {
if (node.parent && this.ALLOWED_PARENT_TYPES.indexOf(node.parent.kind) === -1) {
this.validateNoExtraSemi(node);
}
};
NoExtraSemiWalker.prototype.checkClass = function (node) {
var indexOf = node.getChildren().map(function (child) { return child.kind; }).indexOf(ts.SyntaxKind.FirstPunctuation);
var children = node.getChildren().slice(indexOf);
this.checkClassChildren(children);
};
NoExtraSemiWalker.prototype.checkClassChildren = function (children) {
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
var child = children_1[_i];
if ((child.kind === ts.SyntaxKind.SyntaxList || child.kind === ts.SyntaxKind.SemicolonClassElement) && child.getText() === ';') {
this.validateNoExtraSemi(child);
}
else if (child.kind === ts.SyntaxKind.SyntaxList && child.getText().indexOf(';') !== -1) {
this.checkClassChildren(child.getChildren());
}
}
};
NoExtraSemiWalker.prototype.validateNoExtraSemi = function (node) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
};
return NoExtraSemiWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vRXh0cmFTZW1pUnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwrQkFBaUM7QUFDakMsNkJBQStCO0FBRS9CO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUFPQSxDQUFDO0lBSlEsb0JBQUssR0FBWixVQUFhLFVBQXlCO1FBQ3BDLElBQU0sTUFBTSxHQUFHLElBQUksaUJBQWlCLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQyxDQUFDO1FBQ3BFLE9BQU8sSUFBS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BTyxFQUFFLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQyxFQUFFO2dCQUN2RixJQUFJLENBQUMsa0JBQWtCLENBQUMsS0FBSyxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUM7YUFDOUM7U0FDRjtJQUNILENBQUM7SUFFTywrQ0FBbUIsR0FBM0IsVUFBNEIsSUFBYTtRQUN2QyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsSUFBSSxDQUFDLFFBQVEsRUFBRSxFQUFFLElBQUksQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztJQUM3RixDQUFDO0lBQ0gsd0JBQUM7QUFBRCxDQWhEQSxBQWdEQyxDQWhEK0IsSUFBSSxDQUFDLFVBQVUsR0FnRDlDIiwiZmlsZSI6InJ1bGVzL25vRXh0cmFTZW1pUnVsZS5qcyIsInNvdXJjZVJvb3QiOiIvVXNlcnMvam1sb3Blei90c2xpbnQtZXNsaW50LXJ1bGVzL3NyYyJ9

View File

@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoInnerDeclarationsWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoInnerDeclarationsWalker = (function (_super) {
tslib_1.__extends(NoInnerDeclarationsWalker, _super);
function NoInnerDeclarationsWalker() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.VALID_PARENT_TYPES = [
ts.SyntaxKind.SourceFile,
ts.SyntaxKind.FunctionDeclaration,
ts.SyntaxKind.FunctionExpression,
ts.SyntaxKind.ArrowFunction,
ts.SyntaxKind.MethodDeclaration,
ts.SyntaxKind.ModuleDeclaration,
ts.SyntaxKind.Constructor
];
return _this;
}
NoInnerDeclarationsWalker.prototype.visitFunctionDeclaration = function (node) {
this.validateInnerDeclaration(node);
_super.prototype.visitFunctionDeclaration.call(this, node);
};
NoInnerDeclarationsWalker.prototype.visitVariableStatement = function (node) {
if (this.hasOption('both') && node.declarationList.getFirstToken().kind === ts.SyntaxKind.VarKeyword) {
this.validateInnerDeclaration(node);
}
_super.prototype.visitVariableStatement.call(this, node);
};
NoInnerDeclarationsWalker.prototype.validateInnerDeclaration = function (node) {
var body = this.nearestBody(node);
var isValid = (body.isSourceFile && body.distance === 1) || body.distance === 2;
if (!isValid) {
var decl = node.kind === ts.SyntaxKind.FunctionDeclaration ? 'function' : 'variable';
var root = body.isSourceFile ? 'program' : 'function body';
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "move " + decl + " declaration to " + root + " root"));
}
};
NoInnerDeclarationsWalker.prototype.nearestBody = function (node) {
var ancestor = node.parent;
var generation = 1;
while (ancestor && this.VALID_PARENT_TYPES.indexOf(ancestor.kind) === -1) {
generation++;
ancestor = ancestor.parent;
}
return {
isSourceFile: (ancestor && ancestor.kind === ts.SyntaxKind.SourceFile) || !ancestor,
distance: generation
};
};
return NoInnerDeclarationsWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vSW5uZXJEZWNsYXJhdGlvbnNSdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLCtCQUFpQztBQUNqQyw2QkFBK0I7QUFFL0I7SUFBMEIsZ0NBQXVCO0lBQWpEOztJQUtBLENBQUM7SUFKUSxvQkFBSyxHQUFaLFVBQWEsVUFBeUI7UUFDcEMsSUFBTSxNQUFNLEdBQUcsSUFBSSx5QkFBeUIsQ0FBQyxVQUFVLEVBQUUsSUFBS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BQyxFQUFFO1lBQ3hFLFVBQVUsRUFBRSxDQUFDO1lBQ2IsUUFBUSxHQUFHLFFBQVEsQ0FBQyxNQUFNLENBQUM7U0FDNUI7UUFFRCxPQUFPO1lBQ0wsWUFBWSxFQUFFLENBQUMsUUFBUSxJQUFJLFFBQVEsQ0FBQyxJQUFJLEtBQUssRUFBRSxDQUFDLFVBQVUsQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLFFBQVE7WUFDbkYsUUFBUSxFQUFFLFVBQVU7U0FDckIsQ0FBQztJQUNKLENBQUM7SUFDSCxnQ0FBQztBQUFELENBbkRBLEFBbURDLENBbkR1QyxJQUFJLENBQUMsVUFBVSxHQW1EdEQiLCJmaWxlIjoicnVsZXMvbm9Jbm5lckRlY2xhcmF0aW9uc1J1bGUuanMiLCJzb3VyY2VSb290IjoiL1VzZXJzL2ptbG9wZXovdHNsaW50LWVzbGludC1ydWxlcy9zcmMifQ==

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoInvalidRegexpWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoInvalidRegexpWalker = (function (_super) {
tslib_1.__extends(NoInvalidRegexpWalker, _super);
function NoInvalidRegexpWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoInvalidRegexpWalker.prototype.visitNewExpression = function (node) {
this.validateInvalidRegExp(node);
_super.prototype.visitNewExpression.call(this, node);
};
NoInvalidRegexpWalker.prototype.visitCallExpression = function (node) {
this.validateInvalidRegExp(node);
_super.prototype.visitCallExpression.call(this, node);
};
NoInvalidRegexpWalker.prototype.validateInvalidRegExp = function (node) {
if (node.expression.getText() === 'RegExp') {
var args = node.arguments;
if (args && args.length > 0 && args[0].kind === ts.SyntaxKind.StringLiteral) {
var expr = args[0].text;
var flags = args.length > 1 && args[1].kind === ts.SyntaxKind.StringLiteral ? args[1].text : undefined;
try {
new RegExp(expr, flags);
}
catch (e) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), e.message));
}
}
}
};
return NoInvalidRegexpWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vSW52YWxpZFJlZ2V4cFJ1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsK0JBQWlDO0FBQ2pDLDZCQUErQjtBQUUvQjtJQUEwQixnQ0FBdUI7SUFBakQ7O0lBS0EsQ0FBQztJQUpRLG9CQUFLLEdBQVosVUFBYSxVQUF5QjtRQUNwQyxJQUFNLE1BQU0sR0FBRyxJQUFJLHFCQUFxQixDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsVUFBVSxFQUFFLENBQUMsQ0FBQztRQUN4RSxPQUFPLElBQUksQ0FBQyxlQUFlLENBQUMsTUFBTSxDQUFDLENBQUM7SUFDdEMsQ0FBQztJQUNILFdBQUM7QUFBRCxDQUxBLEFBS0MsQ0FMeUIsSUFBSSxDQUFDLEtBQUssQ0FBQyxZQUFZLEdBS2hEO0FBTFksb0JBQUk7QUFPakI7SUFBb0MsaURBQWU7SUFBbkQ7O0lBNEJBLENBQUM7SUEzQlcsa0RBQWtCLEdBQTVCLFVBQTZCLElBQXNCO1FBQ2pELElBQUksQ0FBQyxxQkFBcUIsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUNqQyxpQkFBTSxrQkFBa0IsWUFBQyxJQUFJLENBQUMsQ0FBQztJQUNqQyxDQUFDO0lBRVMsbURBQW1CLEdBQTdCLFVBQThCLElBQXVCO1FBQ25ELElBQUksQ0FBQyxxQkFBcUIsQ0FBQyxJQUF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lBQ0gsNEJBQUM7QUFBRCxDQTVCQSxBQTRCQyxDQTVCbUMsSUFBSSxDQUFDLFVBQVUsR0E0QmxEIiwiZmlsZSI6InJ1bGVzL25vSW52YWxpZFJlZ2V4cFJ1bGUuanMiLCJzb3VyY2VSb290IjoiL1VzZXJzL2ptbG9wZXovdHNsaW50LWVzbGludC1ydWxlcy9zcmMifQ==

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoRegexSpacesWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoRegexSpacesWalker = (function (_super) {
tslib_1.__extends(NoRegexSpacesWalker, _super);
function NoRegexSpacesWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoRegexSpacesWalker.prototype.visitRegularExpressionLiteral = function (node) {
this.validateMultipleSpaces(node);
_super.prototype.visitRegularExpressionLiteral.call(this, node);
};
NoRegexSpacesWalker.prototype.validateMultipleSpaces = function (node) {
var res = /( {2,})+?/.exec(node.text);
if (res) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "spaces are hard to count - use {" + res[0].length + "}"));
}
};
return NoRegexSpacesWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vUmVnZXhTcGFjZXNSdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLDZCQUErQjtBQUUvQjtJQUEwQixnQ0FBdUI7SUFBakQ7O0lBS0EsQ0FBQztJQUpRLG9CQUFLLEdBQVosVUFBYSxVQUF5QjtRQUNwQyxJQUFNLE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 -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoUnexpectedMultilineWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = {
func: 'unexpected newline between function and ( of function call',
prop: 'unexpected newline between object and [ of property access',
template: 'unexpected newline between template tag and template literal'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoUnexpectedMultilineWalker = (function (_super) {
tslib_1.__extends(NoUnexpectedMultilineWalker, _super);
function NoUnexpectedMultilineWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoUnexpectedMultilineWalker.prototype.visitCallExpression = function (node) {
var firstLeftParen = node.getChildren().filter(function (ch) { return ch.kind === ts.SyntaxKind.OpenParenToken; })[0];
if (this.isBreakBefore(firstLeftParen)) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), this.getMessage(node)));
}
_super.prototype.visitCallExpression.call(this, node);
};
NoUnexpectedMultilineWalker.prototype.visitElementAccessExpression = function (node) {
var firstLeftSquareBracket = node.getChildren().filter(function (ch) { return ch.kind === ts.SyntaxKind.OpenBracketToken; })[0];
if (this.isBreakBefore(firstLeftSquareBracket)) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), this.getMessage(node)));
}
_super.prototype.visitElementAccessExpression.call(this, node);
};
NoUnexpectedMultilineWalker.prototype.visitNode = function (node) {
if (node.kind === ts.SyntaxKind.TaggedTemplateExpression) {
var children = node.getChildren();
var tag = children.filter(function (ch) { return ch.kind === ts.SyntaxKind.Identifier; })[0];
var tagIndex = children.indexOf(tag);
if (tag && children[tagIndex + 1]) {
var template = children[tagIndex + 1];
if (this.isBreakBefore(template)) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), this.getMessage(node)));
}
}
}
_super.prototype.visitNode.call(this, node);
};
NoUnexpectedMultilineWalker.prototype.isBreakBefore = function (node) {
if (node.parent) {
var children = node.parent.getChildren();
var nodeIndex = children.indexOf(node);
if (nodeIndex > 0) {
var nodeLine = this.getStartPosition(node).line;
var previousNodeLine = this.getEndPosition(children[nodeIndex - 1]).line;
if (nodeLine !== previousNodeLine) {
return true;
}
}
}
return false;
};
NoUnexpectedMultilineWalker.prototype.getMessage = function (node) {
switch (node.kind) {
case ts.SyntaxKind.CallExpression:
return Rule.FAILURE_STRING.func;
case ts.SyntaxKind.ElementAccessExpression:
return Rule.FAILURE_STRING.prop;
case ts.SyntaxKind.TaggedTemplateExpression:
return Rule.FAILURE_STRING.template;
default:
throw 'Unexpected node type: ' + ts.SyntaxKind[node.kind];
}
};
NoUnexpectedMultilineWalker.prototype.getStartPosition = function (node) {
return node.getSourceFile().getLineAndCharacterOfPosition(node.getStart());
};
NoUnexpectedMultilineWalker.prototype.getEndPosition = function (node) {
return node.getSourceFile().getLineAndCharacterOfPosition(node.getEnd());
};
return NoUnexpectedMultilineWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vVW5leHBlY3RlZE11bHRpbGluZVJ1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsK0JBQWlDO0FBQ2pDLDZCQUErQjtBQUUvQjtJQUEwQixnQ0FBdUI7SUFBakQ7O0lBV0EsQ0FBQztJQUpRLG9CQUFLLEdBQVosVUFBYSxVQUF5QjtRQUNwQyxJQUFNLE1BQU0sR0FBRyxJQUFJLDJCQUEyQixDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsVUFBVSxFQUFFLENBQUMsQ0FBQztRQUM5RSxPQUFPLElBQUksQ0FBQyxlQUFlLENBQUMsTUFBTSxDQUFDLENBQUM7SUFDdEMsQ0FBQztJQVRhLG1CQU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jLENBQUMsSUFBSSxDQUFDO1lBQ2xDLEtBQUssRUFBRSxDQUFDLFVBQVUsQ0FBQyx1QkFBdUI7Z0JBQ3hDLE9BQU8sSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUM7WUFDbEMsS0FBSyxFQUFFLENBQUMsVUFBVSxDQUFDLHdCQUF3QjtnQkFDekMsT0FBTyxJQUFJLENBQUMsY0FBYyxDQUFDLFFBQVEsQ0FBQztZQUN0QztnQkFDRSxNQUFNLHdCQUF3QixHQUFHLEVBQUUsQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1NBQzdEO0lBQ0gsQ0FBQztJQUVPLHNEQUFnQixHQUF4QixVQUF5QixJQUFhO1FBQ3BDLE9BQU8sSUFBSSxDQUFDLGFBQWEsRUFBRSxDQUFDLDZCQUE2QixDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDO0lBQzdFLENBQUM7SUFFTyxvREFBYyxHQUF0QixVQUF1QixJQUFhO1FBQ2xDLE9BQU8sSUFBSSxDQUFDLGFBQWEsRUFBRSxDQUFDLDZCQUE2QixDQUFDLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDO0lBQzNFLENBQUM7SUFDSCxrQ0FBQztBQUFELENBN0VBLEFBNkVDLENBN0V5QyxJQUFJLENBQUMsVUFBVSxHQTZFeEQiLCJmaWxlIjoicnVsZXMvbm9VbmV4cGVjdGVkTXVsdGlsaW5lUnVsZS5qcyIsInNvdXJjZVJvb3QiOiIvVXNlcnMvam1sb3Blei90c2xpbnQtZXNsaW50LXJ1bGVzL3NyYyJ9

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var RULE_NAME = 'ter-arrow-body-style';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new RuleWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.metadata = {
ruleName: RULE_NAME,
description: 'require braces in arrow function body',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Arrow functions have two syntactic forms for their function bodies. They may be defined with\n a block body (denoted by curly braces) `() => { ... }` or with a single expression\n `() => ...`, whose value is implicitly returned.\n "], ["\n Arrow functions have two syntactic forms for their function bodies. They may be defined with\n a block body (denoted by curly braces) \\`() => { ... }\\` or with a single expression\n \\`() => ...\\`, whose value is implicitly returned.\n "]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n The rule takes one or two options. The first is a string, which can be:\n\n - `\"always\"` enforces braces around the function body\n - `\"as-needed\"` enforces no braces where they can be omitted (default)\n - `\"never\"` enforces no braces around the function body (constrains arrow functions to the\n role of returning an expression)\n\n The second one is an object for more fine-grained configuration when the first option is\n `\"as-needed\"`. Currently, the only available option is `requireReturnForObjectLiteral`, a\n boolean property. It\u2019s false by default. If set to true, it requires braces and an explicit\n return for object literals.\n "], ["\n The rule takes one or two options. The first is a string, which can be:\n\n - \\`\"always\"\\` enforces braces around the function body\n - \\`\"as-needed\"\\` enforces no braces where they can be omitted (default)\n - \\`\"never\"\\` enforces no braces around the function body (constrains arrow functions to the\n role of returning an expression)\n\n The second one is an object for more fine-grained configuration when the first option is\n \\`\"as-needed\"\\`. Currently, the only available option is \\`requireReturnForObjectLiteral\\`, a\n boolean property. It\u2019s false by default. If set to true, it requires braces and an explicit\n return for object literals.\n "]))),
options: {
anyOf: [
{
type: 'array',
items: [
{
enum: ['always', 'never']
}
],
minItems: 0,
maxItems: 1
},
{
type: 'array',
items: [
{
enum: ['as-needed']
},
{
type: 'object',
properties: {
requireReturnForObjectLiteral: { type: 'boolean' }
},
additionalProperties: false
}
],
minItems: 0,
maxItems: 2
}
]
},
optionExamples: [
Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n \"", "\": [true, \"always\"]\n "], ["\n \"", "\": [true, \"always\"]\n "])), RULE_NAME),
Lint.Utils.dedent(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["\n \"", "\": [true, \"never\"]\n "], ["\n \"", "\": [true, \"never\"]\n "])), RULE_NAME),
Lint.Utils.dedent(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["\n \"", "\": [true, \"as-needed\", {\n \"requireReturnForObjectLiteral\": true\n }]\n "], ["\n \"", "\": [true, \"as-needed\", {\n \"requireReturnForObjectLiteral\": true\n }]\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'style'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var RuleWalker = (function (_super) {
tslib_1.__extends(RuleWalker, _super);
function RuleWalker(sourceFile, options) {
var _this = _super.call(this, sourceFile, options) || this;
var opt = _this.getOptions();
_this.always = opt[0] === 'always';
_this.asNeeded = !opt[0] || opt[0] === 'as-needed';
_this.never = opt[0] === 'never';
_this.requireReturnForObjectLiteral = opt[1] && opt[1].requireReturnForObjectLiteral;
return _this;
}
RuleWalker.prototype.visitArrowFunction = function (node) {
var arrowBody = node.body;
if (arrowBody.kind === ts.SyntaxKind.Block) {
var blockBody = arrowBody.statements;
if (blockBody.length !== 1 && !this.never) {
return;
}
var returnExpression = blockBody[0].expression;
if (this.asNeeded &&
this.requireReturnForObjectLiteral &&
blockBody[0].kind === ts.SyntaxKind.ReturnStatement &&
(returnExpression && this.isObjectLiteral(returnExpression))) {
return;
}
if (this.never || this.asNeeded && blockBody[0].kind === ts.SyntaxKind.ReturnStatement) {
this.report(arrowBody, false);
}
}
else {
if (this.always || (this.asNeeded &&
this.requireReturnForObjectLiteral &&
this.isObjectLiteral(arrowBody))) {
this.report(arrowBody, true);
}
}
_super.prototype.visitArrowFunction.call(this, node);
};
RuleWalker.prototype.isObjectLiteral = function (node) {
var obj = node;
while (obj.kind === ts.SyntaxKind.ParenthesizedExpression) {
obj = node.expression;
}
return obj.kind === ts.SyntaxKind.ObjectLiteralExpression;
};
RuleWalker.prototype.report = function (arrowBody, expected) {
var val = expected ? 'Expected' : 'Unexpected';
var failure = this.createFailure(arrowBody.getStart(), arrowBody.getWidth(), val + " block statement surrounding arrow body.");
this.addFailure(failure);
};
return RuleWalker;
}(Lint.RuleWalker));
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3RlckFycm93Qm9keVN0eWxlUnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFJQSwrQkFBaUM7QUFDakMsNkJBQStCO0FBRS9CLElBQU0sU0FBUyxHQUFHLHNCQUFzQixDQUFDO0FBRXpDO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUEwRUEsQ0FBQztJQUpRLG9CQUFLLEdBQVosVUFBYSxVQUF5QjtRQUNwQyxJQUFNLE1BQU0sR0FBRyxJQUFJLFVBQVUsQ0FBQyxVQUFVLEVBQUUsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDLENBQUM7UUFDN0QsT0FBTyxJQUFJLENBQUMsZUFBZSxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3RDLENBQUM7SUF4RWEsYUFBUSxHQUF1QjtRQUMzQyxRQUFRLEVBQUUsU0FBUztRQUNuQixXQUFXLEVBQUUsdUNBQXVDO1FBQ3BELFNBQVMsRUFBRSxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sMlVBQUEsd1FBSXpCLElBQUE7UUFDSCxrQkFBa0IsRUFBRSxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sK3hCQUFBLHd1QkFZbEMsSUFBQTtRQUNILE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QsT0FBTyxHQUFHLENBQUMsSUFBSSxLQUFLLEVBQUUsQ0FBQyxVQUFVLENBQUMsdUJBQXVCLENBQUM7SUFDNUQsQ0FBQztJQUVPLDJCQUFNLEdBQWQsVUFBZSxTQUFrQixFQUFFLFFBQWlCO1FBQ2xELElBQU0sR0FBRyxHQUFHLFFBQVEsQ0FBQyxDQUFDLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQyxZQUFZLENBQUM7UUFDakQsSUFBTSxPQUFPLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FDaEMsU0FBUyxDQUFDLFFBQVEsRUFBRSxFQUNwQixTQUFTLENBQUMsUUFBUSxFQUFFLEVBQ2pCLEdBQUcsNkNBQTBDLENBQ2pELENBQUM7UUFDRixJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQzNCLENBQUM7SUFDSCxpQkFBQztBQUFELENBbkVBLEFBbUVDLENBbkV3QixJQUFJLENBQUMsVUFBVSxHQW1FdkMiLCJmaWxlIjoicnVsZXMvdGVyQXJyb3dCb2R5U3R5bGVSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,104 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Lint = require("tslint");
var RULE_NAME = 'ter-arrow-spacing';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new RuleWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.metadata = {
ruleName: RULE_NAME,
description: 'require space before/after arrow function\'s arrow',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n This rule normalizes the style of spacing before/after an arrow function\u2019s arrow(`=>`).\n "], ["\n This rule normalizes the style of spacing before/after an arrow function\u2019s arrow(\\`=>\\`).\n "]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n This rule takes an object argument with `before` and `after` properties, each with a\n Boolean value.\n\n The default configuration is `{ \"before\": true, \"after\": true }`.\n\n `true` means there should be one or more spaces and `false` means no spaces.\n "], ["\n This rule takes an object argument with \\`before\\` and \\`after\\` properties, each with a\n Boolean value.\n\n The default configuration is \\`{ \"before\": true, \"after\": true }\\`.\n\n \\`true\\` means there should be one or more spaces and \\`false\\` means no spaces.\n "]))),
options: {
type: 'array',
items: [{
type: 'object',
properties: {
before: {
type: 'boolean'
},
after: {
type: 'boolean'
}
},
additionalProperties: false
}],
maxLength: 1
},
optionExamples: [
Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n \"", "\": [true]\n "], ["\n \"", "\": [true]\n "])), RULE_NAME),
Lint.Utils.dedent(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["\n \"", "\": [true, {\n \"before\": false,\n \"after\": false\n }]\n "], ["\n \"", "\": [true, {\n \"before\": false,\n \"after\": false\n }]\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'style'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var RuleWalker = (function (_super) {
tslib_1.__extends(RuleWalker, _super);
function RuleWalker(sourceFile, options) {
var _this = _super.call(this, sourceFile, options) || this;
_this.before = true;
_this.after = true;
var opt = _this.getOptions();
if (opt[0]) {
_this.before = opt[0].before !== false;
_this.after = opt[0].after !== false;
}
_this.srcFile = sourceFile;
_this.srcText = sourceFile.getFullText();
return _this;
}
RuleWalker.prototype.visitArrowFunction = function (node) {
var arrow = node.equalsGreaterThanToken;
var arrowStart = arrow.getStart(this.srcFile);
var bodyStart = node.body.getStart(this.srcFile);
var space = {
before: /\s/.test(this.srcText[arrowStart - 1]),
after: /\s/.test(this.srcText[arrow.end])
};
if (this.before) {
if (!space.before) {
var fix = Lint.Replacement.appendText(arrowStart, ' ');
this.report(arrow, 'Missing', 'before', fix);
}
}
else {
if (space.before) {
var spaces = arrowStart - arrow.getFullStart();
var fix = Lint.Replacement.deleteText(arrowStart - spaces, spaces);
this.report(arrow, 'Unexpected', 'before', fix);
}
}
if (this.after) {
if (!space.after) {
var fix = Lint.Replacement.appendText(arrow.end, ' ');
this.report(arrow, 'Missing', 'after', fix);
}
}
else {
if (space.after) {
var fix = Lint.Replacement.deleteText(arrow.end, bodyStart - arrow.end);
this.report(arrow, 'Unexpected', 'after', fix);
}
}
_super.prototype.visitArrowFunction.call(this, node);
};
RuleWalker.prototype.report = function (arrowToken, status, place, fix) {
var failure = this.createFailure(arrowToken.getStart(this.srcFile), arrowToken.getWidth(this.srcFile), status + " space " + place + " =>.", fix);
this.addFailure(failure);
};
return RuleWalker;
}(Lint.RuleWalker));
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3RlckFycm93U3BhY2luZ1J1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBUUEsNkJBQStCO0FBRS9CLElBQU0sU0FBUyxHQUFHLG1CQUFtQixDQUFDO0FBRXRDO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUFrREEsQ0FBQztJQUpRLG9CQUFLLEdBQVosVUFBYSxVQUF5QjtRQUNwQyxJQUFNLE1BQU0sR0FBRyxJQUFJLFVBQVUsQ0FBQyxVQUFVLEVBQUUsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDLENBQUM7UUFDN0QsT0FBTyxJQUFJLENBQUMsZUFBZSxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3RDLENBQUM7SUFoRGEsYUFBUSxHQUF1QjtRQUMzQyxRQUFRLEVBQUUsU0FBUztRQUNuQixXQUFXLEVBQUUsb0RBQW9EO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DQUFDLEdBQUcsQ0FBQyxDQUFDO2dCQUMxRSxJQUFJLENBQUMsTUFBTSxDQUFDLEtBQUssRUFBRSxZQUFZLEVBQUUsT0FBTyxFQUFFLEdBQUcsQ0FBQyxDQUFDO2FBQ2hEO1NBQ0Y7UUFDRCxpQkFBTSxrQkFBa0IsWUFBQyxJQUFJLENBQUMsQ0FBQztJQUNqQyxDQUFDO0lBRU8sMkJBQU0sR0FBZCxVQUFlLFVBQW1CLEVBQUUsTUFBYyxFQUFFLEtBQWEsRUFBRSxHQUFhO1FBQzlFLElBQU0sT0FBTyxHQUFHLElBQUksQ0FBQyxhQUFhLENBQ2hDLFVBQVUsQ0FBQyxRQUFRLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxFQUNqQyxVQUFVLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsRUFDOUIsTUFBTSxlQUFVLEtBQUssU0FBTSxFQUM5QixHQUFHLENBQ0osQ0FBQztRQUNGLElBQUksQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLENBQUM7SUFDM0IsQ0FBQztJQUNILGlCQUFDO0FBQUQsQ0E1REEsQUE0REMsQ0E1RHdCLElBQUksQ0FBQyxVQUFVLEdBNER2QyIsImZpbGUiOiJydWxlcy90ZXJBcnJvd1NwYWNpbmdSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,113 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var RULE_NAME = 'ter-newline-after-var';
var EXPECTED_BLANK_LINE_MESSAGE = 'Expected blank line after variable declarations.';
var UNEXPECTED_BLANK_LINE_MESSAGE = 'Unexpected blank line after variable declarations.';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.formatOptions = function (_a) {
var alwaysOrNever = _a[0];
return {
always: alwaysOrNever !== 'never'
};
};
Rule.prototype.apply = function (sourceFile) {
var opt = this.formatOptions(this.ruleArguments);
var walker = new RuleWalker(sourceFile, this.ruleName, opt);
return this.applyWithWalker(walker);
};
Rule.metadata = {
ruleName: RULE_NAME,
hasFix: true,
description: 'require or disallow an empty line after variable declarations',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n This rule enforces a coding style where empty lines are required or disallowed after `var`, `let`, or `const`\n statements to achieve a consistent coding style across the project.\n "], ["\n This rule enforces a coding style where empty lines are required or disallowed after \\`var\\`, \\`let\\`, or \\`const\\`\n statements to achieve a consistent coding style across the project.\n "]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n This rule has a string option:\n\n * `\"always\"` (default) requires an empty line after `var`, `let`, or `const`.\n Comments on a line directly after var statements are treated like additional var statements.\n * `\"never\"` disallows empty lines after `var`, `let`, or `const`.\n "], ["\n This rule has a string option:\n\n * \\`\"always\"\\` (default) requires an empty line after \\`var\\`, \\`let\\`, or \\`const\\`.\n Comments on a line directly after var statements are treated like additional var statements.\n * \\`\"never\"\\` disallows empty lines after \\`var\\`, \\`let\\`, or \\`const\\`.\n "]))),
options: {
type: 'array',
items: [{
enum: ['always', 'never']
}],
maxLength: 1
},
optionExamples: [
Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n \"", "\": [true]\n "], ["\n \"", "\": [true]\n "])), RULE_NAME),
Lint.Utils.dedent(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["\n \"", "\": [true, \"always\"]\n "], ["\n \"", "\": [true, \"always\"]\n "])), RULE_NAME),
Lint.Utils.dedent(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["\n \"", "\": [true, \"never\"]\n "], ["\n \"", "\": [true, \"never\"]\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'style'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var RuleWalker = (function (_super) {
tslib_1.__extends(RuleWalker, _super);
function RuleWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
RuleWalker.prototype.walk = function (sourceFile) {
var _this = this;
this.sourceFileText = sourceFile.getFullText();
var onNode = function (node) {
var _a = _this, lastVariableStatementNode = _a.lastVariableStatementNode, sourceFileText = _a.sourceFileText;
if (node.kind === ts.SyntaxKind.VariableStatement) {
_this.lastVariableStatementNode = node;
return;
}
if (node.kind === ts.SyntaxKind.EndOfFileToken) {
_this.lastVariableStatementNode = undefined;
return;
}
if (lastVariableStatementNode) {
var unexpectedLineFixes = [];
var expectedLineFixes = [];
var isNewLineRequired = _this.options.always;
var expectedLinePos = lastVariableStatementNode.end;
var newLinesCount = 0;
for (var i = lastVariableStatementNode.end; i < node.end; i++) {
var code = sourceFileText.charCodeAt(i);
if (code === 10) {
newLinesCount++;
if (!isNewLineRequired && newLinesCount > 1) {
unexpectedLineFixes.push(Lint.Replacement.deleteText(i, 1));
}
}
else if (code !== 9 && code !== 13 && code !== 32) {
var leadingComments = ts.getLeadingCommentRanges("\n" + sourceFileText.slice(i), 0);
var lastLeadingComment = leadingComments && leadingComments.pop();
if (lastLeadingComment && (!isNewLineRequired || (isNewLineRequired && newLinesCount < 2))) {
newLinesCount = 0;
expectedLinePos = i - 1 + lastLeadingComment.end;
i = expectedLinePos - 1;
}
else {
if (isNewLineRequired && newLinesCount < 2) {
expectedLineFixes.push(Lint.Replacement.appendText(expectedLinePos, '\n'));
}
break;
}
}
}
if (isNewLineRequired && expectedLineFixes[0]) {
_this.addFailureAt(lastVariableStatementNode.getStart(), 1, EXPECTED_BLANK_LINE_MESSAGE, expectedLineFixes);
}
else if (unexpectedLineFixes[0]) {
_this.addFailureAt(lastVariableStatementNode.getStart(), 1, UNEXPECTED_BLANK_LINE_MESSAGE, unexpectedLineFixes);
}
_this.lastVariableStatementNode = undefined;
}
return ts.forEachChild(node, onNode);
};
return ts.forEachChild(sourceFile, onNode);
};
return RuleWalker;
}(Lint.AbstractWalker));
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3Rlck5ld2xpbmVBZnRlclZhclJ1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsK0JBQWlDO0FBQ2pDLDZCQUErQjtBQUUvQixJQUFNLFNBQVMsR0FBVyx1QkFBdUIsQ0FBQztBQU1sRCxJQUFNLDJCQUEyQixHQUFXLGtEQUFrRCxDQUFDO0FBQy9GLElBQU0sNkJBQTZCLEdBQVcsb0RBQW9ELENBQUM7QUFFbkc7SUFBMEIsZ0NBQXVCO0lBQWpEOztJQWlEQSxDQUFDO0lBWFMsNEJBQWEsR0FBckIsVUFBdUIsRUFBeUI7WUFBeEIscUJBQWE7UUFDbkMsT0FBTztZQUNMLE1BQU0sRUFBRSxhQUFhLEtBQUssT0FBTztTQUNsQyxDQUFDO0lBQ0osQ0FBQztJQUVNLG9CQUFLLEdBQVosVUFBYyxVQUF5QjtRQUNyQyxJQUFNLEdBQUcsR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsQ0FBQztRQUNuRCxJQUFNLE1BQU0sR0FBRyxJQUFJLFVBQVUsQ0FBQyxVQUFVLEVBQUUsSUFBSSxDQUFDLFFBQVEsRUFBRSxHQUFHLENBQUMsQ0FBQztRQUM5RCxPQUFPLElBQUksQ0FBQyxlQUFlLENBQUMsTUFBTSxDQUFDLENBQUM7SUFDdEMsQ0FBQztJQS9DYSxhQUFRLEdBQXVCO1FBQzNDLFFBQVEsRUFBRSxTQUFTO1FBQ25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eUIsQ0FBQyxRQUFRLEVBQUUsRUFDcEMsQ0FBQyxFQUNELDJCQUEyQixFQUMzQixpQkFBaUIsQ0FDbEIsQ0FBQztpQkFDSDtxQkFBTSxJQUFJLG1CQUFtQixDQUFDLENBQUMsQ0FBQyxFQUFFO29CQUNqQyxLQUFJLENBQUMsWUFBWSxDQUNmLHlCQUF5QixDQUFDLFFBQVEsRUFBRSxFQUNwQyxDQUFDLEVBQ0QsNkJBQTZCLEVBQzdCLG1CQUFtQixDQUNwQixDQUFDO2lCQUNIO2dCQUVELEtBQUksQ0FBQyx5QkFBeUIsR0FBRyxTQUFTLENBQUM7YUFDNUM7WUFFRCxPQUFPLEVBQUUsQ0FBQyxZQUFZLENBQUMsSUFBSSxFQUFFLE1BQU0sQ0FBQyxDQUFDO1FBQ3ZDLENBQUMsQ0FBQztRQUVGLE9BQU8sRUFBRSxDQUFDLFlBQVksQ0FBQyxVQUFVLEVBQUUsTUFBTSxDQUFDLENBQUM7SUFDN0MsQ0FBQztJQUNILGlCQUFDO0FBQUQsQ0FwRkEsQUFvRkMsQ0FwRndCLElBQUksQ0FBQyxjQUFjLEdBb0YzQyIsImZpbGUiOiJydWxlcy90ZXJOZXdsaW5lQWZ0ZXJWYXJSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

View File

@@ -0,0 +1,84 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var RULE_NAME = 'ter-no-irregular-whitespace';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoIrregularWhitespaceWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.metadata = {
ruleName: RULE_NAME,
description: 'disallow irregular whitespace (recommended)',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code\n harder to debug in a similar nature to mixed tabs and spaces.\n "], ["\n Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code\n harder to debug in a similar nature to mixed tabs and spaces.\n "]))),
optionsDescription: '',
options: {},
optionExamples: [
Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n \"", "\": [true]\n "], ["\n \"", "\": [true]\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'typescript'
};
Rule.RULE_NAME = 'ter-no-irregular-whitespace';
Rule.FAILURE_STRING = 'irregular whitespace not allowed';
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoIrregularWhitespaceWalker = (function (_super) {
tslib_1.__extends(NoIrregularWhitespaceWalker, _super);
function NoIrregularWhitespaceWalker() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.IRREGULAR_WHITESPACE = /[\u0085\u00A0\ufeff\f\v\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/mg;
_this.IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/mg;
return _this;
}
NoIrregularWhitespaceWalker.prototype.visitSourceFile = function (node) {
this.validateIrregularWhitespace(node);
_super.prototype.visitSourceFile.call(this, node);
};
NoIrregularWhitespaceWalker.prototype.visitNode = function (node) {
if (node.kind === ts.SyntaxKind.StringLiteral) {
this.removeStringError(node);
}
_super.prototype.visitNode.call(this, node);
};
NoIrregularWhitespaceWalker.prototype.removeStringError = function (node) {
var start = node.getStart();
var end = node.getEnd();
var failures = this.getFailures();
for (var i = failures.length - 1; i >= 0; i--) {
var failure = failures[i];
if (failure.getRuleName() === Rule.RULE_NAME) {
if (failure.getStartPosition().getPosition() >= start && failure.getEndPosition().getPosition() <= end) {
failures.splice(i, 1);
}
}
}
};
NoIrregularWhitespaceWalker.prototype.validateIrregularWhitespace = function (node) {
var _this = this;
var lines = node.text.split(/\n/g);
lines.forEach(function (line, i) {
var match = _this.IRREGULAR_WHITESPACE.exec(line);
while (match) {
_this.addFailure(_this.createFailure(node.getPositionOfLineAndCharacter(i, match.index), 1, Rule.FAILURE_STRING));
match = _this.IRREGULAR_WHITESPACE.exec(line);
}
match = _this.IRREGULAR_LINE_TERMINATORS.exec(line);
while (match) {
_this.addFailure(_this.createFailure(node.getPositionOfLineAndCharacter(i, match.index), 1, Rule.FAILURE_STRING));
match = _this.IRREGULAR_LINE_TERMINATORS.exec(line);
}
});
};
return NoIrregularWhitespaceWalker;
}(Lint.RuleWalker));
var templateObject_1, templateObject_2;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3Rlck5vSXJyZWd1bGFyV2hpdGVzcGFjZVJ1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsK0JBQWlDO0FBQ2pDLDZCQUErQjtBQUUvQixJQUFNLFNBQVMsR0FBRyw2QkFBNkIsQ0FBQztBQUVoRDtJQUEwQixnQ0FBdUI7SUFBakQ7O0lBeUJBLENBQUM7SUFKUSxvQkFBSyxHQUFaLFVBQWEsVUFBeUI7UUFDcEMsSUFBTSxNQUFNLEdBQUcsSUFBSSwyQkFBMkIsQ0FBQyxVQUFVLEVBQUUsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDLENBQUM7UUFDOUUsT0FBTyxJQUFJLENBQUMsZUFBZSxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3RDLENBQUM7SUF2QmEsYUFBUSxHQUF1QjtRQUMzQyxRQUFRLEVBQUUsU0FBUztRQUNuQixXQUFXLEVBQUUsNkNBQTZDO1FBQzFELFNBQVMsRUFBRSxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sNlBBQUEsa0xBR3pCLElBQUE7UUFDSC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Q0FBQyw2QkFBNkIsQ0FBQyxDQUFDLEVBQUUsS0FBSyxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUMsRUFBRSxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztnQkFDaEgsS0FBSyxHQUFHLEtBQUksQ0FBQyxvQkFBb0IsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7YUFDOUM7WUFFRCxLQUFLLEdBQUcsS0FBSSxDQUFDLDBCQUEwQixDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztZQUNuRCxPQUFPLEtBQUssRUFBRTtnQkFDWixLQUFJLENBQUMsVUFBVSxDQUFDLEtBQUksQ0FBQyxhQUFhLENBQUMsSUFBSSxDQUFDLDZCQUE2QixDQUFDLENBQUMsRUFBRSxLQUFLLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQyxFQUFFLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDO2dCQUNoSCxLQUFLLEdBQUcsS0FBSSxDQUFDLDBCQUEwQixDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQzthQUNwRDtRQUNILENBQUMsQ0FBQyxDQUFDO0lBQ0wsQ0FBQztJQUNILGtDQUFDO0FBQUQsQ0FwREEsQUFvREMsQ0FwRHlDLElBQUksQ0FBQyxVQUFVLEdBb0R4RCIsImZpbGUiOiJydWxlcy90ZXJOb0lycmVndWxhcldoaXRlc3BhY2VSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

View File

@@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var tsutils_1 = require("tsutils");
var RULE_NAME = 'ter-no-mixed-spaces-and-tabs';
var OPTION_USE_TABS = 'tabs';
var OPTION_USE_SPACES = 'spaces';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.FAILURE_STRING = function (expected, mixed) {
if (!mixed) {
return expected + " indentation expected";
}
return "indentation has mixed tabs and spaces";
};
Rule.prototype.formatOptions = function (ruleArguments) {
var tabs = undefined;
var smartTabs = false;
var options = ruleArguments[0];
if (options !== undefined) {
tabs = options.type === OPTION_USE_TABS ? true : options.type === OPTION_USE_SPACES ? false : undefined;
smartTabs = options.smartTabs;
}
return {
tabs: tabs,
smartTabs: smartTabs
};
};
Rule.prototype.apply = function (sourceFile) {
var options = this.formatOptions(this.ruleArguments);
return this.applyWithFunction(sourceFile, walk, options);
};
Rule.metadata = {
ruleName: RULE_NAME,
description: 'Enforces indentation with unmixed tabs or spaces.',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using only one of tabs or spaces for indentation leads to more consistent editor behavior,\n cleaner diffs in version control, and easier programmatic manipulation."], ["\n Using only one of tabs or spaces for indentation leads to more consistent editor behavior,\n cleaner diffs in version control, and easier programmatic manipulation."]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n This rule takes an object argument with an optional `type` property which can be set to:\n\n * `", "` enforces consistent spaces for indentation.\n * `", "` enforces consistent tabs for indentation.\n\n If the above is not provided, the rule will enforce either all tabs or all spaces on each\n line, although different lines may differ between tabs and spaces.\n\n Optionally, a `smartTabs` boolean property can be specified. If set to true, smart tabs\n allow mixing tabs and spaces if tabs are used for indentation and spaces for alignment, eg.\n\n function main() {\n // --->const a = 1,\n // --->......b = 2;\n\n const a = 1,\n b = 2;\n }\n "], ["\n This rule takes an object argument with an optional \\`type\\` property which can be set to:\n\n * \\`", "\\` enforces consistent spaces for indentation.\n * \\`", "\\` enforces consistent tabs for indentation.\n\n If the above is not provided, the rule will enforce either all tabs or all spaces on each\n line, although different lines may differ between tabs and spaces.\n\n Optionally, a \\`smartTabs\\` boolean property can be specified. If set to true, smart tabs\n allow mixing tabs and spaces if tabs are used for indentation and spaces for alignment, eg.\n\n function main() {\n // --->const a = 1,\n // --->......b = 2;\n\n const a = 1,\n b = 2;\n }\n "])), OPTION_USE_SPACES, OPTION_USE_TABS),
options: {
type: 'array',
items: [
{
type: 'object',
properties: {
type: {
type: 'string',
enum: [OPTION_USE_TABS, OPTION_USE_SPACES]
},
smartTabs: {
type: 'boolean'
}
},
additionalProperties: false
}
],
minLength: 0,
maxLength: 1
},
optionExamples: [
Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n \"", "\": { \"type\": \"", "\" } ]\n "], ["\n \"", "\": { \"type\": \"", "\" } ]\n "])), RULE_NAME, OPTION_USE_TABS),
Lint.Utils.dedent(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["\n \"", "\": { \"type\": \"", "\" } ]\n "], ["\n \"", "\": { \"type\": \"", "\" } ]\n "])), RULE_NAME, OPTION_USE_SPACES),
Lint.Utils.dedent(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["\n \"", "\": { \"smartTabs\": true } ]\n "], ["\n \"", "\": { \"smartTabs\": true } ]\n "])), RULE_NAME),
Lint.Utils.dedent(templateObject_6 || (templateObject_6 = tslib_1.__makeTemplateObject(["\n \"", "\": { \"type\": \"", "\", \"smartTabs\": true } ]\n "], ["\n \"", "\": { \"type\": \"", "\", \"smartTabs\": true } ]\n "])), RULE_NAME, OPTION_USE_TABS)
],
type: 'maintainability',
typescriptOnly: false
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
var sourceFile = ctx.sourceFile, _a = ctx.options, tabs = _a.tabs, smartTabs = _a.smartTabs;
var regExp;
if (tabs === true) {
regExp = new RegExp(" " + (smartTabs ? '\\t' : ''));
}
else if (tabs === false) {
regExp = new RegExp("\\t");
}
else {
regExp = new RegExp((smartTabs ? '' : '\\t |') + " \\t");
}
var failure = Rule.FAILURE_STRING(tabs ? 'tab' : 'space', typeof tabs === 'undefined');
for (var _i = 0, _b = tsutils_1.getLineRanges(sourceFile); _i < _b.length; _i++) {
var _c = _b[_i], pos = _c.pos, contentLength = _c.contentLength;
if (contentLength === 0) {
continue;
}
var line = sourceFile.text.substr(pos, contentLength);
var indentEnd = line.search(/\S/);
if (indentEnd === 0) {
continue;
}
if (indentEnd === -1) {
indentEnd = contentLength;
}
var indentSpace = line.slice(0, indentEnd);
if (!regExp.test(indentSpace)) {
continue;
}
var token = tsutils_1.getTokenAtPosition(sourceFile, pos);
if (token.kind !== ts.SyntaxKind.JsxText &&
(pos >= token.getStart(sourceFile) || tsutils_1.isPositionInComment(sourceFile, pos, token))) {
continue;
}
ctx.addFailureAt(pos, indentEnd, failure);
}
}
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3Rlck5vTWl4ZWRTcGFjZXNBbmRUYWJzUnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwrQkFBaUM7QUFDakMsNkJBQStCO0FBQy9CLG1DQUFpRjtBQUVqRixJQUFNLFNBQVMsR0FBRyw4QkFBOEIsQ0FBQztBQU1qRCxJQUFNLGVBQWUsR0FBRyxNQUFNLENBQUM7QUFDL0IsSUFBTSxpQkFBaUIsR0FBRyxRQUFRLENBQUM7QUFFbkM7SUFBMEIsZ0NBQXVCO0lBQWpEOztJQTZGQSxDQUFDO0lBNUJlLG1CQUFjLEdBQTVCLFVBQTZCLFFBQWdCLEVBQUUsS0FBZTtRQUM1RCxJQUFJLENBQUMsS0FBSyxFQUFFO1lBQ1YsT0FBVSxRQUFRLDBCQUF1QixDQUFDO1NBQzNDO1FBRUQsT0FBTyx1Q0FBdUMsQ0FBQztJQUNqRCxDQUFDO0lBRU8sNEJBQWEsR0FBckIsVUFBc0IsYUFBb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require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var RULE_NAME = 'ter-no-proto';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
return this.applyWithFunction(sourceFile, walk);
};
Rule.FAILURE_STRING = 'The `__proto__` property is deprecated.';
Rule.metadata = {
ruleName: RULE_NAME,
hasFix: false,
description: 'disallow the use of `__proto__` property',
rationale: '`__proto__` property has been deprecated as of ECMAScript 3.1 and shouldnt be used in the code. Use getPrototypeOf method instead.',
optionsDescription: '',
options: {},
optionExamples: [Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n \"", "\": true\n "], ["\n \"", "\": true\n "])), RULE_NAME)],
typescriptOnly: false,
type: 'functionality'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
return ts.forEachChild(ctx.sourceFile, cb);
function cb(node) {
if ((node.kind === ts.SyntaxKind.Identifier &&
node.text === '__proto__' &&
node.parent &&
node.parent.kind === ts.SyntaxKind.PropertyAccessExpression) ||
(node.kind === ts.SyntaxKind.StringLiteral &&
node.text === '__proto__')) {
return ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
}
return ts.forEachChild(node, cb);
}
}
var templateObject_1;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3Rlck5vUHJvdG9SdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQU1BLCtCQUFpQztBQUNqQyw2QkFBK0I7QUFFL0IsSUFBTSxTQUFTLEdBQUcsY0FBYyxDQUFDO0FBRWpDO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUFxQkEsQ0FBQztJQUhRLG9CQUFLLEdBQVosVUFBYSxVQUF5QjtRQUNwQyxPQUFPLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxVQUFVLE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lCLENBQUMsSUFBSSxLQUFLLFdBQVcsQ0FBQyxFQUNsRDtZQUNBLE9BQU8sR0FBRyxDQUFDLGdCQUFnQixDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUM7U0FDeEQ7UUFDRCxPQUFPLEVBQUUsQ0FBQyxZQUFZLENBQUMsSUFBSSxFQUFFLEVBQUUsQ0FBQyxDQUFDO0lBQ25DLENBQUM7QUFDSCxDQUFDIiwiZmlsZSI6InJ1bGVzL3Rlck5vUHJvdG9SdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

View File

@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var RULE_NAME = 'ter-no-script-url';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
return this.applyWithFunction(sourceFile, walk);
};
Rule.FAILURE_STRING = 'Script URL is a form of eval.';
Rule.metadata = {
ruleName: RULE_NAME,
hasFix: false,
description: 'disallow use of `javascript:` urls.',
rationale: 'Using `javascript:` URLs is considered by some as a form of `eval`. ' +
'Code passed in `javascript:` URLs has to be parsed and evaluated by the browser ' +
'in the same way that eval is processed.',
optionsDescription: '',
options: {},
optionExamples: [
Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n \"", "\": true\n "], ["\n \"", "\": true\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'functionality'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
return ts.forEachChild(ctx.sourceFile, cb);
function cb(node) {
if (node.kind === ts.SyntaxKind.StringLiteral) {
var value = node.text.toLowerCase();
if (value.indexOf('javascript:') === 0) {
return ctx.addFailureAtNode(node, R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BQyxZQUFZLENBQUMsR0FBRyxDQUFDLFVBQVUsRUFBRSxFQUFFLENBQUMsQ0FBQztJQUUzQyxTQUFTLEVBQUUsQ0FBQyxJQUFhO1FBQ3ZCLElBQUksSUFBSSxDQUFDLElBQUksS0FBSyxFQUFFLENBQUMsVUFBVSxDQUFDLGFBQWEsRUFBRTtZQUM3QyxJQUFNLEtBQUssR0FBSSxJQUF5QixDQUFDLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQztZQUM1RCxJQUFJLEtBQUssQ0FBQyxPQUFPLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxFQUFFO2dCQUN0QyxPQUFPLEdBQUcsQ0FBQyxnQkFBZ0IsQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDO2FBQ3hEO1NBQ0Y7UUFDRCxPQUFPLEVBQUUsQ0FBQyxZQUFZLENBQUMsSUFBSSxFQUFFLEVBQUUsQ0FBQyxDQUFDO0lBQ25DLENBQUM7QUFDSCxDQUFDIiwiZmlsZSI6InJ1bGVzL3Rlck5vU2NyaXB0VXJsUnVsZS5qcyIsInNvdXJjZVJvb3QiOiIvVXNlcnMvam1sb3Blei90c2xpbnQtZXNsaW50LXJ1bGVzL3NyYyJ9

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var RULE_NAME = 'ter-no-self-compare';
var Rule = (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 NoSelfCompareWalker(sourceFile, this.ruleName, new Set(this.ruleArguments.map(String))));
};
Rule.FAILURE_STRING = 'Comparing to itself is potentially pointless.';
Rule.metadata = {
ruleName: RULE_NAME,
hasFix: false,
description: 'disallow comparisons where both sides are exactly the same',
rationale: 'Comparing a variable against itself is usually an error, ' +
'either a typo or refactoring error. It is confusing to the reader ' +
'and may potentially introduce a runtime error.',
optionsDescription: '',
options: {},
optionExamples: [
Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n \"", "\": true\n "], ["\n \"", "\": true\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'maintainability'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoSelfCompareWalker = (function (_super) {
tslib_1.__extends(NoSelfCompareWalker, _super);
function NoSelfCompareWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoSelfCompareWalker.prototype.isComparisonOperator = function (node) {
var operators = new Set([
ts.SyntaxKind.EqualsEqualsEqualsToken,
ts.SyntaxKind.EqualsEqualsToken,
ts.SyntaxKind.ExclamationEqualsEqualsToken,
ts.SyntaxKind.ExclamationEqualsToken,
ts.SyntaxKind.GreaterThanToken,
ts.SyntaxKind.LessThanToken,
ts.SyntaxKind.GreaterThanEqualsToken,
ts.SyntaxKind.LessThanEqualsToken
]);
return operators.has(node.operatorToken.kind);
};
NoSelfCompareWalker.prototype.hasSameToken = function (left, right) {
return left.kind === right.kind && left.getText() === right.getText();
};
NoSelfCompareWalker.prototype.walk = function (sourceFile) {
var _this = this;
var cb = function (node) {
if (ts.isBinaryExpression(node)) {
var nodeExpr = node;
if (_this.isComparisonOperator(nodeExpr) &&
_this.hasSameToken(nodeExpr.left, nodeExpr.right)) {
_this.addFailureAt(nodeExpr.operatorToken.getStart(), nodeExpr.operatorToken.getWidth(), Rule.FAILURE_STRING);
}
}
else {
return ts.forEachChild(node, cb);
}
};
return ts.forEachChild(sourceFile, cb);
};
return NoSelfCompareWalker;
}(Lint.AbstractWalker));
var templateObject_1;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3Rlck5vU2VsZkNvbXBhcmVSdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQU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FBUSxDQUFDLEtBQUssQ0FBQyxFQUNoRDtvQkFDQSxLQUFJLENBQUMsWUFBWSxDQUNmLFFBQVEsQ0FBQyxhQUFhLENBQUMsUUFBUSxFQUFFLEVBQ2pDLFFBQVEsQ0FBQyxhQUFhLENBQUMsUUFBUSxFQUFFLEVBQ2pDLElBQUksQ0FBQyxjQUFjLENBQ3BCLENBQUM7aUJBQ0g7YUFDRjtpQkFBTTtnQkFFTCxPQUFPLEVBQUUsQ0FBQyxZQUFZLENBQUMsSUFBSSxFQUFFLEVBQUUsQ0FBQyxDQUFDO2FBQ2xDO1FBQ0gsQ0FBQyxDQUFDO1FBR0YsT0FBTyxFQUFFLENBQUMsWUFBWSxDQUFDLFVBQVUsRUFBRSxFQUFFLENBQUMsQ0FBQztJQUN6QyxDQUFDO0lBQ0gsMEJBQUM7QUFBRCxDQTNDQSxBQTJDQyxDQTNDaUMsSUFBSSxDQUFDLGNBQWMsR0EyQ3BEIiwiZmlsZSI6InJ1bGVzL3Rlck5vU2VsZkNvbXBhcmVSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

View File

@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var RULE_NAME = 'ter-no-sparse-arrays';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new NoSparseArraysWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.metadata = {
ruleName: RULE_NAME,
description: 'disallow sparse arrays (recommended)',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code\n harder to debug in a similar nature to mixed tabs and spaces.\n "], ["\n Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code\n harder to debug in a similar nature to mixed tabs and spaces.\n "]))),
optionsDescription: '',
options: {},
optionExamples: [
Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n \"", "\": [true]\n "], ["\n \"", "\": [true]\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'typescript'
};
Rule.FAILURE_STRING = 'unexpected comma in middle of array';
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var NoSparseArraysWalker = (function (_super) {
tslib_1.__extends(NoSparseArraysWalker, _super);
function NoSparseArraysWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoSparseArraysWalker.prototype.visitArrayLiteralExpression = function (node) {
this.validateNoSparseArray(node);
_super.prototype.visitArrayLiteralExpression.call(this, node);
};
NoSparseArraysWalker.prototype.validateNoSparseArray = function (node) {
var hasEmptySlot = node.elements.some(function (el) { return el.kind === ts.SyntaxKind.OmittedExpression; });
if (hasEmptySlot) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
};
return NoSparseArraysWalker;
}(Lint.RuleWalker));
var templateObject_1, templateObject_2;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3Rlck5vU3BhcnNlQXJyYXlzUnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwrQkFBaUM7QUFDakMsNkJBQStCO0FBRS9CLElBQU0sU0FBUyxHQUFHLHNCQUFzQixDQUFDO0FBRXpDO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUF3QkEsQ0FBQztJQUpRLG9CQUFLLEdBQVosVUFBYSxVQUF5QjtRQUNwQyxJQUFNLE1BQU0sR0FBRyxJQUFJLG9CQUFvQixDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsVUFBVSxFQUFFLENBQUMsQ0FBQztRQUN2RSxPQ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UFBWSxFQUFFO1lBQ2hCLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLFFBQVEsRUFBRSxFQUFFLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDO1NBQzVGO0lBQ0gsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0FiQSxBQWFDLENBYmtDLElBQUksQ0FBQyxVQUFVLEdBYWpEIiwiZmlsZSI6InJ1bGVzL3Rlck5vU3BhcnNlQXJyYXlzUnVsZS5qcyIsInNvdXJjZVJvb3QiOiIvVXNlcnMvam1sb3Blei90c2xpbnQtZXNsaW50LXJ1bGVzL3NyYyJ9

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Lint = require("tslint");
var RULE_NAME = 'ter-no-tabs';
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
return this.applyWithFunction(sourceFile, walk);
};
Rule.FAILURE_STRING = 'Unexpected tab character.';
Rule.metadata = {
ruleName: RULE_NAME,
hasFix: false,
description: 'disallow all tabs',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n This rule looks for tabs anywhere inside a file: code, comments or anything else, and disallows their usage.\n "], ["\n This rule looks for tabs anywhere inside a file: code, comments or anything else, and disallows their usage.\n "]))),
optionsDescription: '',
options: {},
optionExamples: [
Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n \"", "\": true\n "], ["\n \"", "\": true\n "])), RULE_NAME)
],
typescriptOnly: false,
type: 'style'
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function walk(ctx) {
var TAB_REGEX = /\t/;
var lines = ctx.sourceFile.text.split(/\n/g);
lines.forEach(function (line, i) {
var match = TAB_REGEX.exec(line);
if (match) {
ctx.addFailureAt(ctx.sourceFile.getPositionOfLineAndCharacter(i, match.index), 1, Rule.FAILURE_STRING);
}
});
}
var templateObject_1, templateObject_2;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3Rlck5vVGFic1J1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBUUEsNkJBQStCO0FBRS9CLElBQU0sU0FBUyxHQUFHLGFBQWEsQ0FBQztBQUVoQztJQUEwQixnQ0FBdUI7SUFBakQ7O0lBdUJBLENBQUM7SUFIUSxvQkFBSyxHQUFaLFVBQWEsVUFBeUI7UUFDcEMsT0FBTyxJQUFJLENBQUMsaUJBQWlCLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxDQUFDO0lBQ2xELENBQUM7SUFyQmEsbUJBQWMsR0FBRywyQkFBMkIsQ0FBQztJQUM3QyxhQUFRLEdBQXVCO1FBQzNDLFFBQVEsRUFBRSxTQUFTO1FBQ25CLE1BQU0sRUFBRSxLQUFLO1FBQ2IsV0FBVyxFQUFFLG1CQUFtQjtRQUNoQyxTQUFTLEVBQUUsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLHlNQUFBLDhIQUV6QixJQUFBO1FBQ0gsa0JBQWtCLEVBQUUsRUFBRTtRQUN0QixPQUFPLEVBQUUsRUFBRTtRQUNYLGNBQWMsRUFBRTtZQUNkLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSwrR0FBQSxjQUNaLEVBQVMsb0JBQ1gsS0FERSxTQUFTO1NBRWY7UUFDRCxjQUFjLEVBQUUsS0FBSztRQUNyQixJQUFJLEVBQUUsT0FBTztLQUNkLENBQUM7SUFLSixXQUFDO0NBdkJELEFBdUJDLENBdkJ5QixJQUFJLENBQUMsS0FBSyxDQUFDLFlBQVksR0F1QmhEO0FBdkJZLG9CQUFJO0FBeUJqQixTQUFTLElBQUksQ0FBQyxHQUEyQjtJQUN2QyxJQUFNLFNBQVMsR0FBRyxJQUFJLENBQUM7SUFDdkIsSUFBTSxLQUFLLEdBQUcsR0FBRyxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLEtBQUssQ0FBQyxDQUFDO0lBRS9DLEtBQUssQ0FBQyxPQUFPLENBQUMsVUFBQyxJQUFJLEVBQUUsQ0FBQztRQUNwQixJQUFNLEtBQUssR0FBRyxTQUFTLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ25DLElBQUksS0FBSyxFQUFFO1lBQ1QsR0FBRyxDQUFDLFlBQVksQ0FDZCxHQUFHLENBQUMsVUFBVSxDQUFDLDZCQUE2QixDQUFDLENBQUMsRUFBRSxLQUFLLENBQUMsS0FBSyxDQUFDLEVBQzVELENBQUMsRUFDRCxJQUFJLENBQUMsY0FBYyxDQUNwQixDQUFDO1NBQ0g7SUFDSCxDQUFDLENBQUMsQ0FBQztBQUNMLENBQUMiLCJmaWxlIjoicnVsZXMvdGVyTm9UYWJzUnVsZS5qcyIsInNvdXJjZVJvb3QiOiIvVXNlcnMvam1sb3Blei90c2xpbnQtZXNsaW50LXJ1bGVzL3NyYyJ9

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var ts = require("typescript");
var Lint = require("tslint");
var Rule = (function (_super) {
tslib_1.__extends(Rule, _super);
function Rule() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rule.prototype.apply = function (sourceFile) {
var walker = new ValidTypeofWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
};
Rule.FAILURE_STRING = 'invalid typeof comparison value';
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
var ValidTypeofWalker = (function (_super) {
tslib_1.__extends(ValidTypeofWalker, _super);
function ValidTypeofWalker() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.VALID_TYPES = ['symbol', 'undefined', 'object', 'boolean', 'number', 'string', 'function'];
_this.OPERATORS = [ts.SyntaxKind.EqualsEqualsToken, ts.SyntaxKind.EqualsEqualsEqualsToken, ts.SyntaxKind.ExclamationEqualsToken, ts.SyntaxKind.ExclamationEqualsEqualsToken];
return _this;
}
ValidTypeofWalker.prototype.visitNode = function (node) {
if (node.kind === ts.SyntaxKind.TypeOfExpression) {
this.validateTypeOf(node);
}
_super.prototype.visitNode.call(this, node);
};
ValidTypeofWalker.prototype.validateTypeOf = function (node) {
if (node.parent && node.parent.kind === ts.SyntaxKind.BinaryExpression) {
var parent = node.parent;
if (this.OPERATORS.indexOf(parent.operatorToken.kind) !== -1) {
var sibling = parent.left === node ? parent.right : parent.left;
if (sibling.kind === ts.SyntaxKind.StringLiteral && this.VALID_TYPES.indexOf(sibling.text) === -1) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
}
}
};
return ValidTypeofWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3ZhbGlkVHlwZW9mUnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwrQkFBaUM7QUFDakMsNkJBQStCO0FBRS9CO0lBQTBCLGdDQUF1QjtJQUFqRDs7SUFPQSxDQUFDO0lBSlEsb0JBQUssR0FBWixVQUFhLFVBQXlCO1FBQ3BDLElBQU0sTUFBTSxHQUFHLElBQUksaUJBQWlCLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQyxDQUFDO1FBQ3BFLE9BQU8sSUFBSSxDQUFDLGVBQWUsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUN0QyxDQUFDO0lBTGEsbUJBQWMsR0FBRyxpQ0FBaUMs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QUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLEVBQUU7Z0JBQzVELElBQU0sT0FBTyxHQUFHLE1BQU0sQ0FBQyxJQUFJLEtBQUssSUFBSSxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDO2dCQUVsRSxJQUFJLE9BQU8sQ0FBQyxJQUFJLEtBQUssRUFBRSxDQUFDLFVBQVUsQ0FBQyxhQUFhLElBQUksSUFBSSxDQUFDLFdBQVcsQ0FBQyxPQUFPLENBQUUsT0FBNEIsQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsRUFBRTtvQkFDdkgsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDLENBQUM7aUJBQzVGO2FBQ0Y7U0FDRjtJQUNILENBQUM7SUFDSCx3QkFBQztBQUFELENBdkJBLEFBdUJDLENBdkIrQixJQUFJLENBQUMsVUFBVSxHQXVCOUMiLCJmaWxlIjoicnVsZXMvdmFsaWRUeXBlb2ZSdWxlLmpzIiwic291cmNlUm9vdCI6Ii9Vc2Vycy9qbWxvcGV6L3RzbGludC1lc2xpbnQtcnVsZXMvc3JjIn0=

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("typescript");
function isAssignmentToken(token) {
return token.kind >= ts.SyntaxKind.FirstAssignment && token.kind <= ts.SyntaxKind.LastAssignment;
}
exports.isAssignmentToken = isAssignmentToken;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN1cHBvcnQvdG9rZW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwrQkFBaUM7QUFFakMsU0FBZ0IsaUJBQWlCLENBQUMsS0FBYztJQUM5QyxPQUFPLEtBQUssQ0FBQyxJQUFJLElBQUksRUFBRSxDQUFDLFVBQVUsQ0FBQyxlQUFlLElBQUksS0FBSyxDQUFDLElBQUksSUFBSSxFQUFFLENBQUMsVUFBVSxDQUFDLGNBQWMsQ0FBQztBQUNuRyxDQUFDO0FBRkQsOENBRUMiLCJmaWxlIjoic3VwcG9ydC90b2tlbi5qcyIsInNvdXJjZVJvb3QiOiIvVXNlcnMvam1sb3Blei90c2xpbnQtZXNsaW50LXJ1bGVzL3NyYyJ9

5
node_modules/tslint-eslint-rules/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// unopinionated extensable tslint configuration
// loads rules for extending packages, but does not enable any
module.exports = {
rulesDirectory: "./dist/rules",
};

View File

@@ -0,0 +1 @@
*.js linguist-language=TypeScript

View File

@@ -0,0 +1,15 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */

View File

@@ -0,0 +1,55 @@
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:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
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
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

View File

@@ -0,0 +1,134 @@
# tslib
This is a runtime library for [TypeScript](http://www.typescriptlang.org/) that contains all of the TypeScript helper functions.
This library is primarily used by the `--importHelpers` flag in TypeScript.
When using `--importHelpers`, a module that uses helper functions like `__extends` and `__assign` in the following emitted file:
```ts
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
exports.x = {};
exports.y = __assign({}, exports.x);
```
will instead be emitted as something like the following:
```ts
var tslib_1 = require("tslib");
exports.x = {};
exports.y = tslib_1.__assign({}, exports.x);
```
Because this can avoid duplicate declarations of things like `__extends`, `__assign`, etc., this means delivering users smaller files on average, as well as less runtime overhead.
For optimized bundles with TypeScript, you should absolutely consider using `tslib` and `--importHelpers`.
# Installing
For the latest stable version, run:
## npm
```sh
# TypeScript 2.3.3 or later
npm install --save tslib
# TypeScript 2.3.2 or earlier
npm install --save tslib@1.6.1
```
## bower
```sh
# TypeScript 2.3.3 or later
bower install tslib
# TypeScript 2.3.2 or earlier
bower install tslib@1.6.1
```
## JSPM
```sh
# TypeScript 2.3.3 or later
jspm install tslib
# TypeScript 2.3.2 or earlier
jspm install tslib@1.6.1
```
# Usage
Set the `importHelpers` compiler option on the command line:
```
tsc --importHelpers file.ts
```
or in your tsconfig.json:
```json
{
"compilerOptions": {
"importHelpers": true
}
}
```
#### For bower and JSPM users
You will need to add a `paths` mapping for `tslib`, e.g. For Bower users:
```json
{
"compilerOptions": {
"module": "amd",
"importHelpers": true,
"baseUrl": "./",
"paths": {
"tslib" : ["bower_components/tslib/tslib.d.ts"]
}
}
}
```
For JSPM users:
```json
{
"compilerOptions": {
"module": "system",
"importHelpers": true,
"baseUrl": "./",
"paths": {
"tslib" : ["jspm_packages/npm/tslib@1.9.0/tslib.d.ts"]
}
}
}
```
# Contribute
There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).
* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
* Read the language specification ([docx](http://go.microsoft.com/fwlink/?LinkId=267121), [pdf](http://go.microsoft.com/fwlink/?LinkId=267238)).
# Documentation
* [Quick tutorial](http://www.typescriptlang.org/Tutorial)
* [Programming handbook](http://www.typescriptlang.org/Handbook)
* [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)
* [Homepage](http://www.typescriptlang.org/)

View File

@@ -0,0 +1,34 @@
{
"name": "tslib",
"authors": [
"Microsoft Corp."
],
"homepage": "http://typescriptlang.org/",
"version": "1.9.0",
"license": "Apache-2.0",
"description": "Runtime library for TypeScript helper functions",
"keywords": [
"TypeScript",
"Microsoft",
"compiler",
"language",
"javascript",
"tslib",
"runtime"
],
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/tslib.git"
},
"main": "tslib.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"docs",
"package.json",
".npmignore",
".gitignore",
".gitattributes"
]
}

View File

@@ -0,0 +1,486 @@
# The `__generator` helper
The `__generator` helper is a function designed to support TypeScript's down-level emit for
async functions when targeting ES5 and earlier. But how, exactly, does it work?
Here's the body of the `__generator` helper:
```js
__generator = function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;
return { next: verb(0), "throw": verb(1), "return": verb(2) };
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
```
And here's an example of it in use:
```ts
// source
async function func(x) {
try {
await x;
}
catch (e) {
console.error(e);
}
finally {
console.log("finally");
}
}
// generated
function func(x) {
return __awaiter(this, void 0, void 0, function () {
var e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 1, 3, 4]);
return [4 /*yield*/, x];
case 1:
_a.sent();
return [3 /*break*/, 4];
case 2:
e_1 = _a.sent();
console.error(e_1);
return [3 /*break*/, 4];
case 3:
console.log("finally");
return [7 /*endfinally*/];
case 4: return [2 /*return*/];
}
});
});
}
```
There is a lot going on in this function, so the following will break down what each part of the
`__generator` helper does and how it works.
# Opcodes
The `__generator` helper uses opcodes which represent various operations that are interpreted by
the helper to affect its internal state. The following table lists the various opcodes, their
arguments, and their purpose:
| Opcode | Arguments | Purpose |
|----------------|-----------|--------------------------------------------------------------------------------------------------------------------------------|
| 0 (next) | *value* | Starts the generator, or resumes the generator with *value* as the result of the `AwaitExpression` where execution was paused. |
| 1 (throw) | *value* | Resumes the generator, throwing *value* at `AwaitExpression` where execution was paused. |
| 2 (return) | *value* | Exits the generator, executing any `finally` blocks starting at the `AwaitExpression` where execution was paused. |
| 3 (break) | *label* | Performs an unconditional jump to the specified label, executing any `finally` between the current instruction and the label. |
| 4 (yield) | *value* | Suspends the generator, setting the resume point at the next label and yielding the value. |
| 5 (yieldstar) | *value* | Suspends the generator, setting the resume point at the next label and delegating operations to the supplied value. |
| 6 (catch) | *error* | An internal instruction used to indicate an exception that was thrown from the body of the generator. |
| 7 (endfinally) | | Exits a finally block, resuming any previous operation (such as a break, return, throw, etc.) |
# State
The `_`, `f`, `y`, and `t` variables make up the persistent state of the `__generator` function. Each variable
has a specific purpose, as described in the following sections:
## The `_` variable
The `__generator` helper must share state between its internal `step` orchestration function and
the `body` function passed to the helper.
```ts
var _ = {
label: 0,
sent: function() {
if (t[0] & 1) // NOTE: true for `throw`, but not `next` or `catch`
throw t[1];
return sent[1];
},
trys: [],
ops: []
};
```
The following table describes the members of the `_` state object and their purpose:
| Name | Description |
|---------|---------------------------------------------------------------------------------------------------------------------------|
| `label` | Specifies the next switch case to execute in the `body` function. |
| `sent` | Handles the completion result passed to the generator. |
| `trys` | A stack of **Protected Regions**, which are 4-tuples that describe the labels that make up a `try..catch..finally` block. |
| `ops` | A stack of pending operations used for `try..finally` blocks. |
The `__generator` helper passes this state object to the `body` function for use with switching
between switch cases in the body, handling completions from `AwaitExpression`, etc.
## The `f` variable
The `f` variable indicates whether the generator is currently executing, to prevent re-entry of
the same generator during its execution.
## The `y` variable
The `y` variable stores the iterator passed to a `yieldstar` instruction to which operations should be delegated.
## The `t` variable
The `t` variable is a temporary variable that stores one of the following values:
- The completion value when resuming from a `yield` or `yield*`.
- The error value for a catch block.
- The current **Protected Region**.
- The verb (`next`, `throw`, or `return` method) to delegate to the expression of a `yield*`.
- The result of evaluating the verb delegated to the expression of a `yield*`.
> NOTE: None of the above cases overlap.
# Protected Regions
A **Protected Region** is a region within the `body` function that indicates a
`try..catch..finally` statement. It consists of a 4-tuple that contains 4 labels:
| Offset | Description |
|--------|-----------------------------------------------------------------------------------------|
| 0 | *Required* The label that indicates the beginning of a `try..catch..finally` statement. |
| 1 | *Optional* The label that indicates the beginning of a `catch` clause. |
| 2 | *Optional* The label that indicates the beginning of a `finally` clause. |
| 3 | *Required* The label that indicates the end of the `try..catch..finally` statement. |
# The generator object
The final step of the `__generator` helper is the allocation of an object that implements the
`Generator` protocol, to be used by the `__awaiter` helper:
```ts
return { next: verb(0), "throw": verb(1), "return": verb(2) };
function verb(n) { return function (v) { return step([n, v]); }; }
```
This object translates calls to `next`, `throw`, and `return` to the appropriate Opcodes and
invokes the `step` orchestration function to continue execution. The `throw` and `return` method
names are quoted to better support ES3.
# Orchestration
The `step` function is the main orechestration mechanism for the `__generator` helper. It
interprets opcodes, handles **protected regions**, and communicates results back to the caller.
Here's a closer look at the `step` function:
```ts
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
```
The main body of `step` exists in a `while` loop. This allows us to continually interpret
operations until we have reached some completion value, be it a `return`, `await`, or `throw`.
## Preventing re-entry
The first part of the `step` function is used as a check to prevent re-entry into a currently
executing generator:
```ts
if (f) throw new TypeError("Generator is already executing.");
```
## Running the generator
The main body of the `step` function consists of a `while` loop which continues to evaluate
instructions until the generator exits or is suspended:
```ts
while (_) try ...
```
When the generator has run to completion, the `_` state variable will be cleared, forcing the loop
to exit.
## Evaluating the generator body.
```ts
try {
...
op = body.call(thisArg, _);
}
catch (e) {
op = [6, e];
y = 0;
}
finally {
f = t = 0;
}
```
Depending on the current operation, we re-enter the generator body to start or continue execution.
Here we invoke `body` with `thisArg` as the `this` binding and the `_` state object as the only
argument. The result is a tuple that contains the next Opcode and argument.
If evaluation of the body resulted in an exception, we convert this into an Opcode 6 ("catch")
operation to be handled in the next spin of the `while` loop. We also clear the `y` variable in
case it is set to ensure we are no longer delegating operations as the exception occurred in
user code *outside* of, or at the function boundary of, the delegated iterator (otherwise the
iterator would have handled the exception itself).
After executing user code, we clear the `f` flag that indicates we are executing the generator,
as well as the `t` temporary value so that we don't hold onto values sent to the generator for
longer than necessary.
Inside of the `try..finally` statement are a series of statements that are used to evaluate the
operations of the transformed generator body.
The first thing we do is mark the generator as executing:
```ts
if (f = 1, ...)
```
Despite the fact this expression is part of the head of an `if` statement, the comma operator
causes it to be evaluated and the result thrown out. This is a minification added purely to
reduce the overall footprint of the helper.
## Delegating `yield*`
The first two statements of the `try..finally` statement handle delegation for `yield*`:
```ts
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
```
If the `y` variable is set, and `y` has a `next`, `throw`, or `return` method (depending on the
current operation), we invoke this method and store the return value (an IteratorResult) in `t`.
If `t` indicates it is a yielded value (e.g. `t.done === false`), we return `t` to the caller.
If `t` indicates it is a returned value (e.g. `t.done === true`), we mark the operation with the
`next` Opcode, and the returned value.
If `y` did not have the appropriate method, or `t` was a returned value, we reset `y` to a falsey
value and continue processing the operation.
## Handling operations
The various Opcodes are handled in the following switch statement:
```ts
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
```
The following sections describe the various Opcodes:
### Opcode 0 ("next") and Opcode 1 ("throw")
```ts
case 0: // next
case 1: // throw
t = op;
break;
```
Both Opcode 0 ("next") and Opcode 1 ("throw") have the same behavior. The current operation is
stored in the `t` variable and the `body` function is invoked. The `body` function should call
`_.sent()` which will evaluate the appropriate completion result.
### Opcode 4 ("yield")
```ts
case 4: // yield
_.label++;
return { value: op[1], done: false };
```
When we encounter Opcode 4 ("yield"), we increment the label by one to indicate the point at which
the generator will resume execution. We then return an `IteratorResult` whose `value` is the
yielded value, and `done` is `false`.
### Opcode 5 ("yieldstar")
```ts
case 5: // yieldstar
_.label++;
y = op[1];
op = [0];
continue;
```
When we receive Opcode 5 ("yieldstar"), we increment the label by one to indicate the point at which
the generator will resume execution. We then store the iterator in `op[1]` in the `y` variable, and
set the operation to delegate to Opcode 0 ("next") with no value. Finally, we continue execution at
the top of the loop to start delegation.
### Opcode 7 ("endfinally")
```ts
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
```
Opcode 7 ("endfinally") indicates that we have hit the end of a `finally` clause, and that the last
operation recorded before entering the `finally` block should be evaluated.
### Opcode 2 ("return"), Opcode 3 ("break"), and Opcode 6 ("catch")
```ts
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2])
_.ops.pop();
_.trys.pop();
continue;
}
```
The handling for Opcode 2 ("return"), Opcode 3 ("break") and Opcode 6 ("catch") is more
complicated, as we must obey the specified runtime semantics of generators. The first line in this
clause gets the current **Protected Region** if found and stores it in the `t` temp variable:
```ts
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && ...) ...
```
The remainder of this statement, as well as the following by several `if` statements test for more
complex conditions. The first of these is the following:
```ts
if (!(t = ...) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
```
If we encounter an Opcode 6 ("catch") or Opcode 2 ("return"), and we are not in a protected region,
then this operation completes the generator by setting the `_` variable to a falsey value. The
`continue` statement resumes execution at the top of the `while` statement, which will exit the loop
so that we continue execution at the statement following the loop.
```ts
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
_.label = op[1];
break;
}
```
The `if` statement above handles Opcode 3 ("break") when we are either not in a **protected region**, or
are performing an unconditional jump to a label inside of the current **protected region**. In this case
we can unconditionally jump to the specified label.
```ts
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
```
The `if` statement above handles Opcode 6 ("catch") when inside the `try` block of a **protected
region**. In this case we jump to the `catch` block, if present. We replace the value of `t` with
the operation so that the exception can be read as the first statement of the transformed `catch`
clause of the transformed generator body.
```ts
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
```
This `if` statement handles all Opcodes when in a **protected region** with a `finally` clause.
As long as we are not already inside the `finally` clause, we jump to the `finally` clause and
push the pending operation onto the `_.ops` stack. This allows us to resume execution of the
pending operation once we have completed execution of the `finally` clause, as long as it does not
supersede this operation with its own completion value.
```ts
if (t[2])
_.ops.pop();
```
Any other completion value inside of a `finally` clause will supersede the pending completion value
from the `try` or `catch` clauses. The above `if` statement pops the pending completion from the
stack.
```ts
_.trys.pop();
continue;
```
The remaining statements handle the point at which we exit a **protected region**. Here we pop the
current **protected region** from the stack and spin the `while` statement to evaluate the current
operation again in the next **protected region** or at the function boundary.
## Handling a completed generator
Once the generator has completed, the `_` state variable will be falsey. As a result, the `while`
loop will terminate and hand control off to the final statement of the orchestration function,
which deals with how a completed generator is evaluated:
```ts
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
```
If the caller calls `throw` on the generator it will send Opcode 1 ("throw"). If an exception
is uncaught within the body of the generator, it will send Opcode 6 ("catch"). As the generator has
completed, it throws the exception. Both of these cases are caught by the bitmask `5`, which does
not collide with the only two other valid completion Opcodes.
If the caller calls `next` on the generator, it will send Opcode 0 ("next"). As the generator has
completed, it returns an `IteratorResult` where `value` is `undefined` and `done` is true.
If the caller calls `return` on the generator, it will send Opcode 2 ("return"). As the generator
has completed, it returns an `IteratorResult` where `value` is the value provided to `return`, and
`done` is true.

View File

@@ -0,0 +1,28 @@
{
"name": "tslib",
"author": "Microsoft Corp.",
"homepage": "http://typescriptlang.org/",
"version": "1.9.0",
"license": "Apache-2.0",
"description": "Runtime library for TypeScript helper functions",
"keywords": [
"TypeScript",
"Microsoft",
"compiler",
"language",
"javascript",
"tslib",
"runtime"
],
"bugs": {
"url": "https://github.com/Microsoft/TypeScript/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/tslib.git"
},
"main": "tslib.js",
"module": "tslib.es6.js",
"jsnext:main": "tslib.es6.js",
"typings": "tslib.d.ts"
}

View File

@@ -0,0 +1,33 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
export declare function __extends(d: Function, b: Function): void;
export declare function __assign(t: any, ...sources: any[]): any;
export declare function __rest(t: any, propertyNames: (string | symbol)[]): any;
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
export declare function __param(paramIndex: number, decorator: Function): Function;
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;
export declare function __generator(thisArg: any, body: Function): any;
export declare function __exportStar(m: any, exports: any): void;
export declare function __values(o: any): any;
export declare function __read(o: any, n?: number): any[];
export declare function __spread(...args: any[]): any[];
export declare function __await(v: any): any;
export declare function __asyncGenerator(thisArg: any, _arguments: any, generator: Function): any;
export declare function __asyncDelegator(o: any): any;
export declare function __asyncValues(o: any): any;
export declare function __makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray;
export declare function __importStar<T>(mod: T): T;
export declare function __importDefault<T>(mod: T): T | { default: T };

View File

@@ -0,0 +1 @@
<script src="tslib.es6.js"></script>

View File

@@ -0,0 +1,178 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
export function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
export var __assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
}
export function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
export function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
export function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
export function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
export function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
export function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
export function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
export function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
export function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
export function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
export function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
export function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
export function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
}
export function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator];
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
}
export function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
export function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
export function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}

View File

@@ -0,0 +1 @@
<script src="tslib.js"></script>

View File

@@ -0,0 +1,241 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global global, define, System, Reflect, Promise */
var __extends;
var __assign;
var __rest;
var __decorate;
var __param;
var __metadata;
var __awaiter;
var __generator;
var __exportStar;
var __values;
var __read;
var __spread;
var __await;
var __asyncGenerator;
var __asyncDelegator;
var __asyncValues;
var __makeTemplateObject;
var __importStar;
var __importDefault;
(function (factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
if (typeof define === "function" && define.amd) {
define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); });
}
else if (typeof module === "object" && typeof module.exports === "object") {
factory(createExporter(root, createExporter(module.exports)));
}
else {
factory(createExporter(root));
}
function createExporter(exports, previous) {
if (exports !== root) {
if (typeof Object.create === "function") {
Object.defineProperty(exports, "__esModule", { value: true });
}
else {
exports.__esModule = true;
}
}
return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };
}
})
(function (exporter) {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
__extends = function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
__rest = function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};
__decorate = function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__param = function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
__metadata = function (metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
};
__awaiter = function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
__generator = function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
__exportStar = function (m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
};
__values = function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
__read = function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
__spread = function () {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
};
__await = function (v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
};
__asyncGenerator = function (thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
};
__asyncDelegator = function (o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; }
};
__asyncValues = function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator];
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
};
__makeTemplateObject = function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
__importStar = function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
__importDefault = function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exporter("__extends", __extends);
exporter("__assign", __assign);
exporter("__rest", __rest);
exporter("__decorate", __decorate);
exporter("__param", __param);
exporter("__metadata", __metadata);
exporter("__awaiter", __awaiter);
exporter("__generator", __generator);
exporter("__exportStar", __exportStar);
exporter("__values", __values);
exporter("__read", __read);
exporter("__spread", __spread);
exporter("__await", __await);
exporter("__asyncGenerator", __asyncGenerator);
exporter("__asyncDelegator", __asyncDelegator);
exporter("__asyncValues", __asyncValues);
exporter("__makeTemplateObject", __makeTemplateObject);
exporter("__importStar", __importStar);
exporter("__importDefault", __importDefault);
});

View File

@@ -0,0 +1,12 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
[*.{json,yml,md}]
indent_size = 2

View File

@@ -0,0 +1,2 @@
exclude:
- test/rules/**

View File

@@ -0,0 +1,5 @@
extends: wotan:recommended
rules:
# TODO enable once https://github.com/Microsoft/TypeScript/issues/24706 is resolved
no-useless-assertion: off
no-useless-predicate: off

View File

@@ -0,0 +1,741 @@
# 3.17.1
**Bugfixes:**
* `isValidJsxIdentifier`, `isValidPropertyAccess`, `isValidPropertyName`: fix unicode character width handling
# 3.17.0
**Features:**
* `isValidJsxIdentifier` added an optional parameter to specify the target ECMAScript version
**Bugfixes:**
* `isValidJsxIdentifier` now handles astral plane characters
# 3.16.0
**Features:**
* added `getIteratorYieldResultFromIteratorResult` to extract the `yield`ed type from `IteratorResult<TYield, TReturn, TNext>`
# 3.15.0
**Features:**
* `isValidIdentifier`, `isValidPropertyName`, `isValidPropertyAccess`, `isValidNumericLiteral` added an optional parameter to specify the target ECMAScript version
**Bugfixes:**
* `isValidPropertyName`, `isValidPropertyAccess` now handle astral plane characters
# 3.14.1
**Bugfixes:**
* `findImports`: fixed crash on nested namespaces
# 3.14.0
**Features:**
* added `getInstanceTypeOfClassLikeDeclaration` and `getConstructorTypeOfClassLikeDeclaration`
* added `AccessKind.Delete` to `getAccessKind`: `getAccessKind(node) & AccessKind.Modification` can now be used to restore the old behavior of `isReassignmentTarget(node)`
# 3.13.0
**Features:**
* `getAccessKind` determines whether an expression is read from, written to or both
* optimized `getPropertyOfType` for unambiguous property names to partially work around https://github.com/microsoft/TypeScript/issues/31565
**Bugfixes:**
* `isReassignmentTarget` no longer returns `true` for `DeleteExpression` as it doesn't **assign** a value to the operand
# 3.12.0
**Features:**
* `getLateBoundPropertyNamesOfPropertyName` returns all statically analyzable names of a property, method, ...
* `getSingleLateBoundPropertyNameOfPropertyName` returns the literal name of a property, method, ... if statically analyzable
**Bugfixes:**
* fixed circular import
# 3.11.0
**Features:**
* typeguards: `isNumericOrStringLikeLiteral`, `isTupleTypeReference`
* `intersectionTypeParts` as counterpart to `unionTypeParts`
* `someTypePart` to execute a callback for each union or intersection constituent until the callback returns true
* `getPropertyOfType` looks up a property by its escaped name
* `isPropertyReadonlyInType` determines whether a property in a given type cannot be written to
* `symbolHasReadonlyDeclaration` determines if a Symbol has any readonly or constant declaration
* `isNumericPropertyName` determines whether a property name would match an index signature
* `isBindableObjectDefinePropertyCall` returns true for statically analyzable forms of `Object.defineProperty(o, 'p', {value, writable})`
* `isReadonlyAssignmentDeclaration` determines whether an `Object.defineProperty` call is known to result in a readonly property
* `getLateBoundPropertyNames` returns all known property names of an expression
* `getPropertyNameFromType` extracts the property name of literal types
* `isWellKnownSymbolLiterally` to recognize expressions in the form of `Symbol.<name>`
* `getPropertyNameOfWellKnownSymbol` returns the escaped name for a well known symbol literal
* `unwrapParentheses` returns the first child expression that is not a `ParenthesizedExpression`
# 3.10.0
**Features:**
* `isCompilerOptionEnabled`: `incremental` is implicitly enabled by `composite`
**Bugfixes:**
* `collectVariableUsage`/`getUsageDomain`: no longer treat `as const` as type usage
# 3.9.1
**Bugfixes:**
* reverted invalid deprecation of `canHaveJsdoc`
* fixed condition in `parseJsdocOfNode`
# 3.9.0
**Features:**
* added typeguards: `isNullLiteral` and `isBooleanLiteral`
# 3.8.0
**Features:**
* exposes typeguards for typescript@3.2 by default
* added utilities: `isConstAssertion` and `isInConstContext`
# 3.7.0
**Features:**
* added `isBlockScopedDeclarationStatement`
* added `isInSingleStatementContext`
# 3.6.0
**Features:**
* added `getCheckJsDirective` utility to parse `// @ts-check` and `// @ts-nocheck` pragmas
# 3.5.2
**Bugfixes:**
* Published declaration files no longer contain `const enum`. They are now declared as regular enums instead.
# 3.5.1
**Bugfixes:**
* `isThenableType` allows `Node` instead of `Expression` as parameter
* `isBlockScopeBoundary` and `isScopeBoundary` consider `WithStatement` as scope boundary
# 3.5.0
**Features:**
* correctly handle BigInt literals
* added typeguard `isBigIntLiteral`
* `isLiteralType` recognises BigInt
* `getPropertyName` adds special handling for BigInt
# 3.4.0
**Features:**
* added utility `commentText` to get the actual text content of a comment excluding the characters needed to start and end the comment
# 3.3.1
**Bugfixes:**
* `findImports`: fixed handling of ImportEqualsDeclaration
# 3.3.0
**Features:**
* `isCompilerOptionEnabled`: recognizes `strictBindCallApply`
* `getTokenAtPosition`: optionally includes JSDoc during lookup
**Bugfixes:**
* `isCompilerOptionEnabled`: correctly implements logic for `allowSyntheticDefaultImports`
* `findImportLikeNodes`: correctly finds imports in namespaces
* `findImportLikeNodes` / `findImports`: finds import types in JSDoc of JS files
# 3.2.0
**Features:**
* added utility `findImportLikeNodes` that works similar to `findImports` but returns the import statement or expression instead of the module specifier and doesn't filter non-string module specifiers
# 3.1.0
**Features:**
* added utilities: `isKeywordKind` and `isValidJsxIdentifier`
* exposes typeguards for typescript@3.0 by default
# 3.0.0
:warning: **Breaking Changes:**
* Dropped support for `typescript@<2.8.0`
* Dropped support for Node.js 4
* Removed deprecated APIs:
* `getIdentifierText`, `isJsxFramgment`, `ImportOptions`
* deprected overloads of `isModifierFlagSet`, `findImports` and `getControlFlowEnd`
* control flow related symbols can no longer be imported from `'tsutils/util/util'`, import directly from `'tsutils/util/control-flow'` or `'tsutils/util'`
* `isFunctionScopeBoundary` and `isBlockScopeBoundary` now return a enum member of `ScopeBoundary` instead of a boolean
* `isFunctionScopeBoundary` no longer returns a truthy value for `InterfaceDeclaration`, `TypeAliasDeclaration`
**Features:**
* added utility `isTypeScopeBoundary` returning `ScopeBoundary.Type` or `ScopeBoundary.ConditionalType`
* added enum `ScopeBoundarySelector` whose members can be used to determine if a declaration belongs to a given `ScopeBoundary` by using bitwise AND
**Bugfixes:**
* `collectVariableUsage` now correctly handles `infer T` nested inside function signatures or mapped types
* `isCompilerOptionEnabled` correctly handles `skipDefaultLibCHeck` and `suppressImplicitAnyIndexErrors`
# 2.29.0
**Features:**
* added utility `isCompilerOptionEnabled`
# 2.28.0
Typeguards are now split into multiple submodules for each version of TypeScript (starting with 2.8.0).
That means you can now import directly from `"tsutils/typeguard/2.8"` to get compatible declaraton files for TypeScript@2.8.
For more information please read the relevant section in [README.md](README.md).
**Features:**
* added typeguards: `isTupleType`, `isOptionalTypeNode`, `isRestTypeNode`, `isSyntheticExpression` (currently available from `"tsutils/typeguard/3.0"`)
* added utility `isStrictCompilerOptionEnabled`
# 2.27.2
Avoid crash caused by removed function in `typescript@3.0.0`.
# 2.27.1
Added support for TypeScript@3.0.0 nightly builds.
# 2.27.0
**Features:**
* added `getIIFE` utility
# 2.26.2
**Bugfixes:**
* `forEachComment` and `forEachTokenWithTrivia` no longer duplicate comments around missing nodes
# 2.26.1
**Bugfixes:**
* fixed crash in `hasSideEffects` with tagged template literal without substitution: ``tag`template` ``
# 2.26.0
**Features:**
* added typeguard `isLiteralTypeNode`
* added support for type imports (`type T = import('foo')`) to `findImports` via `ImportKind.ImportType`
# 2.25.1
**Bugfixes:**
* `collectVariableUsage`: fixed name lookup in function signatures to match runtime behavior. Note that this is not completely fixed in TypeScript, yet. See: [Microsoft/TypeScript#22825](https://github.com/Microsoft/TypeScript/issues/22825) and [Microsoft/TypeScript#22769](https://github.com/Microsoft/TypeScript/issues/22769)
# 2.25.0
**Features:**
* added utilities: `isStatementInAmbientContext` and `isAmbientModuleBlock`
# 2.24.0
**Features:**
* added typeguards for typescript@2.8: `isConditionalTypeNode`, `isInferTypeNode`, `isConditionalType`, `isInstantiableType`, `isSubstitutionType`
# 2.23.0
**Features:**
* added typeguard `isForInOrOfStatement`
**Bugfixes:**
* correctly handle comments in generic JSX elements: `<MyComponent<string>/*comment*/></MyComponent>`
* fixed a bug with false positive trailing comments at the end of JSX self closing element: `<div><br/>/*no comment*/</div>`
# 2.22.2
**Bugfixes:**
* `collectVariableUsage`: handle ConditionalTypes and `infer T`, which will be introduced in TypeScript@2.8.0 and are already available in nightly builds
* `isLiteralType` no longer returns true for `ts.TypeFlags.BooleanLiteral` as this is not a `ts.LiteralType`
# 2.22.1
**Bugfixes:**
* `endsControlFlow`:
* handle loops that might not even run a single iteration
* handle constant boolean conditions in loops and if
# 2.22.0
**Features:**
* added `isFalsyType` utility
# 2.21.2
**Bugfixes:**
* fixed compile error with `typescript@2.8.0-dev`
# 2.21.1
**Bugfixes:**
* `isReassignmentTarget`: handle type assertions and non-null assertion
# 2.21.0
**Bugfixes:**
* `forEachDeclaredVariable` uses a more precise type for the callback parameter to make it useable again with typescript@2.7.1
**Features:**
* added `isUniqueESSymbolType` typeguard
# 2.20.0
**Features:**
* added `isThenableType` utility
* added `unionTypeParts` utility
# 2.19.1
**Bugfixes:**
* `forEachComment`, `getCommentAtPosition` and `isPositionInComment`: skip shebang (`#! something`) to not miss following comments at the start of the file
# 2.19.0
**Features:**
* added `WrappedAst` interface that models the type of a wrapped SourceFile more accurate
* added `getWrappedNodeAtPosition` utiltiy that takes a `NodeWrap` and returns the most deeply nested NodeWrap that contains the given position
# 2.18.0
**Features:**
* `getControlFlowEnd` accepts BlockLike as argument
**Bugfixes:**
* `getControlFlowEnd` and `endsControlFlow`: correctly handle nested LabeledStatements
* `endsControlFlow` removed erroneous special case when an IterationStatement is passed as argument whose parent is a LabeledStatement.
* if you want labels of an IterationStatement (or SwitchStatement) to be handled, you need to pass the LabeledStatement as argument.
* :warning: this fix may change the returned value if you relied on the buggy behavior
**Deprecations:**
* deprecated overload of `getControlFlowEnd` that contains the `label` parameter. This parameter is no longer used and should no longer be passed to the function.
# 2.17.1
**Bugfixes:**
* `getControlFlowEnd` and `endsControlFlow` (#22)
* ThrowStatements inside `try` are filtered out if there is a `catch` clause
* TryStatements with `catch` only end control flow if `try` AND `catch` definitely end control flow
# 2.17.0
**Features:**
* added `kind` property to `NodeWrap`
* added `getControlFlowEnd` to public API
# 2.16.0
**Features:**
* added `isDecorator` and `isCallLikeExpression` typeguards
# 2.15.0
**Features:**
* added `convertAst` utility to produce a flattened and wrapped version of the AST
# 2.14.0
**Features:**
* added `isDeleteExpression`
* added `getLineBreakStyle`
# 2.13.1
**Bugfixes:**
* fixed name of `isJsxFragment`
# 2.13.0
**Features:**
* added support for `JsxFragment` introduced in typescript@2.6.2
* added corresponding typeguard functions
# 2.12.2
**Bugfixes:**
* `endsControlFlow`
* added missing logic for labeled statement, iteration statements and try-catch
* added missing logic for `break` and `continue` with labels
* take all jump statements into account, not only the last statement
* `isValidIdentifier` and `isValidNumericLiteral` handle irregular whitespace
* `findImports` searches in ambient modules inside regular `.ts` files (not only `.d.ts`)
* `canHaveJsDoc` is now a typeguard
# 2.12.1
**Bugfixes:**
* `forEachTokenWithTrivia`
* handles irregular whitespace and no longer visits some tokens twice
* correctly calculates the range of JsxText
# 2.12.0
**API-Changes:**
* deprecated `ImportOptions` if favor of the new `ImportKind` enum
# 2.11.2
**Bugfixes:**
* `parseJsDocOfNode`: set correct `pos`, `end` and `parent` properties. Also affects `getJsDoc` of `EndOfFileToken`
# 2.11.1
**Bugfixes:**
* `collectVariableUsage`: correctly consider catch binding as block scoped declaration inside catch block
# 2.11.0
**Bugfixes:**
* `getJsDoc` now correctly returns JsDoc for `EndOfFileToken`
**Features:**
* added utility `parseJsDocOfNode`
# 2.10.0
**Features:**
* added utility `findImports` to find all kinds of imports in a source file
# 2.9.0
**Features:**
* added typeguard `isMappedTypeNode`
* added utilities `canHaveJsDoc` and `getJsDoc`
# 2.8.2
**Bugfixes:**
* `collectVariableUsage`: handle global augmentation like other module augmentations
# 2.8.1
**Bugfixes:**
* Support `typescript@2.5.1` with optional catch binding
* `collectVariableUsage` fixed a bug where method decorator had method's parameters in scope
# 2.8.0
* Compatibility with the latest typescript nightly
* Added `getIdentifierText` to unescape identifiers across typescript versions
# 2.7.1
**Bugfixes:**
* `isReassignmentTarget` don't return `true` for right side of assignment
# 2.7.0
**Features:**
* Added `isReassignmentTarget` utility
# 2.6.1
**Bugfixes:**
* `getDeclarationDomain` now returns `undefined` for Parameter in IndexSignature
* `collectVariableUsage` ignores Parameter in IndexSignature
# 2.6.0
**Bugfixes:**
* `collectVariableUsage`:
* don't merge imports with global declarations
* treat everything in a declaration file as exported if there is no explicit `export {};`
* `isExpressionValueUsed`: handle destructuring in `for...of`
**Features:**
* Added `getModifier` utility
* Added `DeclarationDomain.Import` to distinguish imports from other declarations
# 2.5.1
**Bugfixes:**
* `collectVariableUsage` ignore jump labels as in `break label;`
# 2.5.0
**Bugfixes:**
* `isFunctionWithBody` handles constructor overload correctly.
**Features:**
* Implemented `isExpressionValueUsed` to check whether the result of an expression is actually used.
* Implemented `getDeclarationDomain` to determine if a given declaration introduces a new symbol in the value or type domain.
**`collectVariableUses` is now usable**
* no longer ignores signatures and its parameters
* don't merge declarations and uses across domains
* no longer marks exceptions in catch clause or parameter properties as exported
* fixed exports of namespaces
* fixed scoping of ClassExpression name
* correcly handle ambient namespaces and module augmentations
* fixed how `: typeof foo` is handled for parameters and function return type
* **still WIP**: `export {Foo as Bar}` inside ambient namespaces and modules
# 2.4.0
**Bugfixes:**
* `getLineRanges`: `contentLength` now contains the correct line length when there are multiple consecutive line break characters
* `getTokenAtPosition`: don't match tokens that end at the specified position (because that's already outside of their range)
* deprecated the misnamed `isModfierFlagSet`, use the new `isModifierFlagSet` instead
**Features:**
* Added typeguard: `isJsDoc`
* Added experimental scope and usage analysis (`getUsageDomain` and `collectVariableUsage`)
# 2.3.0
**Bugfixes:**
* `forEachComment` no longer omits some comments when callback returns a truthy value
* `isPositionInComment` fixed false positive inside JSXText
**Features:**
* Added utility: `getCommentAtPosition`
# 2.2.0
**Bugfixes:**
* Fixed bit value of `SideEffectOptions.JsxElement` to be a power of 2
**Features:**
* Added utilities: `getTokenAtPosition` and `isPositionInComment`
# 2.1.0
**Features:**
* Added typeguard `isExpression`
* Added utilities: `hasSideEffects`, `getDeclarationOfBindingElement`
# 2.0.0
**Breaking Changes:**
* Dropped compatibility with `typescript@<2.1.0`
* Removed misnamed `isNumericliteral`, use `isNumericLiteral` instead (notice the uppercase L)
* Removed `isEnumLiteralType` which will cause compile errors with typescript@2.4.0
* Refactored directory structure: all imports that referenced subdirectories (e.g. `require('tsutils/src/typeguard')` will be broken
**Features:**
* New directory structure allows imports of typeguards or utils independently, e.g. (`require('tsutils/typeguard')`)
# 1.9.1
**Bugfixes:**
* `isObjectFlagSet` now uses the correct `objectFlags` property
# 1.9.0
**Bugfixes:**
* `getNextToken` no longer omits `EndOfFileToken` when there is no trivia before EOF. That means the only inputs where `getNextToken` returns `undefined` are `SourceFile` and `EndOfFileToken`
**Features**:
* Added typeguards for types
* Added utilities for flag checking: `isNodeFlagSet`, `isTypeFlagSet`, `isSymbolFlagSet`,`isObjectFlagSet`, `isModifierFlagSet`
# 1.8.0
**Features:**
* Support peer dependency of typescript nightlies of 2.4.0
* Added typeguards: `isJsxAttributes`, `isIntersectionTypeNode`, `isTypeOperatorNode`, `isTypePredicateNode`, `isTypeQueryNode`, `isUnionTypeNode`
# 1.7.0
**Bugfixes:**
* `isFunctionScopeBoundary` now handles Interfaces, TypeAliases, FunctionSignatures, etc
**Features:**
* Added utilities: `isThisParameter`, `isSameLine` and `isFunctionWithBody`
# 1.6.0
**Features:**
* Add `isValidPropertyAccess`, `isValidNumericLiteral` and `isValidPropertyName`
# 1.5.0
**Features:**
* Add `isValidIdentifier`
# 1.4.0
**Features:**
* Add `contentLength` property to the result of `getLineRanges`
# 1.3.0
**Bugfixes:**
* `canHaveLeadingTrivia`:
* Fix property access on undefined parent reference
* Fixes: [palantir/tslint#2330](https://github.com/palantir/tslint/issues/2330)
* `hasOwnThisReference`: now includes accessors on object literals
**Features:**
* Typeguards:
* isTypeParameterDeclaration
* isEnitityName
# 1.2.2
**Bugfixes:**
* `hasOwnThisReference`:
* exclude overload signatures of function declarations
* add method declarations on object literals
# 1.2.1
**Bugfixes:**
* Fix name of `isNumericLiteral`
# 1.2.0
**Features:**
* Typeguards:
* isEnumMember
* isExpressionWithTypeArguments
* isImportSpecifier
* Utilities:
* isJsDocKind, isTypeNodeKind
* Allow typescript@next in peerDependencies
# 1.1.0
**Bugfixes:**
* Fix isBlockScopeBoundary: Remove WithStatement, IfStatment, DoStatement and WhileStatement because they are no scope boundary whitout a block.
**Features:**
* Added more typeguards:
* isAssertionExpression
* isEmptyStatement
* isJsxAttributeLike
* isJsxOpeningLikeElement
* isNonNullExpression
* isSyntaxList
* Utilities:
* getNextToken, getPreviousToken
* hasOwnThisReference
* getLineRanges
# 1.0.0
**Features:**
* Initial implementation of typeguards
* Utilities:
* getChildOfKind
* isNodeKind, isAssignmentKind
* hasModifier, isParameterProperty, hasAccessModifier
* getPreviousStatement, getNextStatement
* getPropertyName
* forEachDestructuringIdentifier, forEachDeclaredVariable
* getVariableDeclarationKind, isBlockScopedVariableDeclarationList, isBlockScopedVariableDeclaration
* isScopeBoundary, isFunctionScopeBoundary, isBlockScopeBoundary
* forEachToken, forEachTokenWithTrivia, forEachComment
* endsControlFlow

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Klaus Meinhardt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,61 @@
# Utility functions for working with typescript's AST
[![Greenkeeper badge](https://badges.greenkeeper.io/ajafff/tsutils.svg)](https://greenkeeper.io/)
## Usage
This package consists of two major parts: utilities and typeguard functions.
By importing the project you will get both of them.
```js
import * as utils from "tsutils";
utils.isIdentifier(node); // typeguard
utils.getLineRanges(sourceFile); // utilities
```
If you don't need everything offered by this package, you can select what should be imported. The parts that are not imported are never read from disk and may save some startup time and reduce memory consumtion.
If you only need typeguards you can explicitly import them:
```js
import { isIdentifier } from "tsutils/typeguard";
// You can even distiguish between typeguards for nodes and types
import { isUnionTypeNode } from "tsutils/typeguard/node";
import { isUnionType } from "tsutils/typeguard/type";
```
If you only need the utilities you can also explicitly import them:
```js
import { forEachComment, forEachToken } from "tsutils/util";
```
### Typescript version dependency
This package is backwards compatible with typescript 2.8.0 at runtime although compiling might need a newer version of typescript installed.
Using `typescript@next` might work, but it's not officially supported. If you encounter any bugs, please open an issue.
For compatibility with older versions of TypeScript typeguard functions are separated by TypeScript version. If you are stuck on `typescript@2.8`, you should import directly from the submodule for that version:
```js
// all typeguards compatible with typescript@2.8
import { isIdentifier } from "tsutils/typeguard/2.8";
// you can even use nested submodules
import { isIdentifier } from "tsutils/typeguard/2.8/node";
// all typeguards compatible with typescript@2.9 (includes those of 2.8)
import { isIdentifier } from "tsutils/typeguard/2.9";
// always points to the latest stable version (2.9 as of writing this)
import { isIdentifier } from "tsutils/typeguard";
import { isIdentifier } from "tsutils";
// always points to the typeguards for the next TypeScript version (3.0 as of writing this)
import { isIdentifier } from "tsutils/typeguard/next";
```
Note that if you are also using utility functions, you should prefer the relevant submodule:
```js
// importing directly from 'tsutils' would pull in the latest typeguards
import { forEachToken } from 'tsutils/util';
import { isIdentifier } from 'tsutils/typeguard/2.8';
```

View File

@@ -0,0 +1,2 @@
export * from './typeguard';
export * from './util';

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./typeguard"), exports);
tslib_1.__exportStar(require("./util"), exports);

View File

@@ -0,0 +1,61 @@
{
"name": "tsutils",
"version": "3.17.1",
"description": "utilities for working with typescript's AST",
"scripts": {
"compile": "rm -rf {,util,typeguard,test/**}/*.js; ttsc -p .",
"lint:tslint": "wotan -m @fimbul/valtyr",
"lint:wotan": "wotan",
"lint": "run-p lint:*",
"test": "mocha test/*Tests.js && tslint --test 'test/rules/**/tslint.json'",
"verify": "run-s compile lint coverage",
"prepublishOnly": "run-s verify",
"coverage": "nyc run-s test",
"report-coverage": "cat ./coverage/lcov.info | coveralls",
"github-release": "GITHUB_TOKEN=$(cat ~/github_token.txt) github-release-from-changelog",
"postpublish": "git push origin master --tags; run-s github-release"
},
"repository": {
"type": "git",
"url": "https://github.com/ajafff/tsutils"
},
"keywords": [
"typescript",
"ts",
"ast",
"typeguard",
"utils",
"helper",
"node"
],
"author": "Klaus Meinhardt",
"license": "MIT",
"devDependencies": {
"@fimbul/mithotyn": "^0.17.0",
"@fimbul/valtyr": "^0.20.0",
"@fimbul/wotan": "^0.20.0",
"@types/chai": "^4.0.10",
"@types/mocha": "^5.0.0",
"@types/node": "^11.13.0",
"chai": "^4.1.2",
"coveralls": "^3.0.0",
"github-release-from-changelog": "^1.3.0",
"mocha": "^6.0.2",
"npm-run-all": "^4.1.2",
"nyc": "^13.3.0",
"ts-transform-const-enum": "^0.0.1",
"tslint": "^5.8.0",
"tslint-consistent-codestyle": "^1.11.0",
"ttypescript": "^1.5.5",
"typescript": "^3.6.0-dev.20190804"
},
"peerDependencies": {
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
},
"dependencies": {
"tslib": "^1.8.1"
},
"engines": {
"node": ">= 6"
}
}

View File

@@ -0,0 +1,2 @@
export * from './node';
export * from './type';

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./node"), exports);
tslib_1.__exportStar(require("./type"), exports);

View File

@@ -0,0 +1,155 @@
import * as ts from 'typescript';
export declare function isAccessorDeclaration(node: ts.Node): node is ts.AccessorDeclaration;
export declare function isArrayBindingPattern(node: ts.Node): node is ts.ArrayBindingPattern;
export declare function isArrayLiteralExpression(node: ts.Node): node is ts.ArrayLiteralExpression;
export declare function isArrayTypeNode(node: ts.Node): node is ts.ArrayTypeNode;
export declare function isArrowFunction(node: ts.Node): node is ts.ArrowFunction;
export declare function isAsExpression(node: ts.Node): node is ts.AsExpression;
export declare function isAssertionExpression(node: ts.Node): node is ts.AssertionExpression;
export declare function isAwaitExpression(node: ts.Node): node is ts.AwaitExpression;
export declare function isBinaryExpression(node: ts.Node): node is ts.BinaryExpression;
export declare function isBindingElement(node: ts.Node): node is ts.BindingElement;
export declare function isBindingPattern(node: ts.Node): node is ts.BindingPattern;
export declare function isBlock(node: ts.Node): node is ts.Block;
export declare function isBlockLike(node: ts.Node): node is ts.BlockLike;
export declare function isBooleanLiteral(node: ts.Node): node is ts.BooleanLiteral;
export declare function isBreakOrContinueStatement(node: ts.Node): node is ts.BreakOrContinueStatement;
export declare function isBreakStatement(node: ts.Node): node is ts.BreakStatement;
export declare function isCallExpression(node: ts.Node): node is ts.CallExpression;
export declare function isCallLikeExpression(node: ts.Node): node is ts.CallLikeExpression;
export declare function isCallSignatureDeclaration(node: ts.Node): node is ts.CallSignatureDeclaration;
export declare function isCaseBlock(node: ts.Node): node is ts.CaseBlock;
export declare function isCaseClause(node: ts.Node): node is ts.CaseClause;
export declare function isCaseOrDefaultClause(node: ts.Node): node is ts.CaseOrDefaultClause;
export declare function isCatchClause(node: ts.Node): node is ts.CatchClause;
export declare function isClassDeclaration(node: ts.Node): node is ts.ClassDeclaration;
export declare function isClassExpression(node: ts.Node): node is ts.ClassExpression;
export declare function isClassLikeDeclaration(node: ts.Node): node is ts.ClassLikeDeclaration;
export declare function isCommaListExpression(node: ts.Node): node is ts.CommaListExpression;
export declare function isConditionalExpression(node: ts.Node): node is ts.ConditionalExpression;
export declare function isConditionalTypeNode(node: ts.Node): node is ts.ConditionalTypeNode;
export declare function isConstructorDeclaration(node: ts.Node): node is ts.ConstructorDeclaration;
export declare function isConstructorTypeNode(node: ts.Node): node is ts.ConstructorTypeNode;
export declare function isConstructSignatureDeclaration(node: ts.Node): node is ts.ConstructSignatureDeclaration;
export declare function isContinueStatement(node: ts.Node): node is ts.ContinueStatement;
export declare function isComputedPropertyName(node: ts.Node): node is ts.ComputedPropertyName;
export declare function isDebuggerStatement(node: ts.Node): node is ts.DebuggerStatement;
export declare function isDecorator(node: ts.Node): node is ts.Decorator;
export declare function isDefaultClause(node: ts.Node): node is ts.DefaultClause;
export declare function isDeleteExpression(node: ts.Node): node is ts.DeleteExpression;
export declare function isDoStatement(node: ts.Node): node is ts.DoStatement;
export declare function isElementAccessExpression(node: ts.Node): node is ts.ElementAccessExpression;
export declare function isEmptyStatement(node: ts.Node): node is ts.EmptyStatement;
export declare function isEntityName(node: ts.Node): node is ts.EntityName;
export declare function isEntityNameExpression(node: ts.Node): node is ts.EntityNameExpression;
export declare function isEnumDeclaration(node: ts.Node): node is ts.EnumDeclaration;
export declare function isEnumMember(node: ts.Node): node is ts.EnumMember;
export declare function isExportAssignment(node: ts.Node): node is ts.ExportAssignment;
export declare function isExportDeclaration(node: ts.Node): node is ts.ExportDeclaration;
export declare function isExportSpecifier(node: ts.Node): node is ts.ExportSpecifier;
export declare function isExpression(node: ts.Node): node is ts.Expression;
export declare function isExpressionStatement(node: ts.Node): node is ts.ExpressionStatement;
export declare function isExpressionWithTypeArguments(node: ts.Node): node is ts.ExpressionWithTypeArguments;
export declare function isExternalModuleReference(node: ts.Node): node is ts.ExternalModuleReference;
export declare function isForInStatement(node: ts.Node): node is ts.ForInStatement;
export declare function isForInOrOfStatement(node: ts.Node): node is ts.ForInOrOfStatement;
export declare function isForOfStatement(node: ts.Node): node is ts.ForOfStatement;
export declare function isForStatement(node: ts.Node): node is ts.ForStatement;
export declare function isFunctionDeclaration(node: ts.Node): node is ts.FunctionDeclaration;
export declare function isFunctionExpression(node: ts.Node): node is ts.FunctionExpression;
export declare function isFunctionTypeNode(node: ts.Node): node is ts.FunctionTypeNode;
export declare function isGetAccessorDeclaration(node: ts.Node): node is ts.GetAccessorDeclaration;
export declare function isIdentifier(node: ts.Node): node is ts.Identifier;
export declare function isIfStatement(node: ts.Node): node is ts.IfStatement;
export declare function isImportClause(node: ts.Node): node is ts.ImportClause;
export declare function isImportDeclaration(node: ts.Node): node is ts.ImportDeclaration;
export declare function isImportEqualsDeclaration(node: ts.Node): node is ts.ImportEqualsDeclaration;
export declare function isImportSpecifier(node: ts.Node): node is ts.ImportSpecifier;
export declare function isIndexedAccessTypeNode(node: ts.Node): node is ts.IndexedAccessTypeNode;
export declare function isIndexSignatureDeclaration(node: ts.Node): node is ts.IndexSignatureDeclaration;
export declare function isInferTypeNode(node: ts.Node): node is ts.InferTypeNode;
export declare function isInterfaceDeclaration(node: ts.Node): node is ts.InterfaceDeclaration;
export declare function isIntersectionTypeNode(node: ts.Node): node is ts.IntersectionTypeNode;
export declare function isIterationStatement(node: ts.Node): node is ts.IterationStatement;
export declare function isJsDoc(node: ts.Node): node is ts.JSDoc;
export declare function isJsxAttribute(node: ts.Node): node is ts.JsxAttribute;
export declare function isJsxAttributeLike(node: ts.Node): node is ts.JsxAttributeLike;
export declare function isJsxAttributes(node: ts.Node): node is ts.JsxAttributes;
export declare function isJsxClosingElement(node: ts.Node): node is ts.JsxClosingElement;
export declare function isJsxClosingFragment(node: ts.Node): node is ts.JsxClosingFragment;
export declare function isJsxElement(node: ts.Node): node is ts.JsxElement;
export declare function isJsxExpression(node: ts.Node): node is ts.JsxExpression;
export declare function isJsxFragment(node: ts.Node): node is ts.JsxFragment;
export declare function isJsxOpeningElement(node: ts.Node): node is ts.JsxOpeningElement;
export declare function isJsxOpeningFragment(node: ts.Node): node is ts.JsxOpeningFragment;
export declare function isJsxOpeningLikeElement(node: ts.Node): node is ts.JsxOpeningLikeElement;
export declare function isJsxSelfClosingElement(node: ts.Node): node is ts.JsxSelfClosingElement;
export declare function isJsxSpreadAttribute(node: ts.Node): node is ts.JsxSpreadAttribute;
export declare function isJsxText(node: ts.Node): node is ts.JsxText;
export declare function isLabeledStatement(node: ts.Node): node is ts.LabeledStatement;
export declare function isLiteralExpression(node: ts.Node): node is ts.LiteralExpression;
export declare function isLiteralTypeNode(node: ts.Node): node is ts.LiteralTypeNode;
export declare function isMappedTypeNode(node: ts.Node): node is ts.MappedTypeNode;
export declare function isMetaProperty(node: ts.Node): node is ts.MetaProperty;
export declare function isMethodDeclaration(node: ts.Node): node is ts.MethodDeclaration;
export declare function isMethodSignature(node: ts.Node): node is ts.MethodSignature;
export declare function isModuleBlock(node: ts.Node): node is ts.ModuleBlock;
export declare function isModuleDeclaration(node: ts.Node): node is ts.ModuleDeclaration;
export declare function isNamedExports(node: ts.Node): node is ts.NamedExports;
export declare function isNamedImports(node: ts.Node): node is ts.NamedImports;
export declare function isNamespaceDeclaration(node: ts.Node): node is ts.NamespaceDeclaration;
export declare function isNamespaceImport(node: ts.Node): node is ts.NamespaceImport;
export declare function isNamespaceExportDeclaration(node: ts.Node): node is ts.NamespaceExportDeclaration;
export declare function isNewExpression(node: ts.Node): node is ts.NewExpression;
export declare function isNonNullExpression(node: ts.Node): node is ts.NonNullExpression;
export declare function isNoSubstitutionTemplateLiteral(node: ts.Node): node is ts.NoSubstitutionTemplateLiteral;
export declare function isNullLiteral(node: ts.Node): node is ts.NullLiteral;
export declare function isNumericLiteral(node: ts.Node): node is ts.NumericLiteral;
export declare function isNumericOrStringLikeLiteral(node: ts.Node): node is ts.NumericLiteral | ts.StringLiteral | ts.NoSubstitutionTemplateLiteral;
export declare function isObjectBindingPattern(node: ts.Node): node is ts.ObjectBindingPattern;
export declare function isObjectLiteralExpression(node: ts.Node): node is ts.ObjectLiteralExpression;
export declare function isOmittedExpression(node: ts.Node): node is ts.OmittedExpression;
export declare function isParameterDeclaration(node: ts.Node): node is ts.ParameterDeclaration;
export declare function isParenthesizedExpression(node: ts.Node): node is ts.ParenthesizedExpression;
export declare function isParenthesizedTypeNode(node: ts.Node): node is ts.ParenthesizedTypeNode;
export declare function isPostfixUnaryExpression(node: ts.Node): node is ts.PostfixUnaryExpression;
export declare function isPrefixUnaryExpression(node: ts.Node): node is ts.PrefixUnaryExpression;
export declare function isPropertyAccessExpression(node: ts.Node): node is ts.PropertyAccessExpression;
export declare function isPropertyAssignment(node: ts.Node): node is ts.PropertyAssignment;
export declare function isPropertyDeclaration(node: ts.Node): node is ts.PropertyDeclaration;
export declare function isPropertySignature(node: ts.Node): node is ts.PropertySignature;
export declare function isQualifiedName(node: ts.Node): node is ts.QualifiedName;
export declare function isRegularExpressionLiteral(node: ts.Node): node is ts.RegularExpressionLiteral;
export declare function isReturnStatement(node: ts.Node): node is ts.ReturnStatement;
export declare function isSetAccessorDeclaration(node: ts.Node): node is ts.SetAccessorDeclaration;
export declare function isShorthandPropertyAssignment(node: ts.Node): node is ts.ShorthandPropertyAssignment;
export declare function isSignatureDeclaration(node: ts.Node): node is ts.SignatureDeclaration;
export declare function isSourceFile(node: ts.Node): node is ts.SourceFile;
export declare function isSpreadAssignment(node: ts.Node): node is ts.SpreadAssignment;
export declare function isSpreadElement(node: ts.Node): node is ts.SpreadElement;
export declare function isStringLiteral(node: ts.Node): node is ts.StringLiteral;
export declare function isSwitchStatement(node: ts.Node): node is ts.SwitchStatement;
export declare function isSyntaxList(node: ts.Node): node is ts.SyntaxList;
export declare function isTaggedTemplateExpression(node: ts.Node): node is ts.TaggedTemplateExpression;
export declare function isTemplateExpression(node: ts.Node): node is ts.TemplateExpression;
export declare function isTemplateLiteral(node: ts.Node): node is ts.TemplateLiteral;
export declare function isTextualLiteral(node: ts.Node): node is ts.StringLiteral | ts.NoSubstitutionTemplateLiteral;
export declare function isThrowStatement(node: ts.Node): node is ts.ThrowStatement;
export declare function isTryStatement(node: ts.Node): node is ts.TryStatement;
export declare function isTupleTypeNode(node: ts.Node): node is ts.TupleTypeNode;
export declare function isTypeAliasDeclaration(node: ts.Node): node is ts.TypeAliasDeclaration;
export declare function isTypeAssertion(node: ts.Node): node is ts.TypeAssertion;
export declare function isTypeLiteralNode(node: ts.Node): node is ts.TypeLiteralNode;
export declare function isTypeOfExpression(node: ts.Node): node is ts.TypeOfExpression;
export declare function isTypeOperatorNode(node: ts.Node): node is ts.TypeOperatorNode;
export declare function isTypeParameterDeclaration(node: ts.Node): node is ts.TypeParameterDeclaration;
export declare function isTypePredicateNode(node: ts.Node): node is ts.TypePredicateNode;
export declare function isTypeReferenceNode(node: ts.Node): node is ts.TypeReferenceNode;
export declare function isTypeQueryNode(node: ts.Node): node is ts.TypeQueryNode;
export declare function isUnionTypeNode(node: ts.Node): node is ts.UnionTypeNode;
export declare function isVariableDeclaration(node: ts.Node): node is ts.VariableDeclaration;
export declare function isVariableStatement(node: ts.Node): node is ts.VariableStatement;
export declare function isVariableDeclarationList(node: ts.Node): node is ts.VariableDeclarationList;
export declare function isVoidExpression(node: ts.Node): node is ts.VoidExpression;
export declare function isWhileStatement(node: ts.Node): node is ts.WhileStatement;
export declare function isWithStatement(node: ts.Node): node is ts.WithStatement;

View File

@@ -0,0 +1,709 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ts = require("typescript");
function isAccessorDeclaration(node) {
return node.kind === ts.SyntaxKind.GetAccessor ||
node.kind === ts.SyntaxKind.SetAccessor;
}
exports.isAccessorDeclaration = isAccessorDeclaration;
function isArrayBindingPattern(node) {
return node.kind === ts.SyntaxKind.ArrayBindingPattern;
}
exports.isArrayBindingPattern = isArrayBindingPattern;
function isArrayLiteralExpression(node) {
return node.kind === ts.SyntaxKind.ArrayLiteralExpression;
}
exports.isArrayLiteralExpression = isArrayLiteralExpression;
function isArrayTypeNode(node) {
return node.kind === ts.SyntaxKind.ArrayType;
}
exports.isArrayTypeNode = isArrayTypeNode;
function isArrowFunction(node) {
return node.kind === ts.SyntaxKind.ArrowFunction;
}
exports.isArrowFunction = isArrowFunction;
function isAsExpression(node) {
return node.kind === ts.SyntaxKind.AsExpression;
}
exports.isAsExpression = isAsExpression;
function isAssertionExpression(node) {
return node.kind === ts.SyntaxKind.AsExpression ||
node.kind === ts.SyntaxKind.TypeAssertionExpression;
}
exports.isAssertionExpression = isAssertionExpression;
function isAwaitExpression(node) {
return node.kind === ts.SyntaxKind.AwaitExpression;
}
exports.isAwaitExpression = isAwaitExpression;
function isBinaryExpression(node) {
return node.kind === ts.SyntaxKind.BinaryExpression;
}
exports.isBinaryExpression = isBinaryExpression;
function isBindingElement(node) {
return node.kind === ts.SyntaxKind.BindingElement;
}
exports.isBindingElement = isBindingElement;
function isBindingPattern(node) {
return node.kind === ts.SyntaxKind.ArrayBindingPattern ||
node.kind === ts.SyntaxKind.ObjectBindingPattern;
}
exports.isBindingPattern = isBindingPattern;
function isBlock(node) {
return node.kind === ts.SyntaxKind.Block;
}
exports.isBlock = isBlock;
function isBlockLike(node) {
return node.statements !== undefined;
}
exports.isBlockLike = isBlockLike;
function isBooleanLiteral(node) {
return node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword;
}
exports.isBooleanLiteral = isBooleanLiteral;
function isBreakOrContinueStatement(node) {
return node.kind === ts.SyntaxKind.BreakStatement ||
node.kind === ts.SyntaxKind.ContinueStatement;
}
exports.isBreakOrContinueStatement = isBreakOrContinueStatement;
function isBreakStatement(node) {
return node.kind === ts.SyntaxKind.BreakStatement;
}
exports.isBreakStatement = isBreakStatement;
function isCallExpression(node) {
return node.kind === ts.SyntaxKind.CallExpression;
}
exports.isCallExpression = isCallExpression;
function isCallLikeExpression(node) {
switch (node.kind) {
case ts.SyntaxKind.CallExpression:
case ts.SyntaxKind.Decorator:
case ts.SyntaxKind.JsxOpeningElement:
case ts.SyntaxKind.JsxSelfClosingElement:
case ts.SyntaxKind.NewExpression:
case ts.SyntaxKind.TaggedTemplateExpression:
return true;
default:
return false;
}
}
exports.isCallLikeExpression = isCallLikeExpression;
function isCallSignatureDeclaration(node) {
return node.kind === ts.SyntaxKind.CallSignature;
}
exports.isCallSignatureDeclaration = isCallSignatureDeclaration;
function isCaseBlock(node) {
return node.kind === ts.SyntaxKind.CaseBlock;
}
exports.isCaseBlock = isCaseBlock;
function isCaseClause(node) {
return node.kind === ts.SyntaxKind.CaseClause;
}
exports.isCaseClause = isCaseClause;
function isCaseOrDefaultClause(node) {
return node.kind === ts.SyntaxKind.CaseClause ||
node.kind === ts.SyntaxKind.DefaultClause;
}
exports.isCaseOrDefaultClause = isCaseOrDefaultClause;
function isCatchClause(node) {
return node.kind === ts.SyntaxKind.CatchClause;
}
exports.isCatchClause = isCatchClause;
function isClassDeclaration(node) {
return node.kind === ts.SyntaxKind.ClassDeclaration;
}
exports.isClassDeclaration = isClassDeclaration;
function isClassExpression(node) {
return node.kind === ts.SyntaxKind.ClassExpression;
}
exports.isClassExpression = isClassExpression;
function isClassLikeDeclaration(node) {
return node.kind === ts.SyntaxKind.ClassDeclaration ||
node.kind === ts.SyntaxKind.ClassExpression;
}
exports.isClassLikeDeclaration = isClassLikeDeclaration;
function isCommaListExpression(node) {
return node.kind === ts.SyntaxKind.CommaListExpression;
}
exports.isCommaListExpression = isCommaListExpression;
function isConditionalExpression(node) {
return node.kind === ts.SyntaxKind.ConditionalExpression;
}
exports.isConditionalExpression = isConditionalExpression;
function isConditionalTypeNode(node) {
return node.kind === ts.SyntaxKind.ConditionalType;
}
exports.isConditionalTypeNode = isConditionalTypeNode;
function isConstructorDeclaration(node) {
return node.kind === ts.SyntaxKind.Constructor;
}
exports.isConstructorDeclaration = isConstructorDeclaration;
function isConstructorTypeNode(node) {
return node.kind === ts.SyntaxKind.ConstructorType;
}
exports.isConstructorTypeNode = isConstructorTypeNode;
function isConstructSignatureDeclaration(node) {
return node.kind === ts.SyntaxKind.ConstructSignature;
}
exports.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
function isContinueStatement(node) {
return node.kind === ts.SyntaxKind.ContinueStatement;
}
exports.isContinueStatement = isContinueStatement;
function isComputedPropertyName(node) {
return node.kind === ts.SyntaxKind.ComputedPropertyName;
}
exports.isComputedPropertyName = isComputedPropertyName;
function isDebuggerStatement(node) {
return node.kind === ts.SyntaxKind.DebuggerStatement;
}
exports.isDebuggerStatement = isDebuggerStatement;
function isDecorator(node) {
return node.kind === ts.SyntaxKind.Decorator;
}
exports.isDecorator = isDecorator;
function isDefaultClause(node) {
return node.kind === ts.SyntaxKind.DefaultClause;
}
exports.isDefaultClause = isDefaultClause;
function isDeleteExpression(node) {
return node.kind === ts.SyntaxKind.DeleteExpression;
}
exports.isDeleteExpression = isDeleteExpression;
function isDoStatement(node) {
return node.kind === ts.SyntaxKind.DoStatement;
}
exports.isDoStatement = isDoStatement;
function isElementAccessExpression(node) {
return node.kind === ts.SyntaxKind.ElementAccessExpression;
}
exports.isElementAccessExpression = isElementAccessExpression;
function isEmptyStatement(node) {
return node.kind === ts.SyntaxKind.EmptyStatement;
}
exports.isEmptyStatement = isEmptyStatement;
function isEntityName(node) {
return node.kind === ts.SyntaxKind.Identifier || isQualifiedName(node);
}
exports.isEntityName = isEntityName;
function isEntityNameExpression(node) {
return node.kind === ts.SyntaxKind.Identifier ||
isPropertyAccessExpression(node) && isEntityNameExpression(node.expression);
}
exports.isEntityNameExpression = isEntityNameExpression;
function isEnumDeclaration(node) {
return node.kind === ts.SyntaxKind.EnumDeclaration;
}
exports.isEnumDeclaration = isEnumDeclaration;
function isEnumMember(node) {
return node.kind === ts.SyntaxKind.EnumMember;
}
exports.isEnumMember = isEnumMember;
function isExportAssignment(node) {
return node.kind === ts.SyntaxKind.ExportAssignment;
}
exports.isExportAssignment = isExportAssignment;
function isExportDeclaration(node) {
return node.kind === ts.SyntaxKind.ExportDeclaration;
}
exports.isExportDeclaration = isExportDeclaration;
function isExportSpecifier(node) {
return node.kind === ts.SyntaxKind.ExportSpecifier;
}
exports.isExportSpecifier = isExportSpecifier;
function isExpression(node) {
switch (node.kind) {
case ts.SyntaxKind.ArrayLiteralExpression:
case ts.SyntaxKind.ArrowFunction:
case ts.SyntaxKind.AsExpression:
case ts.SyntaxKind.AwaitExpression:
case ts.SyntaxKind.BinaryExpression:
case ts.SyntaxKind.CallExpression:
case ts.SyntaxKind.ClassExpression:
case ts.SyntaxKind.CommaListExpression:
case ts.SyntaxKind.ConditionalExpression:
case ts.SyntaxKind.DeleteExpression:
case ts.SyntaxKind.ElementAccessExpression:
case ts.SyntaxKind.FalseKeyword:
case ts.SyntaxKind.FunctionExpression:
case ts.SyntaxKind.Identifier:
case ts.SyntaxKind.JsxElement:
case ts.SyntaxKind.JsxFragment:
case ts.SyntaxKind.JsxExpression:
case ts.SyntaxKind.JsxOpeningElement:
case ts.SyntaxKind.JsxOpeningFragment:
case ts.SyntaxKind.JsxSelfClosingElement:
case ts.SyntaxKind.MetaProperty:
case ts.SyntaxKind.NewExpression:
case ts.SyntaxKind.NonNullExpression:
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
case ts.SyntaxKind.NullKeyword:
case ts.SyntaxKind.NumericLiteral:
case ts.SyntaxKind.ObjectLiteralExpression:
case ts.SyntaxKind.OmittedExpression:
case ts.SyntaxKind.ParenthesizedExpression:
case ts.SyntaxKind.PostfixUnaryExpression:
case ts.SyntaxKind.PrefixUnaryExpression:
case ts.SyntaxKind.PropertyAccessExpression:
case ts.SyntaxKind.RegularExpressionLiteral:
case ts.SyntaxKind.SpreadElement:
case ts.SyntaxKind.StringLiteral:
case ts.SyntaxKind.SuperKeyword:
case ts.SyntaxKind.TaggedTemplateExpression:
case ts.SyntaxKind.TemplateExpression:
case ts.SyntaxKind.ThisKeyword:
case ts.SyntaxKind.TrueKeyword:
case ts.SyntaxKind.TypeAssertionExpression:
case ts.SyntaxKind.TypeOfExpression:
case ts.SyntaxKind.VoidExpression:
case ts.SyntaxKind.YieldExpression:
return true;
default:
return false;
}
}
exports.isExpression = isExpression;
function isExpressionStatement(node) {
return node.kind === ts.SyntaxKind.ExpressionStatement;
}
exports.isExpressionStatement = isExpressionStatement;
function isExpressionWithTypeArguments(node) {
return node.kind === ts.SyntaxKind.ExpressionWithTypeArguments;
}
exports.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
function isExternalModuleReference(node) {
return node.kind === ts.SyntaxKind.ExternalModuleReference;
}
exports.isExternalModuleReference = isExternalModuleReference;
function isForInStatement(node) {
return node.kind === ts.SyntaxKind.ForInStatement;
}
exports.isForInStatement = isForInStatement;
function isForInOrOfStatement(node) {
return node.kind === ts.SyntaxKind.ForOfStatement || node.kind === ts.SyntaxKind.ForInStatement;
}
exports.isForInOrOfStatement = isForInOrOfStatement;
function isForOfStatement(node) {
return node.kind === ts.SyntaxKind.ForOfStatement;
}
exports.isForOfStatement = isForOfStatement;
function isForStatement(node) {
return node.kind === ts.SyntaxKind.ForStatement;
}
exports.isForStatement = isForStatement;
function isFunctionDeclaration(node) {
return node.kind === ts.SyntaxKind.FunctionDeclaration;
}
exports.isFunctionDeclaration = isFunctionDeclaration;
function isFunctionExpression(node) {
return node.kind === ts.SyntaxKind.FunctionExpression;
}
exports.isFunctionExpression = isFunctionExpression;
function isFunctionTypeNode(node) {
return node.kind === ts.SyntaxKind.FunctionType;
}
exports.isFunctionTypeNode = isFunctionTypeNode;
function isGetAccessorDeclaration(node) {
return node.kind === ts.SyntaxKind.GetAccessor;
}
exports.isGetAccessorDeclaration = isGetAccessorDeclaration;
function isIdentifier(node) {
return node.kind === ts.SyntaxKind.Identifier;
}
exports.isIdentifier = isIdentifier;
function isIfStatement(node) {
return node.kind === ts.SyntaxKind.IfStatement;
}
exports.isIfStatement = isIfStatement;
function isImportClause(node) {
return node.kind === ts.SyntaxKind.ImportClause;
}
exports.isImportClause = isImportClause;
function isImportDeclaration(node) {
return node.kind === ts.SyntaxKind.ImportDeclaration;
}
exports.isImportDeclaration = isImportDeclaration;
function isImportEqualsDeclaration(node) {
return node.kind === ts.SyntaxKind.ImportEqualsDeclaration;
}
exports.isImportEqualsDeclaration = isImportEqualsDeclaration;
function isImportSpecifier(node) {
return node.kind === ts.SyntaxKind.ImportSpecifier;
}
exports.isImportSpecifier = isImportSpecifier;
function isIndexedAccessTypeNode(node) {
return node.kind === ts.SyntaxKind.IndexedAccessType;
}
exports.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
function isIndexSignatureDeclaration(node) {
return node.kind === ts.SyntaxKind.IndexSignature;
}
exports.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
function isInferTypeNode(node) {
return node.kind === ts.SyntaxKind.InferType;
}
exports.isInferTypeNode = isInferTypeNode;
function isInterfaceDeclaration(node) {
return node.kind === ts.SyntaxKind.InterfaceDeclaration;
}
exports.isInterfaceDeclaration = isInterfaceDeclaration;
function isIntersectionTypeNode(node) {
return node.kind === ts.SyntaxKind.IntersectionType;
}
exports.isIntersectionTypeNode = isIntersectionTypeNode;
function isIterationStatement(node) {
switch (node.kind) {
case ts.SyntaxKind.ForStatement:
case ts.SyntaxKind.ForOfStatement:
case ts.SyntaxKind.ForInStatement:
case ts.SyntaxKind.WhileStatement:
case ts.SyntaxKind.DoStatement:
return true;
default:
return false;
}
}
exports.isIterationStatement = isIterationStatement;
function isJsDoc(node) {
return node.kind === ts.SyntaxKind.JSDocComment;
}
exports.isJsDoc = isJsDoc;
function isJsxAttribute(node) {
return node.kind === ts.SyntaxKind.JsxAttribute;
}
exports.isJsxAttribute = isJsxAttribute;
function isJsxAttributeLike(node) {
return node.kind === ts.SyntaxKind.JsxAttribute ||
node.kind === ts.SyntaxKind.JsxSpreadAttribute;
}
exports.isJsxAttributeLike = isJsxAttributeLike;
function isJsxAttributes(node) {
return node.kind === ts.SyntaxKind.JsxAttributes;
}
exports.isJsxAttributes = isJsxAttributes;
function isJsxClosingElement(node) {
return node.kind === ts.SyntaxKind.JsxClosingElement;
}
exports.isJsxClosingElement = isJsxClosingElement;
function isJsxClosingFragment(node) {
return node.kind === ts.SyntaxKind.JsxClosingFragment;
}
exports.isJsxClosingFragment = isJsxClosingFragment;
function isJsxElement(node) {
return node.kind === ts.SyntaxKind.JsxElement;
}
exports.isJsxElement = isJsxElement;
function isJsxExpression(node) {
return node.kind === ts.SyntaxKind.JsxExpression;
}
exports.isJsxExpression = isJsxExpression;
function isJsxFragment(node) {
return node.kind === ts.SyntaxKind.JsxFragment;
}
exports.isJsxFragment = isJsxFragment;
function isJsxOpeningElement(node) {
return node.kind === ts.SyntaxKind.JsxOpeningElement;
}
exports.isJsxOpeningElement = isJsxOpeningElement;
function isJsxOpeningFragment(node) {
return node.kind === ts.SyntaxKind.JsxOpeningFragment;
}
exports.isJsxOpeningFragment = isJsxOpeningFragment;
function isJsxOpeningLikeElement(node) {
return node.kind === ts.SyntaxKind.JsxOpeningElement ||
node.kind === ts.SyntaxKind.JsxSelfClosingElement;
}
exports.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
function isJsxSelfClosingElement(node) {
return node.kind === ts.SyntaxKind.JsxSelfClosingElement;
}
exports.isJsxSelfClosingElement = isJsxSelfClosingElement;
function isJsxSpreadAttribute(node) {
return node.kind === ts.SyntaxKind.JsxSpreadAttribute;
}
exports.isJsxSpreadAttribute = isJsxSpreadAttribute;
function isJsxText(node) {
return node.kind === ts.SyntaxKind.JsxText;
}
exports.isJsxText = isJsxText;
function isLabeledStatement(node) {
return node.kind === ts.SyntaxKind.LabeledStatement;
}
exports.isLabeledStatement = isLabeledStatement;
function isLiteralExpression(node) {
return node.kind >= ts.SyntaxKind.FirstLiteralToken &&
node.kind <= ts.SyntaxKind.LastLiteralToken;
}
exports.isLiteralExpression = isLiteralExpression;
function isLiteralTypeNode(node) {
return node.kind === ts.SyntaxKind.LiteralType;
}
exports.isLiteralTypeNode = isLiteralTypeNode;
function isMappedTypeNode(node) {
return node.kind === ts.SyntaxKind.MappedType;
}
exports.isMappedTypeNode = isMappedTypeNode;
function isMetaProperty(node) {
return node.kind === ts.SyntaxKind.MetaProperty;
}
exports.isMetaProperty = isMetaProperty;
function isMethodDeclaration(node) {
return node.kind === ts.SyntaxKind.MethodDeclaration;
}
exports.isMethodDeclaration = isMethodDeclaration;
function isMethodSignature(node) {
return node.kind === ts.SyntaxKind.MethodSignature;
}
exports.isMethodSignature = isMethodSignature;
function isModuleBlock(node) {
return node.kind === ts.SyntaxKind.ModuleBlock;
}
exports.isModuleBlock = isModuleBlock;
function isModuleDeclaration(node) {
return node.kind === ts.SyntaxKind.ModuleDeclaration;
}
exports.isModuleDeclaration = isModuleDeclaration;
function isNamedExports(node) {
return node.kind === ts.SyntaxKind.NamedExports;
}
exports.isNamedExports = isNamedExports;
function isNamedImports(node) {
return node.kind === ts.SyntaxKind.NamedImports;
}
exports.isNamedImports = isNamedImports;
function isNamespaceDeclaration(node) {
return isModuleDeclaration(node) &&
node.name.kind === ts.SyntaxKind.Identifier &&
node.body !== undefined &&
(node.body.kind === ts.SyntaxKind.ModuleBlock ||
isNamespaceDeclaration(node.body));
}
exports.isNamespaceDeclaration = isNamespaceDeclaration;
function isNamespaceImport(node) {
return node.kind === ts.SyntaxKind.NamespaceImport;
}
exports.isNamespaceImport = isNamespaceImport;
function isNamespaceExportDeclaration(node) {
return node.kind === ts.SyntaxKind.NamespaceExportDeclaration;
}
exports.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
function isNewExpression(node) {
return node.kind === ts.SyntaxKind.NewExpression;
}
exports.isNewExpression = isNewExpression;
function isNonNullExpression(node) {
return node.kind === ts.SyntaxKind.NonNullExpression;
}
exports.isNonNullExpression = isNonNullExpression;
function isNoSubstitutionTemplateLiteral(node) {
return node.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral;
}
exports.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
function isNullLiteral(node) {
return node.kind === ts.SyntaxKind.NullKeyword;
}
exports.isNullLiteral = isNullLiteral;
function isNumericLiteral(node) {
return node.kind === ts.SyntaxKind.NumericLiteral;
}
exports.isNumericLiteral = isNumericLiteral;
function isNumericOrStringLikeLiteral(node) {
switch (node.kind) {
case ts.SyntaxKind.StringLiteral:
case ts.SyntaxKind.NumericLiteral:
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
return true;
default:
return false;
}
}
exports.isNumericOrStringLikeLiteral = isNumericOrStringLikeLiteral;
function isObjectBindingPattern(node) {
return node.kind === ts.SyntaxKind.ObjectBindingPattern;
}
exports.isObjectBindingPattern = isObjectBindingPattern;
function isObjectLiteralExpression(node) {
return node.kind === ts.SyntaxKind.ObjectLiteralExpression;
}
exports.isObjectLiteralExpression = isObjectLiteralExpression;
function isOmittedExpression(node) {
return node.kind === ts.SyntaxKind.OmittedExpression;
}
exports.isOmittedExpression = isOmittedExpression;
function isParameterDeclaration(node) {
return node.kind === ts.SyntaxKind.Parameter;
}
exports.isParameterDeclaration = isParameterDeclaration;
function isParenthesizedExpression(node) {
return node.kind === ts.SyntaxKind.ParenthesizedExpression;
}
exports.isParenthesizedExpression = isParenthesizedExpression;
function isParenthesizedTypeNode(node) {
return node.kind === ts.SyntaxKind.ParenthesizedType;
}
exports.isParenthesizedTypeNode = isParenthesizedTypeNode;
function isPostfixUnaryExpression(node) {
return node.kind === ts.SyntaxKind.PostfixUnaryExpression;
}
exports.isPostfixUnaryExpression = isPostfixUnaryExpression;
function isPrefixUnaryExpression(node) {
return node.kind === ts.SyntaxKind.PrefixUnaryExpression;
}
exports.isPrefixUnaryExpression = isPrefixUnaryExpression;
function isPropertyAccessExpression(node) {
return node.kind === ts.SyntaxKind.PropertyAccessExpression;
}
exports.isPropertyAccessExpression = isPropertyAccessExpression;
function isPropertyAssignment(node) {
return node.kind === ts.SyntaxKind.PropertyAssignment;
}
exports.isPropertyAssignment = isPropertyAssignment;
function isPropertyDeclaration(node) {
return node.kind === ts.SyntaxKind.PropertyDeclaration;
}
exports.isPropertyDeclaration = isPropertyDeclaration;
function isPropertySignature(node) {
return node.kind === ts.SyntaxKind.PropertySignature;
}
exports.isPropertySignature = isPropertySignature;
function isQualifiedName(node) {
return node.kind === ts.SyntaxKind.QualifiedName;
}
exports.isQualifiedName = isQualifiedName;
function isRegularExpressionLiteral(node) {
return node.kind === ts.SyntaxKind.RegularExpressionLiteral;
}
exports.isRegularExpressionLiteral = isRegularExpressionLiteral;
function isReturnStatement(node) {
return node.kind === ts.SyntaxKind.ReturnStatement;
}
exports.isReturnStatement = isReturnStatement;
function isSetAccessorDeclaration(node) {
return node.kind === ts.SyntaxKind.SetAccessor;
}
exports.isSetAccessorDeclaration = isSetAccessorDeclaration;
function isShorthandPropertyAssignment(node) {
return node.kind === ts.SyntaxKind.ShorthandPropertyAssignment;
}
exports.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
function isSignatureDeclaration(node) {
return node.parameters !== undefined;
}
exports.isSignatureDeclaration = isSignatureDeclaration;
function isSourceFile(node) {
return node.kind === ts.SyntaxKind.SourceFile;
}
exports.isSourceFile = isSourceFile;
function isSpreadAssignment(node) {
return node.kind === ts.SyntaxKind.SpreadAssignment;
}
exports.isSpreadAssignment = isSpreadAssignment;
function isSpreadElement(node) {
return node.kind === ts.SyntaxKind.SpreadElement;
}
exports.isSpreadElement = isSpreadElement;
function isStringLiteral(node) {
return node.kind === ts.SyntaxKind.StringLiteral;
}
exports.isStringLiteral = isStringLiteral;
function isSwitchStatement(node) {
return node.kind === ts.SyntaxKind.SwitchStatement;
}
exports.isSwitchStatement = isSwitchStatement;
function isSyntaxList(node) {
return node.kind === ts.SyntaxKind.SyntaxList;
}
exports.isSyntaxList = isSyntaxList;
function isTaggedTemplateExpression(node) {
return node.kind === ts.SyntaxKind.TaggedTemplateExpression;
}
exports.isTaggedTemplateExpression = isTaggedTemplateExpression;
function isTemplateExpression(node) {
return node.kind === ts.SyntaxKind.TemplateExpression;
}
exports.isTemplateExpression = isTemplateExpression;
function isTemplateLiteral(node) {
return node.kind === ts.SyntaxKind.TemplateExpression ||
node.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral;
}
exports.isTemplateLiteral = isTemplateLiteral;
function isTextualLiteral(node) {
return node.kind === ts.SyntaxKind.StringLiteral ||
node.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral;
}
exports.isTextualLiteral = isTextualLiteral;
function isThrowStatement(node) {
return node.kind === ts.SyntaxKind.ThrowStatement;
}
exports.isThrowStatement = isThrowStatement;
function isTryStatement(node) {
return node.kind === ts.SyntaxKind.TryStatement;
}
exports.isTryStatement = isTryStatement;
function isTupleTypeNode(node) {
return node.kind === ts.SyntaxKind.TupleType;
}
exports.isTupleTypeNode = isTupleTypeNode;
function isTypeAliasDeclaration(node) {
return node.kind === ts.SyntaxKind.TypeAliasDeclaration;
}
exports.isTypeAliasDeclaration = isTypeAliasDeclaration;
function isTypeAssertion(node) {
return node.kind === ts.SyntaxKind.TypeAssertionExpression;
}
exports.isTypeAssertion = isTypeAssertion;
function isTypeLiteralNode(node) {
return node.kind === ts.SyntaxKind.TypeLiteral;
}
exports.isTypeLiteralNode = isTypeLiteralNode;
function isTypeOfExpression(node) {
return node.kind === ts.SyntaxKind.TypeOfExpression;
}
exports.isTypeOfExpression = isTypeOfExpression;
function isTypeOperatorNode(node) {
return node.kind === ts.SyntaxKind.TypeOperator;
}
exports.isTypeOperatorNode = isTypeOperatorNode;
function isTypeParameterDeclaration(node) {
return node.kind === ts.SyntaxKind.TypeParameter;
}
exports.isTypeParameterDeclaration = isTypeParameterDeclaration;
function isTypePredicateNode(node) {
return node.kind === ts.SyntaxKind.TypePredicate;
}
exports.isTypePredicateNode = isTypePredicateNode;
function isTypeReferenceNode(node) {
return node.kind === ts.SyntaxKind.TypeReference;
}
exports.isTypeReferenceNode = isTypeReferenceNode;
function isTypeQueryNode(node) {
return node.kind === ts.SyntaxKind.TypeQuery;
}
exports.isTypeQueryNode = isTypeQueryNode;
function isUnionTypeNode(node) {
return node.kind === ts.SyntaxKind.UnionType;
}
exports.isUnionTypeNode = isUnionTypeNode;
function isVariableDeclaration(node) {
return node.kind === ts.SyntaxKind.VariableDeclaration;
}
exports.isVariableDeclaration = isVariableDeclaration;
function isVariableStatement(node) {
return node.kind === ts.SyntaxKind.VariableStatement;
}
exports.isVariableStatement = isVariableStatement;
function isVariableDeclarationList(node) {
return node.kind === ts.SyntaxKind.VariableDeclarationList;
}
exports.isVariableDeclarationList = isVariableDeclarationList;
function isVoidExpression(node) {
return node.kind === ts.SyntaxKind.VoidExpression;
}
exports.isVoidExpression = isVoidExpression;
function isWhileStatement(node) {
return node.kind === ts.SyntaxKind.WhileStatement;
}
exports.isWhileStatement = isWhileStatement;
function isWithStatement(node) {
return node.kind === ts.SyntaxKind.WithStatement;
}
exports.isWithStatement = isWithStatement;

View File

@@ -0,0 +1,18 @@
import * as ts from 'typescript';
export declare function isConditionalType(type: ts.Type): type is ts.ConditionalType;
export declare function isEnumType(type: ts.Type): type is ts.EnumType;
export declare function isGenericType(type: ts.Type): type is ts.GenericType;
export declare function isIndexedAccessType(type: ts.Type): type is ts.IndexedAccessType;
export declare function isIndexedAccessype(type: ts.Type): type is ts.IndexType;
export declare function isInstantiableType(type: ts.Type): type is ts.InstantiableType;
export declare function isInterfaceType(type: ts.Type): type is ts.InterfaceType;
export declare function isIntersectionType(type: ts.Type): type is ts.IntersectionType;
export declare function isLiteralType(type: ts.Type): type is ts.LiteralType;
export declare function isObjectType(type: ts.Type): type is ts.ObjectType;
export declare function isSubstitutionType(type: ts.Type): type is ts.SubstitutionType;
export declare function isTypeParameter(type: ts.Type): type is ts.TypeParameter;
export declare function isTypeReference(type: ts.Type): type is ts.TypeReference;
export declare function isTypeVariable(type: ts.Type): type is ts.TypeParameter | ts.IndexedAccessType;
export declare function isUnionOrIntersectionType(type: ts.Type): type is ts.UnionOrIntersectionType;
export declare function isUnionType(type: ts.Type): type is ts.UnionType;
export declare function isUniqueESSymbolType(type: ts.Type): type is ts.UniqueESSymbolType;

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ts = require("typescript");
function isConditionalType(type) {
return (type.flags & ts.TypeFlags.Conditional) !== 0;
}
exports.isConditionalType = isConditionalType;
function isEnumType(type) {
return (type.flags & ts.TypeFlags.Enum) !== 0;
}
exports.isEnumType = isEnumType;
function isGenericType(type) {
return (type.flags & ts.TypeFlags.Object) !== 0 &&
(type.objectFlags & ts.ObjectFlags.ClassOrInterface) !== 0 &&
(type.objectFlags & ts.ObjectFlags.Reference) !== 0;
}
exports.isGenericType = isGenericType;
function isIndexedAccessType(type) {
return (type.flags & ts.TypeFlags.IndexedAccess) !== 0;
}
exports.isIndexedAccessType = isIndexedAccessType;
function isIndexedAccessype(type) {
return (type.flags & ts.TypeFlags.Index) !== 0;
}
exports.isIndexedAccessype = isIndexedAccessype;
function isInstantiableType(type) {
return (type.flags & ts.TypeFlags.Instantiable) !== 0;
}
exports.isInstantiableType = isInstantiableType;
function isInterfaceType(type) {
return (type.flags & ts.TypeFlags.Object) !== 0 &&
(type.objectFlags & ts.ObjectFlags.ClassOrInterface) !== 0;
}
exports.isInterfaceType = isInterfaceType;
function isIntersectionType(type) {
return (type.flags & ts.TypeFlags.Intersection) !== 0;
}
exports.isIntersectionType = isIntersectionType;
function isLiteralType(type) {
return (type.flags & (ts.TypeFlags.StringOrNumberLiteral | ts.TypeFlags.BigIntLiteral)) !== 0;
}
exports.isLiteralType = isLiteralType;
function isObjectType(type) {
return (type.flags & ts.TypeFlags.Object) !== 0;
}
exports.isObjectType = isObjectType;
function isSubstitutionType(type) {
return (type.flags & ts.TypeFlags.Substitution) !== 0;
}
exports.isSubstitutionType = isSubstitutionType;
function isTypeParameter(type) {
return (type.flags & ts.TypeFlags.TypeParameter) !== 0;
}
exports.isTypeParameter = isTypeParameter;
function isTypeReference(type) {
return (type.flags & ts.TypeFlags.Object) !== 0 &&
(type.objectFlags & ts.ObjectFlags.Reference) !== 0;
}
exports.isTypeReference = isTypeReference;
function isTypeVariable(type) {
return (type.flags & ts.TypeFlags.TypeVariable) !== 0;
}
exports.isTypeVariable = isTypeVariable;
function isUnionOrIntersectionType(type) {
return (type.flags & ts.TypeFlags.UnionOrIntersection) !== 0;
}
exports.isUnionOrIntersectionType = isUnionOrIntersectionType;
function isUnionType(type) {
return (type.flags & ts.TypeFlags.Union) !== 0;
}
exports.isUnionType = isUnionType;
function isUniqueESSymbolType(type) {
return (type.flags & ts.TypeFlags.UniqueESSymbol) !== 0;
}
exports.isUniqueESSymbolType = isUniqueESSymbolType;

View File

@@ -0,0 +1,2 @@
export * from './node';
export * from './type';

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./node"), exports);
tslib_1.__exportStar(require("./type"), exports);

View File

@@ -0,0 +1,3 @@
export * from '../2.8/node';
import * as ts from 'typescript';
export declare function isImportTypeNode(node: ts.Node): node is ts.ImportTypeNode;

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("../2.8/node"), exports);
const ts = require("typescript");
function isImportTypeNode(node) {
return node.kind === ts.SyntaxKind.ImportType;
}
exports.isImportTypeNode = isImportTypeNode;

View File

@@ -0,0 +1 @@
export * from '../2.8/type';

View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("../2.8/type"), exports);

View File

@@ -0,0 +1,2 @@
export * from './node';
export * from './type';

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./node"), exports);
tslib_1.__exportStar(require("./type"), exports);

View File

@@ -0,0 +1,5 @@
export * from '../2.9/node';
import * as ts from 'typescript';
export declare function isOptionalTypeNode(node: ts.Node): node is ts.OptionalTypeNode;
export declare function isRestTypeNode(node: ts.Node): node is ts.RestTypeNode;
export declare function isSyntheticExpression(node: ts.Node): node is ts.SyntheticExpression;

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("../2.9/node"), exports);
const ts = require("typescript");
function isOptionalTypeNode(node) {
return node.kind === ts.SyntaxKind.OptionalType;
}
exports.isOptionalTypeNode = isOptionalTypeNode;
function isRestTypeNode(node) {
return node.kind === ts.SyntaxKind.RestType;
}
exports.isRestTypeNode = isRestTypeNode;
function isSyntheticExpression(node) {
return node.kind === ts.SyntaxKind.SyntheticExpression;
}
exports.isSyntheticExpression = isSyntheticExpression;

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