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+ 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+ if (
35+ eslintStylisticVersion === undefined ||
36+ semver . satisfies ( process . version , '<19.0.0 || ^21.0.0' )
37+ ) {
38+ return {
39+ line,
40+ column : errorType === 'unexpected' ? column : column - 1 ,
41+ endLine : line ,
42+ endColumn : column
43+ }
44+ }
45+
46+ return {
47+ line,
48+ column,
49+ endLine : line ,
50+ endColumn : errorType === 'unexpected' ? column + 1 : column
51+ }
52+ }
53+
1354tester . run ( 'func-call-spacing' , rule , {
1455 valid : [
1556 `
@@ -61,7 +102,7 @@ tester.run('func-call-spacing', rule, {
61102 errors : [
62103 {
63104 message : 'Unexpected whitespace between function name and paren.' ,
64- line : 3
105+ ... getErrorPosition ( 3 , 23 , 'unexpected' )
65106 }
66107 ]
67108 } ,
@@ -80,7 +121,7 @@ tester.run('func-call-spacing', rule, {
80121 errors : [
81122 {
82123 message : 'Missing space between function name and paren.' ,
83- line : 3
124+ ... getErrorPosition ( 3 , 23 , 'missing' )
84125 }
85126 ]
86127 } ,
@@ -102,7 +143,7 @@ tester.run('func-call-spacing', rule, {
102143 errors : [
103144 {
104145 message : 'Unexpected whitespace between function name and paren.' ,
105- line : 4
146+ ... getErrorPosition ( 4 , 27 , 'unexpected' )
106147 }
107148 ]
108149 }
0 commit comments