Skip to content

Commit

Permalink
test: use ESLint class instead of CLIEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed May 12, 2020
1 parent 9cd37c6 commit a40d17f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions 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 }) => {
Expand Down
4 changes: 2 additions & 2 deletions 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()
})
})

0 comments on commit a40d17f

Please sign in to comment.