Skip to content

Commit

Permalink
Ignore MPEG transport streams in tslint. (palantir#1357)
Browse files Browse the repository at this point in the history
MPEG transport streams also use the `.ts` file extension. Linting causes odd
effects, either by reporting spurious errors, or by timing out because the files
are commonly too large.
  • Loading branch information
mprobst authored and jkillian committed Jun 29, 2016
1 parent 8691882 commit 71d0711
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/tslint-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ const processFile = (file: string) => {
process.exit(1);
}

const buffer = new Buffer(256);
buffer.fill(0);
const fd = fs.openSync(file, "r");
try {
fs.readSync(fd, buffer, 0, 256, null);
if (buffer.readInt8(0) === 0x47 && buffer.readInt8(188) === 0x47) {
// MPEG transport streams use the '.ts' file extension. They use 0x47 as the frame
// separator, repeating every 188 bytes. It is unlikely to find that pattern in
// TypeScript source, so tslint ignores files with the specific pattern.
console.warn(`${file}: ignoring MPEG transport stream`);
return;
}
} finally {
fs.closeSync(fd);
}

const contents = fs.readFileSync(file, "utf8");
const configuration = findConfiguration(possibleConfigAbsolutePath, file);

Expand Down

0 comments on commit 71d0711

Please sign in to comment.