Skip to content

Commit 735064a

Browse files
authored
fix(eslint-plugin): [no-invalid-void-type] report accessor properties with an invalid void type (#10864)
check accessor properties with an invalid void type
1 parent a6feb59 commit 735064a

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎packages/eslint-plugin/src/rules/no-invalid-void-type.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default createRule<[Options], MessageIds>({
8181
AST_NODE_TYPES.TSPropertySignature,
8282
AST_NODE_TYPES.CallExpression,
8383
AST_NODE_TYPES.PropertyDefinition,
84+
AST_NODE_TYPES.AccessorProperty,
8485
AST_NODE_TYPES.Identifier,
8586
];
8687
const validUnionMembers: AST_NODE_TYPES[] = [

‎packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, {
121121
'const arrowGeneric1 = <T = void,>(arg: T) => {};',
122122
'declare function functionDeclaration1<T = void>(arg: T): void;',
123123
`
124+
class ClassName {
125+
accessor propName: number;
126+
}
127+
`,
128+
`
124129
function f(): void;
125130
function f(x: string): string;
126131
function f(x?: string): string | void {
@@ -446,6 +451,20 @@ export function f(x?: string): string | void {
446451
},
447452
],
448453
},
454+
{
455+
code: `
456+
class ClassName {
457+
accessor propName: void;
458+
}
459+
`,
460+
errors: [
461+
{
462+
column: 30,
463+
line: 3,
464+
messageId: 'invalidVoidNotReturnOrGeneric',
465+
},
466+
],
467+
},
449468
{
450469
code: 'let letVoid: void;',
451470
errors: [

0 commit comments

Comments
 (0)