From 489649fbe5daf36bcd4894fc771765e385a43872 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sun, 4 Jul 2021 10:16:26 +0900 Subject: [PATCH 1/3] Update `vue/no-restricted-props` rule to support ` + `, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 4, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 3, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 4, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 4, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 4, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + + `, + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 7, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` + + + ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` + + `, + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 9, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` + + ` + } + ] + } + ] } ] }) From de36e6de544b21e076628c1f9fff881f11fc24da Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sun, 4 Jul 2021 10:19:16 +0900 Subject: [PATCH 2/3] fix --- tests/lib/rules/no-restricted-props.js | 167 +++++++++++++------------ 1 file changed, 87 insertions(+), 80 deletions(-) diff --git a/tests/lib/rules/no-restricted-props.js b/tests/lib/rules/no-restricted-props.js index 1b6317b5d..f05370e44 100644 --- a/tests/lib/rules/no-restricted-props.js +++ b/tests/lib/rules/no-restricted-props.js @@ -413,9 +413,15 @@ tester.run('no-restricted-props', rule, { } ] }, - { - filename: 'test.vue', - code: ` + ...(semver.lt( + require('@typescript-eslint/parser/package.json').version, + '4.0.0' + ) + ? [] + : [ + { + filename: 'test.vue', + code: ` `, - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - }, - options: [{ name: 'foo', suggest: 'Foo' }], - errors: [ - { - message: 'Using `foo` props is not allowed.', - line: 4, - suggestions: [ - { - desc: 'Instead, change to `Foo`.', - output: ` + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 4, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` ` - } - ] - } - ] - }, - { - filename: 'test.vue', - code: ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` `, - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - }, - options: [{ name: 'foo', suggest: 'Foo' }], - errors: [ - { - message: 'Using `foo` props is not allowed.', - line: 4, - suggestions: [ - { - desc: 'Instead, change to `Foo`.', - output: ` + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 4, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` ` - } - ] - } - ] - }, - { - filename: 'test.vue', - code: ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` @@ -506,18 +512,18 @@ tester.run('no-restricted-props', rule, { ) `, - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - }, - options: [{ name: 'foo', suggest: 'Foo' }], - errors: [ - { - message: 'Using `foo` props is not allowed.', - line: 7, - suggestions: [ - { - desc: 'Instead, change to `Foo`.', - output: ` + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 7, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` @@ -532,14 +538,14 @@ tester.run('no-restricted-props', rule, { ) ` - } - ] - } - ] - }, - { - filename: 'test.vue', - code: ` + } + ] + } + ] + }, + { + filename: 'test.vue', + code: ` `, - parserOptions: { - parser: require.resolve('@typescript-eslint/parser') - }, - options: [{ name: 'foo', suggest: 'Foo' }], - errors: [ - { - message: 'Using `foo` props is not allowed.', - line: 9, - suggestions: [ - { - desc: 'Instead, change to `Foo`.', - output: ` + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + options: [{ name: 'foo', suggest: 'Foo' }], + errors: [ + { + message: 'Using `foo` props is not allowed.', + line: 9, + suggestions: [ + { + desc: 'Instead, change to `Foo`.', + output: ` ` - } - ] - } - ] - } + } + ] + } + ] + } + ]) ] }) From 604694ded0cf86bdaab6274a20ed0811b10ed313 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sun, 4 Jul 2021 10:24:01 +0900 Subject: [PATCH 3/3] fix --- tests/lib/rules/no-restricted-props.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/lib/rules/no-restricted-props.js b/tests/lib/rules/no-restricted-props.js index f05370e44..3348ca1a0 100644 --- a/tests/lib/rules/no-restricted-props.js +++ b/tests/lib/rules/no-restricted-props.js @@ -7,6 +7,7 @@ // Requirements // ------------------------------------------------------------------------------ +const semver = require('semver') const RuleTester = require('eslint').RuleTester const rule = require('../../../lib/rules/no-restricted-props')