Skip to content

Commit abff299

Browse files
authored
refactor(test): migrate integrations to TypeScript (#3042)
1 parent 03caa80 commit abff299

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

tests/integrations/eslint-plugin-import.js renamed to tests/integrations/eslint-plugin-import.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
* @copyright 2017 Toru Nagashima. All rights reserved.
44
* See LICENSE file in root directory for full license.
55
*/
6-
'use strict'
7-
8-
const { execSync } = require('node:child_process')
9-
const path = require('node:path')
10-
const semver = require('semver')
6+
import { execSync } from 'node:child_process'
7+
import { readFileSync } from 'node:fs'
8+
import path from 'node:path'
9+
import semver from 'semver'
1110

1211
const PLUGIN_DIR = path.join(__dirname, 'eslint-plugin-import')
1312
const ESLINT = path.join(PLUGIN_DIR, 'node_modules', '.bin', 'eslint')
@@ -17,9 +16,12 @@ let eslintNodeVersion = ''
1716
describe('Integration with eslint-plugin-import', () => {
1817
beforeAll(() => {
1918
execSync('npm i', { cwd: PLUGIN_DIR, stdio: 'inherit' })
20-
eslintNodeVersion = require(
21-
path.join(PLUGIN_DIR, 'node_modules/eslint/package.json')
22-
).engines.node
19+
const eslintPackagePath = path.join(
20+
PLUGIN_DIR,
21+
'node_modules/eslint/package.json'
22+
)
23+
eslintNodeVersion = JSON.parse(readFileSync(eslintPackagePath, 'utf8'))
24+
.engines.node
2325
})
2426

2527
// https://github.com/vuejs/eslint-plugin-vue/issues/21#issuecomment-308957697
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
'use strict'
2-
3-
const { strict: assert } = require('node:assert')
4-
const { execSync } = require('node:child_process')
5-
const path = require('node:path')
6-
const semver = require('semver')
1+
import { strict as assert } from 'node:assert'
2+
import { execSync } from 'node:child_process'
3+
import { readFileSync } from 'node:fs'
4+
import path from 'node:path'
5+
import semver from 'semver'
76

87
const TARGET_DIR = path.join(__dirname, 'flat-config')
98
const ESLINT = path.join(TARGET_DIR, 'node_modules', '.bin', 'eslint')
@@ -13,9 +12,12 @@ let eslintNodeVersion = ''
1312
describe('Integration with flat config', () => {
1413
beforeAll(() => {
1514
execSync('npm i -f', { cwd: TARGET_DIR, stdio: 'inherit' })
16-
eslintNodeVersion = require(
17-
path.join(TARGET_DIR, 'node_modules/eslint/package.json')
18-
).engines.node
15+
const eslintPackagePath = path.join(
16+
TARGET_DIR,
17+
'node_modules/eslint/package.json'
18+
)
19+
eslintNodeVersion = JSON.parse(readFileSync(eslintPackagePath, 'utf8'))
20+
.engines.node
1921
})
2022

2123
it.skipIf(!semver.satisfies(process.version, eslintNodeVersion))(

0 commit comments

Comments
 (0)