Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: remove leche (fixes #13287) #13533

Merged
merged 5 commits into from Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -111,7 +111,6 @@
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.3",
"karma-webpack": "^4.0.0-rc.6",
"leche": "^2.2.3",
"lint-staged": "^10.1.2",
"load-perf": "^0.2.0",
"markdownlint": "^0.19.0",
Expand Down
15 changes: 8 additions & 7 deletions tests/lib/cli-engine/cli-engine.js
Expand Up @@ -12,7 +12,6 @@
const assert = require("chai").assert,
path = require("path"),
sinon = require("sinon"),
leche = require("leche"),
shell = require("shelljs"),
fs = require("fs"),
os = require("os"),
Expand Down Expand Up @@ -4469,7 +4468,9 @@ describe("CLIEngine", () => {
});

it("should call fs.writeFileSync() for each result with output", () => {
const fakeFS = leche.fake(fs),
const fakeFS = {
writeFileSync: () => {}
},
localCLIEngine = proxyquire("../../../lib/cli-engine/cli-engine", {
fs: fakeFS
}).CLIEngine,
Expand All @@ -4486,7 +4487,6 @@ describe("CLIEngine", () => {
]
};

fakeFS.writeFileSync = function() {};
const spy = sinon.spy(fakeFS, "writeFileSync");

localCLIEngine.outputFixes(report);
Expand All @@ -4498,7 +4498,9 @@ describe("CLIEngine", () => {
});

it("should call fs.writeFileSync() for each result with output and not at all for a result without output", () => {
const fakeFS = leche.fake(fs),
const fakeFS = {
writeFileSync: () => {}
},
localCLIEngine = proxyquire("../../../lib/cli-engine/cli-engine", {
fs: fakeFS
}).CLIEngine,
Expand All @@ -4518,7 +4520,6 @@ describe("CLIEngine", () => {
]
};

fakeFS.writeFileSync = function() {};
const spy = sinon.spy(fakeFS, "writeFileSync");

localCLIEngine.outputFixes(report);
Expand Down Expand Up @@ -4555,12 +4556,12 @@ describe("CLIEngine", () => {

describe("resolveFileGlobPatterns", () => {

leche.withData([
[
[".", ["**/*.{js}"]],
["./", ["**/*.{js}"]],
["../", ["../**/*.{js}"]],
["", []]
], (input, expected) => {
].forEach(([input, expected]) => {

it(`should correctly resolve ${input} to ${expected}`, () => {
const engine = new CLIEngine();
Expand Down
13 changes: 8 additions & 5 deletions tests/lib/eslint/eslint.js
Expand Up @@ -16,7 +16,6 @@ const os = require("os");
const path = require("path");
const escapeStringRegExp = require("escape-string-regexp");
const fCache = require("file-entry-cache");
const leche = require("leche");
const sinon = require("sinon");
const proxyquire = require("proxyquire").noCallThru().noPreserveCache();
const shell = require("shelljs");
Expand Down Expand Up @@ -4427,8 +4426,10 @@ describe("ESLint", () => {
});

it("should call fs.writeFile() for each result with output", async () => {
const fakeFS = leche.fake(fs);
const spy = fakeFS.writeFile = sinon.spy(callLastArgument);
const fakeFS = {
writeFile: sinon.spy(callLastArgument)
};
const spy = fakeFS.writeFile;
const localESLint = proxyquire("../../../lib/eslint/eslint", {
fs: fakeFS
}).ESLint;
Expand All @@ -4451,8 +4452,10 @@ describe("ESLint", () => {
});

it("should call fs.writeFile() for each result with output and not at all for a result without output", async () => {
const fakeFS = leche.fake(fs);
const spy = fakeFS.writeFile = sinon.spy(callLastArgument);
const fakeFS = {
writeFile: sinon.spy(callLastArgument)
};
const spy = fakeFS.writeFile;
const localESLint = proxyquire("../../../lib/eslint/eslint", {
fs: fakeFS
}).ESLint;
Expand Down
22 changes: 14 additions & 8 deletions tests/lib/init/config-file.js
Expand Up @@ -9,10 +9,8 @@
//------------------------------------------------------------------------------

const assert = require("chai").assert,
leche = require("leche"),
sinon = require("sinon"),
path = require("path"),
fs = require("fs"),
yaml = require("js-yaml"),
espree = require("espree"),
ConfigFile = require("../../../lib/init/config-file"),
Expand Down Expand Up @@ -59,15 +57,17 @@ describe("ConfigFile", () => {
sinon.verifyAndRestore();
});

leche.withData([
[
["JavaScript", "foo.js", espree.parse],
["JSON", "bar.json", JSON.parse],
["YAML", "foo.yaml", yaml.safeLoad],
["YML", "foo.yml", yaml.safeLoad]
], (fileType, filename, validate) => {
].forEach(([fileType, filename, validate]) => {

it(`should write a file through fs when a ${fileType} path is passed`, () => {
const fakeFS = leche.fake(fs);
const fakeFS = {
writeFileSync: () => {}
};

sinon.mock(fakeFS).expects("writeFileSync").withExactArgs(
filename,
Expand All @@ -83,7 +83,9 @@ describe("ConfigFile", () => {
});

it("should include a newline character at EOF", () => {
const fakeFS = leche.fake(fs);
const fakeFS = {
writeFileSync: () => {}
};

sinon.mock(fakeFS).expects("writeFileSync").withExactArgs(
filename,
Expand All @@ -100,7 +102,9 @@ describe("ConfigFile", () => {
});

it("should make sure js config files match linting rules", () => {
const fakeFS = leche.fake(fs);
const fakeFS = {
writeFileSync: () => {}
};

const singleQuoteConfig = {
rules: {
Expand All @@ -122,7 +126,9 @@ describe("ConfigFile", () => {
});

it("should still write a js config file even if linting fails", () => {
const fakeFS = leche.fake(fs);
const fakeFS = {
writeFileSync: () => {}
};
const fakeCLIEngine = sinon.mock().withExactArgs(sinon.match({
baseConfig: config,
fix: true,
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/shared/config-ops.js
Expand Up @@ -9,7 +9,6 @@
//------------------------------------------------------------------------------

const assert = require("chai").assert,
leche = require("leche"),
util = require("util"),
ConfigOps = require("../../../lib/shared/config-ops");

Expand Down Expand Up @@ -199,7 +198,7 @@ describe("ConfigOps", () => {

describe("isError()", () => {

leche.withData([
[
["error", true],
["Error", true],
[2, true],
Expand All @@ -209,7 +208,7 @@ describe("ConfigOps", () => {
[["error", "foo"], true],
[["eRror", "bar"], true],
[[2, "baz"], true]
], (input, expected) => {
].forEach(([input, expected]) => {

it(`should return ${expected}when passed ${input}`, () => {
const result = ConfigOps.isErrorSeverity(input);
Expand Down
9 changes: 4 additions & 5 deletions tests/lib/shared/naming.js
Expand Up @@ -8,7 +8,6 @@
//------------------------------------------------------------------------------

const assert = require("chai").assert,
leche = require("leche"),
naming = require("../../../lib/shared/naming");

//------------------------------------------------------------------------------
Expand All @@ -18,15 +17,15 @@ const assert = require("chai").assert,
describe("naming", () => {
describe("normalizePackageName()", () => {

leche.withData([
[
["foo", "eslint-config-foo"],
["eslint-config-foo", "eslint-config-foo"],
["@z/foo", "@z/eslint-config-foo"],
["@z\\foo", "@z/eslint-config-foo"],
["@z\\foo\\bar.js", "@z/eslint-config-foo/bar.js"],
["@z/eslint-config", "@z/eslint-config"],
["@z/eslint-config-foo", "@z/eslint-config-foo"]
], (input, expected) => {
].forEach(([input, expected]) => {
it(`should return ${expected} when passed ${input}`, () => {
const result = naming.normalizePackageName(input, "eslint-config");

Expand All @@ -38,14 +37,14 @@ describe("naming", () => {

describe("getShorthandName()", () => {

leche.withData([
[
["foo", "foo"],
["eslint-config-foo", "foo"],
["@z", "@z"],
["@z/eslint-config", "@z"],
["@z/foo", "@z/foo"],
["@z/eslint-config-foo", "@z/foo"]
], (input, expected) => {
].forEach(([input, expected]) => {
it(`should return ${expected} when passed ${input}`, () => {
const result = naming.getShorthandName(input, "eslint-config");

Expand Down