Skip to content

Commit

Permalink
Monkey-patch getFirstTokens
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Oct 11, 2017
1 parent 4197163 commit 52dadaa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ function monkeypatch() {
ts.prototype.getTokenBefore = returnNonceTokenPatch(ts.prototype.getTokenBefore);
ts.prototype.getFirstToken = returnNonceTokenPatch(ts.prototype.getFirstToken);
ts.prototype.getLastToken = returnNonceTokenPatch(ts.prototype.getLastToken);
var origGetFirstTokens = ts.prototype.getFirstTokens;
ts.prototype.getFirstTokens = function() {
if (!arguments[0] || arguments[0].type === "Nonce") return [createNonceToken()];
var toks = origGetFirstTokens.apply(this, arguments);
if (toks == null || toks[0] == null) return [createNonceToken()]; else return toks;
};

// monkeypatch rules
var rules = getModule(eslintMod, "./rules");
Expand Down

0 comments on commit 52dadaa

Please sign in to comment.