Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: avoid using internal Linter APIs in RuleTester (refs #9161) #9172

Merged
merged 1 commit into from Aug 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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