Skip to content

Commit

Permalink
Fix: CircularJSON dependency warning (fixes #11052) (#11314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Teamop authored and not-an-aardvark committed Feb 6, 2019
1 parent 4dd19a3 commit 92fc2f4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -47,7 +47,7 @@
"espree": "^5.0.0",
"esquery": "^1.0.1",
"esutils": "^2.0.2",
"file-entry-cache": "^2.0.0",
"file-entry-cache": "^5.0.1",
"functional-red-black-tree": "^1.0.1",
"glob": "^7.1.2",
"globals": "^11.7.0",
Expand Down
31 changes: 19 additions & 12 deletions tests/lib/cli-engine.js
Expand Up @@ -21,6 +21,8 @@ const assert = require("chai").assert,

const proxyquire = require("proxyquire").noCallThru().noPreserveCache();

const fCache = require("file-entry-cache");

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -2375,11 +2377,12 @@ describe("CLIEngine", () => {

assert.isTrue(shell.test("-f", cacheFile), "the cache for eslint was created");

const cache = JSON.parse(fs.readFileSync(cacheFile));
const fileCache = fCache.createFromFile(cacheFile);
const { cache } = fileCache;

assert.isTrue(typeof cache[goodFile] === "object", "the entry for the good file is in the cache");
assert.isTrue(typeof cache.getKey(goodFile) === "object", "the entry for the good file is in the cache");

assert.isTrue(typeof cache[badFile] === "object", "the entry for the bad file is in the cache");
assert.isTrue(typeof cache.getKey(badFile) === "object", "the entry for the bad file is in the cache");

const cachedResult = engine.executeOnFiles([badFile, goodFile]);

Expand Down Expand Up @@ -2412,9 +2415,10 @@ describe("CLIEngine", () => {

engine.executeOnFiles([badFile, goodFile, toBeDeletedFile]);

let cache = JSON.parse(fs.readFileSync(cacheFile));
const fileCache = fCache.createFromFile(cacheFile);
let { cache } = fileCache;

assert.isTrue(typeof cache[toBeDeletedFile] === "object", "the entry for the file to be deleted is in the cache");
assert.isTrue(typeof cache.getKey(toBeDeletedFile) === "object", "the entry for the file to be deleted is in the cache");

// delete the file from the file system
fs.unlinkSync(toBeDeletedFile);
Expand Down Expand Up @@ -2456,9 +2460,10 @@ describe("CLIEngine", () => {

engine.executeOnFiles([badFile, goodFile, testFile2]);

let cache = JSON.parse(fs.readFileSync(cacheFile));
let fileCache = fCache.createFromFile(cacheFile);
let { cache } = fileCache;

assert.isTrue(typeof cache[testFile2] === "object", "the entry for the test-file2 is in the cache");
assert.isTrue(typeof cache.getKey(testFile2) === "object", "the entry for the test-file2 is in the cache");

/*
* we pass a different set of files minus test-file2
Expand All @@ -2467,9 +2472,10 @@ describe("CLIEngine", () => {
*/
engine.executeOnFiles([badFile, goodFile]);

cache = JSON.parse(fs.readFileSync(cacheFile));
fileCache = fCache.createFromFile(cacheFile);
cache = fileCache.cache;

assert.isTrue(typeof cache[testFile2] === "object", "the entry for the test-file2 is in the cache");
assert.isTrue(typeof cache.getKey(testFile2) === "object", "the entry for the test-file2 is in the cache");
});

it("should not delete cache when executing on text", () => {
Expand Down Expand Up @@ -2590,11 +2596,12 @@ describe("CLIEngine", () => {

assert.isTrue(shell.test("-f", customCacheFile), "the cache for eslint was created");

const cache = JSON.parse(fs.readFileSync(customCacheFile));
const fileCache = fCache.createFromFile(customCacheFile);
const { cache } = fileCache;

assert.isTrue(typeof cache[goodFile] === "object", "the entry for the good file is in the cache");
assert.isTrue(typeof cache.getKey(goodFile) === "object", "the entry for the good file is in the cache");

assert.isTrue(typeof cache[badFile] === "object", "the entry for the bad file is in the cache");
assert.isTrue(typeof cache.getKey(badFile) === "object", "the entry for the bad file is in the cache");

const cachedResult = engine.executeOnFiles([badFile, goodFile]);

Expand Down

0 comments on commit 92fc2f4

Please sign in to comment.