Skip to content
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
4 changes: 4 additions & 0 deletions src/docs/guide/usage/linter/generated-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Arguments:
Enable the promise plugin and detect promise usage problems
- **`--node-plugin`** —
Enable the node plugin and detect node usage problems
- **`--regex-plugin`** —
Enable the regex plugin and detect regex usage problems
- **`--vue-plugin`** —
Enable the vue plugin and detect vue usage problems

## Fix Problems

Expand Down
5 changes: 3 additions & 2 deletions src/docs/guide/usage/linter/generated-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The progress of all rule implementations is tracked [here](https://github.com/oxc-project/oxc/issues/481).

- Total number of rules: 525
- Total number of rules: 526
- Rules turned on by default: 87

**Legend for 'Fixable?' column:**
Expand Down Expand Up @@ -215,7 +215,7 @@ Code that can be written to run faster.
| [prefer-array-flat-map](/docs/guide/usage/linter/rules/unicorn/prefer-array-flat-map.html) | unicorn | | 🛠️ |
| [prefer-set-has](/docs/guide/usage/linter/rules/unicorn/prefer-set-has.html) | unicorn | | ⚠️🛠️️ |

## Restriction (66):
## Restriction (67):

Lints which prevent the use of language and library features. Must not be enabled as a whole, should be considered on a case-by-case basis before enabling.

Expand Down Expand Up @@ -266,6 +266,7 @@ Lints which prevent the use of language and library features. Must not be enable
| [no-danger](/docs/guide/usage/linter/rules/react/no-danger.html) | react | | |
| [no-unknown-property](/docs/guide/usage/linter/rules/react/no-unknown-property.html) | react | | 🚧 |
| [explicit-function-return-type](/docs/guide/usage/linter/rules/typescript/explicit-function-return-type.html) | typescript | | |
| [explicit-module-boundary-types](/docs/guide/usage/linter/rules/typescript/explicit-module-boundary-types.html) | typescript | | |
| [no-dynamic-delete](/docs/guide/usage/linter/rules/typescript/no-dynamic-delete.html) | typescript | | |
| [no-empty-object-type](/docs/guide/usage/linter/rules/typescript/no-empty-object-type.html) | typescript | | |
| [no-explicit-any](/docs/guide/usage/linter/rules/typescript/no-explicit-any.html) | typescript | | 🛠️ |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->

<script setup>
import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/typescript/explicit_module_boundary_types.rs`;
</script>

# typescript/explicit-module-boundary-types <Badge type="info" text="Restriction" />

<div class="rule-meta">
</div>

### What it does

Require explicit return and argument types on exported functions' and classes' public class methods.

### Why is this bad?

Explicit types for function return values and arguments makes it clear
to any calling code what is the module boundary's input and output.
Adding explicit type annotations for those types can help improve code
readability. It can also improve TypeScript type checking performance on
larger codebases.

### Examples

Examples of **incorrect** code for this rule:

```ts
// Should indicate that no value is returned (void)
export function test() {
return;
}

// Should indicate that a string is returned
export var arrowFn = () => "test";

// All arguments should be typed
export var arrowFn = (arg): string => `test ${arg}`;
export var arrowFn = (arg: any): string => `test ${arg}`;

export class Test {
// Should indicate that no value is returned (void)
method() {
return;
}
}
```

Examples of **correct** code for this rule:

```ts
// A function with no return value (void)
export function test(): void {
return;
}

// A return value of type string
export var arrowFn = (): string => "test";

// All arguments should be typed
export var arrowFn = (arg: string): string => `test ${arg}`;
export var arrowFn = (arg: unknown): string => `test ${arg}`;

export class Test {
// A class method with no return value (void)
method(): void {
return;
}
}

// The function does not apply because it is not an exported function.
function test() {
return;
}
```

## How to use

To **enable** this rule in the CLI or using the config file, you can use:

::: code-group

```bash [CLI]
oxlint --deny typescript/explicit-module-boundary-types
```

```json [Config (.oxlintrc.json)]
{
"rules": {
"typescript/explicit-module-boundary-types": "error"
}
}
```

:::

## References

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
2 changes: 1 addition & 1 deletion src/docs/guide/usage/linter/rules/version.data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
load() {
return "2d9291c7d68352eafd0bfcf5d37b137cbadc1120";
return "a696227142fa90e5e895c173ad4b7cb1207d4d92";
},
};