diff --git a/package.json b/package.json index 96f709e0bb8..4433760134f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/lib/cli-engine/cli-engine.js b/tests/lib/cli-engine/cli-engine.js index fb3c365bbbf..0ba01d2a5df 100644 --- a/tests/lib/cli-engine/cli-engine.js +++ b/tests/lib/cli-engine/cli-engine.js @@ -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"), @@ -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, @@ -4486,7 +4487,6 @@ describe("CLIEngine", () => { ] }; - fakeFS.writeFileSync = function() {}; const spy = sinon.spy(fakeFS, "writeFileSync"); localCLIEngine.outputFixes(report); @@ -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, @@ -4518,7 +4520,6 @@ describe("CLIEngine", () => { ] }; - fakeFS.writeFileSync = function() {}; const spy = sinon.spy(fakeFS, "writeFileSync"); localCLIEngine.outputFixes(report); @@ -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(); diff --git a/tests/lib/eslint/eslint.js b/tests/lib/eslint/eslint.js index 6807a57aa8a..d29dbb01640 100644 --- a/tests/lib/eslint/eslint.js +++ b/tests/lib/eslint/eslint.js @@ -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"); @@ -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; @@ -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; diff --git a/tests/lib/init/config-file.js b/tests/lib/init/config-file.js index 69556b4b5b6..e9fe62e2c30 100644 --- a/tests/lib/init/config-file.js +++ b/tests/lib/init/config-file.js @@ -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"), @@ -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, @@ -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, @@ -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: { @@ -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, diff --git a/tests/lib/shared/config-ops.js b/tests/lib/shared/config-ops.js index 73f34155405..519d5a2fa0d 100644 --- a/tests/lib/shared/config-ops.js +++ b/tests/lib/shared/config-ops.js @@ -9,7 +9,6 @@ //------------------------------------------------------------------------------ const assert = require("chai").assert, - leche = require("leche"), util = require("util"), ConfigOps = require("../../../lib/shared/config-ops"); @@ -199,7 +198,7 @@ describe("ConfigOps", () => { describe("isError()", () => { - leche.withData([ + [ ["error", true], ["Error", true], [2, true], @@ -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); diff --git a/tests/lib/shared/naming.js b/tests/lib/shared/naming.js index 0a868a872ed..84bec232431 100644 --- a/tests/lib/shared/naming.js +++ b/tests/lib/shared/naming.js @@ -8,7 +8,6 @@ //------------------------------------------------------------------------------ const assert = require("chai").assert, - leche = require("leche"), naming = require("../../../lib/shared/naming"); //------------------------------------------------------------------------------ @@ -18,7 +17,7 @@ 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"], @@ -26,7 +25,7 @@ describe("naming", () => { ["@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"); @@ -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"); diff --git a/tests/lib/source-code/source-code.js b/tests/lib/source-code/source-code.js index e89f9a3283d..c44d4a2e434 100644 --- a/tests/lib/source-code/source-code.js +++ b/tests/lib/source-code/source-code.js @@ -13,7 +13,6 @@ const fs = require("fs"), assert = require("chai").assert, espree = require("espree"), sinon = require("sinon"), - leche = require("leche"), { Linter } = require("../../../lib/linter"), SourceCode = require("../../../lib/source-code/source-code"), astUtils = require("../../../lib/shared/ast-utils"); @@ -1791,13 +1790,13 @@ describe("SourceCode", () => { describe("isSpaceBetween()", () => { describe("should return true when there is at least one whitespace character between two tokens", () => { - leche.withData([ + [ ["let foo", true], ["let foo", true], ["let /**/ foo", true], ["let/**/foo", false], ["let/*\n*/foo", false] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -1829,7 +1828,7 @@ describe("SourceCode", () => { }); }); - leche.withData([ + [ ["a+b", false], ["a +b", true], ["a/**/+b", false], @@ -1861,7 +1860,7 @@ describe("SourceCode", () => { ["a/* */+ ` /*\n*/ `/* */+c", true], ["a/* */+` /*\n*/ ` /* */+c", true], ["a/* */+ ` /*\n*/ ` /* */+c", true] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -1895,7 +1894,7 @@ describe("SourceCode", () => { }); describe("should return true when there is at least one whitespace character between a token and a node", () => { - leche.withData([ + [ [";let foo = bar", false], [";/**/let foo = bar", false], [";/* */let foo = bar", false], @@ -1923,7 +1922,7 @@ describe("SourceCode", () => { [";/* */\nlet foo = bar", true], [";\n/**/\nlet foo = bar", true], [";\n/* */\nlet foo = bar", true] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -1957,7 +1956,7 @@ describe("SourceCode", () => { }); describe("should return true when there is at least one whitespace character between a node and a token", () => { - leche.withData([ + [ ["let foo = bar;;", false], ["let foo = bar;;;", false], ["let foo = 1; let bar = 2;;", true], @@ -1985,7 +1984,7 @@ describe("SourceCode", () => { ["let foo = bar;/* */\n;", true], ["let foo = bar;\n/**/\n;", true], ["let foo = bar;\n/* */\n;", true] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -2019,7 +2018,7 @@ describe("SourceCode", () => { }); describe("should return true when there is at least one whitespace character between two nodes", () => { - leche.withData([ + [ ["let foo = bar;let baz = qux;", false], ["let foo = bar;/**/let baz = qux;", false], ["let foo = bar;/* */let baz = qux;", false], @@ -2045,7 +2044,7 @@ describe("SourceCode", () => { ["let foo = bar;\n/**/\nlet baz = qux;", true], ["let foo = bar;\n/* */\nlet baz = qux;", true], ["let foo = 1;let foo2 = 2; let foo3 = 3;", true] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -2142,9 +2141,9 @@ describe("SourceCode", () => { }); describe("should return false either of the arguments' location is inside the other one", () => { - leche.withData([ + [ ["let foo = bar;", false] - ], (code, expected) => { + ].forEach(([code, expected]) => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), sourceCode = new SourceCode(code, ast); @@ -2187,13 +2186,13 @@ describe("SourceCode", () => { describe("isSpaceBetweenTokens()", () => { describe("should return true when there is at least one whitespace character between two tokens", () => { - leche.withData([ + [ ["let foo", true], ["let foo", true], ["let /**/ foo", true], ["let/**/foo", false], ["let/*\n*/foo", false] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -2225,7 +2224,7 @@ describe("SourceCode", () => { }); }); - leche.withData([ + [ ["a+b", false], ["a +b", true], ["a/**/+b", false], @@ -2257,7 +2256,7 @@ describe("SourceCode", () => { ["a/* */+ ` /*\n*/ `/* */+c", true], ["a/* */+` /*\n*/ ` /* */+c", true], ["a/* */+ ` /*\n*/ ` /* */+c", true] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -2291,7 +2290,7 @@ describe("SourceCode", () => { }); describe("should return true when there is at least one whitespace character between a token and a node", () => { - leche.withData([ + [ [";let foo = bar", false], [";/**/let foo = bar", false], [";/* */let foo = bar", false], @@ -2319,7 +2318,7 @@ describe("SourceCode", () => { [";/* */\nlet foo = bar", true], [";\n/**/\nlet foo = bar", true], [";\n/* */\nlet foo = bar", true] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -2353,7 +2352,7 @@ describe("SourceCode", () => { }); describe("should return true when there is at least one whitespace character between a node and a token", () => { - leche.withData([ + [ ["let foo = bar;;", false], ["let foo = bar;;;", false], ["let foo = 1; let bar = 2;;", true], @@ -2381,7 +2380,7 @@ describe("SourceCode", () => { ["let foo = bar;/* */\n;", true], ["let foo = bar;\n/**/\n;", true], ["let foo = bar;\n/* */\n;", true] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -2415,7 +2414,7 @@ describe("SourceCode", () => { }); describe("should return true when there is at least one whitespace character between two nodes", () => { - leche.withData([ + [ ["let foo = bar;let baz = qux;", false], ["let foo = bar;/**/let baz = qux;", false], ["let foo = bar;/* */let baz = qux;", false], @@ -2441,7 +2440,7 @@ describe("SourceCode", () => { ["let foo = bar;\n/**/\nlet baz = qux;", true], ["let foo = bar;\n/* */\nlet baz = qux;", true], ["let foo = 1;let foo2 = 2; let foo3 = 3;", true] - ], (code, expected) => { + ].forEach(([code, expected]) => { describe("when the first given is located before the second", () => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), @@ -2538,9 +2537,9 @@ describe("SourceCode", () => { }); describe("should return false either of the arguments' location is inside the other one", () => { - leche.withData([ + [ ["let foo = bar;", false] - ], (code, expected) => { + ].forEach(([code, expected]) => { it(code, () => { const ast = espree.parse(code, DEFAULT_CONFIG), sourceCode = new SourceCode(code, ast);