Skip to content

Commit

Permalink
Fix: CLIEngine#addPlugin reset lastConfigArrays (fixes #12425) (#12468)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Oct 24, 2019
1 parent 923a8cb commit 0f6d0dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/cli-engine/cli-engine.js
Expand Up @@ -667,11 +667,14 @@ class CLIEngine {
addPlugin(name, pluginObject) {
const {
additionalPluginPool,
configArrayFactory
configArrayFactory,
lastConfigArrays
} = internalSlotsMap.get(this);

additionalPluginPool.set(name, pluginObject);
configArrayFactory.clearCache();
lastConfigArrays.length = 1;
lastConfigArrays[0] = configArrayFactory.getConfigArrayForFile();
}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/cli-engine/cli-engine.js
Expand Up @@ -4022,6 +4022,14 @@ describe("CLIEngine", () => {

assert(engine.getRules().has("node/no-deprecated-api"), "node/no-deprecated-api is present");
});

it("should expose the rules of the plugin that is added by 'addPlugin'.", () => {
const engine = new CLIEngine({ plugins: ["foo"] });

engine.addPlugin("foo", require("eslint-plugin-node"));

assert(engine.getRules().has("foo/no-deprecated-api"), "foo/no-deprecated-api is present");
});
});

describe("resolveFileGlobPatterns", () => {
Expand Down

0 comments on commit 0f6d0dc

Please sign in to comment.