8000 fix(eslint-plugin): [no-invalid-void-type] report `accessor` properties with an invalid `void` type by ronami · Pull Request #10864 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

fix(eslint-plugin): [no-invalid-void-type] report accessor properties with an invalid void type #10864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/no-invalid-void-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default createRule<[Options], MessageIds>({
AST_NODE_TYPES.TSPropertySignature,
AST_NODE_TYPES.CallExpression,
AST_NODE_TYPES.PropertyDefinition,
AST_NODE_TYPES.AccessorProperty,
AST_NODE_TYPES.Identifier,
];
const validUnionMembers: AST_NODE_TYPES[] = [
Expand Down
19 changes: 19 additions & 0 deletions packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, {
'const arrowGeneric1 = <T = void,>(arg: T) => {};',
'declare function functionDeclaration1<T = void>(arg: T): void;',
`
class ClassName {
accessor propName: number;
}
`,
`
function f(): void;
function f(x: string): string;
function f(x?: string): string | void {
Expand Down Expand Up @@ -446,6 +451,20 @@ export function f(x?: string): string | void {
},
],
},
{
code: `
class ClassName {
accessor propName: void;
}
`,
errors: [
{
column: 30,
line: 3,
messageId: 'invalidVoidNotReturnOrGeneric',
},
],
},
{
code: 'let letVoid: void;',
errors: [
Expand Down
Loading
0