Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit a40d17f

Browse files
committed
test: use ESLint class instead of CLIEngine
1 parent 9cd37c6 commit a40d17f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

test/lib/runLint.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
'use strict'
22

3-
const CLIEngine = require('eslint').CLIEngine
3+
const { ESLint } = require('eslint')
44
const path = require('path')
55

6-
const runLintWithFixtures = (configFile, target) => {
7-
const cli = new CLIEngine({
8-
configFile,
6+
const runLintWithFixtures = async (configFile, target) => {
7+
const eslint = new ESLint({
8+
overrideConfigFile: configFile,
99
ignore: false,
1010
useEslintrc: false,
1111
extensions: ['.js', '.jsx', '.ts', '.tsx'],
1212
})
13-
const lintResult = cli.executeOnFiles([target])
13+
const lintResult = await eslint.lintFiles([target])
1414
// console.log(JSON.stringify(lintResult, null, 2))
1515

16-
return lintResult.results.reduce((results, { filePath, messages }) => {
16+
return lintResult.reduce((results, { filePath, messages }) => {
1717
return Object.assign(results, {
1818
[path.basename(filePath)]: messages.reduce(
1919
(resultPerFile, { severity, ruleId }) => {

test/run.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const runLint = require('./lib/runLint')
22

33
describe('fixtures', () => {
4-
it('should match the snapshot', () => {
5-
const result = runLint('./index.js', './test/fixtures')
4+
it('should match the snapshot', async () => {
5+
const result = await runLint('./index.js', './test/fixtures')
66
expect(result).toMatchSnapshot()
77
})
88
})

0 commit comments

Comments
 (0)