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
+ console . log ( eslintStylisticVersion )
23
+
24
+ if ( semver . lt ( eslintStylisticVersion , '3.0.0' ) ) {
25
+ return {
26
+ line,
27
+ column : column - 3 ,
28
+ endLine : undefined ,
29
+ endColumn : undefined
30
+ }
31
+ }
32
+
33
+ if ( eslintStylisticVersion === undefined ) {
34
+ return {
35
+ line,
36
+ column,
37
+ endLine : line ,
38
+ endColumn : errorType === 'unexpected' ? column + 1 : column
39
+ }
40
+ }
41
+
42
+ return {
43
+ line,
44
+ column,
45
+ endLine : line ,
46
+ endColumn : errorType === 'unexpected' ? column + 1 : column
47
+ }
48
+ }
49
+
13
50
tester . run ( 'func-call-spacing' , rule , {
14
51
valid : [
15
52
`
@@ -61,7 +98,7 @@ tester.run('func-call-spacing', rule, {
61
98
errors : [
62
99
{
63
100
message : 'Unexpected whitespace between function name and paren.' ,
64
- line : 3
101
+ ... getErrorPosition ( 3 , 23 , 'unexpected' )
65
102
}
66
103
]
67
104
} ,
@@ -80,7 +117,7 @@ tester.run('func-call-spacing', rule, {
80
117
errors : [
81
118
{
82
119
message : 'Missing space between function name and paren.' ,
83
- line : 3
120
+ ... getErrorPosition ( 3 , 23 , 'missing' )
84
121
}
85
122
]
86
123
} ,
@@ -102,7 +139,7 @@ tester.run('func-call-spacing', rule, {
102
139
errors : [
103
140
{
104
141
message : 'Unexpected whitespace between function name and paren.' ,
105
- line : 4
142
+ ... getErrorPosition ( 4 , 27 , 'unexpected' )
106
143
}
107
144
]
108
145
}
0 commit comments