Skip to content

Instantly share code, notes, and snippets.

@andrewborisov
Last active May 11, 2019 09:41
Show Gist options
  • Save andrewborisov/a9a9937232836575f24c7efecd22e683 to your computer and use it in GitHub Desktop.
Save andrewborisov/a9a9937232836575f24c7efecd22e683 to your computer and use it in GitHub Desktop.
creating-ts-lint-rule project
import * as Lint from 'tslint';
import * as ts from 'typescript';
// Exported class always should be named "Rule" and extends Lint.Rules.AbstractRule
export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = 'Wrong import order';
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new Walker(sourceFile, 'module-imports-order', this.getOptions()))
}
}
class Walker extends Lint.AbstractWalker<any> {
public walk(sourceFile: ts.SourceFile) {
// Some code that will implement your rule logic
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment