mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 11:50:54 -06:00
17 lines
488 B
TypeScript
17 lines
488 B
TypeScript
import * as Lint from "tslint/lib";
|
|
import * as ts from "typescript";
|
|
|
|
export class Rule extends Lint.Rules.AbstractRule {
|
|
public static FAILURE_STRING = "This file has a BOM.";
|
|
|
|
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
|
return this.applyWithFunction(sourceFile, walk);
|
|
}
|
|
}
|
|
|
|
function walk(ctx: Lint.WalkContext<void>): void {
|
|
if (ctx.sourceFile.text[0] === "\ufeff") {
|
|
ctx.addFailure(0, 1, Rule.FAILURE_STRING);
|
|
}
|
|
}
|