-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
test.js
87 lines (81 loc) · 2.65 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 fs from 'fs';
import test from 'ava';
import getRuleURI from './';
test('should return url of core rules', t => {
t.deepEqual(getRuleURI('no-var'),
{
found: true,
url: 'https://eslint.org/docs/rules/no-var'
});
t.deepEqual(getRuleURI('no-console'),
{
found: true,
url: 'https://eslint.org/docs/rules/no-console'
});
t.deepEqual(getRuleURI('array-callback-return'),
{
found: true,
url: 'https://eslint.org/docs/rules/array-callback-return'
});
});
test('should return url of found plugin rules', t => {
t.deepEqual(getRuleURI('import/order'),
{
found: true,
url: 'https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md'
});
t.deepEqual(getRuleURI('import/no-unresolved'),
{
found: true,
url: 'https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md'
});
t.deepEqual(getRuleURI('ava/no-identical-title'),
{
found: true,
url: 'https://github.com/avajs/eslint-plugin-ava/blob/master/docs/rules/no-identical-title.md'
});
t.deepEqual(getRuleURI('ava/no-todo-test'),
{
found: true,
url: 'https://github.com/avajs/eslint-plugin-ava/blob/master/docs/rules/no-todo-test.md'
});
t.deepEqual(getRuleURI('eslint-comments/no-unlimited-disable'),
{
found: true,
url: 'https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/no-unlimited-disable.md'
});
t.deepEqual(getRuleURI('promise/no-native'),
{
found: true,
url: 'https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/no-native.md'
});
t.deepEqual(getRuleURI('promise/catch-or-return'),
{
found: true,
url: 'https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/catch-or-return.md'
});
t.deepEqual(getRuleURI('standard/array-bracket-even-spacing'),
{
found: true,
url: 'https://github.com/xjamundx/eslint-plugin-standard#rules-explanations'
});
});
test.cb('should be able to parse `plugin.json`', t => {
fs.readFile('./plugins.json', 'utf8', (err, content) => {
t.falsy(err);
t.truthy(content);
const parsedContent = JSON.parse(content);
t.true(typeof parsedContent === 'object');
t.end();
});
});
test('should return url to help improve this tool', t => {
t.deepEqual(getRuleURI('unknown-foo/bar'),
{
found: false,
url: 'https://github.com/jfmengels/eslint-rule-documentation/blob/master/contributing.md'
});
});
test('should throw when ruleId is not a string', t => {
t.throws(() => getRuleURI(null), 'ruleId must be a string, got object');
});