diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/tslint/lib/language | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/tslint/lib/language')
10 files changed, 126 insertions, 32 deletions
diff --git a/node_modules/tslint/lib/language/rule/abstractRule.d.ts b/node_modules/tslint/lib/language/rule/abstractRule.d.ts index a5c2b82ac..65ed4a1b9 100644 --- a/node_modules/tslint/lib/language/rule/abstractRule.d.ts +++ b/node_modules/tslint/lib/language/rule/abstractRule.d.ts @@ -21,7 +21,7 @@ export declare type NoInfer<T> = T & { [K in keyof T]: T[K]; }; export declare abstract class AbstractRule implements IRule { - private options; + private readonly options; static metadata: IRuleMetadata; protected readonly ruleArguments: any[]; protected readonly ruleSeverity: RuleSeverity; diff --git a/node_modules/tslint/lib/language/rule/rule.d.ts b/node_modules/tslint/lib/language/rule/rule.d.ts index d1ba8ac58..e37861c36 100644 --- a/node_modules/tslint/lib/language/rule/rule.d.ts +++ b/node_modules/tslint/lib/language/rule/rule.d.ts @@ -73,9 +73,19 @@ export interface IRuleMetadata { * Whether or not the rule use for TypeScript only. If `false`, this rule may be used with .js files. */ typescriptOnly: boolean; + /** + * Examples demonstrating what the lint rule will pass and fail + */ + codeExamples?: ICodeExample[]; } export declare type RuleType = "functionality" | "maintainability" | "style" | "typescript"; export declare type RuleSeverity = "warning" | "error" | "off"; +export interface ICodeExample { + config: string; + description: string; + pass: string; + fail?: string; +} export interface IOptions { ruleArguments: any[]; ruleSeverity: RuleSeverity; @@ -141,8 +151,8 @@ export declare class Replacement { toJson(): ReplacementJson; } export declare class RuleFailurePosition { - private position; - private lineAndCharacter; + private readonly position; + private readonly lineAndCharacter; constructor(position: number, lineAndCharacter: ts.LineAndCharacter); getPosition(): number; getLineAndCharacter(): ts.LineAndCharacter; @@ -152,14 +162,14 @@ export declare class RuleFailurePosition { export declare type Fix = Replacement | Replacement[]; export declare type FixJson = ReplacementJson | ReplacementJson[]; export declare class RuleFailure { - private sourceFile; - private failure; - private ruleName; - private fix; - private fileName; - private startPosition; - private endPosition; - private rawLines; + private readonly sourceFile; + private readonly failure; + private readonly ruleName; + private readonly fix?; + private readonly fileName; + private readonly startPosition; + private readonly endPosition; + private readonly rawLines; private ruleSeverity; static compare(a: RuleFailure, b: RuleFailure): number; constructor(sourceFile: ts.SourceFile, start: number, end: number, failure: string, ruleName: string, fix?: Replacement | Replacement[] | undefined); @@ -175,5 +185,5 @@ export declare class RuleFailure { setRuleSeverity(value: RuleSeverity): void; toJson(): IRuleFailureJson; equals(ruleFailure: RuleFailure): boolean; - private createFailurePosition(position); + private createFailurePosition; } diff --git a/node_modules/tslint/lib/language/utils.d.ts b/node_modules/tslint/lib/language/utils.d.ts index ffdd0aabc..40b4aee16 100644 --- a/node_modules/tslint/lib/language/utils.d.ts +++ b/node_modules/tslint/lib/language/utils.d.ts @@ -1,3 +1,19 @@ +/** + * @license + * Copyright 2013 Palantir Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import * as ts from "typescript"; import { IDisabledInterval, RuleFailure } from "./rule/rule"; export declare function getSourceFile(fileName: string, source: string): ts.SourceFile; @@ -5,59 +21,86 @@ export declare function getSourceFile(fileName: string, source: string): ts.Sour export declare function doesIntersect(failure: RuleFailure, disabledIntervals: IDisabledInterval[]): boolean; /** * @returns true if any modifier kinds passed along exist in the given modifiers array + * + * @deprecated use `hasModifier` from `tsutils` */ export declare function hasModifier(modifiers: ts.ModifiersArray | undefined, ...modifierKinds: ts.SyntaxKind[]): boolean; /** * Determines if the appropriate bit in the parent (VariableDeclarationList) is set, * which indicates this is a "let" or "const". + * + * @deprecated use `isBlockScopedVariableDeclarationList` from `tsutils` */ export declare function isBlockScopedVariable(node: ts.VariableDeclaration | ts.VariableStatement): boolean; +/** @deprecated use `isBlockScopedVariableDeclarationList` and `getDeclarationOfBindingElement` from `tsutils` */ export declare function isBlockScopedBindingElement(node: ts.BindingElement): boolean; +/** @deprecated use `getDeclarationOfBindingElement` from `tsutils` */ export declare function getBindingElementVariableDeclaration(node: ts.BindingElement): ts.VariableDeclaration | null; /** * Finds a child of a given node with a given kind. * Note: This uses `node.getChildren()`, which does extra parsing work to include tokens. + * + * @deprecated use `getChildOfKind` from `tsutils` */ export declare function childOfKind(node: ts.Node, kind: ts.SyntaxKind): ts.Node | undefined; /** * @returns true if some ancestor of `node` satisfies `predicate`, including `node` itself. + * + * @deprecated no longer used, use a `while` loop instead */ export declare function someAncestor(node: ts.Node, predicate: (n: ts.Node) => boolean): boolean; -export declare function ancestorWhere<T extends ts.Node>(node: ts.Node, predicate: (n: ts.Node) => n is T): T | undefined; -export declare function ancestorWhere(node: ts.Node, predicate: (n: ts.Node) => boolean): ts.Node | undefined; +export declare function ancestorWhere<T extends ts.Node = ts.Node>(node: ts.Node, predicate: ((n: ts.Node) => n is T) | ((n: ts.Node) => boolean)): T | undefined; +/** @deprecated use `isBinaryExpression(node) && isAssignmentKind(node.operatorToken.kind)` with functions from `tsutils` */ export declare function isAssignment(node: ts.Node): boolean; /** * Bitwise check for node flags. + * + * @deprecated use `isNodeFlagSet` from `tsutils` */ export declare function isNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean; /** * Bitwise check for combined node flags. + * + * @deprecated no longer used */ export declare function isCombinedNodeFlagSet(node: ts.Node, flagToCheck: ts.NodeFlags): boolean; /** * Bitwise check for combined modifier flags. + * + * @deprecated no longer used */ export declare function isCombinedModifierFlagSet(node: ts.Node, flagToCheck: ts.ModifierFlags): boolean; /** * Bitwise check for type flags. + * + * @deprecated use `isTypeFlagSet` from `tsutils` */ export declare function isTypeFlagSet(type: ts.Type, flagToCheck: ts.TypeFlags): boolean; /** * Bitwise check for symbol flags. + * + * @deprecated use `isSymbolFlagSet` from `tsutils` */ export declare function isSymbolFlagSet(symbol: ts.Symbol, flagToCheck: ts.SymbolFlags): boolean; /** * Bitwise check for object flags. * Does not work with TypeScript 2.0.x + * + * @deprecated use `isObjectFlagSet` from `tsutils` */ export declare function isObjectFlagSet(objectType: ts.ObjectType, flagToCheck: ts.ObjectFlags): boolean; /** * @returns true if decl is a nested module declaration, i.e. represents a segment of a dotted module path. + * + * @deprecated use `decl.parent!.kind === ts.SyntaxKind.ModuleDeclaration` */ export declare function isNestedModuleDeclaration(decl: ts.ModuleDeclaration): boolean; export declare function unwrapParentheses(node: ts.Expression): ts.Expression; +/** @deprecated use `isFunctionScopeBoundary` from `tsutils` */ export declare function isScopeBoundary(node: ts.Node): boolean; +/** @deprecated use `isBlockScopeBoundary` from `tsutils` */ export declare function isBlockScopeBoundary(node: ts.Node): boolean; +/** @deprecated use `isIterationStatement` from `tsutils` or `typescript` */ export declare function isLoop(node: ts.Node): node is ts.IterationStatement; /** * @returns Whether node is a numeric expression. @@ -83,9 +126,15 @@ export declare type FilterCallback = (node: ts.Node) => boolean; * @param skipTrivia If set to false all trivia preceeding `node` or any of its children is included * @param cb Is called for every token of `node`. It gets the full text of the SourceFile and the position of the token within that text. * @param filter If provided, will be called for every Node and Token found. If it returns false `cb` will not be called for this subtree. + * + * @deprecated use `forEachToken` or `forEachTokenWithTrivia` from `tsutils` */ export declare function forEachToken(node: ts.Node, skipTrivia: boolean, cb: ForEachTokenCallback, filter?: FilterCallback): void; -/** Iterate over all comments owned by `node` or its children */ +/** + * Iterate over all comments owned by `node` or its children + * + * @deprecated use `forEachComment` from `tsutils` + */ export declare function forEachComment(node: ts.Node, cb: ForEachCommentCallback): void; /** * Checks if there are any comments between `position` and the next non-trivia token 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. diff --git a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.d.ts b/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.d.ts index 92a61039d..0fd097cc7 100644 --- a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.d.ts +++ b/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.d.ts @@ -24,7 +24,7 @@ import { ScopeAwareRuleWalker } from "./scopeAwareRuleWalker"; * are a superset of regular scopes (new block scopes are created more frequently in a program). */ export declare abstract class BlockScopeAwareRuleWalker<T, U> extends ScopeAwareRuleWalker<T> { - private blockScopeStack; + private readonly blockScopeStack; constructor(sourceFile: ts.SourceFile, options: IOptions); abstract createBlockScope(node: ts.Node): U; getAllBlockScopes(): U[]; @@ -34,5 +34,5 @@ export declare abstract class BlockScopeAwareRuleWalker<T, U> extends ScopeAware onBlockScopeEnd(): void; findBlockScope(predicate: (scope: U) => boolean): U | undefined; protected visitNode(node: ts.Node): void; - private isBlockScopeBoundary(node); + private isBlockScopeBoundary; } diff --git a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js b/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js index 0b270d2cb..2bfe8865f 100644 --- a/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js +++ b/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js @@ -20,6 +20,7 @@ var tslib_1 = require("tslib"); var ts = require("typescript"); var utils_1 = require("../utils"); var scopeAwareRuleWalker_1 = require("./scopeAwareRuleWalker"); +// tslint:disable:deprecation (extends deprecated class and uses deprecated utils - doesn't matter because it's deprecated, too) /** * @deprecated See comment on ScopeAwareRuleWalker. * diff --git a/node_modules/tslint/lib/language/walker/programAwareRuleWalker.d.ts b/node_modules/tslint/lib/language/walker/programAwareRuleWalker.d.ts index d0ae8af52..8f949a03a 100644 --- a/node_modules/tslint/lib/language/walker/programAwareRuleWalker.d.ts +++ b/node_modules/tslint/lib/language/walker/programAwareRuleWalker.d.ts @@ -18,8 +18,8 @@ import * as ts from "typescript"; import { IOptions } from "../rule/rule"; import { RuleWalker } from "./ruleWalker"; export declare class ProgramAwareRuleWalker extends RuleWalker { - private program; - private typeChecker; + private readonly program; + private readonly typeChecker; constructor(sourceFile: ts.SourceFile, options: IOptions, program: ts.Program); getProgram(): ts.Program; getTypeChecker(): ts.TypeChecker; diff --git a/node_modules/tslint/lib/language/walker/ruleWalker.d.ts b/node_modules/tslint/lib/language/walker/ruleWalker.d.ts index f78b4c0ed..9d27e8bcb 100644 --- a/node_modules/tslint/lib/language/walker/ruleWalker.d.ts +++ b/node_modules/tslint/lib/language/walker/ruleWalker.d.ts @@ -19,11 +19,11 @@ import { Fix, IOptions, Replacement, RuleFailure } from "../rule/rule"; import { SyntaxWalker } from "./syntaxWalker"; import { IWalker } from "./walker"; export declare class RuleWalker extends SyntaxWalker implements IWalker { - private sourceFile; - private limit; - private options?; - private failures; - private ruleName; + private readonly sourceFile; + private readonly limit; + private readonly options?; + private readonly failures; + private readonly ruleName; constructor(sourceFile: ts.SourceFile, options: IOptions); getSourceFile(): ts.SourceFile; getLineAndCharacterOfPosition(position: number): ts.LineAndCharacter; diff --git a/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.d.ts b/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.d.ts index 64423e23b..dbb21a9f6 100644 --- a/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.d.ts +++ b/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.d.ts @@ -52,7 +52,7 @@ import { RuleWalker } from "./ruleWalker"; * } */ export declare abstract class ScopeAwareRuleWalker<T> extends RuleWalker { - private scopeStack; + private readonly scopeStack; constructor(sourceFile: ts.SourceFile, options: IOptions); abstract createScope(node: ts.Node): T; getCurrentScope(): T; diff --git a/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.js b/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.js index 2c9cb93a1..15cf26478 100644 --- a/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.js +++ b/node_modules/tslint/lib/language/walker/scopeAwareRuleWalker.js @@ -93,7 +93,7 @@ var ScopeAwareRuleWalker = /** @class */ (function (_super) { } }; ScopeAwareRuleWalker.prototype.isScopeBoundary = function (node) { - return utils_1.isScopeBoundary(node); + return utils_1.isScopeBoundary(node); // tslint:disable-line:deprecation }; return ScopeAwareRuleWalker; }(ruleWalker_1.RuleWalker)); |