Skip to content

feat(linter): implement typescript/no-invalid-void-type#19242

Merged
camc314 merged 3 commits intooxc-project:mainfrom
Limerio:feature/implement-no-invalid-void-type
Feb 11, 2026
Merged

feat(linter): implement typescript/no-invalid-void-type#19242
camc314 merged 3 commits intooxc-project:mainfrom
Limerio:feature/implement-no-invalid-void-type

Conversation

@Limerio
Copy link
Contributor

@Limerio Limerio commented Feb 10, 2026

This commit introduces a new linting rule, no-invalid-void-type, which disallows the use of the void type outside of return positions and configured generic contexts in TypeScript. The rule aims to prevent confusion and improve type design by ensuring void is only used where it is semantically appropriate. Additionally, the rule includes configuration options for allowing void in generic type arguments and as a this parameter.

New tests and snapshots have been added to validate the functionality of this rule.

This commit introduces a new linting rule, `no-invalid-void-type`, which disallows the use of the `void` type outside of return positions and configured generic contexts in TypeScript. The rule aims to prevent confusion and improve type design by ensuring `void` is only used where it is semantically appropriate. Additionally, the rule includes configuration options for allowing `void` in generic type arguments and as a `this` parameter.

New tests and snapshots have been added to validate the functionality of this rule.
@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Feb 10, 2026
@Limerio Limerio marked this pull request as ready for review February 10, 2026 23:17
@Limerio Limerio requested a review from camc314 as a code owner February 10, 2026 23:17
@camc314 camc314 self-assigned this Feb 11, 2026
@camc314 camc314 changed the title feat(linter): add no-invalid-void-type rule to TypeScript linting feat(linter): implement typescript/no-invalid-void-type Feb 11, 2026
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing Limerio:feature/implement-no-invalid-void-type (28dcecd) with main (740a009)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (9195430) during the generation of this report, so 740a009 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@camc314 camc314 changed the title feat(linter): implement typescript/no-invalid-void-type feat(linter): implement typescript/no-invalid-void-type Feb 11, 2026
@camc314 camc314 merged commit 1a61f58 into oxc-project:main Feb 11, 2026
30 checks passed
camc314 added a commit that referenced this pull request Feb 12, 2026
# Oxlint
### 🚀 Features

- ebb80b3 ast: Add `node_id` field to all AST struct nodes (#18138)
(Boshen)
- 2879fc5 linter: Implement fixer for unicorn/prefer-math-trunc (#19275)
(camc314)
- a204eda linter: Implement fixer for unicorn/no-typeof-undefined
(#19274) (camc314)
- ab46d9c linter: Implement typescript/class-literal-property-style
(#19252) (Vincent R)
- 1a61f58 linter: Implement typescript/no-invalid-void-type (#19242)
(Vincent R)

### 🐛 Bug Fixes

- 45adda2 oxlint/lsp: Use blocking stdio in Oxlint (#19292)
(overlookmotel)
- 05bc855 linter/import: Count unique module sources in max-dependencies
(#19270) (camc314)
- 8566b44 linter: Check for preceeding token in math trunc fixer
(#19277) (camc314)
- f16f2b6 linter/import-no-cycle: Avoid traversal-order false negatives
with type-only edges (#19267) (camc314)
- d4937e7 linter: Recognize module-scoped callback refs as stable in
exhaustive-deps (#19220) (Sreetam Das)
- 140c9bd linter: Detect fallthrough from `default` when it is not the
last case (#19261) (Boshen)
- 740a009 linter: Accept digits after 'use' in hook names (#19254)
(Sreetam Das)
- 31b562f linter: Update `import/no-named-as-default` to allow named
import if equivalent to the default import (#19100) (connorshea)
- 79c82cc linter: Avoid applying object-level docs to nested object
methods in require-param (#19231) (camc314)

### ⚡ Performance

- 5670291 linter/class-literal-property-style: Avoid unneeded string
allocations (#19262) (camc314)
# Oxfmt
### 🚀 Features

- ebb80b3 ast: Add `node_id` field to all AST struct nodes (#18138)
(Boshen)

### 🐛 Bug Fixes

- 1957908 formatter: Avoid unnecessary parentheses for string literal in
labeled statement (#19272) (Dunqing)

Co-authored-by: camc314 <[email protected]>
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
…19242)

This commit introduces a new linting rule, `no-invalid-void-type`, which
disallows the use of the `void` type outside of return positions and
configured generic contexts in TypeScript. The rule aims to prevent
confusion and improve type design by ensuring `void` is only used where
it is semantically appropriate. Additionally, the rule includes
configuration options for allowing `void` in generic type arguments and
as a `this` parameter.

New tests and snapshots have been added to validate the functionality of
this rule.

---------

Co-authored-by: Cameron Clark <[email protected]>
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
# Oxlint
### 🚀 Features

- ebb80b3 ast: Add `node_id` field to all AST struct nodes (oxc-project#18138)
(Boshen)
- 2879fc5 linter: Implement fixer for unicorn/prefer-math-trunc (oxc-project#19275)
(camc314)
- a204eda linter: Implement fixer for unicorn/no-typeof-undefined
(oxc-project#19274) (camc314)
- ab46d9c linter: Implement typescript/class-literal-property-style
(oxc-project#19252) (Vincent R)
- 1a61f58 linter: Implement typescript/no-invalid-void-type (oxc-project#19242)
(Vincent R)

### 🐛 Bug Fixes

- 45adda2 oxlint/lsp: Use blocking stdio in Oxlint (oxc-project#19292)
(overlookmotel)
- 05bc855 linter/import: Count unique module sources in max-dependencies
(oxc-project#19270) (camc314)
- 8566b44 linter: Check for preceeding token in math trunc fixer
(oxc-project#19277) (camc314)
- f16f2b6 linter/import-no-cycle: Avoid traversal-order false negatives
with type-only edges (oxc-project#19267) (camc314)
- d4937e7 linter: Recognize module-scoped callback refs as stable in
exhaustive-deps (oxc-project#19220) (Sreetam Das)
- 140c9bd linter: Detect fallthrough from `default` when it is not the
last case (oxc-project#19261) (Boshen)
- 740a009 linter: Accept digits after 'use' in hook names (oxc-project#19254)
(Sreetam Das)
- 31b562f linter: Update `import/no-named-as-default` to allow named
import if equivalent to the default import (oxc-project#19100) (connorshea)
- 79c82cc linter: Avoid applying object-level docs to nested object
methods in require-param (oxc-project#19231) (camc314)

### ⚡ Performance

- 5670291 linter/class-literal-property-style: Avoid unneeded string
allocations (oxc-project#19262) (camc314)
# Oxfmt
### 🚀 Features

- ebb80b3 ast: Add `node_id` field to all AST struct nodes (oxc-project#18138)
(Boshen)

### 🐛 Bug Fixes

- 1957908 formatter: Avoid unnecessary parentheses for string literal in
labeled statement (oxc-project#19272) (Dunqing)

Co-authored-by: camc314 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments