@@ -173,3 +168,53 @@ tester.run('comma-style', rule, {
}
]
})
+
+if (
+ eslintStylisticVersion === undefined ||
+ semver.lt(eslintStylisticVersion, '3.0.0') ||
+ semver.satisfies(process.version, '<19.0.0 || ^21.0.0')
+) {
+ tester.run('comma-style', rule, {
+ valid: [
+ `
+
+
+
+ `
+ ],
+ invalid: []
+ })
+} else {
+ tester.run('comma-style', rule, {
+ valid: [],
+ invalid: [
+ {
+ code: `
+
+
+
+ `,
+ output: `
+
+
+
+ `,
+ errors: [
+ {
+ message: "',' should be placed last.",
+ line: 5,
+ column: 13,
+ endLine: 5,
+ endColumn: 14
+ }
+ ]
+ }
+ ]
+ })
+}
diff --git a/tests/lib/rules/func-call-spacing.js b/tests/lib/rules/func-call-spacing.js
index 7f06f72fc..6dfd86837 100644
--- a/tests/lib/rules/func-call-spacing.js
+++ b/tests/lib/rules/func-call-spacing.js
@@ -3,13 +3,54 @@
*/
'use strict'
+const semver = require('semver')
const { RuleTester } = require('../../eslint-compat')
const rule = require('../../../lib/rules/func-call-spacing')
+const { eslintStylisticVersion } = require('../../test-utils/eslint-stylistic')
const tester = new RuleTester({
languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2020 }
})
+/**
+ * @param {number} line
+ * @param {number} column
+ * @param {'unexpected' | 'missing'} errorType
+ * @returns {{line: number, column: number, endLine: number, endColumn: number}}
+ */
+function getErrorPosition(line, column, errorType) {
+ if (
+ eslintStylisticVersion !== undefined &&
+ semver.lt(eslintStylisticVersion, '3.0.0')
+ ) {
+ return {
+ line,
+ column: column - 3,
+ endLine: undefined,
+ endColumn: undefined
+ }
+ }
+
+ if (
+ eslintStylisticVersion === undefined ||
+ semver.satisfies(process.version, '<19.0.0 || ^21.0.0')
+ ) {
+ return {
+ line,
+ column: errorType === 'unexpected' ? column : column - 1,
+ endLine: line,
+ endColumn: column
+ }
+ }
+
+ return {
+ line,
+ column,
+ endLine: line,
+ endColumn: errorType === 'unexpected' ? column + 1 : column
+ }
+}
+
tester.run('func-call-spacing', rule, {
valid: [
`
@@ -61,7 +102,7 @@ tester.run('func-call-spacing', rule, {
errors: [
{
message: 'Unexpected whitespace between function name and paren.',
- line: 3
+ ...getErrorPosition(3, 23, 'unexpected')
}
]
},
@@ -80,7 +121,7 @@ tester.run('func-call-spacing', rule, {
errors: [
{
message: 'Missing space between function name and paren.',
- line: 3
+ ...getErrorPosition(3, 23, 'missing')
}
]
},
@@ -102,7 +143,7 @@ tester.run('func-call-spacing', rule, {
errors: [
{
message: 'Unexpected whitespace between function name and paren.',
- line: 4
+ ...getErrorPosition(4, 27, 'unexpected')
}
]
}
diff --git a/tests/test-utils/eslint-stylistic.js b/tests/test-utils/eslint-stylistic.js
new file mode 100644
index 000000000..81fc774f3
--- /dev/null
+++ b/tests/test-utils/eslint-stylistic.js
@@ -0,0 +1,16 @@
+const { existsSync, readFileSync } = require('node:fs')
+const path = require('node:path')
+
+const eslintStylisticPackagePath = path.join(
+ __dirname,
+ '../..',
+ 'node_modules',
+ '@stylistic',
+ 'eslint-plugin',
+ 'package.json'
+)
+const eslintStylisticVersion = existsSync(eslintStylisticPackagePath)
+ ? JSON.parse(readFileSync(eslintStylisticPackagePath, 'utf8')).version
+ : undefined
+
+module.exports = { eslintStylisticVersion }
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy