-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
validate-config.js
66 lines (56 loc) · 1.32 KB
/
validate-config.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
const { ESLint } = require('eslint')
const test = require('tape')
test('load config in eslint to validate all rule syntax is correct', function (t) {
const cli = new ESLint({
useEslintrc: false,
overrideConfigFile: 'eslintrc.json'
})
const code = 'var foo = 1\nvar bar = function () {}\nbar(foo)\n'
t.equal(cli.lintText(code).errorCount, 0)
t.end()
})
test('space before an opening tag\'s closing bracket should not be allowed', t => {
const cli = new ESLint({
useEslintrc: false,
overrideConfigFile: 'eslintrc.json'
})
const shouldPass = {
selfClosing: '<div />',
withChildren: `
<div>
test
</div>
`,
withChildrenWithPropsMultiLine: `
<div
a
b
>
test
</div>
`
}
const shouldFail = {
selfClosing: '<div/ >',
openingTag: `
<div >
test
</div>
`,
closingTag: `
<div>
test
</div >
`
}
const testPlansCount = Object.keys(shouldPass).length + Object.keys(shouldFail).length
t.plan(testPlansCount)
for (const testCase in shouldPass) {
const { errorCount } = cli.lintText(shouldPass[testCase])
t.equal(errorCount, 0)
}
for (const testCase in shouldFail) {
const { errorCount } = cli.lintText(shouldFail[testCase])
t.true(errorCount > 0)
}
})