forked from vuejs/eslint-config-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.spec.js
59 lines (49 loc) · 1.54 KB
/
index.spec.js
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
58
59
const path = require('path')
const execa = require('execa')
const eslintPath = path.resolve(__dirname, '../node_modules/.bin/eslint')
async function lintProject (name) {
const projectPath = path.resolve(__dirname, 'fixtures', name)
try {
return await execa(
eslintPath,
[
`${projectPath}/`,
'--no-ignore'
],
{
cwd: projectPath,
}
)
} catch (e) {
return e
}
}
test('a default project should pass lint', async () => {
const { stdout } = await lintProject('default')
expect(stdout).toEqual('')
})
test('should lint .ts file', async () => {
const { stdout } = await lintProject('ts')
expect(stdout).toMatch('@typescript-eslint/no-unused-vars')
})
test('should lint .vue file', async () => {
const { stdout } = await lintProject('sfc')
expect(stdout).toMatch('@typescript-eslint/no-unused-vars')
})
test('should lint .tsx', async () => {
const { stdout } = await lintProject('tsx')
expect(stdout).not.toMatch('Parsing error')
expect(stdout).toMatch('@typescript-eslint/no-unused-vars')
})
test('should lint tsx block in .vue file', async () => {
const { stdout } = await lintProject('tsx-in-sfc')
expect(stdout).not.toMatch('Parsing error')
expect(stdout).toMatch('@typescript-eslint/no-unused-vars')
})
test('should not override eslint:recommended rules for normal js files', async () => {
const { stdout } = await lintProject('allow-js')
// errors in .vue file
expect(stdout).toMatch('no-const-assign')
// errors in .js file
expect(stdout).toMatch('no-undef')
})