diff options
Diffstat (limited to 'node_modules/tslint/lib/rules/encodingRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/encodingRule.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/node_modules/tslint/lib/rules/encodingRule.js b/node_modules/tslint/lib/rules/encodingRule.js index 776bfc4fe..eda50bfa6 100644 --- a/node_modules/tslint/lib/rules/encodingRule.js +++ b/node_modules/tslint/lib/rules/encodingRule.js @@ -32,18 +32,18 @@ var Rule = (function (_super) { Rule.prototype.apply = function (sourceFile) { return this.applyWithFunction(sourceFile, walk); }; + /* tslint:disable:object-literal-sort-keys */ + Rule.metadata = { + ruleName: "encoding", + description: "Enforces UTF-8 file encoding.", + optionsDescription: "Not configurable.", + options: null, + optionExamples: ["true"], + type: "style", + typescriptOnly: false, + }; return Rule; }(Lint.Rules.AbstractRule)); -/* tslint:disable:object-literal-sort-keys */ -Rule.metadata = { - ruleName: "encoding", - description: "Enforces UTF-8 file encoding.", - optionsDescription: "Not configurable.", - options: null, - optionExamples: ["true"], - type: "style", - typescriptOnly: false, -}; exports.Rule = Rule; function walk(ctx) { var encoding = detectEncoding(ctx.sourceFile.fileName); @@ -68,5 +68,6 @@ function detectEncoding(fileName) { var maxBytesRead = 3; // Only need 3 bytes to detect the encoding. var buffer = new Buffer(maxBytesRead); var bytesRead = fs.readSync(fd, buffer, /*offset*/ 0, /*length*/ maxBytesRead, /*position*/ 0); + fs.closeSync(fd); return utils_1.detectBufferEncoding(buffer, bytesRead); } |