diff --git a/lib/cli-engine/lint-result-cache.js b/lib/cli-engine/lint-result-cache.js index 14e19d9e5a1..23a142097ba 100644 --- a/lib/cli-engine/lint-result-cache.js +++ b/lib/cli-engine/lint-result-cache.js @@ -20,6 +20,7 @@ const hash = require("./hash"); //----------------------------------------------------------------------------- const configHashCache = new WeakMap(); +const nodeVersion = process && process.version; /** * Calculates the hash of the config @@ -28,7 +29,7 @@ const configHashCache = new WeakMap(); */ function hashOfConfigFor(config) { if (!configHashCache.has(config)) { - configHashCache.set(config, hash(`${pkg.version}_${stringify(config)}`)); + configHashCache.set(config, hash(`${pkg.version}_${nodeVersion}_${stringify(config)}`)); } return configHashCache.get(config); diff --git a/tests/lib/cli-engine/lint-result-cache.js b/tests/lib/cli-engine/lint-result-cache.js index 7c5cc20a1e6..a3b6ee3ab2c 100644 --- a/tests/lib/cli-engine/lint-result-cache.js +++ b/tests/lib/cli-engine/lint-result-cache.js @@ -120,6 +120,35 @@ describe("LintResultCache", () => { lintResultsCache = new LintResultCache(cacheFileLocation); }); + describe("when calculating the hashing", () => { + it("contains eslint version during hashing", () => { + const version = "eslint-=-version"; + const NewLintResultCache = proxyquire("../../../lib/cli-engine/lint-result-cache.js", { + "../../package.json": { version }, + "./hash": hashStub + }); + const newLintResultCache = new NewLintResultCache(cacheFileLocation); + + newLintResultCache.getCachedLintResults(filePath, fakeConfig); + assert.ok(hashStub.calledOnce); + assert.ok(hashStub.calledWithMatch(version)); + }); + + it("contains node version during hashing", () => { + const version = "node-=-version"; + + sinon.stub(process, "version").value(version); + const NewLintResultCache = proxyquire("../../../lib/cli-engine/lint-result-cache.js", { + "./hash": hashStub + }); + const newLintResultCache = new NewLintResultCache(cacheFileLocation); + + newLintResultCache.getCachedLintResults(filePath, fakeConfig); + assert.ok(hashStub.calledOnce); + assert.ok(hashStub.calledWithMatch(version)); + }); + }); + describe("When file is changed", () => { beforeEach(() => { hashStub.returns(hashOfConfig);