Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Chore: remove SourceCode passthroughs from Linter.prototype (refs #9161
…) (#9263)
  • Loading branch information
not-an-aardvark committed Sep 8, 2017
1 parent 40ae27b commit 1a76c4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
23 changes: 2 additions & 21 deletions lib/linter.js
Expand Up @@ -640,7 +640,7 @@ const BASE_TRAVERSAL_CONTEXT = Object.freeze(
* Object that is responsible for verifying JavaScript text
* @name eslint
*/
class Linter {
module.exports = class Linter {

constructor() {
this.currentConfig = null;
Expand Down Expand Up @@ -1140,23 +1140,4 @@ class Linter {

return fixedResult;
}
}

Object.keys(DEPRECATED_SOURCECODE_PASSTHROUGHS).forEach(methodName => {
const exMethodName = DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName];

// Applies the SourceCode methods to the Linter prototype
Object.defineProperty(Linter.prototype, methodName, {
value() {
if (this.sourceCode) {
return this.sourceCode[exMethodName].apply(this.sourceCode, arguments);
}
return null;
},
configurable: true,
writable: true,
enumerable: false
});
});

module.exports = Linter;
};
8 changes: 4 additions & 4 deletions tests/lib/ast-utils.js
Expand Up @@ -62,9 +62,9 @@ describe("ast-utils", () => {

describe("isTokenOnSameLine", () => {
it("should return false if the tokens are not on the same line", () => {
linter.defineRule("checker", mustCall(() => ({
linter.defineRule("checker", mustCall(context => ({
BlockStatement: mustCall(node => {
assert.isFalse(astUtils.isTokenOnSameLine(linter.getTokenBefore(node), node));
assert.isFalse(astUtils.isTokenOnSameLine(context.getTokenBefore(node), node));
})
})));

Expand All @@ -73,9 +73,9 @@ describe("ast-utils", () => {

it("should return true if the tokens are on the same line", () => {

linter.defineRule("checker", mustCall(() => ({
linter.defineRule("checker", mustCall(context => ({
BlockStatement: mustCall(node => {
assert.isTrue(astUtils.isTokenOnSameLine(linter.getTokenBefore(node), node));
assert.isTrue(astUtils.isTokenOnSameLine(context.getTokenBefore(node), node));
})
})));

Expand Down

0 comments on commit 1a76c4d

Please sign in to comment.