Deployed the page to Github Pages.

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

View file

@ -0,0 +1,23 @@
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { RuleFailure } from "../rule/rule";
import { IFormatter, IFormatterMetadata } from "./formatter";
export declare abstract class AbstractFormatter implements IFormatter {
static metadata: IFormatterMetadata;
abstract format(failures: RuleFailure[], fixes?: RuleFailure[], fileNames?: string[]): string;
protected sortFailures(failures: RuleFailure[]): RuleFailure[];
}

View file

@ -0,0 +1,29 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractFormatter = void 0;
var rule_1 = require("../rule/rule");
var AbstractFormatter = /** @class */ (function () {
function AbstractFormatter() {
}
AbstractFormatter.prototype.sortFailures = function (failures) {
return failures.slice().sort(rule_1.RuleFailure.compare);
};
return AbstractFormatter;
}());
exports.AbstractFormatter = AbstractFormatter;

View file

@ -0,0 +1,52 @@
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { RuleFailure } from "../rule/rule";
export interface IFormatterMetadata {
/**
* The name of the formatter.
*/
formatterName: string;
/**
* A short, one line description of what the formatter does.
*/
description: string;
/**
* More elaborate details about the formatter.
*/
descriptionDetails?: string;
/**
* Sample output from the formatter.
*/
sample: string;
/**
* Sample output from the formatter.
*/
consumer: ConsumerType;
}
export declare type ConsumerType = "human" | "machine";
export interface FormatterConstructor {
new (): IFormatter;
}
export interface IFormatter {
/**
* Formats linter results
* @param failures Linter failures that were not fixed
* @param fixes Fixed linter failures. Available when the `--fix` argument is used on the command line
* @param fileNames All of the file paths that were linted
*/
format(failures: RuleFailure[], fixes?: RuleFailure[], fileNames?: string[]): string;
}

View file

@ -0,0 +1,18 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });

View file

@ -0,0 +1,43 @@
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { IWalker, WalkContext } from "../walker";
import { IOptions, IRule, IRuleMetadata, RuleFailure, RuleSeverity } from "./rule";
export declare type NoInfer<T> = T & {
[K in keyof T]: T[K];
};
export declare abstract class AbstractRule implements IRule {
private readonly options;
static metadata: IRuleMetadata;
ruleName: string;
protected readonly ruleArguments: any[];
protected readonly ruleSeverity: RuleSeverity;
constructor(options: IOptions);
getOptions(): IOptions;
abstract apply(sourceFile: ts.SourceFile): RuleFailure[];
applyWithWalker(walker: IWalker): RuleFailure[];
isEnabled(): boolean;
protected applyWithFunction(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext) => void): RuleFailure[];
protected applyWithFunction<T>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T>) => void, options: NoInfer<T>): RuleFailure[];
protected applyWithFunction<T, U>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T>, programOrChecker: U) => void, options: NoInfer<T>, checker: NoInfer<U>): RuleFailure[];
/**
* @deprecated
* Failures will be filtered based on `tslint:disable` comments by tslint.
* This method now does nothing.
*/
protected filterFailures(failures: RuleFailure[]): RuleFailure[];
}

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

@ -0,0 +1,53 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractRule = void 0;
var walker_1 = require("../walker");
var AbstractRule = /** @class */ (function () {
function AbstractRule(options) {
this.options = options;
this.ruleName = options.ruleName;
this.ruleArguments = options.ruleArguments;
this.ruleSeverity = options.ruleSeverity;
}
AbstractRule.prototype.getOptions = function () {
return this.options;
};
AbstractRule.prototype.applyWithWalker = function (walker) {
walker.walk(walker.getSourceFile());
return walker.getFailures();
};
AbstractRule.prototype.isEnabled = function () {
return this.ruleSeverity !== "off";
};
AbstractRule.prototype.applyWithFunction = function (sourceFile, walkFn, options, programOrChecker) {
var ctx = new walker_1.WalkContext(sourceFile, this.ruleName, options);
walkFn(ctx, programOrChecker);
return ctx.failures;
};
/**
* @deprecated
* Failures will be filtered based on `tslint:disable` comments by tslint.
* This method now does nothing.
*/
AbstractRule.prototype.filterFailures = function (failures) {
return failures;
};
return AbstractRule;
}());
exports.AbstractRule = AbstractRule;

View file

@ -0,0 +1,22 @@
/**
* @license
* Copyright 2017 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { AbstractRule } from "./abstractRule";
import { ITypedRule, RuleFailure } from "./rule";
export declare abstract class OptionallyTypedRule extends AbstractRule implements ITypedRule {
abstract applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[];
}

View file

@ -0,0 +1,29 @@
"use strict";
/**
* @license
* Copyright 2017 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.OptionallyTypedRule = void 0;
var tslib_1 = require("tslib");
var abstractRule_1 = require("./abstractRule");
var OptionallyTypedRule = /** @class */ (function (_super) {
tslib_1.__extends(OptionallyTypedRule, _super);
function OptionallyTypedRule() {
return _super !== null && _super.apply(this, arguments) || this;
}
return OptionallyTypedRule;
}(abstractRule_1.AbstractRule));
exports.OptionallyTypedRule = OptionallyTypedRule;

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

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

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

@ -0,0 +1,181 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleFailure = exports.RuleFailurePosition = exports.Replacement = exports.isTypedRule = void 0;
var utils_1 = require("../../utils");
function isTypedRule(rule) {
return "applyWithProgram" in rule;
}
exports.isTypedRule = isTypedRule;
var Replacement = /** @class */ (function () {
function Replacement(start, length, text) {
this.start = start;
this.length = length;
this.text = text;
}
Replacement.applyFixes = function (content, fixes) {
return Replacement.applyAll(content, utils_1.flatMap(fixes, utils_1.arrayify));
};
Replacement.applyAll = function (content, replacements) {
// sort in reverse so that diffs are properly applied
replacements.sort(function (a, b) { return (b.end !== a.end ? b.end - a.end : b.start - a.start); });
return replacements.reduce(function (text, r) { return r.apply(text); }, content);
};
Replacement.replaceNode = function (node, text, sourceFile) {
return Replacement.replaceFromTo(node.getStart(sourceFile), node.getEnd(), text);
};
Replacement.replaceFromTo = function (start, end, text) {
return new Replacement(start, end - start, text);
};
Replacement.deleteText = function (start, length) {
return new Replacement(start, length, "");
};
Replacement.deleteFromTo = function (start, end) {
return new Replacement(start, end - start, "");
};
Replacement.appendText = function (start, text) {
return new Replacement(start, 0, text);
};
Object.defineProperty(Replacement.prototype, "end", {
get: function () {
return this.start + this.length;
},
enumerable: false,
configurable: true
});
Replacement.prototype.apply = function (content) {
return (content.substring(0, this.start) +
this.text +
content.substring(this.start + this.length));
};
Replacement.prototype.toJson = function () {
// tslint:disable object-literal-sort-keys
return {
innerStart: this.start,
innerLength: this.length,
innerText: this.text,
};
// tslint:enable object-literal-sort-keys
};
return Replacement;
}());
exports.Replacement = Replacement;
var RuleFailurePosition = /** @class */ (function () {
function RuleFailurePosition(position, lineAndCharacter) {
this.position = position;
this.lineAndCharacter = lineAndCharacter;
}
RuleFailurePosition.prototype.getPosition = function () {
return this.position;
};
RuleFailurePosition.prototype.getLineAndCharacter = function () {
return this.lineAndCharacter;
};
RuleFailurePosition.prototype.toJson = function () {
return {
character: this.lineAndCharacter.character,
line: this.lineAndCharacter.line,
position: this.position,
};
};
RuleFailurePosition.prototype.equals = function (ruleFailurePosition) {
var ll = this.lineAndCharacter;
var rr = ruleFailurePosition.lineAndCharacter;
return (this.position === ruleFailurePosition.position &&
ll.line === rr.line &&
ll.character === rr.character);
};
return RuleFailurePosition;
}());
exports.RuleFailurePosition = RuleFailurePosition;
var RuleFailure = /** @class */ (function () {
function RuleFailure(sourceFile, start, end, failure, ruleName, fix) {
this.sourceFile = sourceFile;
this.failure = failure;
this.ruleName = ruleName;
this.fix = fix;
this.fileName = sourceFile.fileName;
this.startPosition = this.createFailurePosition(start);
this.endPosition = this.createFailurePosition(end);
this.rawLines = sourceFile.text;
this.ruleSeverity = "error";
}
RuleFailure.compare = function (a, b) {
if (a.fileName !== b.fileName) {
return a.fileName < b.fileName ? -1 : 1;
}
return a.startPosition.getPosition() - b.startPosition.getPosition();
};
RuleFailure.prototype.getFileName = function () {
return this.fileName;
};
RuleFailure.prototype.getRuleName = function () {
return this.ruleName;
};
RuleFailure.prototype.getStartPosition = function () {
return this.startPosition;
};
RuleFailure.prototype.getEndPosition = function () {
return this.endPosition;
};
RuleFailure.prototype.getFailure = function () {
return this.failure;
};
RuleFailure.prototype.hasFix = function () {
return this.fix !== undefined;
};
RuleFailure.prototype.getFix = function () {
return this.fix;
};
RuleFailure.prototype.getRawLines = function () {
return this.rawLines;
};
RuleFailure.prototype.getRuleSeverity = function () {
return this.ruleSeverity;
};
RuleFailure.prototype.setRuleSeverity = function (value) {
this.ruleSeverity = value;
};
RuleFailure.prototype.toJson = function () {
return {
endPosition: this.endPosition.toJson(),
failure: this.failure,
fix: this.fix === undefined
? undefined
: Array.isArray(this.fix)
? this.fix.map(function (r) { return r.toJson(); })
: this.fix.toJson(),
name: this.fileName,
ruleName: this.ruleName,
ruleSeverity: this.ruleSeverity,
startPosition: this.startPosition.toJson(),
};
};
RuleFailure.prototype.equals = function (ruleFailure) {
return (this.failure === ruleFailure.getFailure() &&
this.fileName === ruleFailure.getFileName() &&
this.startPosition.equals(ruleFailure.getStartPosition()) &&
this.endPosition.equals(ruleFailure.getEndPosition()));
};
RuleFailure.prototype.createFailurePosition = function (position) {
var lineAndCharacter = this.sourceFile.getLineAndCharacterOfPosition(position);
return new RuleFailurePosition(position, lineAndCharacter);
};
return RuleFailure;
}());
exports.RuleFailure = RuleFailure;

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

@ -0,0 +1,23 @@
/**
* @license
* Copyright 2018 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { AbstractRule } from "./abstractRule";
import { ITypedRule, RuleFailure } from "./rule";
export declare abstract class TypedRule extends AbstractRule implements ITypedRule {
apply(): RuleFailure[];
abstract applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): RuleFailure[];
}

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

@ -0,0 +1,35 @@
"use strict";
/**
* @license
* Copyright 2018 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypedRule = void 0;
var tslib_1 = require("tslib");
var error_1 = require("../../error");
var abstractRule_1 = require("./abstractRule");
var TypedRule = /** @class */ (function (_super) {
tslib_1.__extends(TypedRule, _super);
function TypedRule() {
return _super !== null && _super.apply(this, arguments) || this;
}
TypedRule.prototype.apply = function () {
// if no program is given to the linter, show an error
error_1.showWarningOnce("Warning: The '" + this.ruleName + "' rule requires type information.");
return [];
};
return TypedRule;
}(abstractRule_1.AbstractRule));
exports.TypedRule = TypedRule;

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

@ -0,0 +1,18 @@
/**
* @license
* Copyright 2017 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
export declare const typeIsOrHasBaseType: (type: ts.Type, parentType: ts.Type) => boolean;

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

@ -0,0 +1,36 @@
"use strict";
/**
* @license
* Copyright 2017 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.typeIsOrHasBaseType = void 0;
exports.typeIsOrHasBaseType = function (type, parentType) {
if (type.symbol === undefined || parentType.symbol === undefined) {
return false;
}
var typeAndBaseTypes = [type];
var ancestorTypes = type.getBaseTypes();
if (ancestorTypes !== undefined) {
typeAndBaseTypes.push.apply(typeAndBaseTypes, ancestorTypes);
}
for (var _i = 0, typeAndBaseTypes_1 = typeAndBaseTypes; _i < typeAndBaseTypes_1.length; _i++) {
var baseType = typeAndBaseTypes_1[_i];
if (baseType.symbol !== undefined && baseType.symbol.name === parentType.symbol.name) {
return true;
}
}
return false;
};

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

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

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

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

View file

@ -0,0 +1,38 @@
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { IOptions } from "../rule/rule";
import { ScopeAwareRuleWalker } from "./scopeAwareRuleWalker";
/**
* @deprecated See comment on ScopeAwareRuleWalker.
*
* An AST walker that is aware of block scopes in addition to regular scopes. Block scopes
* are a superset of regular scopes (new block scopes are created more frequently in a program).
*/
export declare abstract class BlockScopeAwareRuleWalker<T, U> extends ScopeAwareRuleWalker<T> {
private readonly blockScopeStack;
constructor(sourceFile: ts.SourceFile, options: IOptions);
abstract createBlockScope(node: ts.Node): U;
getAllBlockScopes(): U[];
getCurrentBlockScope(): U;
getCurrentBlockDepth(): number;
onBlockScopeStart(): void;
onBlockScopeEnd(): void;
findBlockScope(predicate: (scope: U) => boolean): U | undefined;
protected visitNode(node: ts.Node): void;
private isBlockScopeBoundary;
}

View file

@ -0,0 +1,85 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockScopeAwareRuleWalker = void 0;
var tslib_1 = require("tslib");
var ts = require("typescript");
var utils_1 = require("../utils");
var scopeAwareRuleWalker_1 = require("./scopeAwareRuleWalker");
// tslint:disable:deprecation (extends deprecated class and uses deprecated utils - doesn't matter because it's deprecated, too)
/**
* @deprecated See comment on ScopeAwareRuleWalker.
*
* An AST walker that is aware of block scopes in addition to regular scopes. Block scopes
* are a superset of regular scopes (new block scopes are created more frequently in a program).
*/
var BlockScopeAwareRuleWalker = /** @class */ (function (_super) {
tslib_1.__extends(BlockScopeAwareRuleWalker, _super);
function BlockScopeAwareRuleWalker(sourceFile, options) {
var _this = _super.call(this, sourceFile, options) || this;
// initialize with global scope if file is not a module
_this.blockScopeStack = ts.isExternalModule(sourceFile)
? []
: [_this.createBlockScope(sourceFile)];
return _this;
}
// get all block scopes available at this depth
BlockScopeAwareRuleWalker.prototype.getAllBlockScopes = function () {
return this.blockScopeStack;
};
BlockScopeAwareRuleWalker.prototype.getCurrentBlockScope = function () {
return this.blockScopeStack[this.blockScopeStack.length - 1];
};
BlockScopeAwareRuleWalker.prototype.getCurrentBlockDepth = function () {
return this.blockScopeStack.length;
};
// callback notifier when a block scope begins
BlockScopeAwareRuleWalker.prototype.onBlockScopeStart = function () {
return;
};
// callback notifier when a block scope ends
BlockScopeAwareRuleWalker.prototype.onBlockScopeEnd = function () {
return;
};
BlockScopeAwareRuleWalker.prototype.findBlockScope = function (predicate) {
// look through block scopes from local -> global
for (var i = this.blockScopeStack.length - 1; i >= 0; i--) {
if (predicate(this.blockScopeStack[i])) {
return this.blockScopeStack[i];
}
}
return undefined;
};
BlockScopeAwareRuleWalker.prototype.visitNode = function (node) {
var isNewBlockScope = this.isBlockScopeBoundary(node);
if (isNewBlockScope) {
this.blockScopeStack.push(this.createBlockScope(node));
this.onBlockScopeStart();
}
_super.prototype.visitNode.call(this, node);
if (isNewBlockScope) {
this.onBlockScopeEnd();
this.blockScopeStack.pop();
}
};
BlockScopeAwareRuleWalker.prototype.isBlockScopeBoundary = function (node) {
return utils_1.isBlockScopeBoundary(node);
};
return BlockScopeAwareRuleWalker;
}(scopeAwareRuleWalker_1.ScopeAwareRuleWalker));
exports.BlockScopeAwareRuleWalker = BlockScopeAwareRuleWalker;

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

@ -0,0 +1,23 @@
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from "./blockScopeAwareRuleWalker";
export * from "./programAwareRuleWalker";
export * from "./ruleWalker";
export * from "./scopeAwareRuleWalker";
export * from "./syntaxWalker";
export * from "./walkContext";
export * from "./walker";

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

@ -0,0 +1,26 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./blockScopeAwareRuleWalker"), exports);
tslib_1.__exportStar(require("./programAwareRuleWalker"), exports);
tslib_1.__exportStar(require("./ruleWalker"), exports);
tslib_1.__exportStar(require("./scopeAwareRuleWalker"), exports);
tslib_1.__exportStar(require("./syntaxWalker"), exports);
tslib_1.__exportStar(require("./walkContext"), exports);
tslib_1.__exportStar(require("./walker"), exports);

View file

@ -0,0 +1,32 @@
/**
* @license
* Copyright 2018 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { IOptions } from "../rule/rule";
import { RuleWalker } from "./ruleWalker";
/**
* @deprecated
* RuleWalker-based rules are slow,
* so it's generally preferable to use applyWithFunction instead of applyWithWalker.
* @see https://github.com/palantir/tslint/issues/2522
*/
export declare class ProgramAwareRuleWalker extends RuleWalker {
private readonly program;
private readonly typeChecker;
constructor(sourceFile: ts.SourceFile, options: IOptions, program: ts.Program);
getProgram(): ts.Program;
getTypeChecker(): ts.TypeChecker;
}

View file

@ -0,0 +1,45 @@
"use strict";
/**
* @license
* Copyright 2018 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProgramAwareRuleWalker = void 0;
var tslib_1 = require("tslib");
var ruleWalker_1 = require("./ruleWalker");
/**
* @deprecated
* RuleWalker-based rules are slow,
* so it's generally preferable to use applyWithFunction instead of applyWithWalker.
* @see https://github.com/palantir/tslint/issues/2522
*/
// tslint:disable-next-line deprecation
var ProgramAwareRuleWalker = /** @class */ (function (_super) {
tslib_1.__extends(ProgramAwareRuleWalker, _super);
function ProgramAwareRuleWalker(sourceFile, options, program) {
var _this = _super.call(this, sourceFile, options) || this;
_this.program = program;
_this.typeChecker = program.getTypeChecker();
return _this;
}
ProgramAwareRuleWalker.prototype.getProgram = function () {
return this.program;
};
ProgramAwareRuleWalker.prototype.getTypeChecker = function () {
return this.typeChecker;
};
return ProgramAwareRuleWalker;
}(ruleWalker_1.RuleWalker));
exports.ProgramAwareRuleWalker = ProgramAwareRuleWalker;

View file

@ -0,0 +1,55 @@
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { Fix, IOptions, Replacement, RuleFailure } from "../rule/rule";
import { SyntaxWalker } from "./syntaxWalker";
import { IWalker } from "./walker";
/**
* @deprecated
* RuleWalker-based rules are slow,
* so it's generally preferable to use applyWithFunction instead of applyWithWalker.
* @see https://github.com/palantir/tslint/issues/2522
*/
export declare class RuleWalker extends SyntaxWalker implements IWalker {
private readonly sourceFile;
private readonly limit;
private readonly options?;
private readonly failures;
private readonly ruleName;
constructor(sourceFile: ts.SourceFile, options: IOptions);
getSourceFile(): ts.SourceFile;
getLineAndCharacterOfPosition(position: number): ts.LineAndCharacter;
getFailures(): RuleFailure[];
getLimit(): number;
getOptions(): any;
hasOption(option: string): boolean;
/** @deprecated Prefer `addFailureAt` and its variants. */
createFailure(start: number, width: number, failure: string, fix?: Fix): RuleFailure;
/** @deprecated Prefer `addFailureAt` and its variants. */
addFailure(failure: RuleFailure): void;
/** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
addFailureAt(start: number, width: number, failure: string, fix?: Fix): void;
/** Like `addFailureAt` but uses start and end instead of start and width. */
addFailureFromStartToEnd(start: number, end: number, failure: string, fix?: Fix): void;
/** Add a failure using a node's span. */
addFailureAtNode(node: ts.Node, failure: string, fix?: Fix): void;
createReplacement(start: number, length: number, text: string): Replacement;
appendText(start: number, text: string): Replacement;
deleteText(start: number, length: number): Replacement;
deleteFromTo(start: number, end: number): Replacement;
getRuleName(): string;
}

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

@ -0,0 +1,103 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleWalker = void 0;
var tslib_1 = require("tslib");
var rule_1 = require("../rule/rule");
var syntaxWalker_1 = require("./syntaxWalker");
/**
* @deprecated
* RuleWalker-based rules are slow,
* so it's generally preferable to use applyWithFunction instead of applyWithWalker.
* @see https://github.com/palantir/tslint/issues/2522
*/
var RuleWalker = /** @class */ (function (_super) {
tslib_1.__extends(RuleWalker, _super);
function RuleWalker(sourceFile, options) {
var _this = _super.call(this) || this;
_this.sourceFile = sourceFile;
_this.failures = [];
_this.options = options.ruleArguments;
_this.limit = _this.sourceFile.getFullWidth();
_this.ruleName = options.ruleName;
return _this;
}
RuleWalker.prototype.getSourceFile = function () {
return this.sourceFile;
};
RuleWalker.prototype.getLineAndCharacterOfPosition = function (position) {
return this.sourceFile.getLineAndCharacterOfPosition(position);
};
RuleWalker.prototype.getFailures = function () {
return this.failures;
};
RuleWalker.prototype.getLimit = function () {
return this.limit;
};
RuleWalker.prototype.getOptions = function () {
return this.options;
};
RuleWalker.prototype.hasOption = function (option) {
if (this.options !== undefined) {
return this.options.indexOf(option) !== -1;
}
else {
return false;
}
};
/** @deprecated Prefer `addFailureAt` and its variants. */
RuleWalker.prototype.createFailure = function (start, width, failure, fix) {
var from = start > this.limit ? this.limit : start;
var to = start + width > this.limit ? this.limit : start + width;
return new rule_1.RuleFailure(this.sourceFile, from, to, failure, this.ruleName, fix);
};
/** @deprecated Prefer `addFailureAt` and its variants. */
RuleWalker.prototype.addFailure = function (failure) {
this.failures.push(failure);
};
/** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
RuleWalker.prototype.addFailureAt = function (start, width, failure, fix) {
// tslint:disable-next-line deprecation
this.addFailure(this.createFailure(start, width, failure, fix));
};
/** Like `addFailureAt` but uses start and end instead of start and width. */
RuleWalker.prototype.addFailureFromStartToEnd = function (start, end, failure, fix) {
this.addFailureAt(start, end - start, failure, fix);
};
/** Add a failure using a node's span. */
RuleWalker.prototype.addFailureAtNode = function (node, failure, fix) {
this.addFailureAt(node.getStart(this.sourceFile), node.getWidth(this.sourceFile), failure, fix);
};
RuleWalker.prototype.createReplacement = function (start, length, text) {
return new rule_1.Replacement(start, length, text);
};
RuleWalker.prototype.appendText = function (start, text) {
return this.createReplacement(start, 0, text);
};
RuleWalker.prototype.deleteText = function (start, length) {
return this.createReplacement(start, length, "");
};
RuleWalker.prototype.deleteFromTo = function (start, end) {
return this.createReplacement(start, end - start, "");
};
RuleWalker.prototype.getRuleName = function () {
return this.ruleName;
};
return RuleWalker;
}(syntaxWalker_1.SyntaxWalker));
exports.RuleWalker = RuleWalker;

View file

@ -0,0 +1,65 @@
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { IOptions } from "../rule/rule";
import { RuleWalker } from "./ruleWalker";
/**
* @deprecated Prefer to manually maintain any contextual information.
*
* For example, imagine a `no-break` rule that warns on `break` in `for` but not in `switch`:
*
* function walk(ctx: Lint.WalkContext): void {
* let isInFor = false;
* ts.forEachChild(ctx.sourceFile, function cb(node: ts.Node): void {
* switch (node.kind) {
* case ts.SyntaxKind.Break:
* if (isInFor) {
* ctx.addFailureAtNode(node, "!");
* }
* break;
* case ts.SyntaxKind.ForStatement: {
* const old = isInFor;
* isInFor = true;
* ts.forEachChild(node, cb);
* isInFor = old;
* break;
* }
* case ts.SyntaxKind.SwitchStatement: {
* const old = isInFor;
* isInFor = false;
* ts.forEachChild(node, cb);
* isInFor = old;
* break;
* }
* default:
* ts.forEachChild(node, cb);
* }
* });
* }
*/
export declare abstract class ScopeAwareRuleWalker<T> extends RuleWalker {
private readonly scopeStack;
constructor(sourceFile: ts.SourceFile, options: IOptions);
abstract createScope(node: ts.Node): T;
getCurrentScope(): T;
getAllScopes(): T[];
getCurrentDepth(): number;
onScopeStart(): void;
onScopeEnd(): void;
protected visitNode(node: ts.Node): void;
protected isScopeBoundary(node: ts.Node): boolean;
}

View file

@ -0,0 +1,102 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScopeAwareRuleWalker = void 0;
var tslib_1 = require("tslib");
var ts = require("typescript");
var utils_1 = require("../utils");
var ruleWalker_1 = require("./ruleWalker");
/**
* @deprecated Prefer to manually maintain any contextual information.
*
* For example, imagine a `no-break` rule that warns on `break` in `for` but not in `switch`:
*
* function walk(ctx: Lint.WalkContext): void {
* let isInFor = false;
* ts.forEachChild(ctx.sourceFile, function cb(node: ts.Node): void {
* switch (node.kind) {
* case ts.SyntaxKind.Break:
* if (isInFor) {
* ctx.addFailureAtNode(node, "!");
* }
* break;
* case ts.SyntaxKind.ForStatement: {
* const old = isInFor;
* isInFor = true;
* ts.forEachChild(node, cb);
* isInFor = old;
* break;
* }
* case ts.SyntaxKind.SwitchStatement: {
* const old = isInFor;
* isInFor = false;
* ts.forEachChild(node, cb);
* isInFor = old;
* break;
* }
* default:
* ts.forEachChild(node, cb);
* }
* });
* }
*/
// tslint:disable-next-line deprecation
var ScopeAwareRuleWalker = /** @class */ (function (_super) {
tslib_1.__extends(ScopeAwareRuleWalker, _super);
function ScopeAwareRuleWalker(sourceFile, options) {
var _this = _super.call(this, sourceFile, options) || this;
// initialize with global scope if file is not a module
_this.scopeStack = ts.isExternalModule(sourceFile) ? [] : [_this.createScope(sourceFile)];
return _this;
}
ScopeAwareRuleWalker.prototype.getCurrentScope = function () {
return this.scopeStack[this.scopeStack.length - 1];
};
// get all scopes available at this depth
ScopeAwareRuleWalker.prototype.getAllScopes = function () {
return this.scopeStack;
};
ScopeAwareRuleWalker.prototype.getCurrentDepth = function () {
return this.scopeStack.length;
};
// callback notifier when a scope begins
ScopeAwareRuleWalker.prototype.onScopeStart = function () {
return;
};
// callback notifier when a scope ends
ScopeAwareRuleWalker.prototype.onScopeEnd = function () {
return;
};
ScopeAwareRuleWalker.prototype.visitNode = function (node) {
var isNewScope = this.isScopeBoundary(node);
if (isNewScope) {
this.scopeStack.push(this.createScope(node));
this.onScopeStart();
}
_super.prototype.visitNode.call(this, node);
if (isNewScope) {
this.onScopeEnd();
this.scopeStack.pop();
}
};
ScopeAwareRuleWalker.prototype.isScopeBoundary = function (node) {
return utils_1.isScopeBoundary(node); // tslint:disable-line:deprecation
};
return ScopeAwareRuleWalker;
}(ruleWalker_1.RuleWalker));
exports.ScopeAwareRuleWalker = ScopeAwareRuleWalker;

View file

@ -0,0 +1,105 @@
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
export declare class SyntaxWalker {
walk(node: ts.Node): void;
protected visitAnyKeyword(node: ts.Node): void;
protected visitArrayLiteralExpression(node: ts.ArrayLiteralExpression): void;
protected visitArrayType(node: ts.ArrayTypeNode): void;
protected visitArrowFunction(node: ts.ArrowFunction): void;
protected visitBinaryExpression(node: ts.BinaryExpression): void;
protected visitBindingElement(node: ts.BindingElement): void;
protected visitBindingPattern(node: ts.BindingPattern): void;
protected visitBlock(node: ts.Block): void;
protected visitBreakStatement(node: ts.BreakOrContinueStatement): void;
protected visitCallExpression(node: ts.CallExpression): void;
protected visitCallSignature(node: ts.SignatureDeclaration): void;
protected visitCaseClause(node: ts.CaseClause): void;
protected visitClassDeclaration(node: ts.ClassDeclaration): void;
protected visitClassExpression(node: ts.ClassExpression): void;
protected visitCatchClause(node: ts.CatchClause): void;
protected visitConditionalExpression(node: ts.ConditionalExpression): void;
protected visitConstructSignature(node: ts.ConstructSignatureDeclaration): void;
protected visitConstructorDeclaration(node: ts.ConstructorDeclaration): void;
protected visitConstructorType(node: ts.FunctionOrConstructorTypeNode): void;
protected visitContinueStatement(node: ts.BreakOrContinueStatement): void;
protected visitDebuggerStatement(node: ts.Statement): void;
protected visitDefaultClause(node: ts.DefaultClause): void;
protected visitDoStatement(node: ts.DoStatement): void;
protected visitElementAccessExpression(node: ts.ElementAccessExpression): void;
protected visitEndOfFileToken(node: ts.Node): void;
protected visitEnumDeclaration(node: ts.EnumDeclaration): void;
protected visitEnumMember(node: ts.EnumMember): void;
protected visitExportAssignment(node: ts.ExportAssignment): void;
protected visitExpressionStatement(node: ts.ExpressionStatement): void;
protected visitForStatement(node: ts.ForStatement): void;
protected visitForInStatement(node: ts.ForInStatement): void;
protected visitForOfStatement(node: ts.ForOfStatement): void;
protected visitFunctionDeclaration(node: ts.FunctionDeclaration): void;
protected visitFunctionExpression(node: ts.FunctionExpression): void;
protected visitFunctionType(node: ts.FunctionOrConstructorTypeNode): void;
protected visitGetAccessor(node: ts.AccessorDeclaration): void;
protected visitIdentifier(node: ts.Identifier): void;
protected visitIfStatement(node: ts.IfStatement): void;
protected visitImportDeclaration(node: ts.ImportDeclaration): void;
protected visitImportEqualsDeclaration(node: ts.ImportEqualsDeclaration): void;
protected visitIndexSignatureDeclaration(node: ts.IndexSignatureDeclaration): void;
protected visitInterfaceDeclaration(node: ts.InterfaceDeclaration): void;
protected visitJsxAttribute(node: ts.JsxAttribute): void;
protected visitJsxElement(node: ts.JsxElement): void;
protected visitJsxExpression(node: ts.JsxExpression): void;
protected visitJsxSelfClosingElement(node: ts.JsxSelfClosingElement): void;
protected visitJsxSpreadAttribute(node: ts.JsxSpreadAttribute): void;
protected visitLabeledStatement(node: ts.LabeledStatement): void;
protected visitMethodDeclaration(node: ts.MethodDeclaration): void;
protected visitMethodSignature(node: ts.SignatureDeclaration): void;
protected visitModuleDeclaration(node: ts.ModuleDeclaration): void;
protected visitNamedImports(node: ts.NamedImports): void;
protected visitNamespaceImport(node: ts.NamespaceImport): void;
protected visitNewExpression(node: ts.NewExpression): void;
protected visitNonNullExpression(node: ts.NonNullExpression): void;
protected visitNumericLiteral(node: ts.NumericLiteral): void;
protected visitObjectLiteralExpression(node: ts.ObjectLiteralExpression): void;
protected visitParameterDeclaration(node: ts.ParameterDeclaration): void;
protected visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression): void;
protected visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression): void;
protected visitPropertyAccessExpression(node: ts.PropertyAccessExpression): void;
protected visitPropertyAssignment(node: ts.PropertyAssignment): void;
protected visitPropertyDeclaration(node: ts.PropertyDeclaration): void;
protected visitPropertySignature(node: ts.Node): void;
protected visitRegularExpressionLiteral(node: ts.Node): void;
protected visitReturnStatement(node: ts.ReturnStatement): void;
protected visitSetAccessor(node: ts.AccessorDeclaration): void;
protected visitSourceFile(node: ts.SourceFile): void;
protected visitStringLiteral(node: ts.StringLiteral): void;
protected visitSwitchStatement(node: ts.SwitchStatement): void;
protected visitTemplateExpression(node: ts.TemplateExpression): void;
protected visitThrowStatement(node: ts.ThrowStatement): void;
protected visitTryStatement(node: ts.TryStatement): void;
protected visitTupleType(node: ts.TupleTypeNode): void;
protected visitTypeAliasDeclaration(node: ts.TypeAliasDeclaration): void;
protected visitTypeAssertionExpression(node: ts.TypeAssertion): void;
protected visitTypeLiteral(node: ts.TypeLiteralNode): void;
protected visitTypeReference(node: ts.TypeReferenceNode): void;
protected visitVariableDeclaration(node: ts.VariableDeclaration): void;
protected visitVariableDeclarationList(node: ts.VariableDeclarationList): void;
protected visitVariableStatement(node: ts.VariableStatement): void;
protected visitWhileStatement(node: ts.WhileStatement): void;
protected visitWithStatement(node: ts.WithStatement): void;
protected visitNode(node: ts.Node): void;
protected walkChildren(node: ts.Node): void;
}

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

@ -0,0 +1,540 @@
"use strict";
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SyntaxWalker = void 0;
var ts = require("typescript");
var SyntaxWalker = /** @class */ (function () {
function SyntaxWalker() {
}
SyntaxWalker.prototype.walk = function (node) {
this.visitNode(node);
};
SyntaxWalker.prototype.visitAnyKeyword = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitArrayType = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitArrowFunction = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBinaryExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBindingElement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBindingPattern = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBlock = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitBreakStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitCallExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitCallSignature = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitCaseClause = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitClassDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitClassExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitCatchClause = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitConditionalExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitConstructSignature = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitConstructorDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitConstructorType = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitContinueStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitDebuggerStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitDefaultClause = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitDoStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitElementAccessExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitEndOfFileToken = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitEnumDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitEnumMember = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitExportAssignment = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitExpressionStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitForStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitForInStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitForOfStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitFunctionDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitFunctionExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitFunctionType = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitGetAccessor = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitIdentifier = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitIfStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitImportDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitImportEqualsDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitIndexSignatureDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxAttribute = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxElement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxSelfClosingElement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitJsxSpreadAttribute = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitLabeledStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitMethodDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitMethodSignature = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitModuleDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNamedImports = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNamespaceImport = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNewExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNonNullExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNumericLiteral = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitParameterDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPropertyAccessExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPropertyAssignment = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPropertyDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitPropertySignature = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitRegularExpressionLiteral = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitReturnStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitSetAccessor = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitSourceFile = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitStringLiteral = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitSwitchStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTemplateExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitThrowStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTryStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTupleType = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTypeAliasDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTypeAssertionExpression = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTypeLiteral = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitTypeReference = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitVariableDeclaration = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitVariableDeclarationList = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitVariableStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitWhileStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitWithStatement = function (node) {
this.walkChildren(node);
};
SyntaxWalker.prototype.visitNode = function (node) {
switch (node.kind) {
case ts.SyntaxKind.AnyKeyword:
this.visitAnyKeyword(node);
break;
case ts.SyntaxKind.ArrayBindingPattern:
this.visitBindingPattern(node);
break;
case ts.SyntaxKind.ArrayLiteralExpression:
this.visitArrayLiteralExpression(node);
break;
case ts.SyntaxKind.ArrayType:
this.visitArrayType(node);
break;
case ts.SyntaxKind.ArrowFunction:
this.visitArrowFunction(node);
break;
case ts.SyntaxKind.BinaryExpression:
this.visitBinaryExpression(node);
break;
case ts.SyntaxKind.BindingElement:
this.visitBindingElement(node);
break;
case ts.SyntaxKind.Block:
this.visitBlock(node);
break;
case ts.SyntaxKind.BreakStatement:
this.visitBreakStatement(node);
break;
case ts.SyntaxKind.CallExpression:
this.visitCallExpression(node);
break;
case ts.SyntaxKind.CallSignature:
this.visitCallSignature(node);
break;
case ts.SyntaxKind.CaseClause:
this.visitCaseClause(node);
break;
case ts.SyntaxKind.ClassDeclaration:
this.visitClassDeclaration(node);
break;
case ts.SyntaxKind.ClassExpression:
this.visitClassExpression(node);
break;
case ts.SyntaxKind.CatchClause:
this.visitCatchClause(node);
break;
case ts.SyntaxKind.ConditionalExpression:
this.visitConditionalExpression(node);
break;
case ts.SyntaxKind.ConstructSignature:
this.visitConstructSignature(node);
break;
case ts.SyntaxKind.Constructor:
this.visitConstructorDeclaration(node);
break;
case ts.SyntaxKind.ConstructorType:
this.visitConstructorType(node);
break;
case ts.SyntaxKind.ContinueStatement:
this.visitContinueStatement(node);
break;
case ts.SyntaxKind.DebuggerStatement:
this.visitDebuggerStatement(node);
break;
case ts.SyntaxKind.DefaultClause:
this.visitDefaultClause(node);
break;
case ts.SyntaxKind.DoStatement:
this.visitDoStatement(node);
break;
case ts.SyntaxKind.ElementAccessExpression:
this.visitElementAccessExpression(node);
break;
case ts.SyntaxKind.EndOfFileToken:
this.visitEndOfFileToken(node);
break;
case ts.SyntaxKind.EnumDeclaration:
this.visitEnumDeclaration(node);
break;
case ts.SyntaxKind.EnumMember:
this.visitEnumMember(node);
break;
case ts.SyntaxKind.ExportAssignment:
this.visitExportAssignment(node);
break;
case ts.SyntaxKind.ExpressionStatement:
this.visitExpressionStatement(node);
break;
case ts.SyntaxKind.ForStatement:
this.visitForStatement(node);
break;
case ts.SyntaxKind.ForInStatement:
this.visitForInStatement(node);
break;
case ts.SyntaxKind.ForOfStatement:
this.visitForOfStatement(node);
break;
case ts.SyntaxKind.FunctionDeclaration:
this.visitFunctionDeclaration(node);
break;
case ts.SyntaxKind.FunctionExpression:
this.visitFunctionExpression(node);
break;
case ts.SyntaxKind.FunctionType:
this.visitFunctionType(node);
break;
case ts.SyntaxKind.GetAccessor:
this.visitGetAccessor(node);
break;
case ts.SyntaxKind.Identifier:
this.visitIdentifier(node);
break;
case ts.SyntaxKind.IfStatement:
this.visitIfStatement(node);
break;
case ts.SyntaxKind.ImportDeclaration:
this.visitImportDeclaration(node);
break;
case ts.SyntaxKind.ImportEqualsDeclaration:
this.visitImportEqualsDeclaration(node);
break;
case ts.SyntaxKind.IndexSignature:
this.visitIndexSignatureDeclaration(node);
break;
case ts.SyntaxKind.InterfaceDeclaration:
this.visitInterfaceDeclaration(node);
break;
case ts.SyntaxKind.JsxAttribute:
this.visitJsxAttribute(node);
break;
case ts.SyntaxKind.JsxElement:
this.visitJsxElement(node);
break;
case ts.SyntaxKind.JsxExpression:
this.visitJsxExpression(node);
break;
case ts.SyntaxKind.JsxSelfClosingElement:
this.visitJsxSelfClosingElement(node);
break;
case ts.SyntaxKind.JsxSpreadAttribute:
this.visitJsxSpreadAttribute(node);
break;
case ts.SyntaxKind.LabeledStatement:
this.visitLabeledStatement(node);
break;
case ts.SyntaxKind.MethodDeclaration:
this.visitMethodDeclaration(node);
break;
case ts.SyntaxKind.MethodSignature:
this.visitMethodSignature(node);
break;
case ts.SyntaxKind.ModuleDeclaration:
this.visitModuleDeclaration(node);
break;
case ts.SyntaxKind.NamedImports:
this.visitNamedImports(node);
break;
case ts.SyntaxKind.NamespaceImport:
this.visitNamespaceImport(node);
break;
case ts.SyntaxKind.NewExpression:
this.visitNewExpression(node);
break;
case ts.SyntaxKind.NonNullExpression:
this.visitNonNullExpression(node);
break;
case ts.SyntaxKind.NumericLiteral:
this.visitNumericLiteral(node);
break;
case ts.SyntaxKind.ObjectBindingPattern:
this.visitBindingPattern(node);
break;
case ts.SyntaxKind.ObjectLiteralExpression:
this.visitObjectLiteralExpression(node);
break;
case ts.SyntaxKind.Parameter:
this.visitParameterDeclaration(node);
break;
case ts.SyntaxKind.PostfixUnaryExpression:
this.visitPostfixUnaryExpression(node);
break;
case ts.SyntaxKind.PrefixUnaryExpression:
this.visitPrefixUnaryExpression(node);
break;
case ts.SyntaxKind.PropertyAccessExpression:
this.visitPropertyAccessExpression(node);
break;
case ts.SyntaxKind.PropertyAssignment:
this.visitPropertyAssignment(node);
break;
case ts.SyntaxKind.PropertyDeclaration:
this.visitPropertyDeclaration(node);
break;
case ts.SyntaxKind.PropertySignature:
this.visitPropertySignature(node);
break;
case ts.SyntaxKind.RegularExpressionLiteral:
this.visitRegularExpressionLiteral(node);
break;
case ts.SyntaxKind.ReturnStatement:
this.visitReturnStatement(node);
break;
case ts.SyntaxKind.SetAccessor:
this.visitSetAccessor(node);
break;
case ts.SyntaxKind.SourceFile:
this.visitSourceFile(node);
break;
case ts.SyntaxKind.StringLiteral:
this.visitStringLiteral(node);
break;
case ts.SyntaxKind.SwitchStatement:
this.visitSwitchStatement(node);
break;
case ts.SyntaxKind.TemplateExpression:
this.visitTemplateExpression(node);
break;
case ts.SyntaxKind.ThrowStatement:
this.visitThrowStatement(node);
break;
case ts.SyntaxKind.TryStatement:
this.visitTryStatement(node);
break;
case ts.SyntaxKind.TupleType:
this.visitTupleType(node);
break;
case ts.SyntaxKind.TypeAliasDeclaration:
this.visitTypeAliasDeclaration(node);
break;
case ts.SyntaxKind.TypeAssertionExpression:
this.visitTypeAssertionExpression(node);
break;
case ts.SyntaxKind.TypeLiteral:
this.visitTypeLiteral(node);
break;
case ts.SyntaxKind.TypeReference:
this.visitTypeReference(node);
break;
case ts.SyntaxKind.VariableDeclaration:
this.visitVariableDeclaration(node);
break;
case ts.SyntaxKind.VariableDeclarationList:
this.visitVariableDeclarationList(node);
break;
case ts.SyntaxKind.VariableStatement:
this.visitVariableStatement(node);
break;
case ts.SyntaxKind.WhileStatement:
this.visitWhileStatement(node);
break;
case ts.SyntaxKind.WithStatement:
this.visitWithStatement(node);
break;
default:
this.walkChildren(node);
}
};
SyntaxWalker.prototype.walkChildren = function (node) {
var _this = this;
ts.forEachChild(node, function (child) { return _this.visitNode(child); });
};
return SyntaxWalker;
}());
exports.SyntaxWalker = SyntaxWalker;

View file

@ -0,0 +1,30 @@
/**
* @license
* Copyright 2017 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { Fix, RuleFailure } from "../rule/rule";
export declare class WalkContext<T = undefined> {
readonly sourceFile: ts.SourceFile;
readonly ruleName: string;
readonly options: T;
readonly failures: RuleFailure[];
constructor(sourceFile: ts.SourceFile, ruleName: string, options: T);
/** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
addFailureAt(start: number, width: number, failure: string, fix?: Fix): void;
addFailure(start: number, end: number, failure: string, fix?: Fix): void;
/** Add a failure using a node's span. */
addFailureAtNode(node: ts.Node, failure: string, fix?: Fix): void;
}

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

@ -0,0 +1,42 @@
"use strict";
/**
* @license
* Copyright 2017 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalkContext = void 0;
var rule_1 = require("../rule/rule");
var WalkContext = /** @class */ (function () {
function WalkContext(sourceFile, ruleName, options) {
this.sourceFile = sourceFile;
this.ruleName = ruleName;
this.options = options;
this.failures = [];
}
/** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
WalkContext.prototype.addFailureAt = function (start, width, failure, fix) {
this.addFailure(start, start + width, failure, fix);
};
WalkContext.prototype.addFailure = function (start, end, failure, fix) {
var fileLength = this.sourceFile.end;
this.failures.push(new rule_1.RuleFailure(this.sourceFile, Math.min(start, fileLength), Math.min(end, fileLength), failure, this.ruleName, fix));
};
/** Add a failure using a node's span. */
WalkContext.prototype.addFailureAtNode = function (node, failure, fix) {
this.addFailure(node.getStart(this.sourceFile), node.getEnd(), failure, fix);
};
return WalkContext;
}());
exports.WalkContext = WalkContext;

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

@ -0,0 +1,29 @@
/**
* @license
* Copyright 2017 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ts from "typescript";
import { RuleFailure } from "../rule/rule";
import { WalkContext } from "./walkContext";
export interface IWalker {
getSourceFile(): ts.SourceFile;
walk(sourceFile: ts.SourceFile): void;
getFailures(): RuleFailure[];
}
export declare abstract class AbstractWalker<T = undefined> extends WalkContext<T> implements IWalker {
abstract walk(sourceFile: ts.SourceFile): void;
getSourceFile(): ts.SourceFile;
getFailures(): RuleFailure[];
}

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

@ -0,0 +1,35 @@
"use strict";
/**
* @license
* Copyright 2017 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractWalker = void 0;
var tslib_1 = require("tslib");
var walkContext_1 = require("./walkContext");
var AbstractWalker = /** @class */ (function (_super) {
tslib_1.__extends(AbstractWalker, _super);
function AbstractWalker() {
return _super !== null && _super.apply(this, arguments) || this;
}
AbstractWalker.prototype.getSourceFile = function () {
return this.sourceFile;
};
AbstractWalker.prototype.getFailures = function () {
return this.failures;
};
return AbstractWalker;
}(walkContext_1.WalkContext));
exports.AbstractWalker = AbstractWalker;