diff --git a/tests/lib/rules/jsx-uses-vars.js b/tests/lib/rules/jsx-uses-vars.js index 680df0161..81d907dae 100644 --- a/tests/lib/rules/jsx-uses-vars.js +++ b/tests/lib/rules/jsx-uses-vars.js @@ -4,12 +4,12 @@ */ 'use strict' -const eslint = require('../../eslint-compat') +const semver = require('semver') +const { RuleTester, ESLint } = require('../../eslint-compat') const rule = require('../../../lib/rules/jsx-uses-vars') const { getCoreRule } = require('../../../lib/utils') const ruleNoUnusedVars = getCoreRule('no-unused-vars') -const RuleTester = eslint.RuleTester const ruleTester = new RuleTester({ languageOptions: { ecmaVersion: 6, @@ -108,7 +108,23 @@ describe('jsx-uses-vars', () => { `, errors: [ { - message: "'SomeComponent' is defined but never used." + message: "'SomeComponent' is defined but never used.", + suggestions: semver.gte(ESLint.version, '9.17.0') + ? [ + { + desc: "Remove unused variable 'SomeComponent'.", + output: ` + /* eslint vue/jsx-uses-vars: 1 */ + import './SomeComponent.jsx'; + export default { + render () { + return
; + }, + }; + ` + } + ] + : null } ] }, @@ -128,7 +144,25 @@ describe('jsx-uses-vars', () => { `, errors: [ { - message: "'wrapper' is assigned a value but never used." + message: "'wrapper' is assigned a value but never used.", + suggestions: semver.gte(ESLint.version, '9.17.0') + ? [ + { + desc: "Remove unused variable 'wrapper'.", + output: ` + /* eslint vue/jsx-uses-vars: 1 */ + import SomeComponent from './SomeComponent.jsx'; + + + export default { + render () { + return ; + }, + }; + ` + } + ] + : null } ] } diff --git a/tests/lib/rules/script-setup-uses-vars.js b/tests/lib/rules/script-setup-uses-vars.js index f903a3f9b..cae0f017e 100644 --- a/tests/lib/rules/script-setup-uses-vars.js +++ b/tests/lib/rules/script-setup-uses-vars.js @@ -5,12 +5,12 @@ */ 'use strict' -const eslint = require('../../eslint-compat') +const semver = require('semver') +const { RuleTester, ESLint } = require('../../eslint-compat') const rule = require('../../../lib/rules/script-setup-uses-vars') const { getCoreRule } = require('../../../lib/utils') const ruleNoUnusedVars = getCoreRule('no-unused-vars') -const RuleTester = eslint.RuleTester const ruleTester = new RuleTester({ languageOptions: { parser: require('vue-eslint-parser'), @@ -260,7 +260,39 @@ describe('script-setup-uses-vars', () => { errors: [ { message: "'Bar' is defined but never used.", - line: 6 + line: 6, + suggestions: semver.gte(ESLint.version, '9.17.0') + ? [ + { + desc: "Remove unused variable 'Bar'.", + output: ` + + + +