Skip to content

Commit 0f6d0dc

Browse files
authoredOct 24, 2019
Fix: CLIEngine#addPlugin reset lastConfigArrays (fixes #12425) (#12468)
1 parent 923a8cb commit 0f6d0dc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎lib/cli-engine/cli-engine.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,14 @@ class CLIEngine {
667667
addPlugin(name, pluginObject) {
668668
const {
669669
additionalPluginPool,
670-
configArrayFactory
670+
configArrayFactory,
671+
lastConfigArrays
671672
} = internalSlotsMap.get(this);
672673

673674
additionalPluginPool.set(name, pluginObject);
674675
configArrayFactory.clearCache();
676+
lastConfigArrays.length = 1;
677+
lastConfigArrays[0] = configArrayFactory.getConfigArrayForFile();
675678
}
676679

677680
/**

‎tests/lib/cli-engine/cli-engine.js

+8
Original file line numberDiff line numberDiff line change
@@ -4022,6 +4022,14 @@ describe("CLIEngine", () => {
40224022

40234023
assert(engine.getRules().has("node/no-deprecated-api"), "node/no-deprecated-api is present");
40244024
});
4025+
4026+
it("should expose the rules of the plugin that is added by 'addPlugin'.", () => {
4027+
const engine = new CLIEngine({ plugins: ["foo"] });
4028+
4029+
engine.addPlugin("foo", require("eslint-plugin-node"));
4030+
4031+
assert(engine.getRules().has("foo/no-deprecated-api"), "foo/no-deprecated-api is present");
4032+
});
40254033
});
40264034

40274035
describe("resolveFileGlobPatterns", () => {

0 commit comments

Comments
 (0)
Please sign in to comment.