ruleWalker.d.ts 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. */
  17. import * as ts from "typescript";
  18. import { Fix, IOptions, Replacement, RuleFailure } from "../rule/rule";
  19. import { SyntaxWalker } from "./syntaxWalker";
  20. import { IWalker } from "./walker";
  21. export declare class RuleWalker extends SyntaxWalker implements IWalker {
  22. private readonly sourceFile;
  23. private readonly limit;
  24. private readonly options?;
  25. private readonly failures;
  26. private readonly ruleName;
  27. constructor(sourceFile: ts.SourceFile, options: IOptions);
  28. getSourceFile(): ts.SourceFile;
  29. getLineAndCharacterOfPosition(position: number): ts.LineAndCharacter;
  30. getFailures(): RuleFailure[];
  31. getLimit(): number;
  32. getOptions(): any;
  33. hasOption(option: string): boolean;
  34. /** @deprecated Prefer `addFailureAt` and its variants. */
  35. createFailure(start: number, width: number, failure: string, fix?: Fix): RuleFailure;
  36. /** @deprecated Prefer `addFailureAt` and its variants. */
  37. addFailure(failure: RuleFailure): void;
  38. /** Add a failure with any arbitrary span. Prefer `addFailureAtNode` if possible. */
  39. addFailureAt(start: number, width: number, failure: string, fix?: Fix): void;
  40. /** Like `addFailureAt` but uses start and end instead of start and width. */
  41. addFailureFromStartToEnd(start: number, end: number, failure: string, fix?: Fix): void;
  42. /** Add a failure using a node's span. */
  43. addFailureAtNode(node: ts.Node, failure: string, fix?: Fix): void;
  44. createReplacement(start: number, length: number, text: string): Replacement;
  45. appendText(start: number, text: string): Replacement;
  46. deleteText(start: number, length: number): Replacement;
  47. deleteFromTo(start: number, end: number): Replacement;
  48. getRuleName(): string;
  49. }