22// Requirements
33//------------------------------------------------------------------------------
44
5- const assert = require ( "assert" )
6- const path = require ( "path" )
7- const fs = require ( "fs-extra" )
8- const cp = require ( "child_process" )
9- const eslintCompat = require ( "./lib/eslint-compat" )
5+ import { assert , beforeAll , describe , it } from "vitest"
6+ import path from "path"
7+ import fs from "fs-extra"
8+ import cp from "child_process"
9+ import eslintCompat from "./lib/eslint-compat"
10+ import * as ESLintRaw from "eslint"
1011
1112//------------------------------------------------------------------------------
1213// Helpers
1314//------------------------------------------------------------------------------
1415
16+ // eslint-disable-next-line no-undef
1517const FIXTURE_DIR = path . join ( __dirname , "fixtures/integrations" )
1618
1719//------------------------------------------------------------------------------
1820// Tests
1921//------------------------------------------------------------------------------
2022
2123describe ( "Integration tests" , ( ) => {
24+ beforeAll ( async ( ) => {
25+ await import ( "ts-node/register" )
26+ } )
2227 for ( const target of fs . readdirSync ( FIXTURE_DIR ) ) {
2328 it ( target , async ( ) => {
24- let ESLint = eslintCompat ( require ( "eslint" ) ) . ESLint
29+ let ESLint = eslintCompat ( ESLintRaw ) . ESLint
2530 if ( fs . existsSync ( path . join ( FIXTURE_DIR , target , "package.json" ) ) ) {
2631 const originalCwd = process . cwd ( )
2732 try {
2833 process . chdir ( path . join ( FIXTURE_DIR , target ) )
2934 cp . execSync ( "npm i" , { stdio : "inherit" } )
3035 ESLint = eslintCompat (
36+ // eslint-disable-next-line @typescript-eslint/no-require-imports
3137 require (
3238 path . join (
3339 FIXTURE_DIR ,
@@ -46,7 +52,7 @@ describe("Integration tests", () => {
4652 } )
4753 const report = await cli . lintFiles ( [ "**/*.vue" ] )
4854
49- const outputPath = path . join ( FIXTURE_DIR , target , ` output.json` )
55+ const outputPath = path . join ( FIXTURE_DIR , target , " output.json" )
5056 const expected = JSON . parse ( fs . readFileSync ( outputPath , "utf8" ) )
5157 try {
5258 assert . deepStrictEqual (
@@ -59,7 +65,7 @@ describe("Integration tests", () => {
5965 const actualPath = path . join (
6066 FIXTURE_DIR ,
6167 target ,
62- ` _actual.json` ,
68+ " _actual.json" ,
6369 )
6470 fs . writeFileSync (
6571 actualPath ,
@@ -72,22 +78,18 @@ describe("Integration tests", () => {
7278 function normalizeReport ( report , option = { } ) {
7379 return report
7480 . filter ( ( res ) => res . messages . length )
75- . map ( ( res ) => {
76- return {
77- filePath : res . filePath
78- . replace ( cwd , "" )
79- . replace ( / \\ / gu, "/" ) ,
80- messages : res . messages . map ( ( msg ) => {
81- return {
82- ruleId : msg . ruleId ,
83- line : msg . line ,
84- ...( option . withoutMessage
85- ? { }
86- : { message : msg . message } ) ,
87- }
88- } ) ,
89- }
90- } )
81+ . map ( ( res ) => ( {
82+ filePath : res . filePath
83+ . replace ( cwd , "" )
84+ . replace ( / \\ / gu, "/" ) ,
85+ messages : res . messages . map ( ( msg ) => ( {
86+ ruleId : msg . ruleId ,
87+ line : msg . line ,
88+ ...( option . withoutMessage
89+ ? { }
90+ : { message : msg . message } ) ,
91+ } ) ) ,
92+ } ) )
9193 . sort ( ( a , b ) =>
9294 a . filePath < b . filePath
9395 ? - 1
0 commit comments