aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/language/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tslint/lib/language/utils.js')
-rw-r--r--node_modules/tslint/lib/language/utils.js46
1 files changed, 40 insertions, 6 deletions
diff --git a/node_modules/tslint/lib/language/utils.js b/node_modules/tslint/lib/language/utils.js
index e9ba81a48..aba50291f 100644
--- a/node_modules/tslint/lib/language/utils.js
+++ b/node_modules/tslint/lib/language/utils.js
@@ -35,6 +35,8 @@ function doesIntersect(failure, disabledIntervals) {
exports.doesIntersect = doesIntersect;
/**
* @returns true if any modifier kinds passed along exist in the given modifiers array
+ *
+ * @deprecated use `hasModifier` from `tsutils`
*/
function hasModifier(modifiers) {
var modifierKinds = [];
@@ -50,6 +52,8 @@ exports.hasModifier = hasModifier;
/**
* Determines if the appropriate bit in the parent (VariableDeclarationList) is set,
* which indicates this is a "let" or "const".
+ *
+ * @deprecated use `isBlockScopedVariableDeclarationList` from `tsutils`
*/
function isBlockScopedVariable(node) {
if (node.kind === ts.SyntaxKind.VariableDeclaration) {
@@ -61,12 +65,14 @@ function isBlockScopedVariable(node) {
}
}
exports.isBlockScopedVariable = isBlockScopedVariable;
+/** @deprecated use `isBlockScopedVariableDeclarationList` and `getDeclarationOfBindingElement` from `tsutils` */
function isBlockScopedBindingElement(node) {
- var variableDeclaration = getBindingElementVariableDeclaration(node);
+ var variableDeclaration = getBindingElementVariableDeclaration(node); // tslint:disable-line:deprecation
// if no variable declaration, it must be a function param, which is block scoped
- return (variableDeclaration === null) || isBlockScopedVariable(variableDeclaration);
+ return (variableDeclaration === null) || isBlockScopedVariable(variableDeclaration); // tslint:disable-line:deprecation
}
exports.isBlockScopedBindingElement = isBlockScopedBindingElement;
+/** @deprecated use `getDeclarationOfBindingElement` from `tsutils` */
function getBindingElementVariableDeclaration(node) {
var currentParent = node.parent;
while (currentParent.kind !== ts.SyntaxKind.VariableDeclaration) {
@@ -83,6 +89,8 @@ exports.getBindingElementVariableDeclaration = getBindingElementVariableDeclarat
/**
* Finds a child of a given node with a given kind.
* Note: This uses `node.getChildren()`, which does extra parsing work to include tokens.
+ *
+ * @deprecated use `getChildOfKind` from `tsutils`
*/
function childOfKind(node, kind) {
return node.getChildren().find(function (child) { return child.kind === kind; });
@@ -90,9 +98,11 @@ function childOfKind(node, kind) {
exports.childOfKind = childOfKind;
/**
* @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself.
+ *
+ * @deprecated no longer used, use a `while` loop instead
*/
function someAncestor(node, predicate) {
- return predicate(node) || (node.parent !== undefined && someAncestor(node.parent, predicate));
+ return predicate(node) || (node.parent !== undefined && someAncestor(node.parent, predicate)); // tslint:disable-line:deprecation
}
exports.someAncestor = someAncestor;
function ancestorWhere(node, predicate) {
@@ -106,6 +116,7 @@ function ancestorWhere(node, predicate) {
return undefined;
}
exports.ancestorWhere = ancestorWhere;
+/** @deprecated use `isBinaryExpression(node) && isAssignmentKind(node.operatorToken.kind)` with functions from `tsutils` */
function isAssignment(node) {
if (node.kind === ts.SyntaxKind.BinaryExpression) {
var binaryExpression = node;
@@ -119,6 +130,8 @@ function isAssignment(node) {
exports.isAssignment = isAssignment;
/**
* Bitwise check for node flags.
+ *
+ * @deprecated use `isNodeFlagSet` from `tsutils`
*/
function isNodeFlagSet(node, flagToCheck) {
// tslint:disable-next-line:no-bitwise
@@ -127,6 +140,8 @@ function isNodeFlagSet(node, flagToCheck) {
exports.isNodeFlagSet = isNodeFlagSet;
/**
* Bitwise check for combined node flags.
+ *
+ * @deprecated no longer used
*/
function isCombinedNodeFlagSet(node, flagToCheck) {
// tslint:disable-next-line:no-bitwise
@@ -135,6 +150,8 @@ function isCombinedNodeFlagSet(node, flagToCheck) {
exports.isCombinedNodeFlagSet = isCombinedNodeFlagSet;
/**
* Bitwise check for combined modifier flags.
+ *
+ * @deprecated no longer used
*/
function isCombinedModifierFlagSet(node, flagToCheck) {
// tslint:disable-next-line:no-bitwise
@@ -143,6 +160,8 @@ function isCombinedModifierFlagSet(node, flagToCheck) {
exports.isCombinedModifierFlagSet = isCombinedModifierFlagSet;
/**
* Bitwise check for type flags.
+ *
+ * @deprecated use `isTypeFlagSet` from `tsutils`
*/
function isTypeFlagSet(type, flagToCheck) {
// tslint:disable-next-line:no-bitwise
@@ -151,6 +170,8 @@ function isTypeFlagSet(type, flagToCheck) {
exports.isTypeFlagSet = isTypeFlagSet;
/**
* Bitwise check for symbol flags.
+ *
+ * @deprecated use `isSymbolFlagSet` from `tsutils`
*/
function isSymbolFlagSet(symbol, flagToCheck) {
// tslint:disable-next-line:no-bitwise
@@ -160,6 +181,8 @@ exports.isSymbolFlagSet = isSymbolFlagSet;
/**
* Bitwise check for object flags.
* Does not work with TypeScript 2.0.x
+ *
+ * @deprecated use `isObjectFlagSet` from `tsutils`
*/
function isObjectFlagSet(objectType, flagToCheck) {
// tslint:disable-next-line:no-bitwise
@@ -168,6 +191,8 @@ function isObjectFlagSet(objectType, flagToCheck) {
exports.isObjectFlagSet = isObjectFlagSet;
/**
* @returns true if decl is a nested module declaration, i.e. represents a segment of a dotted module path.
+ *
+ * @deprecated use `decl.parent!.kind === ts.SyntaxKind.ModuleDeclaration`
*/
function isNestedModuleDeclaration(decl) {
// in a declaration expression like 'module a.b.c' - 'a' is the top level module declaration node and 'b' and 'c'
@@ -183,6 +208,7 @@ function unwrapParentheses(node) {
return node;
}
exports.unwrapParentheses = unwrapParentheses;
+/** @deprecated use `isFunctionScopeBoundary` from `tsutils` */
function isScopeBoundary(node) {
return node.kind === ts.SyntaxKind.FunctionDeclaration
|| node.kind === ts.SyntaxKind.FunctionExpression
@@ -201,10 +227,11 @@ function isScopeBoundary(node) {
|| node.kind === ts.SyntaxKind.SourceFile && ts.isExternalModule(node);
}
exports.isScopeBoundary = isScopeBoundary;
+/** @deprecated use `isBlockScopeBoundary` from `tsutils` */
function isBlockScopeBoundary(node) {
- return isScopeBoundary(node)
+ return isScopeBoundary(node) // tslint:disable-line:deprecation
|| node.kind === ts.SyntaxKind.Block
- || isLoop(node)
+ || isLoop(node) // tslint:disable-line:deprecation
|| node.kind === ts.SyntaxKind.WithStatement
|| node.kind === ts.SyntaxKind.SwitchStatement
|| node.parent !== undefined
@@ -212,6 +239,7 @@ function isBlockScopeBoundary(node) {
|| node.parent.kind === ts.SyntaxKind.IfStatement);
}
exports.isBlockScopeBoundary = isBlockScopeBoundary;
+/** @deprecated use `isIterationStatement` from `tsutils` or `typescript` */
function isLoop(node) {
return node.kind === ts.SyntaxKind.DoStatement
|| node.kind === ts.SyntaxKind.WhileStatement
@@ -241,6 +269,8 @@ exports.isNumeric = isNumeric;
* @param skipTrivia If set to false all trivia preceeding `node` or any of its children is included
* @param cb Is called for every token of `node`. It gets the full text of the SourceFile and the position of the token within that text.
* @param filter If provided, will be called for every Node and Token found. If it returns false `cb` will not be called for this subtree.
+ *
+ * @deprecated use `forEachToken` or `forEachTokenWithTrivia` from `tsutils`
*/
function forEachToken(node, skipTrivia, cb, filter) {
// this function will most likely be called with SourceFile anyways, so there is no need for an additional parameter
@@ -305,7 +335,11 @@ function createTriviaHandler(sourceFile, cb) {
}
return handleTrivia;
}
-/** Iterate over all comments owned by `node` or its children */
+/**
+ * Iterate over all comments owned by `node` or its children
+ *
+ * @deprecated use `forEachComment` from `tsutils`
+ */
function forEachComment(node, cb) {
/* Visit all tokens and skip trivia.
Comment ranges between tokens are parsed without the need of a scanner.