-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflat-config.ts
57 lines (49 loc) · 1.45 KB
/
flat-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import cp from 'child_process'
import path from 'path'
import assert from 'assert'
import semver from 'semver'
import { readPackageJson } from './helper'
import { fileURLToPath } from 'url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const TEST_CWD = path.join(__dirname, 'flat-config')
const ESLINT = `.${path.sep}node_modules${path.sep}.bin${path.sep}eslint`
describe('Integration with flat config', () => {
let originalCwd: string
before(() => {
originalCwd = process.cwd();
process.chdir(TEST_CWD);
try {
cp.execSync('yarn --ignore-engines --ignore-scripts', { stdio: 'inherit' });
} catch (error) {
console.error('Error running yarn:', error);
throw error;
}
});
after(() => {
originalCwd && process.chdir(originalCwd)
})
it('should work with flat config', async () => {
if (
!semver.satisfies(
process.version,
readPackageJson(
path.resolve(__dirname, './flat-config/node_modules/eslint')
).engines.node
)
) {
return
}
const cliResult = cp.execSync(`${ESLINT} src/* --format=json`, {
encoding: 'utf-8'
})
const result = JSON.parse(cliResult)
const aSvelte = result.find(
(r: { filePath: string }) => path.basename(r.filePath) === 'a.svelte'
)
assert.strictEqual(aSvelte.messages.length, 1)
assert.strictEqual(
aSvelte.messages[0].ruleId,
'@intlify/svelte/no-raw-text'
)
})
})