From a40d17ff7087e6a97d85162c117d7296e8c96b37 Mon Sep 17 00:00:00 2001 From: Toru Kobayashi Date: Wed, 13 May 2020 00:02:43 +0900 Subject: [PATCH] test: use ESLint class instead of CLIEngine --- test/lib/runLint.js | 12 ++++++------ test/run.test.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/lib/runLint.js b/test/lib/runLint.js index 0c735f13..55447508 100644 --- a/test/lib/runLint.js +++ b/test/lib/runLint.js @@ -1,19 +1,19 @@ 'use strict' -const CLIEngine = require('eslint').CLIEngine +const { ESLint } = require('eslint') const path = require('path') -const runLintWithFixtures = (configFile, target) => { - const cli = new CLIEngine({ - configFile, +const runLintWithFixtures = async (configFile, target) => { + const eslint = new ESLint({ + overrideConfigFile: configFile, ignore: false, useEslintrc: false, extensions: ['.js', '.jsx', '.ts', '.tsx'], }) - const lintResult = cli.executeOnFiles([target]) + const lintResult = await eslint.lintFiles([target]) // console.log(JSON.stringify(lintResult, null, 2)) - return lintResult.results.reduce((results, { filePath, messages }) => { + return lintResult.reduce((results, { filePath, messages }) => { return Object.assign(results, { [path.basename(filePath)]: messages.reduce( (resultPerFile, { severity, ruleId }) => { diff --git a/test/run.test.js b/test/run.test.js index 6ec38953..de1eb8d4 100644 --- a/test/run.test.js +++ b/test/run.test.js @@ -1,8 +1,8 @@ const runLint = require('./lib/runLint') describe('fixtures', () => { - it('should match the snapshot', () => { - const result = runLint('./index.js', './test/fixtures') + it('should match the snapshot', async () => { + const result = await runLint('./index.js', './test/fixtures') expect(result).toMatchSnapshot() }) })