diff --git a/src/docs/guide/usage/linter/generated-cli.md b/src/docs/guide/usage/linter/generated-cli.md index bba097ffb35..092381bceca 100644 --- a/src/docs/guide/usage/linter/generated-cli.md +++ b/src/docs/guide/usage/linter/generated-cli.md @@ -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 diff --git a/src/docs/guide/usage/linter/generated-rules.md b/src/docs/guide/usage/linter/generated-rules.md index bd7d14467fc..d32b5c4cc6d 100644 --- a/src/docs/guide/usage/linter/generated-rules.md +++ b/src/docs/guide/usage/linter/generated-rules.md @@ -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:** @@ -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. @@ -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 | | 🛠️ | diff --git a/src/docs/guide/usage/linter/rules/typescript/explicit-module-boundary-types.md b/src/docs/guide/usage/linter/rules/typescript/explicit-module-boundary-types.md new file mode 100644 index 00000000000..03d12187bd9 --- /dev/null +++ b/src/docs/guide/usage/linter/rules/typescript/explicit-module-boundary-types.md @@ -0,0 +1,100 @@ + + + + +# typescript/explicit-module-boundary-types + +
+
+ +### 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 + +- Rule Source diff --git a/src/docs/guide/usage/linter/rules/version.data.js b/src/docs/guide/usage/linter/rules/version.data.js index 42527136ca5..5e04021edd9 100644 --- a/src/docs/guide/usage/linter/rules/version.data.js +++ b/src/docs/guide/usage/linter/rules/version.data.js @@ -1,5 +1,5 @@ export default { load() { - return "2d9291c7d68352eafd0bfcf5d37b137cbadc1120"; + return "a696227142fa90e5e895c173ad4b7cb1207d4d92"; }, };