From 4d353a236ed4613c5c566026ac6c7fb9e2926982 Mon Sep 17 00:00:00 2001 From: yeonjuan Date: Tue, 13 Feb 2024 16:34:04 +0900 Subject: [PATCH] add testcase --- .../class-literal-property-style.test.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/eslint-plugin/tests/rules/class-literal-property-style.test.ts b/packages/eslint-plugin/tests/rules/class-literal-property-style.test.ts index 0bf1ec8fa0ec..ab195c55d2d9 100644 --- a/packages/eslint-plugin/tests/rules/class-literal-property-style.test.ts +++ b/packages/eslint-plugin/tests/rules/class-literal-property-style.test.ts @@ -733,6 +733,47 @@ class A { } })(); } +} + `, + }, + ], + }, + ], + }, + { + code: ` +class A { + private readonly ['foo']: string = 'bar'; + constructor(foo: string) { + this.b = new (class { + private readonly foo: string = 'baz'; + constructor() { + this['foo'] = 'qux'; + } + })(); + } +} + `, + options: ['getters'], + errors: [ + { + messageId: 'preferGetterStyle', + column: 21, + line: 3, + suggestions: [ + { + messageId: 'preferGetterStyleSuggestion', + output: ` +class A { + private get ['foo']() { return 'bar'; } + constructor(foo: string) { + this.b = new (class { + private readonly foo: string = 'baz'; + constructor() { + this['foo'] = 'qux'; + } + })(); + } } `, },