3
3
*/
4
4
'use strict'
5
5
6
+ const semver = require ( 'semver' )
6
7
const { RuleTester } = require ( '../../eslint-compat' )
7
8
const rule = require ( '../../../lib/rules/func-call-spacing' )
9
+ const { eslintStylisticVersion } = require ( '../../test-utils/eslint-stylistic' )
8
10
9
11
const tester = new RuleTester ( {
10
12
languageOptions : { parser : require ( 'vue-eslint-parser' ) , ecmaVersion : 2020 }
11
13
} )
12
14
15
+ /**
16
+ * @param {number } line
17
+ * @param {number } column
18
+ * @param {'unexpected' | 'missing' } errorType
19
+ * @returns {{line: number, column: number, endLine: number, endColumn: number} }
20
+ */
21
+ function getErrorPosition ( line , column , errorType ) {
22
+ if (
23
+ eslintStylisticVersion !== undefined &&
24
+ semver . lt ( eslintStylisticVersion , '3.0.0' )
25
+ ) {
26
+ return {
27
+ line,
28
+ column : column - 3 ,
29
+ endLine : undefined ,
30
+ endColumn : undefined
31
+ }
32
+ }
33
+
34
+ return {
35
+ line,
36
+ column,
37
+ endLine : line ,
38
+ endColumn : errorType === 'unexpected' ? column + 1 : column
39
+ }
40
+ }
41
+
13
42
tester . run ( 'func-call-spacing' , rule , {
14
43
valid : [
15
44
`
@@ -61,7 +90,7 @@ tester.run('func-call-spacing', rule, {
61
90
errors : [
62
91
{
63
92
message : 'Unexpected whitespace between function name and paren.' ,
64
- line : 3
93
+ ... getErrorPosition ( 3 , 23 , 'unexpected' )
65
94
}
66
95
]
67
96
} ,
@@ -80,7 +109,7 @@ tester.run('func-call-spacing', rule, {
80
109
errors : [
81
110
{
82
111
message : 'Missing space between function name and paren.' ,
83
- line : 3
112
+ ... getErrorPosition ( 3 , 23 , 'missing' )
84
113
}
85
114
]
86
115
} ,
@@ -102,7 +131,7 @@ tester.run('func-call-spacing', rule, {
102
131
errors : [
103
132
{
104
133
message : 'Unexpected whitespace between function name and paren.' ,
105
- line : 4
134
+ ... getErrorPosition ( 4 , 27 , 'unexpected' )
106
135
}
107
136
]
108
137
}
0 commit comments