forked from bradzacher/eslint-plugin-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
space-infix-ops.js
86 lines (81 loc) · 2.24 KB
/
space-infix-ops.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
/**
* @fileoverview Enforces spacing around type annotations
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require("../../../lib/rules/space-infix-ops"),
RuleTester = require("eslint").RuleTester;
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new RuleTester({
parser: "typescript-eslint-parser"
});
ruleTester.run("space-infix-ops", rule, {
valid: ["type Foo = string;", "type Foo<T> = T;"],
invalid: [
{
code: "type Foo=number;",
errors: [
{
message: "Infix operators must be spaced.",
line: 1,
column: 9
}
]
},
{
code: "type Foo =number;",
errors: [
{
message: "Infix operators must be spaced.",
line: 1,
column: 10
}
]
},
{
code: "type Foo= number;",
errors: [
{
message: "Infix operators must be spaced.",
line: 1,
column: 9
}
]
},
{
code: "type Foo<T>=T;",
errors: [
{
message: "Infix operators must be spaced.",
line: 1,
column: 12
}
]
},
{
code: "type Foo<T> =T;",
errors: [
{
message: "Infix operators must be spaced.",
line: 1,
column: 13
}
]
},
{
code: "type Foo<T>= T;",
errors: [
{
message: "Infix operators must be spaced.",
line: 1,
column: 12
}
]
}
]
});