33 */
44'use strict'
55
6+ const semver = require ( 'semver' )
67const { RuleTester } = require ( '../../eslint-compat' )
78const rule = require ( '../../../lib/rules/func-call-spacing' )
9+ const { eslintStylisticVersion } = require ( '../../test-utils/eslint-stylistic' )
810
911const tester = new RuleTester ( {
1012 languageOptions : { parser : require ( 'vue-eslint-parser' ) , ecmaVersion : 2020 }
1113} )
1214
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+
1350tester . run ( 'func-call-spacing' , rule , {
1451 valid : [
1552 `
@@ -61,7 +98,7 @@ tester.run('func-call-spacing', rule, {
6198 errors : [
6299 {
63100 message : 'Unexpected whitespace between function name and paren.' ,
64- line : 3
101+ ... getErrorPosition ( 3 , 23 , 'unexpected' )
65102 }
66103 ]
67104 } ,
@@ -80,7 +117,7 @@ tester.run('func-call-spacing', rule, {
80117 errors : [
81118 {
82119 message : 'Missing space between function name and paren.' ,
83- line : 3
120+ ... getErrorPosition ( 3 , 23 , 'missing' )
84121 }
85122 ]
86123 } ,
@@ -102,7 +139,7 @@ tester.run('func-call-spacing', rule, {
102139 errors : [
103140 {
104141 message : 'Unexpected whitespace between function name and paren.' ,
105- line : 4
142+ ... getErrorPosition ( 4 , 27 , 'unexpected' )
106143 }
107144 ]
108145 }
0 commit comments