Skip to content

Commit

Permalink
fix(eslint-plugin): [class-literal-property-style] don't report nodes…
Browse files Browse the repository at this point in the history
… with `override` keyword (#10135)

[class-literal-property-style] don't report nodes with `override` keyword
  • Loading branch information
kirkwaiblinger authored Oct 18, 2024
1 parent 127066a commit 0cbd4cd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export default createRule<Options, MessageIds>({
MethodDefinition(node): void {
if (
node.kind !== 'get' ||
node.override ||
!node.value.body ||
node.value.body.body.length === 0
) {
Expand Down Expand Up @@ -223,7 +224,7 @@ export default createRule<Options, MessageIds>({
}
},
PropertyDefinition(node): void {
if (!node.readonly || node.declare) {
if (!node.readonly || node.declare || node.override) {
return;
}
const { properties } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,35 @@ class Mx {
`,
options: ['getters'],
},
{
// https://github.com/typescript-eslint/typescript-eslint/issues/3602
// getter with override modifier should be ignored
code: `
declare abstract class BaseClass {
get cursor(): string;
}
class ChildClass extends BaseClass {
override get cursor() {
return 'overridden value';
}
}
`,
},
{
// https://github.com/typescript-eslint/typescript-eslint/issues/3602
// property with override modifier should be ignored
code: `
declare abstract class BaseClass {
protected readonly foo: string;
}
class ChildClass extends BaseClass {
protected override readonly foo = 'bar';
}
`,
options: ['getters'],
},
],
invalid: [
{
Expand Down

0 comments on commit 0cbd4cd

Please sign in to comment.