diff --git a/test/base-test.js b/test/base-test.js index f3adfaf4..a2b7bffe 100644 --- a/test/base-test.js +++ b/test/base-test.js @@ -2,8 +2,8 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("base", () => { - it("should get expected errors and warninigs with base config", () => { - const result = runLintWithFixtures("base"); + it("should get expected errors and warninigs with base config", async () => { + const result = await runLintWithFixtures("base"); assert.deepStrictEqual(result, { "error.js": { errors: [ diff --git a/test/es5-test.js b/test/es5-test.js index ab8e9895..df74f79e 100644 --- a/test/es5-test.js +++ b/test/es5-test.js @@ -2,8 +2,8 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("es5", () => { - it("should get expected errors and warninigs with es5 config", () => { - const result = runLintWithFixtures("es5"); + it("should get expected errors and warninigs with es5 config", async () => { + const result = await runLintWithFixtures("es5"); assert.deepStrictEqual(result, { "error.js": { errors: ["no-unused-vars", "no-redeclare"] diff --git a/test/flowtype-test.js b/test/flowtype-test.js index bfd38f3b..c7ac2b21 100644 --- a/test/flowtype-test.js +++ b/test/flowtype-test.js @@ -2,9 +2,9 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("flowtype", () => { - it("should get expected errors and warninigs with react config with flowtype config", () => { + it("should get expected errors and warninigs with react config with flowtype config", async () => { // We use react presets in order to support ES2017 syntax - const result = runLintWithFixtures("flowtype"); + const result = await runLintWithFixtures("flowtype"); assert.deepStrictEqual(result, { "ok.js": {}, "error.js": { diff --git a/test/globals-kintone-test.js b/test/globals-kintone-test.js index 7c82afa7..b65a1452 100644 --- a/test/globals-kintone-test.js +++ b/test/globals-kintone-test.js @@ -2,8 +2,11 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("kintone", () => { - it("should get expected errors and warninigs with kintone config", () => { - const result = runLintWithFixtures("globals-kintone", "globals/kintone.js"); + it("should get expected errors and warninigs with kintone config", async () => { + const result = await runLintWithFixtures( + "globals-kintone", + "globals/kintone.js" + ); assert.deepStrictEqual(result, { "error.js": { errors: ["no-undef"] diff --git a/test/kintone-test.js b/test/kintone-test.js index eaf3d588..c9afb0b7 100644 --- a/test/kintone-test.js +++ b/test/kintone-test.js @@ -2,8 +2,8 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("kintone", () => { - it("should get expected errors and warninigs with kintone config", () => { - const result = runLintWithFixtures("kintone"); + it("should get expected errors and warninigs with kintone config", async () => { + const result = await runLintWithFixtures("kintone"); assert.deepStrictEqual(result, { "error.js": { errors: ["strict", "strict"] diff --git a/test/lib/runLintWithFixtures.js b/test/lib/runLintWithFixtures.js index 594d809e..34567bce 100644 --- a/test/lib/runLintWithFixtures.js +++ b/test/lib/runLintWithFixtures.js @@ -1,6 +1,6 @@ "use strict"; -const CLIEngine = require("eslint").CLIEngine; +const { ESLint } = require("eslint"); const path = require("path"); /** @@ -8,17 +8,17 @@ const path = require("path"); * @param type lint type, which is in lib directory * @returns {Object} lint results {[fileName]: {errors: [ruleNames], warnings: [ruleNames]}} */ -const runLintWithFixtures = (type, configFile = `lib/${type}.js`) => { - const cli = new CLIEngine({ - configFile: path.resolve(process.cwd(), configFile), +const runLintWithFixtures = async (type, configFile = `lib/${type}.js`) => { + const eslint = new ESLint({ + overrideConfigFile: path.resolve(process.cwd(), configFile), ignore: false, useEslintrc: false, extensions: [".js", ".jsx", ".ts", ".tsx"] }); const targetDir = path.resolve(__dirname, "..", "fixtures", type); - const lintResult = cli.executeOnFiles([targetDir]); + const lintResult = await eslint.lintFiles([targetDir]); // console.log(JSON.stringify(lintResult, null, 2)); - return lintResult.results.reduce((results, { filePath, messages }) => { + return lintResult.reduce((results, { filePath, messages }) => { // strip path const fileName = filePath.replace(`${targetDir}/`, ""); return Object.assign(results, { diff --git a/test/node-test.js b/test/node-test.js index af36cce3..4b4e945b 100644 --- a/test/node-test.js +++ b/test/node-test.js @@ -2,8 +2,8 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("node", () => { - it("should get expected errors and warninigs with node config", () => { - const result = runLintWithFixtures("node"); + it("should get expected errors and warninigs with node config", async () => { + const result = await runLintWithFixtures("node"); assert.deepStrictEqual(result, { "error.js": { errors: [ diff --git a/test/node-typescript.js b/test/node-typescript.js index fe1cdb8e..46df2ecd 100644 --- a/test/node-typescript.js +++ b/test/node-typescript.js @@ -2,8 +2,8 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("node-typescript", () => { - it("should get expected errors and warninigs", () => { - const result = runLintWithFixtures( + it("should get expected errors and warninigs", async () => { + const result = await runLintWithFixtures( "node-typescript", "presets/node-typescript-prettier.js" ); diff --git a/test/presets-test.js b/test/presets-test.js index 0254db1c..7fe5f4ac 100644 --- a/test/presets-test.js +++ b/test/presets-test.js @@ -3,66 +3,72 @@ const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("presets", () => { describe("index", () => { - it("should be able to use index as well as lib/base", () => { + it("should be able to use index as well as lib/base", async () => { assert.deepStrictEqual( - runLintWithFixtures("base"), - runLintWithFixtures("base", "index.js") + await runLintWithFixtures("base"), + await runLintWithFixtures("base", "index.js") ); }); }); describe("react", () => { - it("should be able to use react as well as lib/base and lib/react", () => { - assert.deepStrictEqual(runLintWithFixtures("react", "presets/react.js"), { - "ok.jsx": {} - }); + it("should be able to use react as well as lib/base and lib/react", async () => { assert.deepStrictEqual( - runLintWithFixtures("base"), - runLintWithFixtures("base", "presets/react.js") + await runLintWithFixtures("react", "presets/react.js"), + { + "ok.jsx": {} + } + ); + assert.deepStrictEqual( + await runLintWithFixtures("base"), + await runLintWithFixtures("base", "presets/react.js") ); }); }); describe("flowtype", () => { - it("should be able to use flowtype as well as lib/base and lib/flowtype", () => { + it("should be able to use flowtype as well as lib/base and lib/flowtype", async () => { assert.deepStrictEqual( - runLintWithFixtures("flowtype"), - runLintWithFixtures("flowtype", "presets/flowtype.js") + await runLintWithFixtures("flowtype"), + await runLintWithFixtures("flowtype", "presets/flowtype.js") ); assert.deepStrictEqual( - runLintWithFixtures("base"), - runLintWithFixtures("base", "presets/flowtype.js") + await runLintWithFixtures("base"), + await runLintWithFixtures("base", "presets/flowtype.js") ); }); }); describe("react-flowtype", () => { - it("should be able to use react-flowtype as well as lib/react and lib/flowtype", () => { + it("should be able to use react-flowtype as well as lib/react and lib/flowtype", async () => { assert.deepStrictEqual( - runLintWithFixtures("react", "presets/react.js"), - runLintWithFixtures("react", "presets/react-flowtype.js") + await runLintWithFixtures("react", "presets/react.js"), + await runLintWithFixtures("react", "presets/react-flowtype.js") ); assert.deepStrictEqual( - runLintWithFixtures("flowtype"), - runLintWithFixtures("flowtype", "presets/react-flowtype.js") + await runLintWithFixtures("flowtype"), + await runLintWithFixtures("flowtype", "presets/react-flowtype.js") ); }); }); describe("node", () => { - it("should be able to use node as well as lib/node", () => { + it("should be able to use node as well as lib/node", async () => { assert.deepStrictEqual( - runLintWithFixtures("node"), - runLintWithFixtures("node", "presets/node.js") + await runLintWithFixtures("node"), + await runLintWithFixtures("node", "presets/node.js") ); }); }); describe("kintone-customize-es5", () => { - it("should be able to use kintone-customize-es5 as well as lib/es5 and lib/kintone", () => { + it("should be able to use kintone-customize-es5 as well as lib/es5 and lib/kintone", async () => { assert.deepStrictEqual( - runLintWithFixtures("es5"), - runLintWithFixtures("es5", "presets/kintone-customize-es5.js") + await runLintWithFixtures("es5"), + await runLintWithFixtures("es5", "presets/kintone-customize-es5.js") ); }); - it("should be able to use kintone-customize-es5 as well as lib/kintone", () => { + it("should be able to use kintone-customize-es5 as well as lib/kintone", async () => { assert.deepStrictEqual( - runLintWithFixtures("kintone", "presets/kintone-customize-es5.js"), + await runLintWithFixtures( + "kintone", + "presets/kintone-customize-es5.js" + ), { "ok.js": {}, "error.js": { errors: ["strict", "strict"] } @@ -71,74 +77,83 @@ describe("presets", () => { }); }); describe("prettier", () => { - it("should be able to use prettier as well as lib/prettier", () => { + it("should be able to use prettier as well as lib/prettier", async () => { assert.deepStrictEqual( - runLintWithFixtures("prettier"), - runLintWithFixtures("prettier", "presets/prettier.js") + await runLintWithFixtures("prettier"), + await runLintWithFixtures("prettier", "presets/prettier.js") ); }); }); describe("react-prettier", () => { - it("should be able to use react-prettier as well as lib/prettier", () => { + it("should be able to use react-prettier as well as lib/prettier", async () => { assert.deepStrictEqual( - runLintWithFixtures("prettier"), - runLintWithFixtures("prettier", "presets/react-prettier.js") + await runLintWithFixtures("prettier"), + await runLintWithFixtures("prettier", "presets/react-prettier.js") ); }); }); describe("react-flowtype-prettier", () => { - it("should be able to use react-flowtype-prettier as well as lib/prettier", () => { + it("should be able to use react-flowtype-prettier as well as lib/prettier", async () => { assert.deepStrictEqual( - runLintWithFixtures("prettier"), - runLintWithFixtures("prettier", "presets/react-flowtype-prettier.js") + await runLintWithFixtures("prettier"), + await runLintWithFixtures( + "prettier", + "presets/react-flowtype-prettier.js" + ) ); }); }); describe("node-prettier", () => { - it("should be able to use node-prettier as well as lib/prettier", () => { + it("should be able to use node-prettier as well as lib/prettier", async () => { assert.deepStrictEqual( - runLintWithFixtures("prettier"), - runLintWithFixtures("prettier", "presets/node-prettier.js") + await runLintWithFixtures("prettier"), + await runLintWithFixtures("prettier", "presets/node-prettier.js") ); }); }); describe("node-typescript-prettier", () => { - it("should be able to use node-typescript-prettier as well as lib/prettier", () => { + it("should be able to use node-typescript-prettier as well as lib/prettier", async () => { assert.deepStrictEqual( - runLintWithFixtures("prettier"), - runLintWithFixtures("prettier", "presets/node-typescript-prettier.js") + await runLintWithFixtures("prettier"), + await runLintWithFixtures( + "prettier", + "presets/node-typescript-prettier.js" + ) ); }); }); describe("react-typescript-prettier", () => { - it("should be able to use react-typescript-prettier as well as lib/prettier", () => { + it("should be able to use react-typescript-prettier as well as lib/prettier", async () => { assert.deepStrictEqual( - runLintWithFixtures("prettier"), - runLintWithFixtures("prettier", "presets/react-typescript-prettier.js") + await runLintWithFixtures("prettier"), + await runLintWithFixtures( + "prettier", + "presets/react-typescript-prettier.js" + ) ); }); }); describe("react-typescript", () => { - it("should be able to use react-typescript as well as presets/typescript", () => { + it("should be able to use react-typescript as well as presets/typescript", async () => { assert.deepStrictEqual( - runLintWithFixtures("typescript", "presets/typescript.js"), - runLintWithFixtures("typescript", "presets/react-typescript.js") + await runLintWithFixtures("typescript", "presets/typescript.js"), + await runLintWithFixtures("typescript", "presets/react-typescript.js") ); }); }); describe("typescript-prettier", () => { - it("should be able to use typescript-prettier as well as lib/prettier", () => { + it("should be able to use typescript-prettier as well as lib/prettier", async () => { assert.deepStrictEqual( - runLintWithFixtures("prettier"), - runLintWithFixtures("prettier", "presets/typescript-prettier.js") + await runLintWithFixtures("prettier"), + await runLintWithFixtures("prettier", "presets/typescript-prettier.js") ); }); }); describe("typescript", () => { - it("should be able to use typescript as well as lib/typescript", () => { + it("should be able to use typescript as well as lib/typescript", async () => { assert.deepStrictEqual( - runLintWithFixtures("typescript"), - runLintWithFixtures("typescript", "presets/typescript.js") + await runLintWithFixtures("typescript"), + await runLintWithFixtures("typescript", "presets/typescript.js") ); }); }); diff --git a/test/prettier-test.js b/test/prettier-test.js index 3758ffc5..f0d2a0e6 100644 --- a/test/prettier-test.js +++ b/test/prettier-test.js @@ -2,8 +2,8 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("prettier", () => { - it("should get expected errors and warninigs", () => { - const result = runLintWithFixtures("prettier", "presets/prettier.js"); + it("should get expected errors and warninigs", async () => { + const result = await runLintWithFixtures("prettier", "presets/prettier.js"); assert.deepStrictEqual(result, { "ok.js": {}, "error.js": { diff --git a/test/react-test.js b/test/react-test.js index 548d6d53..16d7c514 100644 --- a/test/react-test.js +++ b/test/react-test.js @@ -2,9 +2,9 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("react", () => { - it("should get expected errors and warninigs", () => { + it("should get expected errors and warninigs", async () => { // We use react presets in order to support ES2017 syntax - const result = runLintWithFixtures("react", "presets/react.js"); + const result = await runLintWithFixtures("react", "presets/react.js"); assert.deepStrictEqual(result, { "ok.jsx": {} }); diff --git a/test/react-typescript-test.js b/test/react-typescript-test.js index b04b5ce6..b8f0230a 100644 --- a/test/react-typescript-test.js +++ b/test/react-typescript-test.js @@ -2,9 +2,9 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("react-typescript", () => { - it("should get expected errors and warninigs", () => { + it("should get expected errors and warninigs", async () => { // We use react presets in order to support ES2017 syntax - const result = runLintWithFixtures( + const result = await runLintWithFixtures( "react-typescript", "presets/react-typescript.js" ); diff --git a/test/typescript-test.js b/test/typescript-test.js index 63246037..8a962e30 100644 --- a/test/typescript-test.js +++ b/test/typescript-test.js @@ -2,9 +2,9 @@ const assert = require("assert"); const runLintWithFixtures = require("./lib/runLintWithFixtures"); describe("typescript", () => { - it("should get expected errors and warninigs", () => { + it("should get expected errors and warninigs", async () => { // We use react presets in order to support ES2017 syntax - const result = runLintWithFixtures("typescript"); + const result = await runLintWithFixtures("typescript"); assert.deepStrictEqual(result, { "ok.ts": {}, "error.ts": {