Skip to content

Commit

Permalink
Chore: avoid using internal Linter APIs in RuleTester (refs #9161)
Browse files Browse the repository at this point in the history
This updates `RuleTester` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
  • Loading branch information
not-an-aardvark committed Aug 28, 2017
1 parent d6e436f commit e6e9f1c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/testers/rule-tester.js
Expand Up @@ -159,7 +159,8 @@ class RuleTester {

// we have to clone because merge uses the first argument for recipient
lodash.cloneDeep(defaultConfig),
testerConfig
testerConfig,
{ rules: { "rule-tester/validate-ast": "error" } }
);

/**
Expand Down Expand Up @@ -333,13 +334,14 @@ class RuleTester {
*/
linter.reset();

linter.on("Program", node => {
beforeAST = cloneDeeplyExcludesParent(node);
});

linter.on("Program:exit", node => {
afterAST = node;
});
linter.defineRule("rule-tester/validate-ast", () => ({
Program(node) {
beforeAST = cloneDeeplyExcludesParent(node);
},
"Program:exit"(node) {
afterAST = node;
}
}));

// Freezes rule-context properties.
const originalGet = linter.rules.get;
Expand Down

0 comments on commit e6e9f1c

Please sign in to comment.