UNPKG

2.54 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2013 Palantir Technologies, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import * as ts from "typescript";
18import { Fix, IOptions, Replacement, RuleFailure } from "../rule/rule";
19import { SyntaxWalker } from "./syntaxWalker";
20import { IWalker } from "./walker";
21/**
22 * @deprecated
23 * RuleWalker-based rules are slow,
24 * so it's generally preferable to use applyWithFunction instead of applyWithWalker.
25 * @see https://github.com/palantir/tslint/issues/2522
26 */
27export declare class RuleWalker extends SyntaxWalker implements IWalker {
28 private readonly sourceFile;
29 private readonly limit;
30 private readonly options?;
31 private readonly failures;
32 private readonly ruleName;
33 constructor(sourceFile: ts.SourceFile, options: IOptions);
34 getSourceFile(): ts.SourceFile;
35 getLineAndCharacterOfPosition(position: number): ts.LineAndCharacter;
36 getFailures(): RuleFailure[];
37 getLimit(): number;
38 getOptions(): any;
39 hasOption(option: string): boolean;
40 /** @deprecated Prefer `addFailureAt` and its variants. */
41 createFailure(start: number, width: number, failure: string, fix?: Fix): RuleFailure;
42 /** @deprecated Prefer `addFailureAt` and its variants. */
43 addFailure(failure: RuleFailure): void;
44 /** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
45 addFailureAt(start: number, width: number, failure: string, fix?: Fix): void;
46 /** Like `addFailureAt` but uses start and end instead of start and width. */
47 addFailureFromStartToEnd(start: number, end: number, failure: string, fix?: Fix): void;
48 /** Add a failure using a node's span. */
49 addFailureAtNode(node: ts.Node, failure: string, fix?: Fix): void;
50 createReplacement(start: number, length: number, text: string): Replacement;
51 appendText(start: number, text: string): Replacement;
52 deleteText(start: number, length: number): Replacement;
53 deleteFromTo(start: number, end: number): Replacement;
54 getRuleName(): string;
55}