Skip to content
Permalink
Browse files

Fix: CLIEngine#addPlugin reset lastConfigArrays (fixes #12425) (#12468)

  • Loading branch information
mysticatea committed Oct 24, 2019
1 parent 923a8cb commit 0f6d0dcdf5adc30079a7379bbf605a4ef3887a85
Showing with 12 additions and 1 deletion.
  1. +4 −1 lib/cli-engine/cli-engine.js
  2. +8 −0 tests/lib/cli-engine/cli-engine.js
@@ -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();
}

/**
@@ -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", () => {

0 comments on commit 0f6d0dc

Please sign in to comment.
You can’t perform that action at this time.