-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
87 lines (80 loc) · 1.88 KB
/
test.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import assert from 'node:assert/strict'
import test from 'node:test'
import {VFile} from 'vfile'
import {toESLint} from 'vfile-to-eslint'
test('toESLint', async function () {
assert.deepEqual(
Object.keys(await import('vfile-to-eslint')).sort(),
['toESLint'],
'should expose the public api'
)
const file = new VFile({path: '~/example.md'})
file.info('?')
file.info('This is perfect', {line: 5, column: 3}, 'alpha:bravo')
file.message('This should be fixed', {
start: {line: 3, column: 5},
end: {line: 3, column: 7}
})
try {
file.fail('This is horrible', {
place: {
start: {line: 2, column: 1},
end: {line: 2, column: 8}
}
})
} catch {}
assert.deepEqual(toESLint([file]), [
{
filePath: '~/example.md',
messages: [
{
fatal: undefined,
severity: 1,
ruleId: null,
line: 0,
column: 0,
endLine: undefined,
endColumn: undefined,
message: '?'
},
{
fatal: undefined,
severity: 1,
ruleId: 'alpha:bravo',
line: 5,
column: 3,
endLine: undefined,
endColumn: undefined,
message: 'This is perfect'
},
{
fatal: undefined,
severity: 1,
ruleId: null,
line: 3,
column: 5,
endLine: 3,
endColumn: 7,
message: 'This should be fixed'
},
{
fatal: true,
severity: 2,
ruleId: null,
line: 2,
column: 1,
endLine: 2,
endColumn: 8,
message: 'This is horrible'
}
],
fatalErrorCount: 1,
errorCount: 1,
warningCount: 3,
fixableErrorCount: 0,
fixableWarningCount: 0,
usedDeprecatedRules: [],
suppressedMessages: []
}
])
})